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

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

Cross-merge networking fixes after downstream PR.

Conflicts:

drivers/net/ethernet/broadcom/bnxt/bnxt.c
e009b2efb7a8 ("bnxt_en: Remove mis-applied code from bnxt_cfg_ntp_filters()")
0f2b21477988 ("bnxt_en: Fix compile error without CONFIG_RFS_ACCEL")
https://lore.kernel.org/all/20240105115509.225aa8a2@canb.auug.org.au/

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

+3491 -1657
+1
.mailmap
··· 436 436 Murali Nalajala <quic_mnalajal@quicinc.com> <mnalajal@codeaurora.org> 437 437 Mythri P K <mythripk@ti.com> 438 438 Nadia Yvette Chambers <nyc@holomorphy.com> William Lee Irwin III <wli@holomorphy.com> 439 + Naoya Horiguchi <naoya.horiguchi@nec.com> <n-horiguchi@ah.jp.nec.com> 439 440 Nathan Chancellor <nathan@kernel.org> <natechancellor@gmail.com> 440 441 Neeraj Upadhyay <quic_neeraju@quicinc.com> <neeraju@codeaurora.org> 441 442 Neil Armstrong <neil.armstrong@linaro.org> <narmstrong@baylibre.com>
+4
CREDITS
··· 1855 1855 D: 'Trinity' and similar fuzz testing work. 1856 1856 D: Misc/Other. 1857 1857 1858 + N: Tom Joseph 1859 + E: tjoseph@cadence.com 1860 + D: Cadence PCIe driver 1861 + 1858 1862 N: Martin Josfsson 1859 1863 E: gandalf@wlug.westbo.se 1860 1864 P: 1024D/F6B6D3B1 7610 7CED 5C34 4AA6 DBA2 8BE1 5A6D AF95 F6B6 D3B1
+6 -4
Documentation/devicetree/bindings/nvmem/mxs-ocotp.yaml
··· 15 15 16 16 properties: 17 17 compatible: 18 - enum: 19 - - fsl,imx23-ocotp 20 - - fsl,imx28-ocotp 18 + items: 19 + - enum: 20 + - fsl,imx23-ocotp 21 + - fsl,imx28-ocotp 22 + - const: fsl,ocotp 21 23 22 24 reg: 23 25 maxItems: 1 ··· 37 35 examples: 38 36 - | 39 37 ocotp: efuse@8002c000 { 40 - compatible = "fsl,imx28-ocotp"; 38 + compatible = "fsl,imx28-ocotp", "fsl,ocotp"; 41 39 #address-cells = <1>; 42 40 #size-cells = <1>; 43 41 reg = <0x8002c000 0x2000>;
+1 -1
Documentation/networking/ip-sysctl.rst
··· 2511 2511 temp_prefered_lft - INTEGER 2512 2512 Preferred lifetime (in seconds) for temporary addresses. If 2513 2513 temp_prefered_lft is less than the minimum required lifetime (typically 2514 - 5 seconds), the preferred lifetime is the minimum required. If 2514 + 5 seconds), temporary addresses will not be created. If 2515 2515 temp_prefered_lft is greater than temp_valid_lft, the preferred lifetime 2516 2516 is temp_valid_lft. 2517 2517
+17 -9
MAINTAINERS
··· 4127 4127 M: Hante Meuleman <hante.meuleman@broadcom.com> 4128 4128 L: linux-wireless@vger.kernel.org 4129 4129 L: brcm80211-dev-list.pdl@broadcom.com 4130 - L: SHA-cyfmac-dev-list@infineon.com 4131 4130 S: Supported 4132 4131 F: drivers/net/wireless/broadcom/brcm80211/ 4133 4132 ··· 9007 9008 GPIO SUBSYSTEM 9008 9009 M: Linus Walleij <linus.walleij@linaro.org> 9009 9010 M: Bartosz Golaszewski <brgl@bgdev.pl> 9010 - R: Andy Shevchenko <andy@kernel.org> 9011 9011 L: linux-gpio@vger.kernel.org 9012 9012 S: Maintained 9013 9013 T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git 9014 - F: Documentation/ABI/obsolete/sysfs-gpio 9015 - F: Documentation/ABI/testing/gpio-cdev 9016 9014 F: Documentation/admin-guide/gpio/ 9017 9015 F: Documentation/devicetree/bindings/gpio/ 9018 9016 F: Documentation/driver-api/gpio/ ··· 9018 9022 F: include/linux/gpio.h 9019 9023 F: include/linux/gpio/ 9020 9024 F: include/linux/of_gpio.h 9025 + 9026 + GPIO UAPI 9027 + M: Bartosz Golaszewski <brgl@bgdev.pl> 9028 + R: Kent Gibson <warthog618@gmail.com> 9029 + L: linux-gpio@vger.kernel.org 9030 + S: Maintained 9031 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git 9032 + F: Documentation/ABI/obsolete/sysfs-gpio 9033 + F: Documentation/ABI/testing/gpio-cdev 9034 + F: drivers/gpio/gpiolib-cdev.c 9021 9035 F: include/uapi/linux/gpio.h 9022 9036 F: tools/gpio/ 9023 9037 ··· 10648 10642 F: drivers/gpio/gpio-sch.c 10649 10643 F: drivers/gpio/gpio-sodaville.c 10650 10644 F: drivers/gpio/gpio-tangier.c 10645 + F: drivers/gpio/gpio-tangier.h 10651 10646 10652 10647 INTEL GVT-g DRIVERS (Intel GPU Virtualization) 10653 10648 M: Zhenyu Wang <zhenyuw@linux.intel.com> ··· 11480 11473 F: scripts/Kbuild* 11481 11474 F: scripts/Makefile* 11482 11475 F: scripts/basic/ 11476 + F: scripts/clang-tools/ 11483 11477 F: scripts/dummy-tools/ 11484 11478 F: scripts/mk* 11485 11479 F: scripts/mod/ ··· 12836 12828 F: drivers/net/ethernet/marvell/mvneta.* 12837 12829 12838 12830 MARVELL MVPP2 ETHERNET DRIVER 12839 - M: Marcin Wojtas <mw@semihalf.com> 12831 + M: Marcin Wojtas <marcin.s.wojtas@gmail.com> 12840 12832 M: Russell King <linux@armlinux.org.uk> 12841 12833 L: netdev@vger.kernel.org 12842 12834 S: Maintained ··· 15101 15093 NETWORKING [MPTCP] 15102 15094 M: Matthieu Baerts <matttbe@kernel.org> 15103 15095 M: Mat Martineau <martineau@kernel.org> 15096 + R: Geliang Tang <geliang.tang@linux.dev> 15104 15097 L: netdev@vger.kernel.org 15105 15098 L: mptcp@lists.linux.dev 15106 15099 S: Maintained ··· 15450 15441 F: drivers/bluetooth/btnxpuart.c 15451 15442 15452 15443 NXP C45 TJA11XX PHY DRIVER 15453 - M: Radu Pirea <radu-nicolae.pirea@oss.nxp.com> 15444 + M: Andrei Botila <andrei.botila@oss.nxp.com> 15454 15445 L: netdev@vger.kernel.org 15455 15446 S: Maintained 15456 15447 F: drivers/net/phy/nxp-c45-tja11xx* ··· 16467 16458 F: drivers/pci/controller/dwc/pcie-armada8k.c 16468 16459 16469 16460 PCI DRIVER FOR CADENCE PCIE IP 16470 - M: Tom Joseph <tjoseph@cadence.com> 16471 16461 L: linux-pci@vger.kernel.org 16472 - S: Maintained 16462 + S: Orphan 16473 16463 F: Documentation/devicetree/bindings/pci/cdns,* 16474 - F: drivers/pci/controller/cadence/ 16464 + F: drivers/pci/controller/cadence/*cadence* 16475 16465 16476 16466 PCI DRIVER FOR FREESCALE LAYERSCAPE 16477 16467 M: Minghuan Lian <minghuan.Lian@nxp.com>
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 7 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc6 5 + EXTRAVERSION = -rc8 6 6 NAME = Hurr durr I'ma ninja sloth 7 7 8 8 # *DOCUMENTATION*
+1 -1
arch/arm64/kvm/arm.c
··· 410 410 kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache); 411 411 kvm_timer_vcpu_terminate(vcpu); 412 412 kvm_pmu_vcpu_destroy(vcpu); 413 - 413 + kvm_vgic_vcpu_destroy(vcpu); 414 414 kvm_arm_vcpu_destroy(vcpu); 415 415 } 416 416
+33 -22
arch/arm64/kvm/vgic/vgic-init.c
··· 368 368 vgic_v4_teardown(kvm); 369 369 } 370 370 371 - void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) 371 + static void __kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) 372 372 { 373 373 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 374 374 ··· 379 379 vgic_flush_pending_lpis(vcpu); 380 380 381 381 INIT_LIST_HEAD(&vgic_cpu->ap_list_head); 382 - vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF; 382 + if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) { 383 + vgic_unregister_redist_iodev(vcpu); 384 + vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF; 385 + } 383 386 } 384 387 385 - static void __kvm_vgic_destroy(struct kvm *kvm) 388 + void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) 386 389 { 387 - struct kvm_vcpu *vcpu; 388 - unsigned long i; 390 + struct kvm *kvm = vcpu->kvm; 389 391 390 - lockdep_assert_held(&kvm->arch.config_lock); 391 - 392 - vgic_debug_destroy(kvm); 393 - 394 - kvm_for_each_vcpu(i, vcpu, kvm) 395 - kvm_vgic_vcpu_destroy(vcpu); 396 - 397 - kvm_vgic_dist_destroy(kvm); 392 + mutex_lock(&kvm->slots_lock); 393 + __kvm_vgic_vcpu_destroy(vcpu); 394 + mutex_unlock(&kvm->slots_lock); 398 395 } 399 396 400 397 void kvm_vgic_destroy(struct kvm *kvm) 401 398 { 399 + struct kvm_vcpu *vcpu; 400 + unsigned long i; 401 + 402 + mutex_lock(&kvm->slots_lock); 403 + 404 + vgic_debug_destroy(kvm); 405 + 406 + kvm_for_each_vcpu(i, vcpu, kvm) 407 + __kvm_vgic_vcpu_destroy(vcpu); 408 + 402 409 mutex_lock(&kvm->arch.config_lock); 403 - __kvm_vgic_destroy(kvm); 410 + 411 + kvm_vgic_dist_destroy(kvm); 412 + 404 413 mutex_unlock(&kvm->arch.config_lock); 414 + mutex_unlock(&kvm->slots_lock); 405 415 } 406 416 407 417 /** ··· 479 469 type = VGIC_V3; 480 470 } 481 471 482 - if (ret) { 483 - __kvm_vgic_destroy(kvm); 472 + if (ret) 484 473 goto out; 485 - } 474 + 486 475 dist->ready = true; 487 476 dist_base = dist->vgic_dist_base; 488 477 mutex_unlock(&kvm->arch.config_lock); 489 478 490 479 ret = vgic_register_dist_iodev(kvm, dist_base, type); 491 - if (ret) { 480 + if (ret) 492 481 kvm_err("Unable to register VGIC dist MMIO regions\n"); 493 - kvm_vgic_destroy(kvm); 494 - } 495 - mutex_unlock(&kvm->slots_lock); 496 - return ret; 497 482 483 + goto out_slots; 498 484 out: 499 485 mutex_unlock(&kvm->arch.config_lock); 486 + out_slots: 500 487 mutex_unlock(&kvm->slots_lock); 488 + 489 + if (ret) 490 + kvm_vgic_destroy(kvm); 491 + 501 492 return ret; 502 493 } 503 494
+3 -1
arch/arm64/kvm/vgic/vgic-mmio-v3.c
··· 820 820 return ret; 821 821 } 822 822 823 - static void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu) 823 + void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu) 824 824 { 825 825 struct vgic_io_device *rd_dev = &vcpu->arch.vgic_cpu.rd_iodev; 826 826 ··· 832 832 struct kvm_vcpu *vcpu; 833 833 unsigned long c; 834 834 int ret = 0; 835 + 836 + lockdep_assert_held(&kvm->slots_lock); 835 837 836 838 kvm_for_each_vcpu(c, vcpu, kvm) { 837 839 ret = vgic_register_redist_iodev(vcpu);
+1
arch/arm64/kvm/vgic/vgic.h
··· 241 241 int vgic_v3_save_pending_tables(struct kvm *kvm); 242 242 int vgic_v3_set_redist_base(struct kvm *kvm, u32 index, u64 addr, u32 count); 243 243 int vgic_register_redist_iodev(struct kvm_vcpu *vcpu); 244 + void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu); 244 245 bool vgic_v3_check_base(struct kvm *kvm); 245 246 246 247 void vgic_v3_load(struct kvm_vcpu *vcpu);
+2 -2
arch/powerpc/Kconfig
··· 608 608 def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP) 609 609 610 610 config ARCH_SUPPORTS_KEXEC_FILE 611 - def_bool PPC64 && CRYPTO=y && CRYPTO_SHA256=y 611 + def_bool PPC64 612 612 613 613 config ARCH_SUPPORTS_KEXEC_PURGATORY 614 - def_bool KEXEC_FILE 614 + def_bool y 615 615 616 616 config ARCH_SELECTS_KEXEC_FILE 617 617 def_bool y
+1 -3
arch/riscv/Kconfig
··· 702 702 select KEXEC_ELF 703 703 704 704 config ARCH_SUPPORTS_KEXEC_PURGATORY 705 - def_bool KEXEC_FILE 706 - depends on CRYPTO=y 707 - depends on CRYPTO_SHA256=y 705 + def_bool ARCH_SUPPORTS_KEXEC_FILE 708 706 709 707 config ARCH_SUPPORTS_CRASH_DUMP 710 708 def_bool y
+13
arch/riscv/kvm/aia_imsic.c
··· 55 55 /* IMSIC SW-file */ 56 56 struct imsic_mrif *swfile; 57 57 phys_addr_t swfile_pa; 58 + spinlock_t swfile_extirq_lock; 58 59 }; 59 60 60 61 #define imsic_vs_csr_read(__c) \ ··· 614 613 { 615 614 struct imsic *imsic = vcpu->arch.aia_context.imsic_state; 616 615 struct imsic_mrif *mrif = imsic->swfile; 616 + unsigned long flags; 617 + 618 + /* 619 + * The critical section is necessary during external interrupt 620 + * updates to avoid the risk of losing interrupts due to potential 621 + * interruptions between reading topei and updating pending status. 622 + */ 623 + 624 + spin_lock_irqsave(&imsic->swfile_extirq_lock, flags); 617 625 618 626 if (imsic_mrif_atomic_read(mrif, &mrif->eidelivery) && 619 627 imsic_mrif_topei(mrif, imsic->nr_eix, imsic->nr_msis)) 620 628 kvm_riscv_vcpu_set_interrupt(vcpu, IRQ_VS_EXT); 621 629 else 622 630 kvm_riscv_vcpu_unset_interrupt(vcpu, IRQ_VS_EXT); 631 + 632 + spin_unlock_irqrestore(&imsic->swfile_extirq_lock, flags); 623 633 } 624 634 625 635 static void imsic_swfile_read(struct kvm_vcpu *vcpu, bool clear, ··· 1051 1039 } 1052 1040 imsic->swfile = page_to_virt(swfile_page); 1053 1041 imsic->swfile_pa = page_to_phys(swfile_page); 1042 + spin_lock_init(&imsic->swfile_extirq_lock); 1054 1043 1055 1044 /* Setup IO device */ 1056 1045 kvm_iodevice_init(&imsic->iodev, &imsic_iodoev_ops);
+2 -2
arch/s390/Kconfig
··· 254 254 def_bool y 255 255 256 256 config ARCH_SUPPORTS_KEXEC_FILE 257 - def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390 257 + def_bool y 258 258 259 259 config ARCH_SUPPORTS_KEXEC_SIG 260 260 def_bool MODULE_SIG_FORMAT 261 261 262 262 config ARCH_SUPPORTS_KEXEC_PURGATORY 263 - def_bool KEXEC_FILE 263 + def_bool y 264 264 265 265 config ARCH_SUPPORTS_CRASH_DUMP 266 266 def_bool y
+2 -2
arch/x86/Kconfig
··· 2072 2072 def_bool y 2073 2073 2074 2074 config ARCH_SUPPORTS_KEXEC_FILE 2075 - def_bool X86_64 && CRYPTO && CRYPTO_SHA256 2075 + def_bool X86_64 2076 2076 2077 2077 config ARCH_SELECTS_KEXEC_FILE 2078 2078 def_bool y ··· 2080 2080 select HAVE_IMA_KEXEC if IMA 2081 2081 2082 2082 config ARCH_SUPPORTS_KEXEC_PURGATORY 2083 - def_bool KEXEC_FILE 2083 + def_bool y 2084 2084 2085 2085 config ARCH_SUPPORTS_KEXEC_SIG 2086 2086 def_bool y
+1 -1
arch/x86/kernel/acpi/boot.c
··· 293 293 processor->processor_id, /* ACPI ID */ 294 294 processor->lapic_flags & ACPI_MADT_ENABLED); 295 295 296 + has_lapic_cpus = true; 296 297 return 0; 297 298 } 298 299 ··· 1135 1134 if (!count) { 1136 1135 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, 1137 1136 acpi_parse_lapic, MAX_LOCAL_APIC); 1138 - has_lapic_cpus = count > 0; 1139 1137 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC, 1140 1138 acpi_parse_x2apic, MAX_LOCAL_APIC); 1141 1139 }
+12 -2
arch/x86/kernel/alternative.c
··· 256 256 } 257 257 } 258 258 259 + static void __init_or_module noinline optimize_nops_inplace(u8 *instr, size_t len) 260 + { 261 + unsigned long flags; 262 + 263 + local_irq_save(flags); 264 + optimize_nops(instr, len); 265 + sync_core(); 266 + local_irq_restore(flags); 267 + } 268 + 259 269 /* 260 270 * In this context, "source" is where the instructions are placed in the 261 271 * section .altinstr_replacement, for example during kernel build by the ··· 449 439 * patch if feature is *NOT* present. 450 440 */ 451 441 if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) { 452 - optimize_nops(instr, a->instrlen); 442 + optimize_nops_inplace(instr, a->instrlen); 453 443 continue; 454 444 } 455 445 ··· 1766 1756 } else { 1767 1757 local_irq_save(flags); 1768 1758 memcpy(addr, opcode, len); 1769 - local_irq_restore(flags); 1770 1759 sync_core(); 1760 + local_irq_restore(flags); 1771 1761 1772 1762 /* 1773 1763 * Could also do a CLFLUSH here to speed up CPU recovery; but
+16
arch/x86/kernel/head_64.S
··· 255 255 testl $X2APIC_ENABLE, %eax 256 256 jnz .Lread_apicid_msr 257 257 258 + #ifdef CONFIG_X86_X2APIC 259 + /* 260 + * If system is in X2APIC mode then MMIO base might not be 261 + * mapped causing the MMIO read below to fault. Faults can't 262 + * be handled at that point. 263 + */ 264 + cmpl $0, x2apic_mode(%rip) 265 + jz .Lread_apicid_mmio 266 + 267 + /* Force the AP into X2APIC mode. */ 268 + orl $X2APIC_ENABLE, %eax 269 + wrmsr 270 + jmp .Lread_apicid_msr 271 + #endif 272 + 273 + .Lread_apicid_mmio: 258 274 /* Read the APIC ID from the fix-mapped MMIO space. */ 259 275 movq apic_mmio_base(%rip), %rcx 260 276 addq $APIC_ID, %rcx
+19
arch/x86/kvm/svm/sev.c
··· 2972 2972 2973 2973 set_msr_interception(vcpu, svm->msrpm, MSR_TSC_AUX, v_tsc_aux, v_tsc_aux); 2974 2974 } 2975 + 2976 + /* 2977 + * For SEV-ES, accesses to MSR_IA32_XSS should not be intercepted if 2978 + * the host/guest supports its use. 2979 + * 2980 + * guest_can_use() checks a number of requirements on the host/guest to 2981 + * ensure that MSR_IA32_XSS is available, but it might report true even 2982 + * if X86_FEATURE_XSAVES isn't configured in the guest to ensure host 2983 + * MSR_IA32_XSS is always properly restored. For SEV-ES, it is better 2984 + * to further check that the guest CPUID actually supports 2985 + * X86_FEATURE_XSAVES so that accesses to MSR_IA32_XSS by misbehaved 2986 + * guests will still get intercepted and caught in the normal 2987 + * kvm_emulate_rdmsr()/kvm_emulated_wrmsr() paths. 2988 + */ 2989 + if (guest_can_use(vcpu, X86_FEATURE_XSAVES) && 2990 + guest_cpuid_has(vcpu, X86_FEATURE_XSAVES)) 2991 + set_msr_interception(vcpu, svm->msrpm, MSR_IA32_XSS, 1, 1); 2992 + else 2993 + set_msr_interception(vcpu, svm->msrpm, MSR_IA32_XSS, 0, 0); 2975 2994 } 2976 2995 2977 2996 void sev_vcpu_after_set_cpuid(struct vcpu_svm *svm)
+1
arch/x86/kvm/svm/svm.c
··· 103 103 { .index = MSR_IA32_LASTBRANCHTOIP, .always = false }, 104 104 { .index = MSR_IA32_LASTINTFROMIP, .always = false }, 105 105 { .index = MSR_IA32_LASTINTTOIP, .always = false }, 106 + { .index = MSR_IA32_XSS, .always = false }, 106 107 { .index = MSR_EFER, .always = false }, 107 108 { .index = MSR_IA32_CR_PAT, .always = false }, 108 109 { .index = MSR_AMD64_SEV_ES_GHCB, .always = true },
+1 -1
arch/x86/kvm/svm/svm.h
··· 30 30 #define IOPM_SIZE PAGE_SIZE * 3 31 31 #define MSRPM_SIZE PAGE_SIZE * 2 32 32 33 - #define MAX_DIRECT_ACCESS_MSRS 46 33 + #define MAX_DIRECT_ACCESS_MSRS 47 34 34 #define MSRPM_OFFSETS 32 35 35 extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; 36 36 extern bool npt_enabled;
+35 -70
arch/x86/lib/csum-partial_64.c
··· 11 11 #include <asm/checksum.h> 12 12 #include <asm/word-at-a-time.h> 13 13 14 - static inline unsigned short from32to16(unsigned a) 14 + static inline __wsum csum_finalize_sum(u64 temp64) 15 15 { 16 - unsigned short b = a >> 16; 17 - asm("addw %w2,%w0\n\t" 18 - "adcw $0,%w0\n" 19 - : "=r" (b) 20 - : "0" (b), "r" (a)); 21 - return b; 16 + return (__force __wsum)((temp64 + ror64(temp64, 32)) >> 32); 22 17 } 23 18 24 - static inline __wsum csum_tail(u64 temp64, int odd) 19 + static inline unsigned long update_csum_40b(unsigned long sum, const unsigned long m[5]) 25 20 { 26 - unsigned int result; 27 - 28 - result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff); 29 - if (unlikely(odd)) { 30 - result = from32to16(result); 31 - result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); 32 - } 33 - return (__force __wsum)result; 21 + asm("addq %1,%0\n\t" 22 + "adcq %2,%0\n\t" 23 + "adcq %3,%0\n\t" 24 + "adcq %4,%0\n\t" 25 + "adcq %5,%0\n\t" 26 + "adcq $0,%0" 27 + :"+r" (sum) 28 + :"m" (m[0]), "m" (m[1]), "m" (m[2]), 29 + "m" (m[3]), "m" (m[4])); 30 + return sum; 34 31 } 35 32 36 33 /* ··· 44 47 __wsum csum_partial(const void *buff, int len, __wsum sum) 45 48 { 46 49 u64 temp64 = (__force u64)sum; 47 - unsigned odd; 48 50 49 - odd = 1 & (unsigned long) buff; 50 - if (unlikely(odd)) { 51 - if (unlikely(len == 0)) 52 - return sum; 53 - temp64 = ror32((__force u32)sum, 8); 54 - temp64 += (*(unsigned char *)buff << 8); 55 - len--; 56 - buff++; 51 + /* Do two 40-byte chunks in parallel to get better ILP */ 52 + if (likely(len >= 80)) { 53 + u64 temp64_2 = 0; 54 + do { 55 + temp64 = update_csum_40b(temp64, buff); 56 + temp64_2 = update_csum_40b(temp64_2, buff + 40); 57 + buff += 80; 58 + len -= 80; 59 + } while (len >= 80); 60 + 61 + asm("addq %1,%0\n\t" 62 + "adcq $0,%0" 63 + :"+r" (temp64): "r" (temp64_2)); 57 64 } 58 65 59 66 /* 60 - * len == 40 is the hot case due to IPv6 headers, but annotating it likely() 61 - * has noticeable negative affect on codegen for all other cases with 62 - * minimal performance benefit here. 67 + * len == 40 is the hot case due to IPv6 headers, so return 68 + * early for that exact case without checking the tail bytes. 63 69 */ 64 - if (len == 40) { 65 - asm("addq 0*8(%[src]),%[res]\n\t" 66 - "adcq 1*8(%[src]),%[res]\n\t" 67 - "adcq 2*8(%[src]),%[res]\n\t" 68 - "adcq 3*8(%[src]),%[res]\n\t" 69 - "adcq 4*8(%[src]),%[res]\n\t" 70 - "adcq $0,%[res]" 71 - : [res] "+r"(temp64) 72 - : [src] "r"(buff), "m"(*(const char(*)[40])buff)); 73 - return csum_tail(temp64, odd); 74 - } 75 - if (unlikely(len >= 64)) { 76 - /* 77 - * Extra accumulators for better ILP in the loop. 78 - */ 79 - u64 tmp_accum, tmp_carries; 80 - 81 - asm("xorl %k[tmp_accum],%k[tmp_accum]\n\t" 82 - "xorl %k[tmp_carries],%k[tmp_carries]\n\t" 83 - "subl $64, %[len]\n\t" 84 - "1:\n\t" 85 - "addq 0*8(%[src]),%[res]\n\t" 86 - "adcq 1*8(%[src]),%[res]\n\t" 87 - "adcq 2*8(%[src]),%[res]\n\t" 88 - "adcq 3*8(%[src]),%[res]\n\t" 89 - "adcl $0,%k[tmp_carries]\n\t" 90 - "addq 4*8(%[src]),%[tmp_accum]\n\t" 91 - "adcq 5*8(%[src]),%[tmp_accum]\n\t" 92 - "adcq 6*8(%[src]),%[tmp_accum]\n\t" 93 - "adcq 7*8(%[src]),%[tmp_accum]\n\t" 94 - "adcl $0,%k[tmp_carries]\n\t" 95 - "addq $64, %[src]\n\t" 96 - "subl $64, %[len]\n\t" 97 - "jge 1b\n\t" 98 - "addq %[tmp_accum],%[res]\n\t" 99 - "adcq %[tmp_carries],%[res]\n\t" 100 - "adcq $0,%[res]" 101 - : [tmp_accum] "=&r"(tmp_accum), 102 - [tmp_carries] "=&r"(tmp_carries), [res] "+r"(temp64), 103 - [len] "+r"(len), [src] "+r"(buff) 104 - : "m"(*(const char *)buff)); 70 + if (len >= 40) { 71 + temp64 = update_csum_40b(temp64, buff); 72 + len -= 40; 73 + if (!len) 74 + return csum_finalize_sum(temp64); 75 + buff += 40; 105 76 } 106 77 107 78 if (len & 32) { ··· 108 143 : [res] "+r"(temp64) 109 144 : [trail] "r"(trail)); 110 145 } 111 - return csum_tail(temp64, odd); 146 + return csum_finalize_sum(temp64); 112 147 } 113 148 EXPORT_SYMBOL(csum_partial); 114 149
+1
arch/x86/xen/Kconfig
··· 9 9 select PARAVIRT_CLOCK 10 10 select X86_HV_CALLBACK_VECTOR 11 11 depends on X86_64 || (X86_32 && X86_PAE) 12 + depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MCORE2 || MATOM || MK8) 12 13 depends on X86_LOCAL_APIC && X86_TSC 13 14 help 14 15 This is the Linux Xen port. Enabling this will allow the
+4 -2
block/badblocks.c
··· 1312 1312 prev = prev_badblocks(bb, &bad, hint); 1313 1313 1314 1314 /* start after all badblocks */ 1315 - if ((prev + 1) >= bb->count && !overlap_front(bb, prev, &bad)) { 1315 + if ((prev >= 0) && 1316 + ((prev + 1) >= bb->count) && !overlap_front(bb, prev, &bad)) { 1316 1317 len = sectors; 1317 1318 goto update_sectors; 1318 1319 } 1319 1320 1320 - if (overlap_front(bb, prev, &bad)) { 1321 + /* Overlapped with front badblocks record */ 1322 + if ((prev >= 0) && overlap_front(bb, prev, &bad)) { 1321 1323 if (BB_ACK(p[prev])) 1322 1324 acked_badblocks++; 1323 1325 else
+14 -1
drivers/accel/qaic/mhi_controller.c
··· 404 404 405 405 static int mhi_read_reg(struct mhi_controller *mhi_cntrl, void __iomem *addr, u32 *out) 406 406 { 407 - u32 tmp = readl_relaxed(addr); 407 + u32 tmp; 408 408 409 + /* 410 + * SOC_HW_VERSION quirk 411 + * The SOC_HW_VERSION register (offset 0x224) is not reliable and 412 + * may contain uninitialized values, including 0xFFFFFFFF. This could 413 + * cause a false positive link down error. Instead, intercept any 414 + * reads and provide the correct value of the register. 415 + */ 416 + if (addr - mhi_cntrl->regs == 0x224) { 417 + *out = 0x60110200; 418 + return 0; 419 + } 420 + 421 + tmp = readl_relaxed(addr); 409 422 if (tmp == U32_MAX) 410 423 return -EIO; 411 424
+2 -4
drivers/accel/qaic/qaic_data.c
··· 777 777 struct dma_buf_attachment *attach; 778 778 struct drm_gem_object *obj; 779 779 struct qaic_bo *bo; 780 - size_t size; 781 780 int ret; 782 781 783 782 bo = qaic_alloc_init_bo(); ··· 794 795 goto attach_fail; 795 796 } 796 797 797 - size = PAGE_ALIGN(attach->dmabuf->size); 798 - if (size == 0) { 798 + if (!attach->dmabuf->size) { 799 799 ret = -EINVAL; 800 800 goto size_align_fail; 801 801 } 802 802 803 - drm_gem_private_object_init(dev, obj, size); 803 + drm_gem_private_object_init(dev, obj, attach->dmabuf->size); 804 804 /* 805 805 * skipping dma_buf_map_attachment() as we do not know the direction 806 806 * just yet. Once the direction is known in the subsequent IOCTL to
+4 -4
drivers/block/virtio_blk.c
··· 1019 1019 static int init_vq(struct virtio_blk *vblk) 1020 1020 { 1021 1021 int err; 1022 - int i; 1022 + unsigned short i; 1023 1023 vq_callback_t **callbacks; 1024 1024 const char **names; 1025 1025 struct virtqueue **vqs; 1026 1026 unsigned short num_vqs; 1027 - unsigned int num_poll_vqs; 1027 + unsigned short num_poll_vqs; 1028 1028 struct virtio_device *vdev = vblk->vdev; 1029 1029 struct irq_affinity desc = { 0, }; 1030 1030 ··· 1068 1068 1069 1069 for (i = 0; i < num_vqs - num_poll_vqs; i++) { 1070 1070 callbacks[i] = virtblk_done; 1071 - snprintf(vblk->vqs[i].name, VQ_NAME_LEN, "req.%d", i); 1071 + snprintf(vblk->vqs[i].name, VQ_NAME_LEN, "req.%u", i); 1072 1072 names[i] = vblk->vqs[i].name; 1073 1073 } 1074 1074 1075 1075 for (; i < num_vqs; i++) { 1076 1076 callbacks[i] = NULL; 1077 - snprintf(vblk->vqs[i].name, VQ_NAME_LEN, "req_poll.%d", i); 1077 + snprintf(vblk->vqs[i].name, VQ_NAME_LEN, "req_poll.%u", i); 1078 1078 names[i] = vblk->vqs[i].name; 1079 1079 } 1080 1080
+3 -2
drivers/connector/cn_proc.c
··· 108 108 filter_data[1] = 0; 109 109 } 110 110 111 - cn_netlink_send_mult(msg, msg->len, 0, CN_IDX_PROC, GFP_NOWAIT, 112 - cn_filter, (void *)filter_data); 111 + if (cn_netlink_send_mult(msg, msg->len, 0, CN_IDX_PROC, GFP_NOWAIT, 112 + cn_filter, (void *)filter_data) == -ESRCH) 113 + atomic_set(&proc_event_num_listeners, 0); 113 114 114 115 local_unlock(&local_event.lock); 115 116 }
+2
drivers/firmware/efi/libstub/x86-stub.c
··· 787 787 efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n"); 788 788 seed[0] = 0; 789 789 } 790 + 791 + boot_params_ptr->hdr.loadflags |= KASLR_FLAG; 790 792 } 791 793 792 794 status = efi_random_alloc(alloc_size, CONFIG_PHYSICAL_ALIGN, &addr,
+8 -4
drivers/gpio/gpio-dwapb.c
··· 282 282 { 283 283 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 284 284 struct dwapb_gpio *gpio = to_dwapb_gpio(gc); 285 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 285 286 unsigned long flags; 286 287 u32 val; 287 288 288 289 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 289 - val = dwapb_read(gpio, GPIO_INTEN); 290 - val |= BIT(irqd_to_hwirq(d)); 290 + val = dwapb_read(gpio, GPIO_INTEN) | BIT(hwirq); 291 291 dwapb_write(gpio, GPIO_INTEN, val); 292 + val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(hwirq); 293 + dwapb_write(gpio, GPIO_INTMASK, val); 292 294 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 293 295 } 294 296 ··· 298 296 { 299 297 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 300 298 struct dwapb_gpio *gpio = to_dwapb_gpio(gc); 299 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 301 300 unsigned long flags; 302 301 u32 val; 303 302 304 303 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 305 - val = dwapb_read(gpio, GPIO_INTEN); 306 - val &= ~BIT(irqd_to_hwirq(d)); 304 + val = dwapb_read(gpio, GPIO_INTMASK) | BIT(hwirq); 305 + dwapb_write(gpio, GPIO_INTMASK, val); 306 + val = dwapb_read(gpio, GPIO_INTEN) & ~BIT(hwirq); 307 307 dwapb_write(gpio, GPIO_INTEN, val); 308 308 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 309 309 }
+12 -4
drivers/gpio/gpiolib-cdev.c
··· 2481 2481 return 0; 2482 2482 } 2483 2483 2484 - /* 2485 - * gpio_ioctl() - ioctl handler for the GPIO chardev 2486 - */ 2487 - static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2484 + static long gpio_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg) 2488 2485 { 2489 2486 struct gpio_chardev_data *cdev = file->private_data; 2490 2487 struct gpio_device *gdev = cdev->gdev; ··· 2516 2519 default: 2517 2520 return -EINVAL; 2518 2521 } 2522 + } 2523 + 2524 + /* 2525 + * gpio_ioctl() - ioctl handler for the GPIO chardev 2526 + */ 2527 + static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2528 + { 2529 + struct gpio_chardev_data *cdev = file->private_data; 2530 + 2531 + return call_ioctl_locked(file, cmd, arg, cdev->gdev, 2532 + gpio_ioctl_unlocked); 2519 2533 } 2520 2534 2521 2535 #ifdef CONFIG_COMPAT
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 285 285 list_for_each_entry_safe(vm_bo, tmp, &vm->idle, vm_status) { 286 286 struct amdgpu_bo *bo = vm_bo->bo; 287 287 288 + vm_bo->moved = true; 288 289 if (!bo || bo->tbo.type != ttm_bo_type_kernel) 289 290 list_move(&vm_bo->vm_status, &vm_bo->vm->moved); 290 291 else if (bo->parent)
+12 -6
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
··· 1653 1653 if (test_bit(gpuidx, prange->bitmap_access)) 1654 1654 bitmap_set(ctx->bitmap, gpuidx, 1); 1655 1655 } 1656 + 1657 + /* 1658 + * If prange is already mapped or with always mapped flag, 1659 + * update mapping on GPUs with ACCESS attribute 1660 + */ 1661 + if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) { 1662 + if (prange->mapped_to_gpu || 1663 + prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED) 1664 + bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE); 1665 + } 1656 1666 } else { 1657 1667 bitmap_or(ctx->bitmap, prange->bitmap_access, 1658 1668 prange->bitmap_aip, MAX_GPU_INSTANCE); 1659 1669 } 1660 1670 1661 1671 if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) { 1662 - bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE); 1663 - if (!prange->mapped_to_gpu || 1664 - bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) { 1665 - r = 0; 1666 - goto free_ctx; 1667 - } 1672 + r = 0; 1673 + goto free_ctx; 1668 1674 } 1669 1675 1670 1676 if (prange->actual_loc && !prange->ttm_res) {
+15 -12
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
··· 1014 1014 DC_LOG_BIOS("AS_SIGNAL_TYPE_HDMI ss_percentage: %d\n", ss_info->spread_spectrum_percentage); 1015 1015 break; 1016 1016 case AS_SIGNAL_TYPE_DISPLAY_PORT: 1017 - ss_info->spread_spectrum_percentage = 1017 + if (bp->base.integrated_info) { 1018 + DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", bp->base.integrated_info->gpuclk_ss_percentage); 1019 + ss_info->spread_spectrum_percentage = 1020 + bp->base.integrated_info->gpuclk_ss_percentage; 1021 + ss_info->type.CENTER_MODE = 1022 + bp->base.integrated_info->gpuclk_ss_type; 1023 + } else { 1024 + ss_info->spread_spectrum_percentage = 1018 1025 disp_cntl_tbl->dp_ss_percentage; 1019 - ss_info->spread_spectrum_range = 1026 + ss_info->spread_spectrum_range = 1020 1027 disp_cntl_tbl->dp_ss_rate_10hz * 10; 1021 - if (disp_cntl_tbl->dp_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 1022 - ss_info->type.CENTER_MODE = true; 1023 - 1028 + if (disp_cntl_tbl->dp_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 1029 + ss_info->type.CENTER_MODE = true; 1030 + } 1024 1031 DC_LOG_BIOS("AS_SIGNAL_TYPE_DISPLAY_PORT ss_percentage: %d\n", ss_info->spread_spectrum_percentage); 1025 1032 break; 1026 1033 case AS_SIGNAL_TYPE_GPU_PLL: ··· 2393 2386 return BP_RESULT_BADBIOSTABLE; 2394 2387 2395 2388 info->num_chans = info_v30->channel_num; 2396 - /* As suggested by VBIOS we should always use 2397 - * dram_channel_width_bytes = 2 when using VRAM 2398 - * table version 3.0. This is because the channel_width 2399 - * param in the VRAM info table is changed in 7000 series and 2400 - * no longer represents the memory channel width. 2401 - */ 2402 - info->dram_channel_width_bytes = 2; 2389 + info->dram_channel_width_bytes = (1 << info_v30->channel_width) / 8; 2403 2390 2404 2391 return result; 2405 2392 } ··· 2821 2820 info->ma_channel_number = info_v2_2->umachannelnumber; 2822 2821 info->dp_ss_control = 2823 2822 le16_to_cpu(info_v2_2->reserved1); 2823 + info->gpuclk_ss_percentage = info_v2_2->gpuclk_ss_percentage; 2824 + info->gpuclk_ss_type = info_v2_2->gpuclk_ss_type; 2824 2825 2825 2826 for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; ++i) { 2826 2827 info->ext_disp_conn_info.gu_id[i] =
+18 -8
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 5095 5095 */ 5096 5096 bool dc_is_dmub_outbox_supported(struct dc *dc) 5097 5097 { 5098 - /* DCN31 B0 USB4 DPIA needs dmub notifications for interrupts */ 5099 - if (dc->ctx->asic_id.chip_family == FAMILY_YELLOW_CARP && 5100 - dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0 && 5101 - !dc->debug.dpia_debug.bits.disable_dpia) 5102 - return true; 5098 + switch (dc->ctx->asic_id.chip_family) { 5103 5099 5104 - if (dc->ctx->asic_id.chip_family == AMDGPU_FAMILY_GC_11_0_1 && 5105 - !dc->debug.dpia_debug.bits.disable_dpia) 5106 - return true; 5100 + case FAMILY_YELLOW_CARP: 5101 + /* DCN31 B0 USB4 DPIA needs dmub notifications for interrupts */ 5102 + if (dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0 && 5103 + !dc->debug.dpia_debug.bits.disable_dpia) 5104 + return true; 5105 + break; 5106 + 5107 + case AMDGPU_FAMILY_GC_11_0_1: 5108 + case AMDGPU_FAMILY_GC_11_5_0: 5109 + if (!dc->debug.dpia_debug.bits.disable_dpia) 5110 + return true; 5111 + break; 5112 + 5113 + default: 5114 + break; 5115 + } 5107 5116 5108 5117 /* dmub aux needs dmub notifications to be enabled */ 5109 5118 return dc->debug.enable_dmub_aux_for_legacy_ddc; 5119 + 5110 5120 } 5111 5121 5112 5122 /**
+1 -1
drivers/gpu/drm/amd/display/dc/dml2/display_mode_core.c
··· 5420 5420 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 13500, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output, 5421 5421 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots); 5422 5422 5423 - if (OutBpp == 0 && PHYCLKD32PerState < 20000 / 32 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) { 5423 + if (*OutBpp == 0 && PHYCLKD32PerState < 20000 / 32 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) { 5424 5424 *RequiresDSC = true; 5425 5425 LinkDSCEnable = true; 5426 5426 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 13500, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
+6
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c
··· 960 960 dc->caps.dmub_caps.subvp_psr = dc->ctx->dmub_srv->dmub->feature_caps.subvp_psr_support; 961 961 dc->caps.dmub_caps.gecc_enable = dc->ctx->dmub_srv->dmub->feature_caps.gecc_enable; 962 962 dc->caps.dmub_caps.mclk_sw = dc->ctx->dmub_srv->dmub->feature_caps.fw_assisted_mclk_switch; 963 + 964 + if (dc->ctx->dmub_srv->dmub->fw_version < 965 + DMUB_FW_VERSION(7, 0, 35)) { 966 + dc->debug.force_disable_subvp = true; 967 + dc->debug.disable_fpo_optimizations = true; 968 + } 963 969 } 964 970 } 965 971
+2
drivers/gpu/drm/amd/display/include/grph_object_ctrl_defs.h
··· 417 417 /* V2.1 */ 418 418 struct edp_info edp1_info; 419 419 struct edp_info edp2_info; 420 + uint32_t gpuclk_ss_percentage; 421 + uint32_t gpuclk_ss_type; 420 422 }; 421 423 422 424 /*
+4 -3
drivers/gpu/drm/bridge/parade-ps8640.c
··· 210 210 struct ps8640 *ps_bridge = aux_to_ps8640(aux); 211 211 struct regmap *map = ps_bridge->regmap[PAGE0_DP_CNTL]; 212 212 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; 213 - unsigned int len = msg->size; 213 + size_t len = msg->size; 214 214 unsigned int data; 215 215 unsigned int base; 216 216 int ret; ··· 330 330 return ret; 331 331 } 332 332 333 - buf[i] = data; 333 + if (i < msg->size) 334 + buf[i] = data; 334 335 } 335 336 } 336 337 337 - return len; 338 + return min(len, msg->size); 338 339 } 339 340 340 341 static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux,
+3 -1
drivers/gpu/drm/bridge/ti-sn65dsi86.c
··· 527 527 u32 request_val = AUX_CMD_REQ(msg->request); 528 528 u8 *buf = msg->buffer; 529 529 unsigned int len = msg->size; 530 + unsigned int short_len; 530 531 unsigned int val; 531 532 int ret; 532 533 u8 addr_len[SN_AUX_LENGTH_REG + 1 - SN_AUX_ADDR_19_16_REG]; ··· 601 600 } 602 601 603 602 if (val & AUX_IRQ_STATUS_AUX_SHORT) { 604 - ret = regmap_read(pdata->regmap, SN_AUX_LENGTH_REG, &len); 603 + ret = regmap_read(pdata->regmap, SN_AUX_LENGTH_REG, &short_len); 604 + len = min(len, short_len); 605 605 if (ret) 606 606 goto exit; 607 607 } else if (val & AUX_IRQ_STATUS_NAT_I2C_FAIL) {
+2 -1
drivers/gpu/drm/i915/display/intel_cx0_phy.c
··· 2465 2465 2466 2466 val |= XELPDP_FORWARD_CLOCK_UNGATE; 2467 2467 2468 - if (is_hdmi_frl(crtc_state->port_clock)) 2468 + if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) && 2469 + is_hdmi_frl(crtc_state->port_clock)) 2469 2470 val |= XELPDP_DDI_CLOCK_SELECT(XELPDP_DDI_CLOCK_SELECT_DIV18CLK); 2470 2471 else 2471 2472 val |= XELPDP_DDI_CLOCK_SELECT(XELPDP_DDI_CLOCK_SELECT_MAXPCLK);
+12 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 3747 3747 if (!active) 3748 3748 goto out; 3749 3749 3750 - intel_dsc_get_config(pipe_config); 3751 3750 intel_bigjoiner_get_config(pipe_config); 3751 + intel_dsc_get_config(pipe_config); 3752 3752 3753 3753 if (!transcoder_is_dsi(pipe_config->cpu_transcoder) || 3754 3754 DISPLAY_VER(dev_priv) >= 11) ··· 6029 6029 if (intel_crtc_needs_modeset(new_crtc_state)) { 6030 6030 drm_dbg_kms(&i915->drm, 6031 6031 "[CRTC:%d:%s] modeset required\n", 6032 + crtc->base.base.id, crtc->base.name); 6033 + return -EINVAL; 6034 + } 6035 + 6036 + /* 6037 + * FIXME: Bigjoiner+async flip is busted currently. 6038 + * Remove this check once the issues are fixed. 6039 + */ 6040 + if (new_crtc_state->bigjoiner_pipes) { 6041 + drm_dbg_kms(&i915->drm, 6042 + "[CRTC:%d:%s] async flip disallowed with bigjoiner\n", 6032 6043 crtc->base.base.id, crtc->base.name); 6033 6044 return -EINVAL; 6034 6045 }
+41 -2
drivers/gpu/drm/i915/display/intel_dmc.c
··· 389 389 enum intel_dmc_id dmc_id; 390 390 391 391 /* TODO: check if the following applies to all D13+ platforms. */ 392 - if (!IS_DG2(i915) && !IS_TIGERLAKE(i915)) 392 + if (!IS_TIGERLAKE(i915)) 393 393 return; 394 394 395 395 for_each_dmc_id(dmc_id) { ··· 493 493 intel_de_rmw(i915, PIPEDMC_CONTROL(pipe), PIPEDMC_ENABLE, 0); 494 494 } 495 495 496 + static bool is_dmc_evt_ctl_reg(struct drm_i915_private *i915, 497 + enum intel_dmc_id dmc_id, i915_reg_t reg) 498 + { 499 + u32 offset = i915_mmio_reg_offset(reg); 500 + u32 start = i915_mmio_reg_offset(DMC_EVT_CTL(i915, dmc_id, 0)); 501 + u32 end = i915_mmio_reg_offset(DMC_EVT_CTL(i915, dmc_id, DMC_EVENT_HANDLER_COUNT_GEN12)); 502 + 503 + return offset >= start && offset < end; 504 + } 505 + 506 + static bool disable_dmc_evt(struct drm_i915_private *i915, 507 + enum intel_dmc_id dmc_id, 508 + i915_reg_t reg, u32 data) 509 + { 510 + if (!is_dmc_evt_ctl_reg(i915, dmc_id, reg)) 511 + return false; 512 + 513 + /* keep all pipe DMC events disabled by default */ 514 + if (dmc_id != DMC_FW_MAIN) 515 + return true; 516 + 517 + return false; 518 + } 519 + 520 + static u32 dmc_mmiodata(struct drm_i915_private *i915, 521 + struct intel_dmc *dmc, 522 + enum intel_dmc_id dmc_id, int i) 523 + { 524 + if (disable_dmc_evt(i915, dmc_id, 525 + dmc->dmc_info[dmc_id].mmioaddr[i], 526 + dmc->dmc_info[dmc_id].mmiodata[i])) 527 + return REG_FIELD_PREP(DMC_EVT_CTL_TYPE_MASK, 528 + DMC_EVT_CTL_TYPE_EDGE_0_1) | 529 + REG_FIELD_PREP(DMC_EVT_CTL_EVENT_ID_MASK, 530 + DMC_EVT_CTL_EVENT_ID_FALSE); 531 + else 532 + return dmc->dmc_info[dmc_id].mmiodata[i]; 533 + } 534 + 496 535 /** 497 536 * intel_dmc_load_program() - write the firmware from memory to register. 498 537 * @i915: i915 drm device. ··· 571 532 for_each_dmc_id(dmc_id) { 572 533 for (i = 0; i < dmc->dmc_info[dmc_id].mmio_count; i++) { 573 534 intel_de_write(i915, dmc->dmc_info[dmc_id].mmioaddr[i], 574 - dmc->dmc_info[dmc_id].mmiodata[i]); 535 + dmc_mmiodata(i915, dmc, dmc_id, i)); 575 536 } 576 537 } 577 538
+1 -1
drivers/gpu/drm/i915/display/intel_dp.c
··· 4496 4496 intel_dp->train_set, crtc_state->lane_count); 4497 4497 4498 4498 drm_dp_set_phy_test_pattern(&intel_dp->aux, data, 4499 - link_status[DP_DPCD_REV]); 4499 + intel_dp->dpcd[DP_DPCD_REV]); 4500 4500 } 4501 4501 4502 4502 static u8 intel_dp_autotest_phy_pattern(struct intel_dp *intel_dp)
+2 -2
drivers/gpu/drm/i915/i915_hwmon.c
··· 175 175 * tau4 = (4 | x) << y 176 176 * but add 2 when doing the final right shift to account for units 177 177 */ 178 - tau4 = ((1 << x_w) | x) << y; 178 + tau4 = (u64)((1 << x_w) | x) << y; 179 179 /* val in hwmon interface units (millisec) */ 180 180 out = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); 181 181 ··· 211 211 r = FIELD_PREP(PKG_MAX_WIN, PKG_MAX_WIN_DEFAULT); 212 212 x = REG_FIELD_GET(PKG_MAX_WIN_X, r); 213 213 y = REG_FIELD_GET(PKG_MAX_WIN_Y, r); 214 - tau4 = ((1 << x_w) | x) << y; 214 + tau4 = (u64)((1 << x_w) | x) << y; 215 215 max_win = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); 216 216 217 217 if (val > max_win)
+34 -5
drivers/gpu/drm/i915/i915_perf.c
··· 772 772 * The reason field includes flags identifying what 773 773 * triggered this specific report (mostly timer 774 774 * triggered or e.g. due to a context switch). 775 - * 776 - * In MMIO triggered reports, some platforms do not set the 777 - * reason bit in this field and it is valid to have a reason 778 - * field of zero. 779 775 */ 780 776 reason = oa_report_reason(stream, report); 781 777 ctx_id = oa_context_id(stream, report32); ··· 783 787 * 784 788 * Note: that we don't clear the valid_ctx_bit so userspace can 785 789 * understand that the ID has been squashed by the kernel. 790 + * 791 + * Update: 792 + * 793 + * On XEHP platforms the behavior of context id valid bit has 794 + * changed compared to prior platforms. To describe this, we 795 + * define a few terms: 796 + * 797 + * context-switch-report: This is a report with the reason type 798 + * being context-switch. It is generated when a context switches 799 + * out. 800 + * 801 + * context-valid-bit: A bit that is set in the report ID field 802 + * to indicate that a valid context has been loaded. 803 + * 804 + * gpu-idle: A condition characterized by a 805 + * context-switch-report with context-valid-bit set to 0. 806 + * 807 + * On prior platforms, context-id-valid bit is set to 0 only 808 + * when GPU goes idle. In all other reports, it is set to 1. 809 + * 810 + * On XEHP platforms, context-valid-bit is set to 1 in a context 811 + * switch report if a new context switched in. For all other 812 + * reports it is set to 0. 813 + * 814 + * This change in behavior causes an issue with MMIO triggered 815 + * reports. MMIO triggered reports have the markers in the 816 + * context ID field and the context-valid-bit is 0. The logic 817 + * below to squash the context ID would render the report 818 + * useless since the user will not be able to find it in the OA 819 + * buffer. Since MMIO triggered reports exist only on XEHP, 820 + * we should avoid squashing these for XEHP platforms. 786 821 */ 787 - if (oa_report_ctx_invalid(stream, report)) { 822 + 823 + if (oa_report_ctx_invalid(stream, report) && 824 + GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) { 788 825 ctx_id = INVALID_CTX_ID; 789 826 oa_context_id_squash(stream, report32); 790 827 }
+5
drivers/gpu/drm/mgag200/mgag200_drv.h
··· 392 392 .destroy = drm_plane_cleanup, \ 393 393 DRM_GEM_SHADOW_PLANE_FUNCS 394 394 395 + void mgag200_crtc_set_gamma_linear(struct mga_device *mdev, const struct drm_format_info *format); 396 + void mgag200_crtc_set_gamma(struct mga_device *mdev, 397 + const struct drm_format_info *format, 398 + struct drm_color_lut *lut); 399 + 395 400 enum drm_mode_status mgag200_crtc_helper_mode_valid(struct drm_crtc *crtc, 396 401 const struct drm_display_mode *mode); 397 402 int mgag200_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *new_state);
+5
drivers/gpu/drm/mgag200/mgag200_g200er.c
··· 202 202 203 203 mgag200_g200er_reset_tagfifo(mdev); 204 204 205 + if (crtc_state->gamma_lut) 206 + mgag200_crtc_set_gamma(mdev, format, crtc_state->gamma_lut->data); 207 + else 208 + mgag200_crtc_set_gamma_linear(mdev, format); 209 + 205 210 mgag200_enable_display(mdev); 206 211 207 212 if (funcs->enable_vidrst)
+5
drivers/gpu/drm/mgag200/mgag200_g200ev.c
··· 203 203 204 204 mgag200_g200ev_set_hiprilvl(mdev); 205 205 206 + if (crtc_state->gamma_lut) 207 + mgag200_crtc_set_gamma(mdev, format, crtc_state->gamma_lut->data); 208 + else 209 + mgag200_crtc_set_gamma_linear(mdev, format); 210 + 206 211 mgag200_enable_display(mdev); 207 212 208 213 if (funcs->enable_vidrst)
+5
drivers/gpu/drm/mgag200/mgag200_g200se.c
··· 334 334 335 335 mgag200_g200se_set_hiprilvl(mdev, adjusted_mode, format); 336 336 337 + if (crtc_state->gamma_lut) 338 + mgag200_crtc_set_gamma(mdev, format, crtc_state->gamma_lut->data); 339 + else 340 + mgag200_crtc_set_gamma_linear(mdev, format); 341 + 337 342 mgag200_enable_display(mdev); 338 343 339 344 if (funcs->enable_vidrst)
+5 -5
drivers/gpu/drm/mgag200/mgag200_mode.c
··· 28 28 * This file contains setup code for the CRTC. 29 29 */ 30 30 31 - static void mgag200_crtc_set_gamma_linear(struct mga_device *mdev, 32 - const struct drm_format_info *format) 31 + void mgag200_crtc_set_gamma_linear(struct mga_device *mdev, 32 + const struct drm_format_info *format) 33 33 { 34 34 int i; 35 35 ··· 65 65 } 66 66 } 67 67 68 - static void mgag200_crtc_set_gamma(struct mga_device *mdev, 69 - const struct drm_format_info *format, 70 - struct drm_color_lut *lut) 68 + void mgag200_crtc_set_gamma(struct mga_device *mdev, 69 + const struct drm_format_info *format, 70 + struct drm_color_lut *lut) 71 71 { 72 72 int i; 73 73
+32 -16
drivers/i2c/busses/i2c-aspeed.c
··· 249 249 if (!slave) 250 250 return 0; 251 251 252 - command = readl(bus->base + ASPEED_I2C_CMD_REG); 252 + /* 253 + * Handle stop conditions early, prior to SLAVE_MATCH. Some masters may drive 254 + * transfers with low enough latency between the nak/stop phase of the current 255 + * command and the start/address phase of the following command that the 256 + * interrupts are coalesced by the time we process them. 257 + */ 258 + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { 259 + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; 260 + bus->slave_state = ASPEED_I2C_SLAVE_STOP; 261 + } 253 262 254 - /* Slave was requested, restart state machine. */ 263 + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && 264 + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { 265 + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; 266 + bus->slave_state = ASPEED_I2C_SLAVE_STOP; 267 + } 268 + 269 + /* Propagate any stop conditions to the slave implementation. */ 270 + if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { 271 + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); 272 + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; 273 + } 274 + 275 + /* 276 + * Now that we've dealt with any potentially coalesced stop conditions, 277 + * address any start conditions. 278 + */ 255 279 if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { 256 280 irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; 257 281 bus->slave_state = ASPEED_I2C_SLAVE_START; 258 282 } 259 283 260 - /* Slave is not currently active, irq was for someone else. */ 284 + /* 285 + * If the slave has been stopped and not started then slave interrupt 286 + * handling is complete. 287 + */ 261 288 if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) 262 289 return irq_handled; 263 290 291 + command = readl(bus->base + ASPEED_I2C_CMD_REG); 264 292 dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", 265 293 irq_status, command); 266 294 ··· 305 277 ASPEED_I2C_SLAVE_WRITE_REQUESTED; 306 278 } 307 279 irq_handled |= ASPEED_I2CD_INTR_RX_DONE; 308 - } 309 - 310 - /* Slave was asked to stop. */ 311 - if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { 312 - irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; 313 - bus->slave_state = ASPEED_I2C_SLAVE_STOP; 314 - } 315 - if (irq_status & ASPEED_I2CD_INTR_TX_NAK && 316 - bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { 317 - irq_handled |= ASPEED_I2CD_INTR_TX_NAK; 318 - bus->slave_state = ASPEED_I2C_SLAVE_STOP; 319 280 } 320 281 321 282 switch (bus->slave_state) { ··· 341 324 i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value); 342 325 break; 343 326 case ASPEED_I2C_SLAVE_STOP: 344 - i2c_slave_event(slave, I2C_SLAVE_STOP, &value); 345 - bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; 327 + /* Stop event handling is done early. Unreachable. */ 346 328 break; 347 329 case ASPEED_I2C_SLAVE_START: 348 330 /* Slave was just started. Waiting for the next event. */;
+7 -1
drivers/i2c/busses/i2c-qcom-geni.c
··· 858 858 ret = geni_se_resources_on(&gi2c->se); 859 859 if (ret) { 860 860 dev_err(dev, "Error turning on resources %d\n", ret); 861 + clk_disable_unprepare(gi2c->core_clk); 861 862 return ret; 862 863 } 863 864 proto = geni_se_read_proto(&gi2c->se); ··· 878 877 /* FIFO is disabled, so we can only use GPI DMA */ 879 878 gi2c->gpi_mode = true; 880 879 ret = setup_gpi_dma(gi2c); 881 - if (ret) 880 + if (ret) { 881 + geni_se_resources_off(&gi2c->se); 882 + clk_disable_unprepare(gi2c->core_clk); 882 883 return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n"); 884 + } 883 885 884 886 dev_dbg(dev, "Using GPI DMA mode for I2C\n"); 885 887 } else { ··· 895 891 896 892 if (!tx_depth) { 897 893 dev_err(dev, "Invalid TX FIFO depth\n"); 894 + geni_se_resources_off(&gi2c->se); 895 + clk_disable_unprepare(gi2c->core_clk); 898 896 return -EINVAL; 899 897 } 900 898
+11 -2
drivers/i2c/busses/i2c-rk3x.c
··· 178 178 * @clk: function clk for rk3399 or function & Bus clks for others 179 179 * @pclk: Bus clk for rk3399 180 180 * @clk_rate_nb: i2c clk rate change notify 181 + * @irq: irq number 181 182 * @t: I2C known timing information 182 183 * @lock: spinlock for the i2c bus 183 184 * @wait: the waitqueue to wait for i2c transfer ··· 201 200 struct clk *clk; 202 201 struct clk *pclk; 203 202 struct notifier_block clk_rate_nb; 203 + int irq; 204 204 205 205 /* Settings */ 206 206 struct i2c_timings t; ··· 1089 1087 1090 1088 spin_unlock_irqrestore(&i2c->lock, flags); 1091 1089 1092 - rk3x_i2c_start(i2c); 1093 - 1094 1090 if (!polling) { 1091 + rk3x_i2c_start(i2c); 1092 + 1095 1093 timeout = wait_event_timeout(i2c->wait, !i2c->busy, 1096 1094 msecs_to_jiffies(WAIT_TIMEOUT)); 1097 1095 } else { 1096 + disable_irq(i2c->irq); 1097 + rk3x_i2c_start(i2c); 1098 + 1098 1099 timeout = rk3x_i2c_wait_xfer_poll(i2c); 1100 + 1101 + enable_irq(i2c->irq); 1099 1102 } 1100 1103 1101 1104 spin_lock_irqsave(&i2c->lock, flags); ··· 1316 1309 dev_err(&pdev->dev, "cannot request IRQ\n"); 1317 1310 return ret; 1318 1311 } 1312 + 1313 + i2c->irq = irq; 1319 1314 1320 1315 platform_set_drvdata(pdev, i2c); 1321 1316
+26 -11
drivers/iio/accel/kionix-kx022a.c
··· 393 393 * (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2 394 394 * => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed 395 395 * in low-power mode(?) ) 396 - * => +/-2G => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro) 397 - * => +/-2G - 598.550415 398 - * +/-4G - 1197.10083 399 - * +/-8G - 2394.20166 400 - * +/-16G - 4788.40332 396 + * => +/-2G => 4 / 2^16 * 9,80665 397 + * => +/-2G - 0.000598550415 398 + * +/-4G - 0.00119710083 399 + * +/-8G - 0.00239420166 400 + * +/-16G - 0.00478840332 401 401 */ 402 402 static const int kx022a_scale_table[][2] = { 403 - { 598, 550415 }, 404 - { 1197, 100830 }, 405 - { 2394, 201660 }, 406 - { 4788, 403320 }, 403 + { 0, 598550 }, 404 + { 0, 1197101 }, 405 + { 0, 2394202 }, 406 + { 0, 4788403 }, 407 407 }; 408 408 409 409 static int kx022a_read_avail(struct iio_dev *indio_dev, ··· 422 422 *vals = (const int *)kx022a_scale_table; 423 423 *length = ARRAY_SIZE(kx022a_scale_table) * 424 424 ARRAY_SIZE(kx022a_scale_table[0]); 425 - *type = IIO_VAL_INT_PLUS_MICRO; 425 + *type = IIO_VAL_INT_PLUS_NANO; 426 426 return IIO_AVAIL_LIST; 427 427 default: 428 428 return -EINVAL; ··· 483 483 mutex_unlock(&data->mutex); 484 484 485 485 return ret; 486 + } 487 + 488 + static int kx022a_write_raw_get_fmt(struct iio_dev *idev, 489 + struct iio_chan_spec const *chan, 490 + long mask) 491 + { 492 + switch (mask) { 493 + case IIO_CHAN_INFO_SCALE: 494 + return IIO_VAL_INT_PLUS_NANO; 495 + case IIO_CHAN_INFO_SAMP_FREQ: 496 + return IIO_VAL_INT_PLUS_MICRO; 497 + default: 498 + return -EINVAL; 499 + } 486 500 } 487 501 488 502 static int kx022a_write_raw(struct iio_dev *idev, ··· 643 629 644 630 kx022a_reg2scale(regval, val, val2); 645 631 646 - return IIO_VAL_INT_PLUS_MICRO; 632 + return IIO_VAL_INT_PLUS_NANO; 647 633 } 648 634 649 635 return -EINVAL; ··· 870 856 static const struct iio_info kx022a_info = { 871 857 .read_raw = &kx022a_read_raw, 872 858 .write_raw = &kx022a_write_raw, 859 + .write_raw_get_fmt = &kx022a_write_raw_get_fmt, 873 860 .read_avail = &kx022a_read_avail, 874 861 875 862 .validate_trigger = iio_validate_own_trigger,
+4
drivers/iio/adc/imx93_adc.c
··· 93 93 IMX93_ADC_CHAN(1), 94 94 IMX93_ADC_CHAN(2), 95 95 IMX93_ADC_CHAN(3), 96 + IMX93_ADC_CHAN(4), 97 + IMX93_ADC_CHAN(5), 98 + IMX93_ADC_CHAN(6), 99 + IMX93_ADC_CHAN(7), 96 100 }; 97 101 98 102 static void imx93_adc_power_down(struct imx93_adc *adc)
+4 -4
drivers/iio/adc/mcp3564.c
··· 918 918 mutex_unlock(&adc->lock); 919 919 return ret; 920 920 case IIO_CHAN_INFO_CALIBBIAS: 921 - if (val < mcp3564_calib_bias[0] && val > mcp3564_calib_bias[2]) 921 + if (val < mcp3564_calib_bias[0] || val > mcp3564_calib_bias[2]) 922 922 return -EINVAL; 923 923 924 924 mutex_lock(&adc->lock); ··· 928 928 mutex_unlock(&adc->lock); 929 929 return ret; 930 930 case IIO_CHAN_INFO_CALIBSCALE: 931 - if (val < mcp3564_calib_scale[0] && val > mcp3564_calib_scale[2]) 931 + if (val < mcp3564_calib_scale[0] || val > mcp3564_calib_scale[2]) 932 932 return -EINVAL; 933 933 934 934 if (adc->calib_scale == val) ··· 1122 1122 enum mcp3564_ids ids; 1123 1123 int ret = 0; 1124 1124 unsigned int tmp = 0x01; 1125 - bool err = true; 1125 + bool err = false; 1126 1126 1127 1127 /* 1128 1128 * The address is set on a per-device basis by fuses in the factory, ··· 1509 1509 module_spi_driver(mcp3564_driver); 1510 1510 1511 1511 MODULE_AUTHOR("Marius Cristea <marius.cristea@microchip.com>"); 1512 - MODULE_DESCRIPTION("Microchip MCP346x/MCP346xR and MCP356x/MCP346xR ADCs"); 1512 + MODULE_DESCRIPTION("Microchip MCP346x/MCP346xR and MCP356x/MCP356xR ADCs"); 1513 1513 MODULE_LICENSE("GPL v2");
+15 -1
drivers/iio/adc/meson_saradc.c
··· 1241 1241 .cmv_select = 1, 1242 1242 }; 1243 1243 1244 + static const struct meson_sar_adc_param meson_sar_adc_axg_param = { 1245 + .has_bl30_integration = true, 1246 + .clock_rate = 1200000, 1247 + .bandgap_reg = MESON_SAR_ADC_REG11, 1248 + .regmap_config = &meson_sar_adc_regmap_config_gxbb, 1249 + .resolution = 12, 1250 + .disable_ring_counter = 1, 1251 + .has_reg11 = true, 1252 + .vref_volatge = 1, 1253 + .has_vref_select = true, 1254 + .vref_select = VREF_VDDA, 1255 + .cmv_select = 1, 1256 + }; 1257 + 1244 1258 static const struct meson_sar_adc_param meson_sar_adc_g12a_param = { 1245 1259 .has_bl30_integration = false, 1246 1260 .clock_rate = 1200000, ··· 1299 1285 }; 1300 1286 1301 1287 static const struct meson_sar_adc_data meson_sar_adc_axg_data = { 1302 - .param = &meson_sar_adc_gxl_param, 1288 + .param = &meson_sar_adc_axg_param, 1303 1289 .name = "meson-axg-saradc", 1304 1290 }; 1305 1291
+3 -1
drivers/iio/adc/ti_am335x_adc.c
··· 670 670 platform_set_drvdata(pdev, indio_dev); 671 671 672 672 err = tiadc_request_dma(pdev, adc_dev); 673 - if (err && err == -EPROBE_DEFER) 673 + if (err && err != -ENODEV) { 674 + dev_err_probe(&pdev->dev, err, "DMA request failed\n"); 674 675 goto err_dma; 676 + } 675 677 676 678 return 0; 677 679
+10
drivers/iio/buffer/industrialio-triggered-buffer.c
··· 46 46 struct iio_buffer *buffer; 47 47 int ret; 48 48 49 + /* 50 + * iio_triggered_buffer_cleanup() assumes that the buffer allocated here 51 + * is assigned to indio_dev->buffer but this is only the case if this 52 + * function is the first caller to iio_device_attach_buffer(). If 53 + * indio_dev->buffer is already set then we can't proceed otherwise the 54 + * cleanup function will try to free a buffer that was not allocated here. 55 + */ 56 + if (indio_dev->buffer) 57 + return -EADDRINUSE; 58 + 49 59 buffer = iio_kfifo_allocate(); 50 60 if (!buffer) { 51 61 ret = -ENOMEM;
+2 -2
drivers/iio/common/ms_sensors/ms_sensors_i2c.c
··· 15 15 /* Conversion times in us */ 16 16 static const u16 ms_sensors_ht_t_conversion_time[] = { 50000, 25000, 17 17 13000, 7000 }; 18 - static const u16 ms_sensors_ht_h_conversion_time[] = { 16000, 3000, 19 - 5000, 8000 }; 18 + static const u16 ms_sensors_ht_h_conversion_time[] = { 16000, 5000, 19 + 3000, 8000 }; 20 20 static const u16 ms_sensors_tp_conversion_time[] = { 500, 1100, 2100, 21 21 4100, 8220, 16440 }; 22 22
+80 -53
drivers/iio/imu/adis16475.c
··· 70 70 #define ADIS16475_MAX_SCAN_DATA 20 71 71 /* spi max speed in brust mode */ 72 72 #define ADIS16475_BURST_MAX_SPEED 1000000 73 - #define ADIS16475_LSB_DEC_MASK BIT(0) 74 - #define ADIS16475_LSB_FIR_MASK BIT(1) 73 + #define ADIS16475_LSB_DEC_MASK 0 74 + #define ADIS16475_LSB_FIR_MASK 1 75 75 #define ADIS16500_BURST_DATA_SEL_0_CHN_MASK GENMASK(5, 0) 76 76 #define ADIS16500_BURST_DATA_SEL_1_CHN_MASK GENMASK(12, 7) 77 77 ··· 1406 1406 return 0; 1407 1407 } 1408 1408 1409 + 1410 + static int adis16475_probe(struct spi_device *spi) 1411 + { 1412 + struct iio_dev *indio_dev; 1413 + struct adis16475 *st; 1414 + int ret; 1415 + 1416 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 1417 + if (!indio_dev) 1418 + return -ENOMEM; 1419 + 1420 + st = iio_priv(indio_dev); 1421 + 1422 + st->info = spi_get_device_match_data(spi); 1423 + if (!st->info) 1424 + return -EINVAL; 1425 + 1426 + ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data); 1427 + if (ret) 1428 + return ret; 1429 + 1430 + indio_dev->name = st->info->name; 1431 + indio_dev->channels = st->info->channels; 1432 + indio_dev->num_channels = st->info->num_channels; 1433 + indio_dev->info = &adis16475_info; 1434 + indio_dev->modes = INDIO_DIRECT_MODE; 1435 + 1436 + ret = __adis_initial_startup(&st->adis); 1437 + if (ret) 1438 + return ret; 1439 + 1440 + ret = adis16475_config_irq_pin(st); 1441 + if (ret) 1442 + return ret; 1443 + 1444 + ret = adis16475_config_sync_mode(st); 1445 + if (ret) 1446 + return ret; 1447 + 1448 + ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, 1449 + adis16475_trigger_handler); 1450 + if (ret) 1451 + return ret; 1452 + 1453 + ret = devm_iio_device_register(&spi->dev, indio_dev); 1454 + if (ret) 1455 + return ret; 1456 + 1457 + adis16475_debugfs_init(indio_dev); 1458 + 1459 + return 0; 1460 + } 1461 + 1409 1462 static const struct of_device_id adis16475_of_match[] = { 1410 1463 { .compatible = "adi,adis16470", 1411 1464 .data = &adis16475_chip_info[ADIS16470] }, ··· 1504 1451 }; 1505 1452 MODULE_DEVICE_TABLE(of, adis16475_of_match); 1506 1453 1507 - static int adis16475_probe(struct spi_device *spi) 1508 - { 1509 - struct iio_dev *indio_dev; 1510 - struct adis16475 *st; 1511 - int ret; 1512 - 1513 - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 1514 - if (!indio_dev) 1515 - return -ENOMEM; 1516 - 1517 - st = iio_priv(indio_dev); 1518 - 1519 - st->info = device_get_match_data(&spi->dev); 1520 - if (!st->info) 1521 - return -EINVAL; 1522 - 1523 - ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data); 1524 - if (ret) 1525 - return ret; 1526 - 1527 - indio_dev->name = st->info->name; 1528 - indio_dev->channels = st->info->channels; 1529 - indio_dev->num_channels = st->info->num_channels; 1530 - indio_dev->info = &adis16475_info; 1531 - indio_dev->modes = INDIO_DIRECT_MODE; 1532 - 1533 - ret = __adis_initial_startup(&st->adis); 1534 - if (ret) 1535 - return ret; 1536 - 1537 - ret = adis16475_config_irq_pin(st); 1538 - if (ret) 1539 - return ret; 1540 - 1541 - ret = adis16475_config_sync_mode(st); 1542 - if (ret) 1543 - return ret; 1544 - 1545 - ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, 1546 - adis16475_trigger_handler); 1547 - if (ret) 1548 - return ret; 1549 - 1550 - ret = devm_iio_device_register(&spi->dev, indio_dev); 1551 - if (ret) 1552 - return ret; 1553 - 1554 - adis16475_debugfs_init(indio_dev); 1555 - 1556 - return 0; 1557 - } 1454 + static const struct spi_device_id adis16475_ids[] = { 1455 + { "adis16470", (kernel_ulong_t)&adis16475_chip_info[ADIS16470] }, 1456 + { "adis16475-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_1] }, 1457 + { "adis16475-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_2] }, 1458 + { "adis16475-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_3] }, 1459 + { "adis16477-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_1] }, 1460 + { "adis16477-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_2] }, 1461 + { "adis16477-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_3] }, 1462 + { "adis16465-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_1] }, 1463 + { "adis16465-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_2] }, 1464 + { "adis16465-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_3] }, 1465 + { "adis16467-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_1] }, 1466 + { "adis16467-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_2] }, 1467 + { "adis16467-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_3] }, 1468 + { "adis16500", (kernel_ulong_t)&adis16475_chip_info[ADIS16500] }, 1469 + { "adis16505-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_1] }, 1470 + { "adis16505-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_2] }, 1471 + { "adis16505-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_3] }, 1472 + { "adis16507-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_1] }, 1473 + { "adis16507-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_2] }, 1474 + { "adis16507-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_3] }, 1475 + { } 1476 + }; 1477 + MODULE_DEVICE_TABLE(spi, adis16475_ids); 1558 1478 1559 1479 static struct spi_driver adis16475_driver = { 1560 1480 .driver = { ··· 1535 1509 .of_match_table = adis16475_of_match, 1536 1510 }, 1537 1511 .probe = adis16475_probe, 1512 + .id_table = adis16475_ids, 1538 1513 }; 1539 1514 module_spi_driver(adis16475_driver); 1540 1515
+2 -2
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
··· 750 750 ret = inv_mpu6050_sensor_show(st, st->reg->gyro_offset, 751 751 chan->channel2, val); 752 752 mutex_unlock(&st->lock); 753 - return IIO_VAL_INT; 753 + return ret; 754 754 case IIO_ACCEL: 755 755 mutex_lock(&st->lock); 756 756 ret = inv_mpu6050_sensor_show(st, st->reg->accl_offset, 757 757 chan->channel2, val); 758 758 mutex_unlock(&st->lock); 759 - return IIO_VAL_INT; 759 + return ret; 760 760 761 761 default: 762 762 return -EINVAL;
+2 -98
drivers/iio/light/hid-sensor-als.c
··· 14 14 #include "../common/hid-sensors/hid-sensor-trigger.h" 15 15 16 16 enum { 17 - CHANNEL_SCAN_INDEX_INTENSITY, 18 - CHANNEL_SCAN_INDEX_ILLUM, 19 - CHANNEL_SCAN_INDEX_COLOR_TEMP, 20 - CHANNEL_SCAN_INDEX_CHROMATICITY_X, 21 - CHANNEL_SCAN_INDEX_CHROMATICITY_Y, 17 + CHANNEL_SCAN_INDEX_INTENSITY = 0, 18 + CHANNEL_SCAN_INDEX_ILLUM = 1, 22 19 CHANNEL_SCAN_INDEX_MAX 23 20 }; 24 21 ··· 65 68 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), 66 69 .scan_index = CHANNEL_SCAN_INDEX_ILLUM, 67 70 }, 68 - { 69 - .type = IIO_COLORTEMP, 70 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 71 - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 72 - BIT(IIO_CHAN_INFO_SCALE) | 73 - BIT(IIO_CHAN_INFO_SAMP_FREQ) | 74 - BIT(IIO_CHAN_INFO_HYSTERESIS) | 75 - BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), 76 - .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP, 77 - }, 78 - { 79 - .type = IIO_CHROMATICITY, 80 - .modified = 1, 81 - .channel2 = IIO_MOD_X, 82 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 83 - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 84 - BIT(IIO_CHAN_INFO_SCALE) | 85 - BIT(IIO_CHAN_INFO_SAMP_FREQ) | 86 - BIT(IIO_CHAN_INFO_HYSTERESIS) | 87 - BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), 88 - .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X, 89 - }, 90 - { 91 - .type = IIO_CHROMATICITY, 92 - .modified = 1, 93 - .channel2 = IIO_MOD_Y, 94 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 95 - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 96 - BIT(IIO_CHAN_INFO_SCALE) | 97 - BIT(IIO_CHAN_INFO_SAMP_FREQ) | 98 - BIT(IIO_CHAN_INFO_HYSTERESIS) | 99 - BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), 100 - .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y, 101 - }, 102 71 IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP) 103 72 }; 104 73 ··· 102 139 report_id = als_state->als[chan->scan_index].report_id; 103 140 min = als_state->als[chan->scan_index].logical_minimum; 104 141 address = HID_USAGE_SENSOR_LIGHT_ILLUM; 105 - break; 106 - case CHANNEL_SCAN_INDEX_COLOR_TEMP: 107 - report_id = als_state->als[chan->scan_index].report_id; 108 - min = als_state->als[chan->scan_index].logical_minimum; 109 - address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE; 110 - break; 111 - case CHANNEL_SCAN_INDEX_CHROMATICITY_X: 112 - report_id = als_state->als[chan->scan_index].report_id; 113 - min = als_state->als[chan->scan_index].logical_minimum; 114 - address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X; 115 - break; 116 - case CHANNEL_SCAN_INDEX_CHROMATICITY_Y: 117 - report_id = als_state->als[chan->scan_index].report_id; 118 - min = als_state->als[chan->scan_index].logical_minimum; 119 - address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y; 120 142 break; 121 143 default: 122 144 report_id = -1; ··· 223 275 als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data; 224 276 ret = 0; 225 277 break; 226 - case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE: 227 - als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data; 228 - ret = 0; 229 - break; 230 - case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X: 231 - als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data; 232 - ret = 0; 233 - break; 234 - case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y: 235 - als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data; 236 - ret = 0; 237 - break; 238 278 case HID_USAGE_SENSOR_TIME_TIMESTAMP: 239 279 als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes, 240 280 *(s64 *)raw_data); ··· 256 320 257 321 dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index, 258 322 st->als[i].report_id); 259 - } 260 - 261 - ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, 262 - usage_id, 263 - HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE, 264 - &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); 265 - if (ret < 0) 266 - return ret; 267 - als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP, 268 - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); 269 - 270 - dev_dbg(&pdev->dev, "als %x:%x\n", 271 - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index, 272 - st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id); 273 - 274 - for (i = 0; i < 2; i++) { 275 - int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i; 276 - 277 - ret = sensor_hub_input_get_attribute_info(hsdev, 278 - HID_INPUT_REPORT, usage_id, 279 - HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i, 280 - &st->als[next_scan_index]); 281 - if (ret < 0) 282 - return ret; 283 - 284 - als_adjust_channel_bit_mask(channels, 285 - CHANNEL_SCAN_INDEX_CHROMATICITY_X + i, 286 - st->als[next_scan_index].size); 287 - 288 - dev_dbg(&pdev->dev, "als %x:%x\n", 289 - st->als[next_scan_index].index, 290 - st->als[next_scan_index].report_id); 291 323 } 292 324 293 325 st->scale_precision = hid_sensor_format_scale(usage_id,
+1 -1
drivers/iio/magnetometer/tmag5273.c
··· 356 356 case IIO_CHAN_INFO_OFFSET: 357 357 switch (chan->type) { 358 358 case IIO_TEMP: 359 - *val = -266314; 359 + *val = -16005; 360 360 return IIO_VAL_INT; 361 361 default: 362 362 return -EINVAL;
+1
drivers/input/joystick/xpad.c
··· 286 286 { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 287 287 { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 288 288 { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, 289 + { 0x1532, 0x0a29, "Razer Wolverine V2", 0, XTYPE_XBOXONE }, 289 290 { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 }, 290 291 { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, 291 292 { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
+42 -4
drivers/input/keyboard/atkbd.c
··· 765 765 ps2dev->serio->phys); 766 766 } 767 767 768 + #ifdef CONFIG_X86 769 + static bool atkbd_is_portable_device(void) 770 + { 771 + static const char * const chassis_types[] = { 772 + "8", /* Portable */ 773 + "9", /* Laptop */ 774 + "10", /* Notebook */ 775 + "14", /* Sub-Notebook */ 776 + "31", /* Convertible */ 777 + "32", /* Detachable */ 778 + }; 779 + int i; 780 + 781 + for (i = 0; i < ARRAY_SIZE(chassis_types); i++) 782 + if (dmi_match(DMI_CHASSIS_TYPE, chassis_types[i])) 783 + return true; 784 + 785 + return false; 786 + } 787 + 788 + /* 789 + * On many modern laptops ATKBD_CMD_GETID may cause problems, on these laptops 790 + * the controller is always in translated mode. In this mode mice/touchpads will 791 + * not work. So in this case simply assume a keyboard is connected to avoid 792 + * confusing some laptop keyboards. 793 + * 794 + * Skipping ATKBD_CMD_GETID ends up using a fake keyboard id. Using a fake id is 795 + * ok in translated mode, only atkbd_select_set() checks atkbd->id and in 796 + * translated mode that is a no-op. 797 + */ 798 + static bool atkbd_skip_getid(struct atkbd *atkbd) 799 + { 800 + return atkbd->translated && atkbd_is_portable_device(); 801 + } 802 + #else 803 + static inline bool atkbd_skip_getid(struct atkbd *atkbd) { return false; } 804 + #endif 805 + 768 806 /* 769 807 * atkbd_probe() probes for an AT keyboard on a serio port. 770 808 */ ··· 832 794 */ 833 795 834 796 param[0] = param[1] = 0xa5; /* initialize with invalid values */ 835 - if (ps2_command(ps2dev, param, ATKBD_CMD_GETID)) { 797 + if (atkbd_skip_getid(atkbd) || ps2_command(ps2dev, param, ATKBD_CMD_GETID)) { 836 798 837 799 /* 838 - * If the get ID command failed, we check if we can at least set the LEDs on 839 - * the keyboard. This should work on every keyboard out there. It also turns 840 - * the LEDs off, which we want anyway. 800 + * If the get ID command was skipped or failed, we check if we can at least set 801 + * the LEDs on the keyboard. This should work on every keyboard out there. 802 + * It also turns the LEDs off, which we want anyway. 841 803 */ 842 804 param[0] = 0; 843 805 if (ps2_command(ps2dev, param, ATKBD_CMD_SETLEDS))
+3
drivers/input/keyboard/ipaq-micro-keys.c
··· 105 105 keys->codes = devm_kmemdup(&pdev->dev, micro_keycodes, 106 106 keys->input->keycodesize * keys->input->keycodemax, 107 107 GFP_KERNEL); 108 + if (!keys->codes) 109 + return -ENOMEM; 110 + 108 111 keys->input->keycode = keys->codes; 109 112 110 113 __set_bit(EV_KEY, keys->input->evbit);
+5
drivers/input/misc/soc_button_array.c
··· 299 299 info->name = "power"; 300 300 info->event_code = KEY_POWER; 301 301 info->wakeup = true; 302 + } else if (upage == 0x01 && usage == 0xc6) { 303 + info->name = "airplane mode switch"; 304 + info->event_type = EV_SW; 305 + info->event_code = SW_RFKILL_ALL; 306 + info->active_low = false; 302 307 } else if (upage == 0x01 && usage == 0xca) { 303 308 info->name = "rotation lock switch"; 304 309 info->event_type = EV_SW;
+2 -3
drivers/input/mouse/amimouse.c
··· 125 125 return 0; 126 126 } 127 127 128 - static int __exit amimouse_remove(struct platform_device *pdev) 128 + static void __exit amimouse_remove(struct platform_device *pdev) 129 129 { 130 130 struct input_dev *dev = platform_get_drvdata(pdev); 131 131 132 132 input_unregister_device(dev); 133 - return 0; 134 133 } 135 134 136 135 static struct platform_driver amimouse_driver = { 137 - .remove = __exit_p(amimouse_remove), 136 + .remove_new = __exit_p(amimouse_remove), 138 137 .driver = { 139 138 .name = "amiga-mouse", 140 139 },
+1
drivers/input/mouse/synaptics.c
··· 183 183 "LEN009b", /* T580 */ 184 184 "LEN0402", /* X1 Extreme Gen 2 / P1 Gen 2 */ 185 185 "LEN040f", /* P1 Gen 3 */ 186 + "LEN0411", /* L14 Gen 1 */ 186 187 "LEN200f", /* T450s */ 187 188 "LEN2044", /* L470 */ 188 189 "LEN2054", /* E480 */
+8
drivers/input/serio/i8042-acpipnpio.h
··· 361 361 .driver_data = (void *)(SERIO_QUIRK_DRITEK) 362 362 }, 363 363 { 364 + /* Acer TravelMate P459-G2-M */ 365 + .matches = { 366 + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 367 + DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate P459-G2-M"), 368 + }, 369 + .driver_data = (void *)(SERIO_QUIRK_NOMUX) 370 + }, 371 + { 364 372 /* Amoi M636/A737 */ 365 373 .matches = { 366 374 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
+3
drivers/interconnect/core.c
··· 395 395 } 396 396 mutex_unlock(&icc_lock); 397 397 398 + if (!node) 399 + return ERR_PTR(-EINVAL); 400 + 398 401 if (IS_ERR(node)) 399 402 return ERR_CAST(node); 400 403
+1 -1
drivers/interconnect/qcom/icc-rpm.c
··· 307 307 308 308 if (qn->ib_coeff) { 309 309 agg_peak_rate = qn->max_peak[ctx] * 100; 310 - agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff); 310 + agg_peak_rate = div_u64(agg_peak_rate, qn->ib_coeff); 311 311 } else { 312 312 agg_peak_rate = qn->max_peak[ctx]; 313 313 }
+1
drivers/interconnect/qcom/sm8250.c
··· 1995 1995 .driver = { 1996 1996 .name = "qnoc-sm8250", 1997 1997 .of_match_table = qnoc_of_match, 1998 + .sync_state = icc_sync_state, 1998 1999 }, 1999 2000 }; 2000 2001 module_platform_driver(qnoc_driver);
+2 -2
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 13024 13024 bnxt_cfg_ntp_filters(bp); 13025 13025 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) 13026 13026 bnxt_hwrm_exec_fwd_req(bp); 13027 + if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) 13028 + netdev_info(bp->dev, "Receive PF driver unload event!\n"); 13027 13029 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { 13028 13030 bnxt_hwrm_port_qstats(bp, 0); 13029 13031 bnxt_hwrm_port_qstats_ext(bp, 0); ··· 14097 14095 bnxt_del_ntp_filter(bp, fltr); 14098 14096 } 14099 14097 } 14100 - if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) 14101 - netdev_info(bp->dev, "Receive PF driver unload event!\n"); 14102 14098 #endif 14103 14099 } 14104 14100
+3 -1
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 2132 2132 /* Note: if we ever change from DMA_TX_APPEND_CRC below we 2133 2133 * will need to restore software padding of "runt" packets 2134 2134 */ 2135 + len_stat |= DMA_TX_APPEND_CRC; 2136 + 2135 2137 if (!i) { 2136 - len_stat |= DMA_TX_APPEND_CRC | DMA_SOP; 2138 + len_stat |= DMA_SOP; 2137 2139 if (skb->ip_summed == CHECKSUM_PARTIAL) 2138 2140 len_stat |= DMA_TX_DO_CSUM; 2139 2141 }
+10 -1
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 107 107 static void netdev_hw_addr_refcnt(struct i40e_mac_filter *f, 108 108 struct net_device *netdev, int delta) 109 109 { 110 + struct netdev_hw_addr_list *ha_list; 110 111 struct netdev_hw_addr *ha; 111 112 112 113 if (!f || !netdev) 113 114 return; 114 115 115 - netdev_for_each_mc_addr(ha, netdev) { 116 + if (is_unicast_ether_addr(f->macaddr) || is_link_local_ether_addr(f->macaddr)) 117 + ha_list = &netdev->uc; 118 + else 119 + ha_list = &netdev->mc; 120 + 121 + netdev_hw_addr_list_for_each(ha, ha_list) { 116 122 if (ether_addr_equal(ha->addr, f->macaddr)) { 117 123 ha->refcount += delta; 118 124 if (ha->refcount <= 0) ··· 16455 16449 return; 16456 16450 16457 16451 i40e_reset_and_rebuild(pf, false, false); 16452 + #ifdef CONFIG_PCI_IOV 16453 + i40e_restore_all_vfs_msi_state(pdev); 16454 + #endif /* CONFIG_PCI_IOV */ 16458 16455 } 16459 16456 16460 16457 /**
+30 -4
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 154 154 (u8 *)&pfe, sizeof(struct virtchnl_pf_event)); 155 155 } 156 156 157 + #ifdef CONFIG_PCI_IOV 158 + void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev) 159 + { 160 + u16 vf_id; 161 + u16 pos; 162 + 163 + /* Continue only if this is a PF */ 164 + if (!pdev->is_physfn) 165 + return; 166 + 167 + if (!pci_num_vf(pdev)) 168 + return; 169 + 170 + pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV); 171 + if (pos) { 172 + struct pci_dev *vf_dev = NULL; 173 + 174 + pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &vf_id); 175 + while ((vf_dev = pci_get_device(pdev->vendor, vf_id, vf_dev))) { 176 + if (vf_dev->is_virtfn && vf_dev->physfn == pdev) 177 + pci_restore_msi_state(vf_dev); 178 + } 179 + } 180 + } 181 + #endif /* CONFIG_PCI_IOV */ 182 + 157 183 /** 158 184 * i40e_vc_notify_vf_reset 159 185 * @vf: pointer to the VF structure ··· 3553 3527 bool found = false; 3554 3528 int bkt; 3555 3529 3556 - if (!tc_filter->action) { 3530 + if (tc_filter->action != VIRTCHNL_ACTION_TC_REDIRECT) { 3557 3531 dev_info(&pf->pdev->dev, 3558 - "VF %d: Currently ADq doesn't support Drop Action\n", 3559 - vf->vf_id); 3532 + "VF %d: ADQ doesn't support this action (%d)\n", 3533 + vf->vf_id, tc_filter->action); 3560 3534 goto err; 3561 3535 } 3562 3536 3563 3537 /* action_meta is TC number here to which the filter is applied */ 3564 3538 if (!tc_filter->action_meta || 3565 - tc_filter->action_meta > I40E_MAX_VF_VSI) { 3539 + tc_filter->action_meta > vf->num_tc) { 3566 3540 dev_info(&pf->pdev->dev, "VF %d: Invalid TC number %u\n", 3567 3541 vf->vf_id, tc_filter->action_meta); 3568 3542 goto err;
+3
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
··· 138 138 139 139 void i40e_vc_notify_link_state(struct i40e_pf *pf); 140 140 void i40e_vc_notify_reset(struct i40e_pf *pf); 141 + #ifdef CONFIG_PCI_IOV 142 + void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev); 143 + #endif /* CONFIG_PCI_IOV */ 141 144 int i40e_get_vf_stats(struct net_device *netdev, int vf_id, 142 145 struct ifla_vf_stats *vf_stats); 143 146
+2 -1
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
··· 1360 1360 u8 lp_flowcontrol; 1361 1361 #define ICE_AQ_LINK_LP_PAUSE_ADV BIT(0) 1362 1362 #define ICE_AQ_LINK_LP_ASM_DIR_ADV BIT(1) 1363 + u8 reserved5[5]; 1363 1364 #define ICE_AQC_LS_DATA_SIZE_V2 \ 1364 - offsetofend(struct ice_aqc_get_link_status_data, lp_flowcontrol) 1365 + offsetofend(struct ice_aqc_get_link_status_data, reserved5) 1365 1366 } __packed; 1366 1367 1367 1368 /* Set event mask command (direct 0x0613) */
+1 -3
drivers/net/ethernet/intel/ice/ice_common.c
··· 5141 5141 u8 *eec_mode) 5142 5142 { 5143 5143 struct ice_aqc_get_cgu_dpll_status *cmd; 5144 - const s64 nsec_per_psec = 1000LL; 5145 5144 struct ice_aq_desc desc; 5146 5145 int status; 5147 5146 ··· 5156 5157 *phase_offset = le32_to_cpu(cmd->phase_offset_h); 5157 5158 *phase_offset <<= 32; 5158 5159 *phase_offset += le32_to_cpu(cmd->phase_offset_l); 5159 - *phase_offset = div64_s64(sign_extend64(*phase_offset, 47), 5160 - nsec_per_psec); 5160 + *phase_offset = sign_extend64(*phase_offset, 47); 5161 5161 *eec_mode = cmd->eec_mode; 5162 5162 } 5163 5163
+9 -3
drivers/net/ethernet/intel/ice/ice_main.c
··· 2161 2161 2162 2162 /* Ensure we have media as we cannot configure a medialess port */ 2163 2163 if (!(phy->link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) 2164 - return -EPERM; 2164 + return -ENOMEDIUM; 2165 2165 2166 2166 ice_print_topo_conflict(vsi); 2167 2167 ··· 9398 9398 int link_err = ice_force_phys_link_state(vsi, false); 9399 9399 9400 9400 if (link_err) { 9401 - netdev_err(vsi->netdev, "Failed to set physical link down, VSI %d error %d\n", 9402 - vsi->vsi_num, link_err); 9401 + if (link_err == -ENOMEDIUM) 9402 + netdev_info(vsi->netdev, "Skipping link reconfig - no media attached, VSI %d\n", 9403 + vsi->vsi_num); 9404 + else 9405 + netdev_err(vsi->netdev, "Failed to set physical link down, VSI %d error %d\n", 9406 + vsi->vsi_num, link_err); 9407 + 9408 + ice_vsi_close(vsi); 9403 9409 return -EIO; 9404 9410 } 9405 9411 }
-1
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
··· 1043 1043 } 1044 1044 1045 1045 idpf_rx_sync_for_cpu(rx_buf, fields.size); 1046 - skb = rx_q->skb; 1047 1046 if (skb) 1048 1047 idpf_rx_add_frag(rx_buf, skb, fields.size); 1049 1048 else
+1 -1
drivers/net/ethernet/intel/idpf/idpf_txrx.c
··· 396 396 if (!rxq) 397 397 return; 398 398 399 - if (!bufq && idpf_is_queue_model_split(q_model) && rxq->skb) { 399 + if (rxq->skb) { 400 400 dev_kfree_skb_any(rxq->skb); 401 401 rxq->skb = NULL; 402 402 }
+3 -3
drivers/net/ethernet/intel/idpf/virtchnl2.h
··· 1104 1104 __le32 vport_id; 1105 1105 __le16 key_len; 1106 1106 u8 pad; 1107 - __DECLARE_FLEX_ARRAY(u8, key_flex); 1108 - }; 1109 - VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_rss_key); 1107 + u8 key_flex[]; 1108 + } __packed; 1109 + VIRTCHNL2_CHECK_STRUCT_LEN(7, virtchnl2_rss_key); 1110 1110 1111 1111 /** 1112 1112 * struct virtchnl2_queue_chunk - chunk of contiguous queues
+1
drivers/net/ethernet/intel/igc/igc.h
··· 587 587 u16 etype; 588 588 __be16 vlan_etype; 589 589 u16 vlan_tci; 590 + u16 vlan_tci_mask; 590 591 u8 src_addr[ETH_ALEN]; 591 592 u8 dst_addr[ETH_ALEN]; 592 593 u8 user_data[8];
+39 -3
drivers/net/ethernet/intel/igc/igc_ethtool.c
··· 956 956 } 957 957 958 958 #define ETHER_TYPE_FULL_MASK ((__force __be16)~0) 959 + #define VLAN_TCI_FULL_MASK ((__force __be16)~0) 959 960 static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, 960 961 struct ethtool_rxnfc *cmd) 961 962 { ··· 979 978 fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; 980 979 } 981 980 981 + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) { 982 + fsp->flow_type |= FLOW_EXT; 983 + fsp->h_ext.vlan_etype = rule->filter.vlan_etype; 984 + fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK; 985 + } 986 + 982 987 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { 983 988 fsp->flow_type |= FLOW_EXT; 984 989 fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci); 985 - fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK); 990 + fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask); 986 991 } 987 992 988 993 if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { ··· 1223 1216 1224 1217 if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { 1225 1218 rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); 1219 + rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci); 1226 1220 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; 1227 1221 } 1228 1222 ··· 1261 1253 memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data)); 1262 1254 } 1263 1255 1264 - /* When multiple filter options or user data or vlan etype is set, use a 1265 - * flex filter. 1256 + /* The i225/i226 has various different filters. Flex filters provide a 1257 + * way to match up to the first 128 bytes of a packet. Use them for: 1258 + * a) For specific user data 1259 + * b) For VLAN EtherType 1260 + * c) For full TCI match 1261 + * d) Or in case multiple filter criteria are set 1262 + * 1263 + * Otherwise, use the simple MAC, VLAN PRIO or EtherType filters. 1266 1264 */ 1267 1265 if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) || 1268 1266 (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) || 1267 + ((rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) && 1268 + rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) || 1269 1269 (rule->filter.match_flags & (rule->filter.match_flags - 1))) 1270 1270 rule->flex = true; 1271 1271 else ··· 1341 1325 if (fsp->ring_cookie >= adapter->num_rx_queues) { 1342 1326 netdev_dbg(netdev, "Invalid action\n"); 1343 1327 return -EINVAL; 1328 + } 1329 + 1330 + /* There are two ways to match the VLAN TCI: 1331 + * 1. Match on PCP field and use vlan prio filter for it 1332 + * 2. Match on complete TCI field and use flex filter for it 1333 + */ 1334 + if ((fsp->flow_type & FLOW_EXT) && 1335 + fsp->m_ext.vlan_tci && 1336 + fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) && 1337 + fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) { 1338 + netdev_dbg(netdev, "VLAN mask not supported\n"); 1339 + return -EOPNOTSUPP; 1340 + } 1341 + 1342 + /* VLAN EtherType can only be matched by full mask. */ 1343 + if ((fsp->flow_type & FLOW_EXT) && 1344 + fsp->m_ext.vlan_etype && 1345 + fsp->m_ext.vlan_etype != ETHER_TYPE_FULL_MASK) { 1346 + netdev_dbg(netdev, "VLAN EtherType mask not supported\n"); 1347 + return -EOPNOTSUPP; 1344 1348 } 1345 1349 1346 1350 if (fsp->location >= IGC_MAX_RXNFC_RULES) {
+1 -1
drivers/net/ethernet/intel/igc/igc_tsn.c
··· 227 227 wr32(IGC_TQAVCC(i), tqavcc); 228 228 229 229 wr32(IGC_TQAVHC(i), 230 - 0x80000000 + ring->hicredit * 0x7735); 230 + 0x80000000 + ring->hicredit * 0x7736); 231 231 } else { 232 232 /* Disable any CBS for the queue */ 233 233 txqctl &= ~(IGC_TXQCTL_QAV_SEL_MASK);
+2 -2
drivers/net/ethernet/marvell/octeontx2/af/npc.h
··· 530 530 u8 ltype_mask; 531 531 u8 ltype_match; 532 532 u8 lid; 533 - }; 533 + } __packed; 534 534 535 535 struct npc_lt_def_ipsec { 536 536 u8 ltype_mask; ··· 538 538 u8 lid; 539 539 u8 spi_offset; 540 540 u8 spi_nz; 541 - }; 541 + } __packed; 542 542 543 543 struct npc_lt_def_apad { 544 544 u8 ltype_mask;
+1
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
··· 934 934 void *rvu_first_cgx_pdata(struct rvu *rvu); 935 935 int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id); 936 936 int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable); 937 + int rvu_cgx_tx_enable(struct rvu *rvu, u16 pcifunc, bool enable); 937 938 int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause, 938 939 u16 pfc_en); 939 940 int rvu_cgx_cfg_pause_frm(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause);
+17
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
··· 465 465 return mac_ops->mac_rx_tx_enable(cgxd, lmac_id, start); 466 466 } 467 467 468 + int rvu_cgx_tx_enable(struct rvu *rvu, u16 pcifunc, bool enable) 469 + { 470 + int pf = rvu_get_pf(pcifunc); 471 + struct mac_ops *mac_ops; 472 + u8 cgx_id, lmac_id; 473 + void *cgxd; 474 + 475 + if (!is_cgx_config_permitted(rvu, pcifunc)) 476 + return LMAC_AF_ERR_PERM_DENIED; 477 + 478 + rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); 479 + cgxd = rvu_cgx_pdata(cgx_id, rvu); 480 + mac_ops = get_mac_ops(cgxd); 481 + 482 + return mac_ops->mac_tx_enable(cgxd, lmac_id, enable); 483 + } 484 + 468 485 int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable) 469 486 { 470 487 struct mac_ops *mac_ops;
+10 -108
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
··· 4399 4399 req->minlen = minlen; 4400 4400 } 4401 4401 4402 - static int 4403 - nix_config_link_credits(struct rvu *rvu, int blkaddr, int link, 4404 - u16 pcifunc, u64 tx_credits) 4405 - { 4406 - struct rvu_hwinfo *hw = rvu->hw; 4407 - int pf = rvu_get_pf(pcifunc); 4408 - u8 cgx_id = 0, lmac_id = 0; 4409 - unsigned long poll_tmo; 4410 - bool restore_tx_en = 0; 4411 - struct nix_hw *nix_hw; 4412 - u64 cfg, sw_xoff = 0; 4413 - u32 schq = 0; 4414 - u32 credits; 4415 - int rc; 4416 - 4417 - nix_hw = get_nix_hw(rvu->hw, blkaddr); 4418 - if (!nix_hw) 4419 - return NIX_AF_ERR_INVALID_NIXBLK; 4420 - 4421 - if (tx_credits == nix_hw->tx_credits[link]) 4422 - return 0; 4423 - 4424 - /* Enable cgx tx if disabled for credits to be back */ 4425 - if (is_pf_cgxmapped(rvu, pf)) { 4426 - rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); 4427 - restore_tx_en = !rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), 4428 - lmac_id, true); 4429 - } 4430 - 4431 - mutex_lock(&rvu->rsrc_lock); 4432 - /* Disable new traffic to link */ 4433 - if (hw->cap.nix_shaping) { 4434 - schq = nix_get_tx_link(rvu, pcifunc); 4435 - sw_xoff = rvu_read64(rvu, blkaddr, NIX_AF_TL1X_SW_XOFF(schq)); 4436 - rvu_write64(rvu, blkaddr, 4437 - NIX_AF_TL1X_SW_XOFF(schq), BIT_ULL(0)); 4438 - } 4439 - 4440 - rc = NIX_AF_ERR_LINK_CREDITS; 4441 - poll_tmo = jiffies + usecs_to_jiffies(200000); 4442 - /* Wait for credits to return */ 4443 - do { 4444 - if (time_after(jiffies, poll_tmo)) 4445 - goto exit; 4446 - usleep_range(100, 200); 4447 - 4448 - cfg = rvu_read64(rvu, blkaddr, 4449 - NIX_AF_TX_LINKX_NORM_CREDIT(link)); 4450 - credits = (cfg >> 12) & 0xFFFFFULL; 4451 - } while (credits != nix_hw->tx_credits[link]); 4452 - 4453 - cfg &= ~(0xFFFFFULL << 12); 4454 - cfg |= (tx_credits << 12); 4455 - rvu_write64(rvu, blkaddr, NIX_AF_TX_LINKX_NORM_CREDIT(link), cfg); 4456 - rc = 0; 4457 - 4458 - nix_hw->tx_credits[link] = tx_credits; 4459 - 4460 - exit: 4461 - /* Enable traffic back */ 4462 - if (hw->cap.nix_shaping && !sw_xoff) 4463 - rvu_write64(rvu, blkaddr, NIX_AF_TL1X_SW_XOFF(schq), 0); 4464 - 4465 - /* Restore state of cgx tx */ 4466 - if (restore_tx_en) 4467 - rvu_cgx_config_tx(rvu_cgx_pdata(cgx_id, rvu), lmac_id, false); 4468 - 4469 - mutex_unlock(&rvu->rsrc_lock); 4470 - return rc; 4471 - } 4472 - 4473 4402 int rvu_mbox_handler_nix_set_hw_frs(struct rvu *rvu, struct nix_frs_cfg *req, 4474 4403 struct msg_rsp *rsp) 4475 4404 { 4476 4405 struct rvu_hwinfo *hw = rvu->hw; 4477 4406 u16 pcifunc = req->hdr.pcifunc; 4478 4407 int pf = rvu_get_pf(pcifunc); 4479 - int blkaddr, schq, link = -1; 4480 - struct nix_txsch *txsch; 4481 - u64 cfg, lmac_fifo_len; 4408 + int blkaddr, link = -1; 4482 4409 struct nix_hw *nix_hw; 4483 4410 struct rvu_pfvf *pfvf; 4484 4411 u8 cgx = 0, lmac = 0; 4485 4412 u16 max_mtu; 4413 + u64 cfg; 4486 4414 4487 4415 blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); 4488 4416 if (blkaddr < 0) ··· 4431 4503 if (req->update_minlen && req->minlen < NIC_HW_MIN_FRS) 4432 4504 return NIX_AF_ERR_FRS_INVALID; 4433 4505 4434 - /* Check if requester wants to update SMQ's */ 4435 - if (!req->update_smq) 4436 - goto rx_frscfg; 4437 - 4438 - /* Update min/maxlen in each of the SMQ attached to this PF/VF */ 4439 - txsch = &nix_hw->txsch[NIX_TXSCH_LVL_SMQ]; 4440 - mutex_lock(&rvu->rsrc_lock); 4441 - for (schq = 0; schq < txsch->schq.max; schq++) { 4442 - if (TXSCH_MAP_FUNC(txsch->pfvf_map[schq]) != pcifunc) 4443 - continue; 4444 - cfg = rvu_read64(rvu, blkaddr, NIX_AF_SMQX_CFG(schq)); 4445 - cfg = (cfg & ~(0xFFFFULL << 8)) | ((u64)req->maxlen << 8); 4446 - if (req->update_minlen) 4447 - cfg = (cfg & ~0x7FULL) | ((u64)req->minlen & 0x7F); 4448 - rvu_write64(rvu, blkaddr, NIX_AF_SMQX_CFG(schq), cfg); 4449 - } 4450 - mutex_unlock(&rvu->rsrc_lock); 4451 - 4452 - rx_frscfg: 4453 4506 /* Check if config is for SDP link */ 4454 4507 if (req->sdp_link) { 4455 4508 if (!hw->sdp_links) ··· 4453 4544 if (link < 0) 4454 4545 return NIX_AF_ERR_RX_LINK_INVALID; 4455 4546 4456 - 4457 4547 linkcfg: 4458 4548 nix_find_link_frs(rvu, req, pcifunc); 4459 4549 ··· 4462 4554 cfg = (cfg & ~0xFFFFULL) | req->minlen; 4463 4555 rvu_write64(rvu, blkaddr, NIX_AF_RX_LINKX_CFG(link), cfg); 4464 4556 4465 - if (req->sdp_link || pf == 0) 4466 - return 0; 4467 - 4468 - /* Update transmit credits for CGX links */ 4469 - lmac_fifo_len = rvu_cgx_get_lmac_fifolen(rvu, cgx, lmac); 4470 - if (!lmac_fifo_len) { 4471 - dev_err(rvu->dev, 4472 - "%s: Failed to get CGX/RPM%d:LMAC%d FIFO size\n", 4473 - __func__, cgx, lmac); 4474 - return 0; 4475 - } 4476 - return nix_config_link_credits(rvu, blkaddr, link, pcifunc, 4477 - (lmac_fifo_len - req->maxlen) / 16); 4557 + return 0; 4478 4558 } 4479 4559 4480 4560 int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req, ··· 5067 5171 pfvf = rvu_get_pfvf(rvu, pcifunc); 5068 5172 clear_bit(NIXLF_INITIALIZED, &pfvf->flags); 5069 5173 5070 - return rvu_cgx_start_stop_io(rvu, pcifunc, false); 5174 + err = rvu_cgx_start_stop_io(rvu, pcifunc, false); 5175 + if (err) 5176 + return err; 5177 + 5178 + rvu_cgx_tx_enable(rvu, pcifunc, true); 5179 + 5180 + return 0; 5071 5181 } 5072 5182 5073 5183 #define RX_SA_BASE GENMASK_ULL(52, 7)
+7 -2
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
··· 267 267 priv->stats.rx_truncate_errors++; 268 268 } 269 269 270 + /* Read receive consumer index before replenish so that this routine 271 + * returns accurate return value even if packet is received into 272 + * just-replenished buffer prior to exiting this routine. 273 + */ 274 + rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); 275 + rx_ci_rem = rx_ci % priv->rx_q_entries; 276 + 270 277 /* Let hardware know we've replenished one buffer */ 271 278 rx_pi++; 272 279 ··· 286 279 rx_pi_rem = rx_pi % priv->rx_q_entries; 287 280 if (rx_pi_rem == 0) 288 281 priv->valid_polarity ^= 1; 289 - rx_ci = readq(priv->base + MLXBF_GIGE_RX_CQE_PACKET_CI); 290 - rx_ci_rem = rx_ci % priv->rx_q_entries; 291 282 292 283 if (skb) 293 284 netif_receive_skb(skb);
+2
drivers/net/ethernet/qlogic/qla3xxx.c
··· 2591 2591 2592 2592 if (qdev->lrg_buf_q_alloc_virt_addr == NULL) { 2593 2593 netdev_err(qdev->ndev, "lBufQ failed\n"); 2594 + kfree(qdev->lrg_buf); 2594 2595 return -ENOMEM; 2595 2596 } 2596 2597 qdev->lrg_buf_q_virt_addr = qdev->lrg_buf_q_alloc_virt_addr; ··· 2616 2615 qdev->lrg_buf_q_alloc_size, 2617 2616 qdev->lrg_buf_q_alloc_virt_addr, 2618 2617 qdev->lrg_buf_q_alloc_phy_addr); 2618 + kfree(qdev->lrg_buf); 2619 2619 return -ENOMEM; 2620 2620 } 2621 2621
+1 -1
drivers/net/ethernet/realtek/r8169_main.c
··· 1265 1265 { 1266 1266 r8168ep_ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_START); 1267 1267 r8168ep_ocp_write(tp, 0x01, 0x30, r8168ep_ocp_read(tp, 0x30) | 0x01); 1268 - rtl_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10000, 10); 1268 + rtl_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10000, 30); 1269 1269 } 1270 1270 1271 1271 static void rtl8168_driver_start(struct rtl8169_private *tp)
+42 -23
drivers/net/ethernet/renesas/ravb_main.c
··· 66 66 return -ETIMEDOUT; 67 67 } 68 68 69 - static int ravb_config(struct net_device *ndev) 69 + static int ravb_set_opmode(struct net_device *ndev, u32 opmode) 70 70 { 71 + u32 csr_ops = 1U << (opmode & CCC_OPC); 72 + u32 ccc_mask = CCC_OPC; 71 73 int error; 72 74 73 - /* Set config mode */ 74 - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); 75 - /* Check if the operating mode is changed to the config mode */ 76 - error = ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_CONFIG); 77 - if (error) 78 - netdev_err(ndev, "failed to switch device to config mode\n"); 75 + /* If gPTP active in config mode is supported it needs to be configured 76 + * along with CSEL and operating mode in the same access. This is a 77 + * hardware limitation. 78 + */ 79 + if (opmode & CCC_GAC) 80 + ccc_mask |= CCC_GAC | CCC_CSEL; 81 + 82 + /* Set operating mode */ 83 + ravb_modify(ndev, CCC, ccc_mask, opmode); 84 + /* Check if the operating mode is changed to the requested one */ 85 + error = ravb_wait(ndev, CSR, CSR_OPS, csr_ops); 86 + if (error) { 87 + netdev_err(ndev, "failed to switch device to requested mode (%u)\n", 88 + opmode & CCC_OPC); 89 + } 79 90 80 91 return error; 81 92 } ··· 684 673 int error; 685 674 686 675 /* Set CONFIG mode */ 687 - error = ravb_config(ndev); 676 + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); 688 677 if (error) 689 678 return error; 690 679 ··· 693 682 return error; 694 683 695 684 /* Setting the control will start the AVB-DMAC process. */ 696 - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_OPERATION); 697 - 698 - return 0; 685 + return ravb_set_opmode(ndev, CCC_OPC_OPERATION); 699 686 } 700 687 701 688 static void ravb_get_tx_tstamp(struct net_device *ndev) ··· 1055 1046 return error; 1056 1047 1057 1048 /* Stop AVB-DMAC process */ 1058 - return ravb_config(ndev); 1049 + return ravb_set_opmode(ndev, CCC_OPC_CONFIG); 1059 1050 } 1060 1051 1061 1052 /* E-MAC interrupt handler */ ··· 2569 2560 return 0; 2570 2561 } 2571 2562 2572 - static void ravb_set_config_mode(struct net_device *ndev) 2563 + static int ravb_set_config_mode(struct net_device *ndev) 2573 2564 { 2574 2565 struct ravb_private *priv = netdev_priv(ndev); 2575 2566 const struct ravb_hw_info *info = priv->info; 2567 + int error; 2576 2568 2577 2569 if (info->gptp) { 2578 - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); 2570 + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); 2571 + if (error) 2572 + return error; 2579 2573 /* Set CSEL value */ 2580 2574 ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); 2581 2575 } else if (info->ccc_gac) { 2582 - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG | 2583 - CCC_GAC | CCC_CSEL_HPB); 2576 + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); 2584 2577 } else { 2585 - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); 2578 + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); 2586 2579 } 2580 + 2581 + return error; 2587 2582 } 2588 2583 2589 2584 /* Set tx and rx clock internal delay modes */ ··· 2807 2794 ndev->ethtool_ops = &ravb_ethtool_ops; 2808 2795 2809 2796 /* Set AVB config mode */ 2810 - ravb_set_config_mode(ndev); 2797 + error = ravb_set_config_mode(ndev); 2798 + if (error) 2799 + goto out_disable_gptp_clk; 2811 2800 2812 2801 if (info->gptp || info->ccc_gac) { 2813 2802 /* Set GTI value */ ··· 2932 2917 dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, 2933 2918 priv->desc_bat_dma); 2934 2919 2935 - /* Set reset mode */ 2936 - ravb_write(ndev, CCC_OPC_RESET, CCC); 2920 + ravb_set_opmode(ndev, CCC_OPC_RESET); 2937 2921 2938 2922 clk_disable_unprepare(priv->gptp_clk); 2939 2923 clk_disable_unprepare(priv->refclk); ··· 3014 3000 int ret = 0; 3015 3001 3016 3002 /* If WoL is enabled set reset mode to rearm the WoL logic */ 3017 - if (priv->wol_enabled) 3018 - ravb_write(ndev, CCC_OPC_RESET, CCC); 3003 + if (priv->wol_enabled) { 3004 + ret = ravb_set_opmode(ndev, CCC_OPC_RESET); 3005 + if (ret) 3006 + return ret; 3007 + } 3019 3008 3020 3009 /* All register have been reset to default values. 3021 3010 * Restore all registers which where setup at probe time and ··· 3026 3009 */ 3027 3010 3028 3011 /* Set AVB config mode */ 3029 - ravb_set_config_mode(ndev); 3012 + ret = ravb_set_config_mode(ndev); 3013 + if (ret) 3014 + return ret; 3030 3015 3031 3016 if (info->gptp || info->ccc_gac) { 3032 3017 /* Set GTI value */
+3 -1
drivers/net/ethernet/sfc/rx_common.c
··· 823 823 } 824 824 825 825 if (!success) { 826 - efx_for_each_channel(channel, efx) 826 + efx_for_each_channel(channel, efx) { 827 827 kfree(channel->rps_flow_id); 828 + channel->rps_flow_id = NULL; 829 + } 828 830 efx->type->filter_table_remove(efx); 829 831 rc = -ENOMEM; 830 832 goto out_unlock;
+3 -1
drivers/net/usb/ax88172a.c
··· 161 161 u8 buf[ETH_ALEN]; 162 162 struct ax88172a_private *priv; 163 163 164 - usbnet_get_endpoints(dev, intf); 164 + ret = usbnet_get_endpoints(dev, intf); 165 + if (ret) 166 + return ret; 165 167 166 168 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 167 169 if (!priv)
+20 -3
drivers/net/usb/ax88179_178a.c
··· 173 173 u8 in_pm; 174 174 u32 wol_supported; 175 175 u32 wolopts; 176 + u8 disconnecting; 176 177 }; 177 178 178 179 struct ax88179_int_data { ··· 209 208 { 210 209 int ret; 211 210 int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); 211 + struct ax88179_data *ax179_data = dev->driver_priv; 212 212 213 213 BUG_ON(!dev); 214 214 ··· 221 219 ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 222 220 value, index, data, size); 223 221 224 - if (unlikely(ret < 0)) 222 + if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting))) 225 223 netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", 226 224 index, ret); 227 225 ··· 233 231 { 234 232 int ret; 235 233 int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); 234 + struct ax88179_data *ax179_data = dev->driver_priv; 236 235 237 236 BUG_ON(!dev); 238 237 ··· 245 242 ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 246 243 value, index, data, size); 247 244 248 - if (unlikely(ret < 0)) 245 + if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting))) 249 246 netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", 250 247 index, ret); 251 248 ··· 493 490 ax88179_set_pm_mode(dev, false); 494 491 495 492 return usbnet_resume(intf); 493 + } 494 + 495 + static void ax88179_disconnect(struct usb_interface *intf) 496 + { 497 + struct usbnet *dev = usb_get_intfdata(intf); 498 + struct ax88179_data *ax179_data; 499 + 500 + if (!dev) 501 + return; 502 + 503 + ax179_data = dev->driver_priv; 504 + ax179_data->disconnecting = 1; 505 + 506 + usbnet_disconnect(intf); 496 507 } 497 508 498 509 static void ··· 1921 1904 .suspend = ax88179_suspend, 1922 1905 .resume = ax88179_resume, 1923 1906 .reset_resume = ax88179_resume, 1924 - .disconnect = usbnet_disconnect, 1907 + .disconnect = ax88179_disconnect, 1925 1908 .supports_autosuspend = 1, 1926 1909 .disable_hub_initiated_lpm = 1, 1927 1910 };
+30 -30
drivers/net/virtio_net.c
··· 349 349 }; 350 350 }; 351 351 352 - static void virtnet_rq_free_unused_buf(struct virtqueue *vq, void *buf); 353 352 static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf); 354 353 355 354 static bool is_xdp_frame(void *ptr) ··· 420 421 } else 421 422 p = alloc_page(gfp_mask); 422 423 return p; 424 + } 425 + 426 + static void virtnet_rq_free_buf(struct virtnet_info *vi, 427 + struct receive_queue *rq, void *buf) 428 + { 429 + if (vi->mergeable_rx_bufs) 430 + put_page(virt_to_head_page(buf)); 431 + else if (vi->big_packets) 432 + give_pages(rq, buf); 433 + else 434 + put_page(virt_to_head_page(buf)); 423 435 } 424 436 425 437 static void enable_delayed_refill(struct virtnet_info *vi) ··· 663 653 return buf; 664 654 } 665 655 666 - static void *virtnet_rq_detach_unused_buf(struct receive_queue *rq) 667 - { 668 - void *buf; 669 - 670 - buf = virtqueue_detach_unused_buf(rq->vq); 671 - if (buf && rq->do_dma) 672 - virtnet_rq_unmap(rq, buf, 0); 673 - 674 - return buf; 675 - } 676 - 677 656 static void virtnet_rq_init_one_sg(struct receive_queue *rq, void *buf, u32 len) 678 657 { 679 658 struct virtnet_rq_dma *dma; ··· 760 761 761 762 vi->rq[i].do_dma = true; 762 763 } 764 + } 765 + 766 + static void virtnet_rq_unmap_free_buf(struct virtqueue *vq, void *buf) 767 + { 768 + struct virtnet_info *vi = vq->vdev->priv; 769 + struct receive_queue *rq; 770 + int i = vq2rxq(vq); 771 + 772 + rq = &vi->rq[i]; 773 + 774 + if (rq->do_dma) 775 + virtnet_rq_unmap(rq, buf, 0); 776 + 777 + virtnet_rq_free_buf(vi, rq, buf); 763 778 } 764 779 765 780 static void free_old_xmit_skbs(struct send_queue *sq, bool in_napi) ··· 1796 1783 if (unlikely(len < vi->hdr_len + ETH_HLEN)) { 1797 1784 pr_debug("%s: short packet %i\n", dev->name, len); 1798 1785 DEV_STATS_INC(dev, rx_length_errors); 1799 - virtnet_rq_free_unused_buf(rq->vq, buf); 1786 + virtnet_rq_free_buf(vi, rq, buf); 1800 1787 return; 1801 1788 } 1802 1789 ··· 2453 2440 cancel_work_sync(&rq->dim.work); 2454 2441 } 2455 2442 2456 - err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_free_unused_buf); 2443 + err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf); 2457 2444 if (err) 2458 2445 netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qindex, err); 2459 2446 ··· 4243 4230 xdp_return_frame(ptr_to_xdp(buf)); 4244 4231 } 4245 4232 4246 - static void virtnet_rq_free_unused_buf(struct virtqueue *vq, void *buf) 4247 - { 4248 - struct virtnet_info *vi = vq->vdev->priv; 4249 - int i = vq2rxq(vq); 4250 - 4251 - if (vi->mergeable_rx_bufs) 4252 - put_page(virt_to_head_page(buf)); 4253 - else if (vi->big_packets) 4254 - give_pages(&vi->rq[i], buf); 4255 - else 4256 - put_page(virt_to_head_page(buf)); 4257 - } 4258 - 4259 4233 static void free_unused_bufs(struct virtnet_info *vi) 4260 4234 { 4261 4235 void *buf; ··· 4256 4256 } 4257 4257 4258 4258 for (i = 0; i < vi->max_queue_pairs; i++) { 4259 - struct receive_queue *rq = &vi->rq[i]; 4259 + struct virtqueue *vq = vi->rq[i].vq; 4260 4260 4261 - while ((buf = virtnet_rq_detach_unused_buf(rq)) != NULL) 4262 - virtnet_rq_free_unused_buf(rq->vq, buf); 4261 + while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) 4262 + virtnet_rq_unmap_free_buf(vq, buf); 4263 4263 cond_resched(); 4264 4264 } 4265 4265 }
+2 -2
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
··· 770 770 } 771 771 } 772 772 773 - void iwl_pcie_handle_rfkill_irq(struct iwl_trans *trans); 773 + void iwl_pcie_handle_rfkill_irq(struct iwl_trans *trans, bool from_irq); 774 774 775 775 static inline bool iwl_is_rfkill_set(struct iwl_trans *trans) 776 776 { ··· 817 817 return (trans->dbg.dest_tlv || iwl_trans_dbg_ini_valid(trans)); 818 818 } 819 819 820 - void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state); 820 + void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state, bool from_irq); 821 821 void iwl_trans_pcie_dump_regs(struct iwl_trans *trans); 822 822 823 823 #ifdef CONFIG_IWLWIFI_DEBUGFS
+4 -4
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
··· 1782 1782 return inta; 1783 1783 } 1784 1784 1785 - void iwl_pcie_handle_rfkill_irq(struct iwl_trans *trans) 1785 + void iwl_pcie_handle_rfkill_irq(struct iwl_trans *trans, bool from_irq) 1786 1786 { 1787 1787 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1788 1788 struct isr_statistics *isr_stats = &trans_pcie->isr_stats; ··· 1806 1806 isr_stats->rfkill++; 1807 1807 1808 1808 if (prev != report) 1809 - iwl_trans_pcie_rf_kill(trans, report); 1809 + iwl_trans_pcie_rf_kill(trans, report, from_irq); 1810 1810 mutex_unlock(&trans_pcie->mutex); 1811 1811 1812 1812 if (hw_rfkill) { ··· 1946 1946 1947 1947 /* HW RF KILL switch toggled */ 1948 1948 if (inta & CSR_INT_BIT_RF_KILL) { 1949 - iwl_pcie_handle_rfkill_irq(trans); 1949 + iwl_pcie_handle_rfkill_irq(trans, true); 1950 1950 handled |= CSR_INT_BIT_RF_KILL; 1951 1951 } 1952 1952 ··· 2369 2369 2370 2370 /* HW RF KILL switch toggled */ 2371 2371 if (inta_hw & MSIX_HW_INT_CAUSES_REG_RF_KILL) 2372 - iwl_pcie_handle_rfkill_irq(trans); 2372 + iwl_pcie_handle_rfkill_irq(trans, true); 2373 2373 2374 2374 if (inta_hw & MSIX_HW_INT_CAUSES_REG_HW_ERR) { 2375 2375 IWL_ERR(trans,
+9 -8
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 1082 1082 report = test_bit(STATUS_RFKILL_OPMODE, &trans->status); 1083 1083 1084 1084 if (prev != report) 1085 - iwl_trans_pcie_rf_kill(trans, report); 1085 + iwl_trans_pcie_rf_kill(trans, report, false); 1086 1086 1087 1087 return hw_rfkill; 1088 1088 } ··· 1237 1237 trans_pcie->hw_mask = trans_pcie->hw_init_mask; 1238 1238 } 1239 1239 1240 - static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans) 1240 + static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool from_irq) 1241 1241 { 1242 1242 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1243 1243 ··· 1264 1264 if (test_and_clear_bit(STATUS_DEVICE_ENABLED, &trans->status)) { 1265 1265 IWL_DEBUG_INFO(trans, 1266 1266 "DEVICE_ENABLED bit was set and is now cleared\n"); 1267 - iwl_pcie_synchronize_irqs(trans); 1267 + if (!from_irq) 1268 + iwl_pcie_synchronize_irqs(trans); 1268 1269 iwl_pcie_rx_napi_sync(trans); 1269 1270 iwl_pcie_tx_stop(trans); 1270 1271 iwl_pcie_rx_stop(trans); ··· 1455 1454 clear_bit(STATUS_RFKILL_OPMODE, &trans->status); 1456 1455 } 1457 1456 if (hw_rfkill != was_in_rfkill) 1458 - iwl_trans_pcie_rf_kill(trans, hw_rfkill); 1457 + iwl_trans_pcie_rf_kill(trans, hw_rfkill, false); 1459 1458 } 1460 1459 1461 1460 static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) ··· 1470 1469 mutex_lock(&trans_pcie->mutex); 1471 1470 trans_pcie->opmode_down = true; 1472 1471 was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status); 1473 - _iwl_trans_pcie_stop_device(trans); 1472 + _iwl_trans_pcie_stop_device(trans, false); 1474 1473 iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill); 1475 1474 mutex_unlock(&trans_pcie->mutex); 1476 1475 } 1477 1476 1478 - void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state) 1477 + void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state, bool from_irq) 1479 1478 { 1480 1479 struct iwl_trans_pcie __maybe_unused *trans_pcie = 1481 1480 IWL_TRANS_GET_PCIE_TRANS(trans); ··· 1488 1487 if (trans->trans_cfg->gen2) 1489 1488 _iwl_trans_pcie_gen2_stop_device(trans); 1490 1489 else 1491 - _iwl_trans_pcie_stop_device(trans); 1490 + _iwl_trans_pcie_stop_device(trans, from_irq); 1492 1491 } 1493 1492 } 1494 1493 ··· 2874 2873 IWL_WARN(trans, "changing debug rfkill %d->%d\n", 2875 2874 trans_pcie->debug_rfkill, new_value); 2876 2875 trans_pcie->debug_rfkill = new_value; 2877 - iwl_pcie_handle_rfkill_irq(trans); 2876 + iwl_pcie_handle_rfkill_irq(trans, false); 2878 2877 2879 2878 return count; 2880 2879 }
+2 -1
drivers/nvme/host/core.c
··· 4137 4137 struct nvme_ctrl, fw_act_work); 4138 4138 unsigned long fw_act_timeout; 4139 4139 4140 + nvme_auth_stop(ctrl); 4141 + 4140 4142 if (ctrl->mtfa) 4141 4143 fw_act_timeout = jiffies + 4142 4144 msecs_to_jiffies(ctrl->mtfa * 100); ··· 4194 4192 * firmware activation. 4195 4193 */ 4196 4194 if (nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) { 4197 - nvme_auth_stop(ctrl); 4198 4195 requeue = false; 4199 4196 queue_work(nvme_wq, &ctrl->fw_act_work); 4200 4197 }
+5 -16
drivers/nvme/host/fc.c
··· 2548 2548 * the controller. Abort any ios on the association and let the 2549 2549 * create_association error path resolve things. 2550 2550 */ 2551 - enum nvme_ctrl_state state; 2552 - unsigned long flags; 2553 - 2554 - spin_lock_irqsave(&ctrl->lock, flags); 2555 - state = ctrl->ctrl.state; 2556 - if (state == NVME_CTRL_CONNECTING) { 2557 - set_bit(ASSOC_FAILED, &ctrl->flags); 2558 - spin_unlock_irqrestore(&ctrl->lock, flags); 2551 + if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { 2559 2552 __nvme_fc_abort_outstanding_ios(ctrl, true); 2553 + set_bit(ASSOC_FAILED, &ctrl->flags); 2560 2554 dev_warn(ctrl->ctrl.device, 2561 2555 "NVME-FC{%d}: transport error during (re)connect\n", 2562 2556 ctrl->cnum); 2563 2557 return; 2564 2558 } 2565 - spin_unlock_irqrestore(&ctrl->lock, flags); 2566 2559 2567 2560 /* Otherwise, only proceed if in LIVE state - e.g. on first error */ 2568 - if (state != NVME_CTRL_LIVE) 2561 + if (ctrl->ctrl.state != NVME_CTRL_LIVE) 2569 2562 return; 2570 2563 2571 2564 dev_warn(ctrl->ctrl.device, ··· 3173 3180 else 3174 3181 ret = nvme_fc_recreate_io_queues(ctrl); 3175 3182 } 3176 - 3177 - spin_lock_irqsave(&ctrl->lock, flags); 3178 3183 if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) 3179 3184 ret = -EIO; 3180 - if (ret) { 3181 - spin_unlock_irqrestore(&ctrl->lock, flags); 3185 + if (ret) 3182 3186 goto out_term_aen_ops; 3183 - } 3187 + 3184 3188 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 3185 - spin_unlock_irqrestore(&ctrl->lock, flags); 3186 3189 3187 3190 ctrl->ctrl.nr_reconnects = 0; 3188 3191
+94 -40
drivers/nvmem/brcm_nvram.c
··· 17 17 18 18 #define NVRAM_MAGIC "FLSH" 19 19 20 + /** 21 + * struct brcm_nvram - driver state internal struct 22 + * 23 + * @dev: NVMEM device pointer 24 + * @nvmem_size: Size of the whole space available for NVRAM 25 + * @data: NVRAM data copy stored to avoid poking underlaying flash controller 26 + * @data_len: NVRAM data size 27 + * @padding_byte: Padding value used to fill remaining space 28 + * @cells: Array of discovered NVMEM cells 29 + * @ncells: Number of elements in cells 30 + */ 20 31 struct brcm_nvram { 21 32 struct device *dev; 22 - void __iomem *base; 33 + size_t nvmem_size; 34 + uint8_t *data; 35 + size_t data_len; 36 + uint8_t padding_byte; 23 37 struct nvmem_cell_info *cells; 24 38 int ncells; 25 39 }; ··· 50 36 size_t bytes) 51 37 { 52 38 struct brcm_nvram *priv = context; 53 - u8 *dst = val; 39 + size_t to_copy; 54 40 55 - while (bytes--) 56 - *dst++ = readb(priv->base + offset++); 41 + if (offset + bytes > priv->data_len) 42 + to_copy = max_t(ssize_t, (ssize_t)priv->data_len - offset, 0); 43 + else 44 + to_copy = bytes; 45 + 46 + memcpy(val, priv->data + offset, to_copy); 47 + 48 + memset((uint8_t *)val + to_copy, priv->padding_byte, bytes - to_copy); 49 + 50 + return 0; 51 + } 52 + 53 + static int brcm_nvram_copy_data(struct brcm_nvram *priv, struct platform_device *pdev) 54 + { 55 + struct resource *res; 56 + void __iomem *base; 57 + 58 + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 59 + if (IS_ERR(base)) 60 + return PTR_ERR(base); 61 + 62 + priv->nvmem_size = resource_size(res); 63 + 64 + priv->padding_byte = readb(base + priv->nvmem_size - 1); 65 + for (priv->data_len = priv->nvmem_size; 66 + priv->data_len; 67 + priv->data_len--) { 68 + if (readb(base + priv->data_len - 1) != priv->padding_byte) 69 + break; 70 + } 71 + WARN(priv->data_len > SZ_128K, "Unexpected (big) NVRAM size: %zu B\n", priv->data_len); 72 + 73 + priv->data = devm_kzalloc(priv->dev, priv->data_len, GFP_KERNEL); 74 + if (!priv->data) 75 + return -ENOMEM; 76 + 77 + memcpy_fromio(priv->data, base, priv->data_len); 78 + 79 + bcm47xx_nvram_init_from_iomem(base, priv->data_len); 57 80 58 81 return 0; 59 82 } ··· 118 67 size_t len) 119 68 { 120 69 struct device *dev = priv->dev; 121 - char *var, *value, *eq; 70 + char *var, *value; 71 + uint8_t tmp; 122 72 int idx; 73 + int err = 0; 74 + 75 + tmp = priv->data[len - 1]; 76 + priv->data[len - 1] = '\0'; 123 77 124 78 priv->ncells = 0; 125 79 for (var = data + sizeof(struct brcm_nvram_header); ··· 134 78 } 135 79 136 80 priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL); 137 - if (!priv->cells) 138 - return -ENOMEM; 81 + if (!priv->cells) { 82 + err = -ENOMEM; 83 + goto out; 84 + } 139 85 140 86 for (var = data + sizeof(struct brcm_nvram_header), idx = 0; 141 87 var < (char *)data + len && *var; 142 88 var = value + strlen(value) + 1, idx++) { 89 + char *eq, *name; 90 + 143 91 eq = strchr(var, '='); 144 92 if (!eq) 145 93 break; 146 94 *eq = '\0'; 95 + name = devm_kstrdup(dev, var, GFP_KERNEL); 96 + *eq = '='; 97 + if (!name) { 98 + err = -ENOMEM; 99 + goto out; 100 + } 147 101 value = eq + 1; 148 102 149 - priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL); 150 - if (!priv->cells[idx].name) 151 - return -ENOMEM; 103 + priv->cells[idx].name = name; 152 104 priv->cells[idx].offset = value - (char *)data; 153 105 priv->cells[idx].bytes = strlen(value); 154 106 priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name); 155 - if (!strcmp(var, "et0macaddr") || 156 - !strcmp(var, "et1macaddr") || 157 - !strcmp(var, "et2macaddr")) { 107 + if (!strcmp(name, "et0macaddr") || 108 + !strcmp(name, "et1macaddr") || 109 + !strcmp(name, "et2macaddr")) { 158 110 priv->cells[idx].raw_len = strlen(value); 159 111 priv->cells[idx].bytes = ETH_ALEN; 160 112 priv->cells[idx].read_post_process = brcm_nvram_read_post_process_macaddr; 161 113 } 162 114 } 163 115 164 - return 0; 116 + out: 117 + priv->data[len - 1] = tmp; 118 + return err; 165 119 } 166 120 167 121 static int brcm_nvram_parse(struct brcm_nvram *priv) 168 122 { 123 + struct brcm_nvram_header *header = (struct brcm_nvram_header *)priv->data; 169 124 struct device *dev = priv->dev; 170 - struct brcm_nvram_header header; 171 - uint8_t *data; 172 125 size_t len; 173 126 int err; 174 127 175 - memcpy_fromio(&header, priv->base, sizeof(header)); 176 - 177 - if (memcmp(header.magic, NVRAM_MAGIC, 4)) { 128 + if (memcmp(header->magic, NVRAM_MAGIC, 4)) { 178 129 dev_err(dev, "Invalid NVRAM magic\n"); 179 130 return -EINVAL; 180 131 } 181 132 182 - len = le32_to_cpu(header.len); 183 - 184 - data = kzalloc(len, GFP_KERNEL); 185 - if (!data) 186 - return -ENOMEM; 187 - 188 - memcpy_fromio(data, priv->base, len); 189 - data[len - 1] = '\0'; 190 - 191 - err = brcm_nvram_add_cells(priv, data, len); 192 - if (err) { 193 - dev_err(dev, "Failed to add cells: %d\n", err); 194 - return err; 133 + len = le32_to_cpu(header->len); 134 + if (len > priv->nvmem_size) { 135 + dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len, 136 + priv->nvmem_size); 137 + return -EINVAL; 195 138 } 196 139 197 - kfree(data); 140 + err = brcm_nvram_add_cells(priv, priv->data, len); 141 + if (err) 142 + dev_err(dev, "Failed to add cells: %d\n", err); 198 143 199 144 return 0; 200 145 } ··· 207 150 .reg_read = brcm_nvram_read, 208 151 }; 209 152 struct device *dev = &pdev->dev; 210 - struct resource *res; 211 153 struct brcm_nvram *priv; 212 154 int err; 213 155 ··· 215 159 return -ENOMEM; 216 160 priv->dev = dev; 217 161 218 - priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 219 - if (IS_ERR(priv->base)) 220 - return PTR_ERR(priv->base); 162 + err = brcm_nvram_copy_data(priv, pdev); 163 + if (err) 164 + return err; 221 165 222 166 err = brcm_nvram_parse(priv); 223 167 if (err) 224 168 return err; 225 169 226 - bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res)); 227 - 228 170 config.dev = dev; 229 171 config.cells = priv->cells; 230 172 config.ncells = priv->ncells; 231 173 config.priv = priv; 232 - config.size = resource_size(res); 174 + config.size = priv->nvmem_size; 233 175 234 176 return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config)); 235 177 }
+6
drivers/pci/pci.c
··· 1338 1338 pci_restore_bars(dev); 1339 1339 } 1340 1340 1341 + if (dev->bus->self) 1342 + pcie_aspm_pm_state_change(dev->bus->self); 1343 + 1341 1344 return 0; 1342 1345 } 1343 1346 ··· 1434 1431 pci_info_ratelimited(dev, "Refused to change power state from %s to %s\n", 1435 1432 pci_power_name(dev->current_state), 1436 1433 pci_power_name(state)); 1434 + 1435 + if (dev->bus->self) 1436 + pcie_aspm_pm_state_change(dev->bus->self); 1437 1437 1438 1438 return 0; 1439 1439 }
+2
drivers/pci/pci.h
··· 569 569 #ifdef CONFIG_PCIEASPM 570 570 void pcie_aspm_init_link_state(struct pci_dev *pdev); 571 571 void pcie_aspm_exit_link_state(struct pci_dev *pdev); 572 + void pcie_aspm_pm_state_change(struct pci_dev *pdev); 572 573 void pcie_aspm_powersave_config_link(struct pci_dev *pdev); 573 574 #else 574 575 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } 575 576 static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } 577 + static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { } 576 578 static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } 577 579 #endif 578 580
+19
drivers/pci/pcie/aspm.c
··· 1008 1008 up_read(&pci_bus_sem); 1009 1009 } 1010 1010 1011 + /* @pdev: the root port or switch downstream port */ 1012 + void pcie_aspm_pm_state_change(struct pci_dev *pdev) 1013 + { 1014 + struct pcie_link_state *link = pdev->link_state; 1015 + 1016 + if (aspm_disabled || !link) 1017 + return; 1018 + /* 1019 + * Devices changed PM state, we should recheck if latency 1020 + * meets all functions' requirement 1021 + */ 1022 + down_read(&pci_bus_sem); 1023 + mutex_lock(&aspm_lock); 1024 + pcie_update_aspm_capable(link->root); 1025 + pcie_config_aspm_path(link); 1026 + mutex_unlock(&aspm_lock); 1027 + up_read(&pci_bus_sem); 1028 + } 1029 + 1011 1030 void pcie_aspm_powersave_config_link(struct pci_dev *pdev) 1012 1031 { 1013 1032 struct pcie_link_state *link = pdev->link_state;
+9
drivers/pinctrl/pinctrl-amd.c
··· 923 923 924 924 raw_spin_lock_irqsave(&gpio_dev->lock, flags); 925 925 gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin * 4) & ~PIN_IRQ_PENDING; 926 + 927 + /* mask any interrupts not intended to be a wake source */ 928 + if (!(gpio_dev->saved_regs[i] & WAKE_SOURCE)) { 929 + writel(gpio_dev->saved_regs[i] & ~BIT(INTERRUPT_MASK_OFF), 930 + gpio_dev->base + pin * 4); 931 + pm_pr_dbg("Disabling GPIO #%d interrupt for suspend.\n", 932 + pin); 933 + } 934 + 926 935 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 927 936 } 928 937
+5
drivers/pinctrl/pinctrl-amd.h
··· 80 80 #define FUNCTION_MASK GENMASK(1, 0) 81 81 #define FUNCTION_INVALID GENMASK(7, 0) 82 82 83 + #define WAKE_SOURCE (BIT(WAKE_CNTRL_OFF_S0I3) | \ 84 + BIT(WAKE_CNTRL_OFF_S3) | \ 85 + BIT(WAKE_CNTRL_OFF_S4) | \ 86 + BIT(WAKECNTRL_Z_OFF)) 87 + 83 88 struct amd_function { 84 89 const char *name; 85 90 const char * const groups[NSELECTS];
+8
drivers/pinctrl/pinctrl-at91-pio4.c
··· 1068 1068 } 1069 1069 }; 1070 1070 1071 + /* 1072 + * This lock class allows to tell lockdep that parent IRQ and children IRQ do 1073 + * not share the same class so it does not raise false positive 1074 + */ 1075 + static struct lock_class_key atmel_lock_key; 1076 + static struct lock_class_key atmel_request_key; 1077 + 1071 1078 static int atmel_pinctrl_probe(struct platform_device *pdev) 1072 1079 { 1073 1080 struct device *dev = &pdev->dev; ··· 1221 1214 irq_set_chip_and_handler(irq, &atmel_gpio_irq_chip, 1222 1215 handle_simple_irq); 1223 1216 irq_set_chip_data(irq, atmel_pioctrl); 1217 + irq_set_lockdep_class(irq, &atmel_lock_key, &atmel_request_key); 1224 1218 dev_dbg(dev, 1225 1219 "atmel gpio irq domain: hwirq: %d, linux irq: %d\n", 1226 1220 i, irq);
+13 -1
drivers/pinctrl/pinctrl-cy8c95x0.c
··· 308 308 "gp77", 309 309 }; 310 310 311 + static int cy8c95x0_pinmux_direction(struct cy8c95x0_pinctrl *chip, 312 + unsigned int pin, bool input); 313 + 311 314 static inline u8 cypress_get_port(struct cy8c95x0_pinctrl *chip, unsigned int pin) 312 315 { 313 316 /* Account for GPORT2 which only has 4 bits */ ··· 715 712 ret = regmap_read(chip->regmap, reg, &reg_val); 716 713 if (reg_val & bit) 717 714 arg = 1; 715 + if (param == PIN_CONFIG_OUTPUT_ENABLE) 716 + arg = !arg; 718 717 719 718 *config = pinconf_to_config_packed(param, (u16)arg); 720 719 out: ··· 732 727 u8 port = cypress_get_port(chip, off); 733 728 u8 bit = cypress_get_pin_mask(chip, off); 734 729 unsigned long param = pinconf_to_config_param(config); 730 + unsigned long arg = pinconf_to_config_argument(config); 735 731 unsigned int reg; 736 732 int ret; 737 733 ··· 771 765 case PIN_CONFIG_MODE_PWM: 772 766 reg = CY8C95X0_PWMSEL; 773 767 break; 768 + case PIN_CONFIG_OUTPUT_ENABLE: 769 + ret = cy8c95x0_pinmux_direction(chip, off, !arg); 770 + goto out; 771 + case PIN_CONFIG_INPUT_ENABLE: 772 + ret = cy8c95x0_pinmux_direction(chip, off, arg); 773 + goto out; 774 774 default: 775 775 ret = -ENOTSUPP; 776 776 goto out; ··· 834 822 gc->get_direction = cy8c95x0_gpio_get_direction; 835 823 gc->get_multiple = cy8c95x0_gpio_get_multiple; 836 824 gc->set_multiple = cy8c95x0_gpio_set_multiple; 837 - gc->set_config = gpiochip_generic_config, 825 + gc->set_config = gpiochip_generic_config; 838 826 gc->can_sleep = true; 839 827 gc->add_pin_ranges = cy8c95x0_add_pin_ranges; 840 828
+2 -2
drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
··· 492 492 493 493 nmaps = 0; 494 494 ngroups = 0; 495 - for_each_child_of_node(np, child) { 495 + for_each_available_child_of_node(np, child) { 496 496 int npinmux = of_property_count_u32_elems(child, "pinmux"); 497 497 int npins = of_property_count_u32_elems(child, "pins"); 498 498 ··· 527 527 nmaps = 0; 528 528 ngroups = 0; 529 529 mutex_lock(&sfp->mutex); 530 - for_each_child_of_node(np, child) { 530 + for_each_available_child_of_node(np, child) { 531 531 int npins; 532 532 int i; 533 533
+2 -2
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
··· 135 135 int ret; 136 136 137 137 ngroups = 0; 138 - for_each_child_of_node(np, child) 138 + for_each_available_child_of_node(np, child) 139 139 ngroups += 1; 140 140 nmaps = 2 * ngroups; 141 141 ··· 150 150 nmaps = 0; 151 151 ngroups = 0; 152 152 mutex_lock(&sfp->mutex); 153 - for_each_child_of_node(np, child) { 153 + for_each_available_child_of_node(np, child) { 154 154 int npins = of_property_count_u32_elems(child, "pinmux"); 155 155 int *pins; 156 156 u32 *pinmux;
+3 -6
drivers/platform/x86/intel/pmc/adl.c
··· 314 314 struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; 315 315 int ret; 316 316 317 + pmcdev->suspend = cnl_suspend; 318 + pmcdev->resume = cnl_resume; 319 + 317 320 pmc->map = &adl_reg_map; 318 321 ret = get_primary_reg_base(pmc); 319 322 if (ret) 320 323 return ret; 321 - 322 - /* Due to a hardware limitation, the GBE LTR blocks PC10 323 - * when a cable is attached. Tell the PMC to ignore it. 324 - */ 325 - dev_dbg(&pmcdev->pdev->dev, "ignoring GBE LTR\n"); 326 - pmc_core_send_ltr_ignore(pmcdev, 3); 327 324 328 325 return 0; 329 326 }
+20 -6
drivers/platform/x86/intel/pmc/cnp.c
··· 204 204 .etr3_offset = ETR3_OFFSET, 205 205 }; 206 206 207 + void cnl_suspend(struct pmc_dev *pmcdev) 208 + { 209 + /* 210 + * Due to a hardware limitation, the GBE LTR blocks PC10 211 + * when a cable is attached. To unblock PC10 during suspend, 212 + * tell the PMC to ignore it. 213 + */ 214 + pmc_core_send_ltr_ignore(pmcdev, 3, 1); 215 + } 216 + 217 + int cnl_resume(struct pmc_dev *pmcdev) 218 + { 219 + pmc_core_send_ltr_ignore(pmcdev, 3, 0); 220 + 221 + return pmc_core_resume_common(pmcdev); 222 + } 223 + 207 224 int cnp_core_init(struct pmc_dev *pmcdev) 208 225 { 209 226 struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; 210 227 int ret; 211 228 229 + pmcdev->suspend = cnl_suspend; 230 + pmcdev->resume = cnl_resume; 231 + 212 232 pmc->map = &cnp_reg_map; 213 233 ret = get_primary_reg_base(pmc); 214 234 if (ret) 215 235 return ret; 216 - 217 - /* Due to a hardware limitation, the GBE LTR blocks PC10 218 - * when a cable is attached. Tell the PMC to ignore it. 219 - */ 220 - dev_dbg(&pmcdev->pdev->dev, "ignoring GBE LTR\n"); 221 - pmc_core_send_ltr_ignore(pmcdev, 3); 222 236 223 237 return 0; 224 238 }
+9 -3
drivers/platform/x86/intel/pmc/core.c
··· 460 460 } 461 461 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll); 462 462 463 - int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value) 463 + int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore) 464 464 { 465 465 struct pmc *pmc; 466 466 const struct pmc_reg_map *map; ··· 498 498 mutex_lock(&pmcdev->lock); 499 499 500 500 reg = pmc_core_reg_read(pmc, map->ltr_ignore_offset); 501 - reg |= BIT(ltr_index); 501 + if (ignore) 502 + reg |= BIT(ltr_index); 503 + else 504 + reg &= ~BIT(ltr_index); 502 505 pmc_core_reg_write(pmc, map->ltr_ignore_offset, reg); 503 506 504 507 mutex_unlock(&pmcdev->lock); ··· 524 521 if (err) 525 522 return err; 526 523 527 - err = pmc_core_send_ltr_ignore(pmcdev, value); 524 + err = pmc_core_send_ltr_ignore(pmcdev, value, 1); 528 525 529 526 return err == 0 ? count : err; 530 527 } ··· 1281 1278 { 1282 1279 struct pmc_dev *pmcdev = dev_get_drvdata(dev); 1283 1280 struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; 1281 + 1282 + if (pmcdev->suspend) 1283 + pmcdev->suspend(pmcdev); 1284 1284 1285 1285 /* Check if the syspend will actually use S0ix */ 1286 1286 if (pm_suspend_via_firmware())
+6 -1
drivers/platform/x86/intel/pmc/core.h
··· 363 363 * @s0ix_counter: S0ix residency (step adjusted) 364 364 * @num_lpm_modes: Count of enabled modes 365 365 * @lpm_en_modes: Array of enabled modes from lowest to highest priority 366 + * @suspend: Function to perform platform specific suspend 366 367 * @resume: Function to perform platform specific resume 367 368 * 368 369 * pmc_dev contains info about power management controller device. ··· 380 379 u64 s0ix_counter; 381 380 int num_lpm_modes; 382 381 int lpm_en_modes[LPM_MAX_NUM_MODES]; 382 + void (*suspend)(struct pmc_dev *pmcdev); 383 383 int (*resume)(struct pmc_dev *pmcdev); 384 384 385 385 bool has_die_c6; ··· 488 486 extern const struct pmc_reg_map mtl_ioem_reg_map; 489 487 490 488 extern void pmc_core_get_tgl_lpm_reqs(struct platform_device *pdev); 491 - extern int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value); 489 + int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore); 492 490 493 491 int pmc_core_resume_common(struct pmc_dev *pmcdev); 494 492 int get_primary_reg_base(struct pmc *pmc); ··· 501 499 int tgl_core_init(struct pmc_dev *pmcdev); 502 500 int adl_core_init(struct pmc_dev *pmcdev); 503 501 int mtl_core_init(struct pmc_dev *pmcdev); 502 + 503 + void cnl_suspend(struct pmc_dev *pmcdev); 504 + int cnl_resume(struct pmc_dev *pmcdev); 504 505 505 506 #define pmc_for_each_mode(i, mode, pmcdev) \ 506 507 for (i = 0, mode = pmcdev->lpm_en_modes[i]; \
+3 -6
drivers/platform/x86/intel/pmc/mtl.c
··· 979 979 static int mtl_resume(struct pmc_dev *pmcdev) 980 980 { 981 981 mtl_d3_fixup(); 982 + pmc_core_send_ltr_ignore(pmcdev, 3, 0); 983 + 982 984 return pmc_core_resume_common(pmcdev); 983 985 } 984 986 ··· 991 989 992 990 mtl_d3_fixup(); 993 991 992 + pmcdev->suspend = cnl_suspend; 994 993 pmcdev->resume = mtl_resume; 995 994 996 995 pmcdev->regmap_list = mtl_pmc_info_list; ··· 1004 1001 if (ret) 1005 1002 return ret; 1006 1003 } 1007 - 1008 - /* Due to a hardware limitation, the GBE LTR blocks PC10 1009 - * when a cable is attached. Tell the PMC to ignore it. 1010 - */ 1011 - dev_dbg(&pmcdev->pdev->dev, "ignoring GBE LTR\n"); 1012 - pmc_core_send_ltr_ignore(pmcdev, 3); 1013 1004 1014 1005 return 0; 1015 1006 }
+4 -5
drivers/platform/x86/intel/pmc/tgl.c
··· 259 259 int ret; 260 260 261 261 pmc->map = &tgl_reg_map; 262 + 263 + pmcdev->suspend = cnl_suspend; 264 + pmcdev->resume = cnl_resume; 265 + 262 266 ret = get_primary_reg_base(pmc); 263 267 if (ret) 264 268 return ret; 265 269 266 270 pmc_core_get_tgl_lpm_reqs(pmcdev->pdev); 267 - /* Due to a hardware limitation, the GBE LTR blocks PC10 268 - * when a cable is attached. Tell the PMC to ignore it. 269 - */ 270 - dev_dbg(&pmcdev->pdev->dev, "ignoring GBE LTR\n"); 271 - pmc_core_send_ltr_ignore(pmcdev, 3); 272 271 273 272 return 0; 274 273 }
+1 -1
drivers/ptp/ptp_ocp.c
··· 4470 4470 cancel_delayed_work_sync(&bp->sync_work); 4471 4471 for (i = 0; i < OCP_SMA_NUM; i++) { 4472 4472 if (bp->sma[i].dpll_pin) { 4473 - dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, bp); 4473 + dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]); 4474 4474 dpll_pin_put(bp->sma[i].dpll_pin); 4475 4475 } 4476 4476 }
+3 -6
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 429 429 struct fcoe_ctlr *ctlr; 430 430 struct fcoe_rcv_info *fr; 431 431 struct fcoe_percpu_s *bg; 432 - struct sk_buff *tmp_skb; 433 432 434 433 interface = container_of(ptype, struct bnx2fc_interface, 435 434 fcoe_packet_type); ··· 440 441 goto err; 441 442 } 442 443 443 - tmp_skb = skb_share_check(skb, GFP_ATOMIC); 444 - if (!tmp_skb) 445 - goto err; 446 - 447 - skb = tmp_skb; 444 + skb = skb_share_check(skb, GFP_ATOMIC); 445 + if (!skb) 446 + return -1; 448 447 449 448 if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { 450 449 printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");
+2
drivers/scsi/scsi_error.c
··· 1152 1152 1153 1153 scsi_log_send(scmd); 1154 1154 scmd->submitter = SUBMITTED_BY_SCSI_ERROR_HANDLER; 1155 + scmd->flags |= SCMD_LAST; 1155 1156 1156 1157 /* 1157 1158 * Lock sdev->state_mutex to avoid that scsi_device_quiesce() can ··· 2460 2459 scsi_init_command(dev, scmd); 2461 2460 2462 2461 scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL; 2462 + scmd->flags |= SCMD_LAST; 2463 2463 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 2464 2464 2465 2465 scmd->cmd_len = 0;
+1 -1
drivers/thunderbolt/debugfs.c
··· 959 959 snprintf(dir_name, sizeof(dir_name), "port%d", port->port); 960 960 parent = debugfs_lookup(dir_name, port->sw->debugfs_dir); 961 961 if (parent) 962 - debugfs_remove_recursive(debugfs_lookup("margining", parent)); 962 + debugfs_lookup_and_remove("margining", parent); 963 963 964 964 kfree(port->usb4->margining); 965 965 port->usb4->margining = NULL;
+5 -5
drivers/thunderbolt/usb4.c
··· 2311 2311 goto err_request; 2312 2312 2313 2313 /* 2314 - * Always keep 1000 Mb/s to make sure xHCI has at least some 2314 + * Always keep 900 Mb/s to make sure xHCI has at least some 2315 2315 * bandwidth available for isochronous traffic. 2316 2316 */ 2317 - if (consumed_up < 1000) 2318 - consumed_up = 1000; 2319 - if (consumed_down < 1000) 2320 - consumed_down = 1000; 2317 + if (consumed_up < 900) 2318 + consumed_up = 900; 2319 + if (consumed_down < 900) 2320 + consumed_down = 900; 2321 2321 2322 2322 ret = usb4_usb3_port_write_allocated_bandwidth(port, consumed_up, 2323 2323 consumed_down);
+2 -1
drivers/ufs/core/ufshcd.c
··· 2274 2274 if (is_mcq_enabled(hba)) { 2275 2275 int utrd_size = sizeof(struct utp_transfer_req_desc); 2276 2276 struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr; 2277 - struct utp_transfer_req_desc *dest = hwq->sqe_base_addr + hwq->sq_tail_slot; 2277 + struct utp_transfer_req_desc *dest; 2278 2278 2279 2279 spin_lock(&hwq->sq_lock); 2280 + dest = hwq->sqe_base_addr + hwq->sq_tail_slot; 2280 2281 memcpy(dest, src, utrd_size); 2281 2282 ufshcd_inc_sq_tail(hwq); 2282 2283 spin_unlock(&hwq->sq_lock);
+4 -2
drivers/ufs/host/ufs-qcom.c
··· 1516 1516 err = ufs_qcom_clk_scale_up_pre_change(hba); 1517 1517 else 1518 1518 err = ufs_qcom_clk_scale_down_pre_change(hba); 1519 - if (err) 1520 - ufshcd_uic_hibern8_exit(hba); 1521 1519 1520 + if (err) { 1521 + ufshcd_uic_hibern8_exit(hba); 1522 + return err; 1523 + } 1522 1524 } else { 1523 1525 if (scale_up) 1524 1526 err = ufs_qcom_clk_scale_up_post_change(hba);
-3
drivers/usb/fotg210/fotg210-hcd.c
··· 428 428 temp = size; 429 429 size -= temp; 430 430 next += temp; 431 - if (temp == size) 432 - goto done; 433 431 } 434 432 435 433 temp = snprintf(next, size, "\n"); ··· 437 439 size -= temp; 438 440 next += temp; 439 441 440 - done: 441 442 *sizep = size; 442 443 *nextp = next; 443 444 }
+3 -3
drivers/usb/serial/ftdi_sio.c
··· 1033 1033 { USB_DEVICE(FTDI_VID, ACTISENSE_USG_PID) }, 1034 1034 { USB_DEVICE(FTDI_VID, ACTISENSE_NGT_PID) }, 1035 1035 { USB_DEVICE(FTDI_VID, ACTISENSE_NGW_PID) }, 1036 - { USB_DEVICE(FTDI_VID, ACTISENSE_D9AC_PID) }, 1037 - { USB_DEVICE(FTDI_VID, ACTISENSE_D9AD_PID) }, 1038 - { USB_DEVICE(FTDI_VID, ACTISENSE_D9AE_PID) }, 1036 + { USB_DEVICE(FTDI_VID, ACTISENSE_UID_PID) }, 1037 + { USB_DEVICE(FTDI_VID, ACTISENSE_USA_PID) }, 1038 + { USB_DEVICE(FTDI_VID, ACTISENSE_NGX_PID) }, 1039 1039 { USB_DEVICE(FTDI_VID, ACTISENSE_D9AF_PID) }, 1040 1040 { USB_DEVICE(FTDI_VID, CHETCO_SEAGAUGE_PID) }, 1041 1041 { USB_DEVICE(FTDI_VID, CHETCO_SEASWITCH_PID) },
+3 -3
drivers/usb/serial/ftdi_sio_ids.h
··· 1568 1568 #define ACTISENSE_USG_PID 0xD9A9 /* USG USB Serial Adapter */ 1569 1569 #define ACTISENSE_NGT_PID 0xD9AA /* NGT NMEA2000 Interface */ 1570 1570 #define ACTISENSE_NGW_PID 0xD9AB /* NGW NMEA2000 Gateway */ 1571 - #define ACTISENSE_D9AC_PID 0xD9AC /* Actisense Reserved */ 1572 - #define ACTISENSE_D9AD_PID 0xD9AD /* Actisense Reserved */ 1573 - #define ACTISENSE_D9AE_PID 0xD9AE /* Actisense Reserved */ 1571 + #define ACTISENSE_UID_PID 0xD9AC /* USB Isolating Device */ 1572 + #define ACTISENSE_USA_PID 0xD9AD /* USB to Serial Adapter */ 1573 + #define ACTISENSE_NGX_PID 0xD9AE /* NGX NMEA2000 Gateway */ 1574 1574 #define ACTISENSE_D9AF_PID 0xD9AF /* Actisense Reserved */ 1575 1575 #define CHETCO_SEAGAUGE_PID 0xA548 /* SeaGauge USB Adapter */ 1576 1576 #define CHETCO_SEASWITCH_PID 0xA549 /* SeaSwitch USB Adapter */
+5
drivers/usb/serial/option.c
··· 272 272 #define QUECTEL_PRODUCT_RM500Q 0x0800 273 273 #define QUECTEL_PRODUCT_RM520N 0x0801 274 274 #define QUECTEL_PRODUCT_EC200U 0x0901 275 + #define QUECTEL_PRODUCT_EG912Y 0x6001 275 276 #define QUECTEL_PRODUCT_EC200S_CN 0x6002 276 277 #define QUECTEL_PRODUCT_EC200A 0x6005 277 278 #define QUECTEL_PRODUCT_EM061K_LWW 0x6008 ··· 1233 1232 { USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, 0x0700, 0xff), /* BG95 */ 1234 1233 .driver_info = RSVD(3) | ZLP }, 1235 1234 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x30) }, 1235 + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0x40) }, 1236 1236 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0) }, 1237 1237 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x10), 1238 1238 .driver_info = ZLP }, ··· 1246 1244 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200U, 0xff, 0, 0) }, 1247 1245 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200S_CN, 0xff, 0, 0) }, 1248 1246 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) }, 1247 + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG912Y, 0xff, 0, 0) }, 1249 1248 { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500K, 0xff, 0x00, 0x00) }, 1250 1249 1251 1250 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, ··· 2245 2242 .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 2246 2243 { USB_DEVICE(0x0489, 0xe0b5), /* Foxconn T77W968 ESIM */ 2247 2244 .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 2245 + { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe0da, 0xff), /* Foxconn T99W265 MBIM variant */ 2246 + .driver_info = RSVD(3) | RSVD(5) }, 2248 2247 { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe0db, 0xff), /* Foxconn T99W265 MBIM */ 2249 2248 .driver_info = RSVD(3) }, 2250 2249 { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe0ee, 0xff), /* Foxconn T99W368 MBIM */
+11
drivers/usb/storage/unusual_devs.h
··· 1306 1306 US_FL_INITIAL_READ10 ), 1307 1307 1308 1308 /* 1309 + * Patch by Tasos Sahanidis <tasos@tasossah.com> 1310 + * This flash drive always shows up with write protect enabled 1311 + * during the first mode sense. 1312 + */ 1313 + UNUSUAL_DEV(0x0951, 0x1697, 0x0100, 0x0100, 1314 + "Kingston", 1315 + "DT Ultimate G3", 1316 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 1317 + US_FL_NO_WP_DETECT), 1318 + 1319 + /* 1309 1320 * This Pentax still camera is not conformant 1310 1321 * to the USB storage specification: - 1311 1322 * - It does not like the INQUIRY command. So we must handle this command
+1 -1
drivers/usb/typec/ucsi/ucsi_glink.c
··· 228 228 229 229 con_num = UCSI_CCI_CONNECTOR(cci); 230 230 if (con_num) { 231 - if (con_num < PMIC_GLINK_MAX_PORTS && 231 + if (con_num <= PMIC_GLINK_MAX_PORTS && 232 232 ucsi->port_orientation[con_num - 1]) { 233 233 int orientation = gpiod_get_value(ucsi->port_orientation[con_num - 1]); 234 234
+2 -4
drivers/virtio/virtio_ring.c
··· 3219 3219 if (!vq->use_dma_api) 3220 3220 return; 3221 3221 3222 - dma_sync_single_range_for_cpu(dev, addr, offset, size, 3223 - DMA_BIDIRECTIONAL); 3222 + dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); 3224 3223 } 3225 3224 EXPORT_SYMBOL_GPL(virtqueue_dma_sync_single_range_for_cpu); 3226 3225 ··· 3245 3246 if (!vq->use_dma_api) 3246 3247 return; 3247 3248 3248 - dma_sync_single_range_for_device(dev, addr, offset, size, 3249 - DMA_BIDIRECTIONAL); 3249 + dma_sync_single_range_for_device(dev, addr, offset, size, dir); 3250 3250 } 3251 3251 EXPORT_SYMBOL_GPL(virtqueue_dma_sync_single_range_for_device); 3252 3252
+4 -2
fs/afs/cell.c
··· 409 409 if (ret == -ENOMEM) 410 410 goto out_wake; 411 411 412 - ret = -ENOMEM; 413 412 vllist = afs_alloc_vlserver_list(0); 414 - if (!vllist) 413 + if (!vllist) { 414 + if (ret >= 0) 415 + ret = -ENOMEM; 415 416 goto out_wake; 417 + } 416 418 417 419 switch (ret) { 418 420 case -ENODATA:
+17 -14
fs/afs/dynroot.c
··· 114 114 struct afs_net *net = afs_d2net(dentry); 115 115 const char *name = dentry->d_name.name; 116 116 size_t len = dentry->d_name.len; 117 + char *result = NULL; 117 118 int ret; 118 119 119 120 /* Names prefixed with a dot are R/W mounts. */ ··· 132 131 } 133 132 134 133 ret = dns_query(net->net, "afsdb", name, len, "srv=1", 135 - NULL, NULL, false); 136 - if (ret == -ENODATA || ret == -ENOKEY) 134 + &result, NULL, false); 135 + if (ret == -ENODATA || ret == -ENOKEY || ret == 0) 137 136 ret = -ENOENT; 137 + if (ret > 0 && ret >= sizeof(struct dns_server_list_v1_header)) { 138 + struct dns_server_list_v1_header *v1 = (void *)result; 139 + 140 + if (v1->hdr.zero == 0 && 141 + v1->hdr.content == DNS_PAYLOAD_IS_SERVER_LIST && 142 + v1->hdr.version == 1 && 143 + (v1->status != DNS_LOOKUP_GOOD && 144 + v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) 145 + return -ENOENT; 146 + 147 + } 148 + 149 + kfree(result); 138 150 return ret; 139 151 } 140 152 ··· 266 252 return 1; 267 253 } 268 254 269 - /* 270 - * Allow the VFS to enquire as to whether a dentry should be unhashed (mustn't 271 - * sleep) 272 - * - called from dput() when d_count is going to 0. 273 - * - return 1 to request dentry be unhashed, 0 otherwise 274 - */ 275 - static int afs_dynroot_d_delete(const struct dentry *dentry) 276 - { 277 - return d_really_is_positive(dentry); 278 - } 279 - 280 255 const struct dentry_operations afs_dynroot_dentry_operations = { 281 256 .d_revalidate = afs_dynroot_d_revalidate, 282 - .d_delete = afs_dynroot_d_delete, 257 + .d_delete = always_delete_dentry, 283 258 .d_release = afs_d_release, 284 259 .d_automount = afs_d_automount, 285 260 };
+2
fs/afs/internal.h
··· 586 586 #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ 587 587 #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ 588 588 #define AFS_VOLUME_MAYBE_NO_IBULK 6 /* - T if some servers don't have InlineBulkStatus */ 589 + #define AFS_VOLUME_RM_TREE 7 /* - Set if volume removed from cell->volumes */ 589 590 #ifdef CONFIG_AFS_FSCACHE 590 591 struct fscache_volume *cache; /* Caching cookie */ 591 592 #endif ··· 1514 1513 extern struct afs_volume *afs_create_volume(struct afs_fs_context *); 1515 1514 extern int afs_activate_volume(struct afs_volume *); 1516 1515 extern void afs_deactivate_volume(struct afs_volume *); 1516 + bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason); 1517 1517 extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace); 1518 1518 extern void afs_put_volume(struct afs_net *, struct afs_volume *, enum afs_volume_trace); 1519 1519 extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *);
+23 -3
fs/afs/volume.c
··· 32 32 } else if (p->vid > volume->vid) { 33 33 pp = &(*pp)->rb_right; 34 34 } else { 35 - volume = afs_get_volume(p, afs_volume_trace_get_cell_insert); 36 - goto found; 35 + if (afs_try_get_volume(p, afs_volume_trace_get_cell_insert)) { 36 + volume = p; 37 + goto found; 38 + } 39 + 40 + set_bit(AFS_VOLUME_RM_TREE, &volume->flags); 41 + rb_replace_node_rcu(&p->cell_node, &volume->cell_node, &cell->volumes); 37 42 } 38 43 } 39 44 ··· 61 56 afs_volume_trace_remove); 62 57 write_seqlock(&cell->volume_lock); 63 58 hlist_del_rcu(&volume->proc_link); 64 - rb_erase(&volume->cell_node, &cell->volumes); 59 + if (!test_and_set_bit(AFS_VOLUME_RM_TREE, &volume->flags)) 60 + rb_erase(&volume->cell_node, &cell->volumes); 65 61 write_sequnlock(&cell->volume_lock); 66 62 } 67 63 } ··· 235 229 kfree_rcu(volume, rcu); 236 230 237 231 _leave(" [destroyed]"); 232 + } 233 + 234 + /* 235 + * Try to get a reference on a volume record. 236 + */ 237 + bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason) 238 + { 239 + int r; 240 + 241 + if (__refcount_inc_not_zero(&volume->ref, &r)) { 242 + trace_afs_volume(volume->vid, r + 1, reason); 243 + return true; 244 + } 245 + return false; 238 246 } 239 247 240 248 /*
+2
fs/bcachefs/Makefile
··· 28 28 clock.o \ 29 29 compress.o \ 30 30 counters.o \ 31 + darray.o \ 31 32 debug.o \ 32 33 dirent.o \ 33 34 disk_groups.o \ ··· 71 70 reflink.o \ 72 71 replicas.o \ 73 72 sb-clean.o \ 73 + sb-downgrade.o \ 74 74 sb-errors.o \ 75 75 sb-members.o \ 76 76 siphash.o \
+2 -1
fs/bcachefs/acl.c
··· 366 366 bch2_trans_begin(trans); 367 367 acl = _acl; 368 368 369 - ret = bch2_inode_peek(trans, &inode_iter, &inode_u, inode_inum(inode), 369 + ret = bch2_subvol_is_ro_trans(trans, inode->ei_subvol) ?: 370 + bch2_inode_peek(trans, &inode_iter, &inode_u, inode_inum(inode), 370 371 BTREE_ITER_INTENT); 371 372 if (ret) 372 373 goto btree_err;
+1
fs/bcachefs/bcachefs.h
··· 737 737 unsigned nsec_per_time_unit; 738 738 u64 features; 739 739 u64 compat; 740 + unsigned long errors_silent[BITS_TO_LONGS(BCH_SB_ERR_MAX)]; 740 741 } sb; 741 742 742 743
+38 -13
fs/bcachefs/bcachefs_format.h
··· 1207 1207 }; 1208 1208 1209 1209 #define BCH_SB_FIELDS() \ 1210 - x(journal, 0) \ 1211 - x(members_v1, 1) \ 1212 - x(crypt, 2) \ 1213 - x(replicas_v0, 3) \ 1214 - x(quota, 4) \ 1215 - x(disk_groups, 5) \ 1216 - x(clean, 6) \ 1217 - x(replicas, 7) \ 1218 - x(journal_seq_blacklist, 8) \ 1219 - x(journal_v2, 9) \ 1220 - x(counters, 10) \ 1221 - x(members_v2, 11) \ 1222 - x(errors, 12) 1210 + x(journal, 0) \ 1211 + x(members_v1, 1) \ 1212 + x(crypt, 2) \ 1213 + x(replicas_v0, 3) \ 1214 + x(quota, 4) \ 1215 + x(disk_groups, 5) \ 1216 + x(clean, 6) \ 1217 + x(replicas, 7) \ 1218 + x(journal_seq_blacklist, 8) \ 1219 + x(journal_v2, 9) \ 1220 + x(counters, 10) \ 1221 + x(members_v2, 11) \ 1222 + x(errors, 12) \ 1223 + x(ext, 13) \ 1224 + x(downgrade, 14) 1223 1225 1224 1226 enum bch_sb_field_type { 1225 1227 #define x(f, nr) BCH_SB_FIELD_##f = nr, ··· 1633 1631 LE64_BITMASK(BCH_SB_ERROR_ENTRY_ID, struct bch_sb_field_error_entry, v, 0, 16); 1634 1632 LE64_BITMASK(BCH_SB_ERROR_ENTRY_NR, struct bch_sb_field_error_entry, v, 16, 64); 1635 1633 1634 + struct bch_sb_field_ext { 1635 + struct bch_sb_field field; 1636 + __le64 recovery_passes_required[2]; 1637 + __le64 errors_silent[8]; 1638 + }; 1639 + 1640 + struct bch_sb_field_downgrade_entry { 1641 + __le16 version; 1642 + __le64 recovery_passes[2]; 1643 + __le16 nr_errors; 1644 + __le16 errors[] __counted_by(nr_errors); 1645 + } __packed __aligned(2); 1646 + 1647 + struct bch_sb_field_downgrade { 1648 + struct bch_sb_field field; 1649 + struct bch_sb_field_downgrade_entry entries[]; 1650 + }; 1651 + 1636 1652 /* Superblock: */ 1637 1653 1638 1654 /* ··· 1664 1644 1665 1645 #define RECOVERY_PASS_ALL_FSCK (1ULL << 63) 1666 1646 1647 + /* 1648 + * field 1: version name 1649 + * field 2: BCH_VERSION(major, minor) 1650 + * field 3: recovery passess required on upgrade 1651 + */ 1667 1652 #define BCH_METADATA_VERSIONS() \ 1668 1653 x(bkey_renumber, BCH_VERSION(0, 10), \ 1669 1654 RECOVERY_PASS_ALL_FSCK) \
+24 -11
fs/bcachefs/btree_iter.c
··· 2085 2085 goto out_no_locked; 2086 2086 2087 2087 /* 2088 - * iter->pos should be mononotically increasing, and always be 2089 - * equal to the key we just returned - except extents can 2090 - * straddle iter->pos: 2088 + * We need to check against @end before FILTER_SNAPSHOTS because 2089 + * if we get to a different inode that requested we might be 2090 + * seeing keys for a different snapshot tree that will all be 2091 + * filtered out. 2092 + * 2093 + * But we can't do the full check here, because bkey_start_pos() 2094 + * isn't monotonically increasing before FILTER_SNAPSHOTS, and 2095 + * that's what we check against in extents mode: 2091 2096 */ 2092 - if (!(iter->flags & BTREE_ITER_IS_EXTENTS)) 2093 - iter_pos = k.k->p; 2094 - else 2095 - iter_pos = bkey_max(iter->pos, bkey_start_pos(k.k)); 2096 - 2097 - if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS) 2098 - ? bkey_gt(iter_pos, end) 2099 - : bkey_ge(iter_pos, end))) 2097 + if (k.k->p.inode > end.inode) 2100 2098 goto end; 2101 2099 2102 2100 if (iter->update_path && ··· 2152 2154 search_key = bkey_successor(iter, k.k->p); 2153 2155 continue; 2154 2156 } 2157 + 2158 + /* 2159 + * iter->pos should be mononotically increasing, and always be 2160 + * equal to the key we just returned - except extents can 2161 + * straddle iter->pos: 2162 + */ 2163 + if (!(iter->flags & BTREE_ITER_IS_EXTENTS)) 2164 + iter_pos = k.k->p; 2165 + else 2166 + iter_pos = bkey_max(iter->pos, bkey_start_pos(k.k)); 2167 + 2168 + if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS) 2169 + ? bkey_gt(iter_pos, end) 2170 + : bkey_ge(iter_pos, end))) 2171 + goto end; 2155 2172 2156 2173 break; 2157 2174 }
+8 -7
fs/bcachefs/btree_update.c
··· 186 186 enum btree_id btree_id = iter->btree_id; 187 187 struct bkey_i *update; 188 188 struct bpos new_start = bkey_start_pos(new.k); 189 - bool front_split = bkey_lt(bkey_start_pos(old.k), new_start); 190 - bool back_split = bkey_gt(old.k->p, new.k->p); 189 + unsigned front_split = bkey_lt(bkey_start_pos(old.k), new_start); 190 + unsigned back_split = bkey_gt(old.k->p, new.k->p); 191 + unsigned middle_split = (front_split || back_split) && 192 + old.k->p.snapshot != new.k->p.snapshot; 193 + unsigned nr_splits = front_split + back_split + middle_split; 191 194 int ret = 0, compressed_sectors; 192 195 193 196 /* ··· 198 195 * so that __bch2_trans_commit() can increase our disk 199 196 * reservation: 200 197 */ 201 - if (((front_split && back_split) || 202 - ((front_split || back_split) && old.k->p.snapshot != new.k->p.snapshot)) && 198 + if (nr_splits > 1 && 203 199 (compressed_sectors = bch2_bkey_sectors_compressed(old))) 204 - trans->extra_journal_res += compressed_sectors; 200 + trans->extra_journal_res += compressed_sectors * (nr_splits - 1); 205 201 206 202 if (front_split) { 207 203 update = bch2_bkey_make_mut_noupdate(trans, old); ··· 218 216 } 219 217 220 218 /* If we're overwriting in a different snapshot - middle split: */ 221 - if (old.k->p.snapshot != new.k->p.snapshot && 222 - (front_split || back_split)) { 219 + if (middle_split) { 223 220 update = bch2_bkey_make_mut_noupdate(trans, old); 224 221 if ((ret = PTR_ERR_OR_ZERO(update))) 225 222 return ret;
+24
fs/bcachefs/darray.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/log2.h> 4 + #include <linux/slab.h> 5 + #include "darray.h" 6 + 7 + int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, gfp_t gfp) 8 + { 9 + if (new_size > d->size) { 10 + new_size = roundup_pow_of_two(new_size); 11 + 12 + void *data = kvmalloc_array(new_size, element_size, gfp); 13 + if (!data) 14 + return -ENOMEM; 15 + 16 + memcpy(data, d->data, d->size * element_size); 17 + if (d->data != d->preallocated) 18 + kvfree(d->data); 19 + d->data = data; 20 + d->size = new_size; 21 + } 22 + 23 + return 0; 24 + }
+30 -18
fs/bcachefs/darray.h
··· 8 8 * Inspired by CCAN's darray 9 9 */ 10 10 11 - #include "util.h" 12 11 #include <linux/slab.h> 13 12 14 - #define DARRAY(type) \ 13 + #define DARRAY_PREALLOCATED(_type, _nr) \ 15 14 struct { \ 16 15 size_t nr, size; \ 17 - type *data; \ 16 + _type *data; \ 17 + _type preallocated[_nr]; \ 18 18 } 19 19 20 - typedef DARRAY(void) darray_void; 20 + #define DARRAY(_type) DARRAY_PREALLOCATED(_type, 0) 21 21 22 - static inline int __darray_make_room(darray_void *d, size_t t_size, size_t more, gfp_t gfp) 22 + typedef DARRAY(char) darray_char; 23 + 24 + int __bch2_darray_resize(darray_char *, size_t, size_t, gfp_t); 25 + 26 + static inline int __darray_resize(darray_char *d, size_t element_size, 27 + size_t new_size, gfp_t gfp) 23 28 { 24 - if (d->nr + more > d->size) { 25 - size_t new_size = roundup_pow_of_two(d->nr + more); 26 - void *data = krealloc_array(d->data, new_size, t_size, gfp); 29 + return unlikely(new_size > d->size) 30 + ? __bch2_darray_resize(d, element_size, new_size, gfp) 31 + : 0; 32 + } 27 33 28 - if (!data) 29 - return -ENOMEM; 34 + #define darray_resize_gfp(_d, _new_size, _gfp) \ 35 + unlikely(__darray_resize((darray_char *) (_d), sizeof((_d)->data[0]), (_new_size), _gfp)) 30 36 31 - d->data = data; 32 - d->size = new_size; 33 - } 37 + #define darray_resize(_d, _new_size) \ 38 + darray_resize_gfp(_d, _new_size, GFP_KERNEL) 34 39 35 - return 0; 40 + static inline int __darray_make_room(darray_char *d, size_t t_size, size_t more, gfp_t gfp) 41 + { 42 + return __darray_resize(d, t_size, d->nr + more, gfp); 36 43 } 37 44 38 45 #define darray_make_room_gfp(_d, _more, _gfp) \ 39 - __darray_make_room((darray_void *) (_d), sizeof((_d)->data[0]), (_more), _gfp) 46 + __darray_make_room((darray_char *) (_d), sizeof((_d)->data[0]), (_more), _gfp) 40 47 41 48 #define darray_make_room(_d, _more) \ 42 49 darray_make_room_gfp(_d, _more, GFP_KERNEL) 50 + 51 + #define darray_room(_d) ((_d).size - (_d).nr) 43 52 44 53 #define darray_top(_d) ((_d).data[(_d).nr]) 45 54 ··· 89 80 90 81 #define darray_init(_d) \ 91 82 do { \ 92 - (_d)->data = NULL; \ 93 - (_d)->nr = (_d)->size = 0; \ 83 + (_d)->nr = 0; \ 84 + (_d)->size = ARRAY_SIZE((_d)->preallocated); \ 85 + (_d)->data = (_d)->size ? (_d)->preallocated : NULL; \ 94 86 } while (0) 95 87 96 88 #define darray_exit(_d) \ 97 89 do { \ 98 - kfree((_d)->data); \ 90 + if (!ARRAY_SIZE((_d)->preallocated) || \ 91 + (_d)->data != (_d)->preallocated) \ 92 + kvfree((_d)->data); \ 99 93 darray_init(_d); \ 100 94 } while (0) 101 95
+2 -1
fs/bcachefs/data_update.c
··· 587 587 * Increasing replication is an explicit operation triggered by 588 588 * rereplicate, currently, so that users don't get an unexpected -ENOSPC 589 589 */ 590 - if (durability_have >= io_opts.data_replicas) { 590 + if (!(m->data_opts.write_flags & BCH_WRITE_CACHED) && 591 + durability_have >= io_opts.data_replicas) { 591 592 m->data_opts.kill_ptrs |= m->data_opts.rewrite_ptrs; 592 593 m->data_opts.rewrite_ptrs = 0; 593 594 /* if iter == NULL, it's just a promote */
+3
fs/bcachefs/errcode.h
··· 95 95 x(ENOSPC, ENOSPC_sb_members) \ 96 96 x(ENOSPC, ENOSPC_sb_members_v2) \ 97 97 x(ENOSPC, ENOSPC_sb_crypt) \ 98 + x(ENOSPC, ENOSPC_sb_downgrade) \ 98 99 x(ENOSPC, ENOSPC_btree_slot) \ 99 100 x(ENOSPC, ENOSPC_snapshot_tree) \ 100 101 x(ENOENT, ENOENT_bkey_type_mismatch) \ ··· 219 218 x(BCH_ERR_invalid_sb, invalid_sb_quota) \ 220 219 x(BCH_ERR_invalid_sb, invalid_sb_errors) \ 221 220 x(BCH_ERR_invalid_sb, invalid_sb_opt_compression) \ 221 + x(BCH_ERR_invalid_sb, invalid_sb_ext) \ 222 + x(BCH_ERR_invalid_sb, invalid_sb_downgrade) \ 222 223 x(BCH_ERR_invalid, invalid_bkey) \ 223 224 x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ 224 225 x(EIO, btree_node_read_err) \
+3
fs/bcachefs/error.c
··· 152 152 struct printbuf buf = PRINTBUF, *out = &buf; 153 153 int ret = -BCH_ERR_fsck_ignore; 154 154 155 + if (test_bit(err, c->sb.errors_silent)) 156 + return -BCH_ERR_fsck_fix; 157 + 155 158 bch2_sb_error_count(c, err); 156 159 157 160 va_start(args, fmt);
+1 -1
fs/bcachefs/error.h
··· 157 157 #define fsck_err_on(cond, c, _err_type, ...) \ 158 158 __fsck_err_on(cond, c, FSCK_CAN_FIX|FSCK_CAN_IGNORE, _err_type, __VA_ARGS__) 159 159 160 + __printf(4, 0) 160 161 static inline void bch2_bkey_fsck_err(struct bch_fs *c, 161 162 struct printbuf *err_msg, 162 163 enum bch_sb_error_id err_type, ··· 168 167 va_start(args, fmt); 169 168 prt_vprintf(err_msg, fmt, args); 170 169 va_end(args); 171 - 172 170 } 173 171 174 172 #define bkey_fsck_err(c, _err_msg, _err_type, ...) \
+5 -8
fs/bcachefs/fs-io-direct.c
··· 216 216 struct address_space *mapping; 217 217 struct bch_inode_info *inode; 218 218 struct mm_struct *mm; 219 + const struct iovec *iov; 219 220 unsigned loop:1, 220 221 extending:1, 221 222 sync:1, 222 - flush:1, 223 - free_iov:1; 223 + flush:1; 224 224 struct quota_res quota_res; 225 225 u64 written; 226 226 ··· 312 312 return -1; 313 313 314 314 if (dio->iter.nr_segs > ARRAY_SIZE(dio->inline_vecs)) { 315 - iov = kmalloc_array(dio->iter.nr_segs, sizeof(*iov), 315 + dio->iov = iov = kmalloc_array(dio->iter.nr_segs, sizeof(*iov), 316 316 GFP_KERNEL); 317 317 if (unlikely(!iov)) 318 318 return -ENOMEM; 319 - 320 - dio->free_iov = true; 321 319 } 322 320 323 321 memcpy(iov, dio->iter.__iov, dio->iter.nr_segs * sizeof(*iov)); ··· 379 381 380 382 bch2_pagecache_block_put(inode); 381 383 382 - if (dio->free_iov) 383 - kfree(dio->iter.__iov); 384 + kfree(dio->iov); 384 385 385 386 ret = dio->op.error ?: ((long) dio->written << 9); 386 387 bio_put(&dio->op.wbio.bio); ··· 623 626 dio->mapping = mapping; 624 627 dio->inode = inode; 625 628 dio->mm = current->mm; 629 + dio->iov = NULL; 626 630 dio->loop = false; 627 631 dio->extending = extending; 628 632 dio->sync = is_sync_kiocb(req) || extending; 629 633 dio->flush = iocb_is_dsync(req) && !c->opts.journal_flush_disabled; 630 - dio->free_iov = false; 631 634 dio->quota_res.sectors = 0; 632 635 dio->written = 0; 633 636 dio->iter = *iter;
+5 -7
fs/bcachefs/fs-ioctl.c
··· 100 100 } 101 101 102 102 mutex_lock(&inode->ei_update_lock); 103 - ret = bch2_write_inode(c, inode, bch2_inode_flags_set, &s, 103 + ret = bch2_subvol_is_ro(c, inode->ei_subvol) ?: 104 + bch2_write_inode(c, inode, bch2_inode_flags_set, &s, 104 105 ATTR_CTIME); 105 106 mutex_unlock(&inode->ei_update_lock); 106 107 ··· 184 183 } 185 184 186 185 mutex_lock(&inode->ei_update_lock); 187 - ret = bch2_set_projid(c, inode, fa.fsx_projid); 188 - if (ret) 189 - goto err_unlock; 190 - 191 - ret = bch2_write_inode(c, inode, fssetxattr_inode_update_fn, &s, 186 + ret = bch2_subvol_is_ro(c, inode->ei_subvol) ?: 187 + bch2_set_projid(c, inode, fa.fsx_projid) ?: 188 + bch2_write_inode(c, inode, fssetxattr_inode_update_fn, &s, 192 189 ATTR_CTIME); 193 - err_unlock: 194 190 mutex_unlock(&inode->ei_update_lock); 195 191 err: 196 192 inode_unlock(&inode->v);
+33 -5
fs/bcachefs/fs.c
··· 258 258 retry: 259 259 bch2_trans_begin(trans); 260 260 261 - ret = bch2_create_trans(trans, 261 + ret = bch2_subvol_is_ro_trans(trans, dir->ei_subvol) ?: 262 + bch2_create_trans(trans, 262 263 inode_inum(dir), &dir_u, &inode_u, 263 264 !(flags & BCH_CREATE_TMPFILE) 264 265 ? &dentry->d_name : NULL, ··· 431 430 432 431 lockdep_assert_held(&inode->v.i_rwsem); 433 432 434 - ret = __bch2_link(c, inode, dir, dentry); 433 + ret = bch2_subvol_is_ro(c, dir->ei_subvol) ?: 434 + bch2_subvol_is_ro(c, inode->ei_subvol) ?: 435 + __bch2_link(c, inode, dir, dentry); 435 436 if (unlikely(ret)) 436 437 return ret; 437 438 ··· 484 481 485 482 static int bch2_unlink(struct inode *vdir, struct dentry *dentry) 486 483 { 487 - return __bch2_unlink(vdir, dentry, false); 484 + struct bch_inode_info *dir= to_bch_ei(vdir); 485 + struct bch_fs *c = dir->v.i_sb->s_fs_info; 486 + 487 + return bch2_subvol_is_ro(c, dir->ei_subvol) ?: 488 + __bch2_unlink(vdir, dentry, false); 488 489 } 489 490 490 491 static int bch2_symlink(struct mnt_idmap *idmap, ··· 568 561 dst_dir, 569 562 src_inode, 570 563 dst_inode); 564 + 565 + ret = bch2_subvol_is_ro_trans(trans, src_dir->ei_subvol) ?: 566 + bch2_subvol_is_ro_trans(trans, dst_dir->ei_subvol); 567 + if (ret) 568 + goto err; 571 569 572 570 if (inode_attr_changing(dst_dir, src_inode, Inode_opt_project)) { 573 571 ret = bch2_fs_quota_transfer(c, src_inode, ··· 795 783 struct dentry *dentry, struct iattr *iattr) 796 784 { 797 785 struct bch_inode_info *inode = to_bch_ei(dentry->d_inode); 786 + struct bch_fs *c = inode->v.i_sb->s_fs_info; 798 787 int ret; 799 788 800 789 lockdep_assert_held(&inode->v.i_rwsem); 801 790 802 - ret = setattr_prepare(idmap, dentry, iattr); 791 + ret = bch2_subvol_is_ro(c, inode->ei_subvol) ?: 792 + setattr_prepare(idmap, dentry, iattr); 803 793 if (ret) 804 794 return ret; 805 795 ··· 1024 1010 return bch2_err_class(ret); 1025 1011 } 1026 1012 1013 + static int bch2_open(struct inode *vinode, struct file *file) 1014 + { 1015 + if (file->f_flags & (O_WRONLY|O_RDWR)) { 1016 + struct bch_inode_info *inode = to_bch_ei(vinode); 1017 + struct bch_fs *c = inode->v.i_sb->s_fs_info; 1018 + 1019 + int ret = bch2_subvol_is_ro(c, inode->ei_subvol); 1020 + if (ret) 1021 + return ret; 1022 + } 1023 + 1024 + return generic_file_open(vinode, file); 1025 + } 1026 + 1027 1027 static const struct file_operations bch_file_operations = { 1028 + .open = bch2_open, 1028 1029 .llseek = bch2_llseek, 1029 1030 .read_iter = bch2_read_iter, 1030 1031 .write_iter = bch2_write_iter, 1031 1032 .mmap = bch2_mmap, 1032 - .open = generic_file_open, 1033 1033 .fsync = bch2_fsync, 1034 1034 .splice_read = filemap_splice_read, 1035 1035 .splice_write = iter_file_splice_write,
+41 -41
fs/bcachefs/io_write.c
··· 1216 1216 bch2_write_done(cl); 1217 1217 } 1218 1218 1219 + struct bucket_to_lock { 1220 + struct bpos b; 1221 + unsigned gen; 1222 + struct nocow_lock_bucket *l; 1223 + }; 1224 + 1219 1225 static void bch2_nocow_write(struct bch_write_op *op) 1220 1226 { 1221 1227 struct bch_fs *c = op->c; ··· 1230 1224 struct bkey_s_c k; 1231 1225 struct bkey_ptrs_c ptrs; 1232 1226 const struct bch_extent_ptr *ptr; 1233 - struct { 1234 - struct bpos b; 1235 - unsigned gen; 1236 - struct nocow_lock_bucket *l; 1237 - } buckets[BCH_REPLICAS_MAX]; 1238 - unsigned nr_buckets = 0; 1227 + DARRAY_PREALLOCATED(struct bucket_to_lock, 3) buckets; 1228 + struct bucket_to_lock *i; 1239 1229 u32 snapshot; 1240 - int ret, i; 1230 + struct bucket_to_lock *stale_at; 1231 + int ret; 1241 1232 1242 1233 if (op->flags & BCH_WRITE_MOVE) 1243 1234 return; 1244 1235 1236 + darray_init(&buckets); 1245 1237 trans = bch2_trans_get(c); 1246 1238 retry: 1247 1239 bch2_trans_begin(trans); ··· 1254 1250 while (1) { 1255 1251 struct bio *bio = &op->wbio.bio; 1256 1252 1257 - nr_buckets = 0; 1253 + buckets.nr = 0; 1258 1254 1259 1255 k = bch2_btree_iter_peek_slot(&iter); 1260 1256 ret = bkey_err(k); ··· 1267 1263 break; 1268 1264 1269 1265 if (bch2_keylist_realloc(&op->insert_keys, 1270 - op->inline_keys, 1271 - ARRAY_SIZE(op->inline_keys), 1272 - k.k->u64s)) 1266 + op->inline_keys, 1267 + ARRAY_SIZE(op->inline_keys), 1268 + k.k->u64s)) 1273 1269 break; 1274 1270 1275 1271 /* Get iorefs before dropping btree locks: */ 1276 1272 ptrs = bch2_bkey_ptrs_c(k); 1277 1273 bkey_for_each_ptr(ptrs, ptr) { 1278 - buckets[nr_buckets].b = PTR_BUCKET_POS(c, ptr); 1279 - buckets[nr_buckets].gen = ptr->gen; 1280 - buckets[nr_buckets].l = 1281 - bucket_nocow_lock(&c->nocow_locks, 1282 - bucket_to_u64(buckets[nr_buckets].b)); 1283 - 1284 - prefetch(buckets[nr_buckets].l); 1274 + struct bpos b = PTR_BUCKET_POS(c, ptr); 1275 + struct nocow_lock_bucket *l = 1276 + bucket_nocow_lock(&c->nocow_locks, bucket_to_u64(b)); 1277 + prefetch(l); 1285 1278 1286 1279 if (unlikely(!bch2_dev_get_ioref(bch_dev_bkey_exists(c, ptr->dev), WRITE))) 1287 1280 goto err_get_ioref; 1288 1281 1289 - nr_buckets++; 1282 + /* XXX allocating memory with btree locks held - rare */ 1283 + darray_push_gfp(&buckets, ((struct bucket_to_lock) { 1284 + .b = b, .gen = ptr->gen, .l = l, 1285 + }), GFP_KERNEL|__GFP_NOFAIL); 1290 1286 1291 1287 if (ptr->unwritten) 1292 1288 op->flags |= BCH_WRITE_CONVERT_UNWRITTEN; ··· 1300 1296 if (op->flags & BCH_WRITE_CONVERT_UNWRITTEN) 1301 1297 bch2_cut_back(POS(op->pos.inode, op->pos.offset + bio_sectors(bio)), op->insert_keys.top); 1302 1298 1303 - for (i = 0; i < nr_buckets; i++) { 1304 - struct bch_dev *ca = bch_dev_bkey_exists(c, buckets[i].b.inode); 1305 - struct nocow_lock_bucket *l = buckets[i].l; 1306 - bool stale; 1299 + darray_for_each(buckets, i) { 1300 + struct bch_dev *ca = bch_dev_bkey_exists(c, i->b.inode); 1307 1301 1308 - __bch2_bucket_nocow_lock(&c->nocow_locks, l, 1309 - bucket_to_u64(buckets[i].b), 1302 + __bch2_bucket_nocow_lock(&c->nocow_locks, i->l, 1303 + bucket_to_u64(i->b), 1310 1304 BUCKET_NOCOW_LOCK_UPDATE); 1311 1305 1312 1306 rcu_read_lock(); 1313 - stale = gen_after(*bucket_gen(ca, buckets[i].b.offset), buckets[i].gen); 1307 + bool stale = gen_after(*bucket_gen(ca, i->b.offset), i->gen); 1314 1308 rcu_read_unlock(); 1315 1309 1316 - if (unlikely(stale)) 1310 + if (unlikely(stale)) { 1311 + stale_at = i; 1317 1312 goto err_bucket_stale; 1313 + } 1318 1314 } 1319 1315 1320 1316 bio = &op->wbio.bio; ··· 1350 1346 1351 1347 if (ret) { 1352 1348 bch_err_inum_offset_ratelimited(c, 1353 - op->pos.inode, 1354 - op->pos.offset << 9, 1355 - "%s: btree lookup error %s", 1356 - __func__, bch2_err_str(ret)); 1349 + op->pos.inode, op->pos.offset << 9, 1350 + "%s: btree lookup error %s", __func__, bch2_err_str(ret)); 1357 1351 op->error = ret; 1358 1352 op->flags |= BCH_WRITE_DONE; 1359 1353 } 1360 1354 1361 1355 bch2_trans_put(trans); 1356 + darray_exit(&buckets); 1362 1357 1363 1358 /* fallback to cow write path? */ 1364 1359 if (!(op->flags & BCH_WRITE_DONE)) { ··· 1377 1374 } 1378 1375 return; 1379 1376 err_get_ioref: 1380 - for (i = 0; i < nr_buckets; i++) 1381 - percpu_ref_put(&bch_dev_bkey_exists(c, buckets[i].b.inode)->io_ref); 1377 + darray_for_each(buckets, i) 1378 + percpu_ref_put(&bch_dev_bkey_exists(c, i->b.inode)->io_ref); 1382 1379 1383 1380 /* Fall back to COW path: */ 1384 1381 goto out; 1385 1382 err_bucket_stale: 1386 - while (i >= 0) { 1387 - bch2_bucket_nocow_unlock(&c->nocow_locks, 1388 - buckets[i].b, 1389 - BUCKET_NOCOW_LOCK_UPDATE); 1390 - --i; 1383 + darray_for_each(buckets, i) { 1384 + bch2_bucket_nocow_unlock(&c->nocow_locks, i->b, BUCKET_NOCOW_LOCK_UPDATE); 1385 + if (i == stale_at) 1386 + break; 1391 1387 } 1392 - for (i = 0; i < nr_buckets; i++) 1393 - percpu_ref_put(&bch_dev_bkey_exists(c, buckets[i].b.inode)->io_ref); 1394 1388 1395 1389 /* We can retry this: */ 1396 1390 ret = -BCH_ERR_transaction_restart; 1397 - goto out; 1391 + goto err_get_ioref; 1398 1392 } 1399 1393 1400 1394 static void __bch2_write(struct bch_write_op *op)
+4 -2
fs/bcachefs/journal_io.c
··· 408 408 return 0; 409 409 } 410 410 411 - return journal_validate_key(c, jset, entry, 1, entry->btree_id, k, 412 - version, big_endian, flags); 411 + ret = journal_validate_key(c, jset, entry, 1, entry->btree_id, k, 412 + version, big_endian, flags); 413 + if (ret == FSCK_DELETED_KEY) 414 + ret = 0; 413 415 fsck_err: 414 416 return ret; 415 417 }
+22
fs/bcachefs/printbuf.c
··· 1 1 // SPDX-License-Identifier: LGPL-2.1+ 2 2 /* Copyright (C) 2022 Kent Overstreet */ 3 3 4 + #include <linux/bitmap.h> 4 5 #include <linux/err.h> 5 6 #include <linux/export.h> 6 7 #include <linux/kernel.h> ··· 422 421 first = false; 423 422 bch2_prt_printf(out, "%s", list[bit]); 424 423 flags ^= BIT_ULL(bit); 424 + } 425 + } 426 + 427 + void bch2_prt_bitflags_vector(struct printbuf *out, 428 + const char * const list[], 429 + unsigned long *v, unsigned nr) 430 + { 431 + bool first = true; 432 + unsigned i; 433 + 434 + for (i = 0; i < nr; i++) 435 + if (!list[i]) { 436 + nr = i - 1; 437 + break; 438 + } 439 + 440 + for_each_set_bit(i, v, nr) { 441 + if (!first) 442 + bch2_prt_printf(out, ","); 443 + first = false; 444 + bch2_prt_printf(out, "%s", list[i]); 425 445 } 426 446 }
+2
fs/bcachefs/printbuf.h
··· 124 124 void bch2_prt_units_s64(struct printbuf *, s64); 125 125 void bch2_prt_string_option(struct printbuf *, const char * const[], size_t); 126 126 void bch2_prt_bitflags(struct printbuf *, const char * const[], u64); 127 + void bch2_prt_bitflags_vector(struct printbuf *, const char * const[], 128 + unsigned long *, unsigned); 127 129 128 130 /* Initializer for a heap allocated printbuf: */ 129 131 #define PRINTBUF ((struct printbuf) { .heap_allocated = true })
+118 -21
fs/bcachefs/recovery.c
··· 27 27 #include "recovery.h" 28 28 #include "replicas.h" 29 29 #include "sb-clean.h" 30 + #include "sb-downgrade.h" 30 31 #include "snapshot.h" 31 32 #include "subvolume.h" 32 33 #include "super-io.h" ··· 482 481 } 483 482 484 483 const char * const bch2_recovery_passes[] = { 485 - #define x(_fn, _when) #_fn, 484 + #define x(_fn, ...) #_fn, 486 485 BCH_RECOVERY_PASSES() 487 486 #undef x 488 487 NULL ··· 505 504 }; 506 505 507 506 static struct recovery_pass_fn recovery_pass_fns[] = { 508 - #define x(_fn, _when) { .fn = bch2_##_fn, .when = _when }, 507 + #define x(_fn, _id, _when) { .fn = bch2_##_fn, .when = _when }, 509 508 BCH_RECOVERY_PASSES() 510 509 #undef x 511 510 }; 512 511 513 - static void check_version_upgrade(struct bch_fs *c) 512 + u64 bch2_recovery_passes_to_stable(u64 v) 513 + { 514 + static const u8 map[] = { 515 + #define x(n, id, ...) [BCH_RECOVERY_PASS_##n] = BCH_RECOVERY_PASS_STABLE_##n, 516 + BCH_RECOVERY_PASSES() 517 + #undef x 518 + }; 519 + 520 + u64 ret = 0; 521 + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) 522 + if (v & BIT_ULL(i)) 523 + ret |= BIT_ULL(map[i]); 524 + return ret; 525 + } 526 + 527 + u64 bch2_recovery_passes_from_stable(u64 v) 528 + { 529 + static const u8 map[] = { 530 + #define x(n, id, ...) [BCH_RECOVERY_PASS_STABLE_##n] = BCH_RECOVERY_PASS_##n, 531 + BCH_RECOVERY_PASSES() 532 + #undef x 533 + }; 534 + 535 + u64 ret = 0; 536 + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) 537 + if (v & BIT_ULL(i)) 538 + ret |= BIT_ULL(map[i]); 539 + return ret; 540 + } 541 + 542 + static bool check_version_upgrade(struct bch_fs *c) 514 543 { 515 544 unsigned latest_compatible = bch2_latest_compatible_version(c->sb.version); 516 545 unsigned latest_version = bcachefs_metadata_version_current; 517 546 unsigned old_version = c->sb.version_upgrade_complete ?: c->sb.version; 518 547 unsigned new_version = 0; 519 - u64 recovery_passes; 520 548 521 549 if (old_version < bcachefs_metadata_required_upgrade_below) { 522 550 if (c->opts.version_upgrade == BCH_VERSION_UPGRADE_incompatible || ··· 589 559 bch2_version_to_text(&buf, new_version); 590 560 prt_newline(&buf); 591 561 592 - recovery_passes = bch2_upgrade_recovery_passes(c, old_version, new_version); 562 + u64 recovery_passes = bch2_upgrade_recovery_passes(c, old_version, new_version); 593 563 if (recovery_passes) { 594 564 if ((recovery_passes & RECOVERY_PASS_ALL_FSCK) == RECOVERY_PASS_ALL_FSCK) 595 565 prt_str(&buf, "fsck required"); ··· 604 574 605 575 bch_info(c, "%s", buf.buf); 606 576 607 - mutex_lock(&c->sb_lock); 608 577 bch2_sb_upgrade(c, new_version); 609 - mutex_unlock(&c->sb_lock); 610 578 611 579 printbuf_exit(&buf); 580 + return true; 612 581 } 582 + 583 + return false; 613 584 } 614 585 615 586 u64 bch2_fsck_recovery_passes(void) ··· 685 654 struct bch_sb_field_clean *clean = NULL; 686 655 struct jset *last_journal_entry = NULL; 687 656 u64 last_seq = 0, blacklist_seq, journal_seq; 688 - bool write_sb = false; 689 657 int ret = 0; 690 658 691 659 if (c->sb.clean) { ··· 712 682 goto err; 713 683 } 714 684 715 - if (c->opts.fsck || !(c->opts.nochanges && c->opts.norecovery)) 716 - check_version_upgrade(c); 717 - 718 685 if (c->opts.fsck && c->opts.norecovery) { 719 686 bch_err(c, "cannot select both norecovery and fsck"); 720 687 ret = -EINVAL; 721 688 goto err; 722 689 } 690 + 691 + if (!(c->opts.nochanges && c->opts.norecovery)) { 692 + mutex_lock(&c->sb_lock); 693 + bool write_sb = false; 694 + 695 + struct bch_sb_field_ext *ext = 696 + bch2_sb_field_get_minsize(&c->disk_sb, ext, sizeof(*ext) / sizeof(u64)); 697 + if (!ext) { 698 + ret = -BCH_ERR_ENOSPC_sb; 699 + mutex_unlock(&c->sb_lock); 700 + goto err; 701 + } 702 + 703 + if (BCH_SB_HAS_TOPOLOGY_ERRORS(c->disk_sb.sb)) { 704 + ext->recovery_passes_required[0] |= 705 + cpu_to_le64(bch2_recovery_passes_to_stable(BIT_ULL(BCH_RECOVERY_PASS_check_topology))); 706 + write_sb = true; 707 + } 708 + 709 + u64 sb_passes = bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_required[0])); 710 + if (sb_passes) { 711 + struct printbuf buf = PRINTBUF; 712 + prt_str(&buf, "superblock requires following recovery passes to be run:\n "); 713 + prt_bitflags(&buf, bch2_recovery_passes, sb_passes); 714 + bch_info(c, "%s", buf.buf); 715 + printbuf_exit(&buf); 716 + } 717 + 718 + if (bch2_check_version_downgrade(c)) { 719 + struct printbuf buf = PRINTBUF; 720 + 721 + prt_str(&buf, "Version downgrade required:\n"); 722 + 723 + __le64 passes = ext->recovery_passes_required[0]; 724 + bch2_sb_set_downgrade(c, 725 + BCH_VERSION_MINOR(bcachefs_metadata_version_current), 726 + BCH_VERSION_MINOR(c->sb.version)); 727 + passes = ext->recovery_passes_required[0] & ~passes; 728 + if (passes) { 729 + prt_str(&buf, " running recovery passes: "); 730 + prt_bitflags(&buf, bch2_recovery_passes, 731 + bch2_recovery_passes_from_stable(le64_to_cpu(passes))); 732 + } 733 + 734 + bch_info(c, "%s", buf.buf); 735 + printbuf_exit(&buf); 736 + write_sb = true; 737 + } 738 + 739 + if (check_version_upgrade(c)) 740 + write_sb = true; 741 + 742 + if (write_sb) 743 + bch2_write_super(c); 744 + 745 + c->recovery_passes_explicit |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_required[0])); 746 + mutex_unlock(&c->sb_lock); 747 + } 748 + 749 + if (c->opts.fsck && IS_ENABLED(CONFIG_BCACHEFS_DEBUG)) 750 + c->recovery_passes_explicit |= BIT_ULL(BCH_RECOVERY_PASS_check_topology); 723 751 724 752 ret = bch2_blacklist_table_initialize(c); 725 753 if (ret) { ··· 915 827 if (ret) 916 828 goto err; 917 829 918 - if (c->opts.fsck && 919 - (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) || 920 - BCH_SB_HAS_TOPOLOGY_ERRORS(c->disk_sb.sb))) 921 - c->recovery_passes_explicit |= BIT_ULL(BCH_RECOVERY_PASS_check_topology); 922 - 923 830 ret = bch2_run_recovery_passes(c); 924 831 if (ret) 925 832 goto err; ··· 951 868 } 952 869 953 870 mutex_lock(&c->sb_lock); 954 - if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) != c->sb.version) { 955 - SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, c->sb.version); 871 + bool write_sb = false; 872 + 873 + if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) != le16_to_cpu(c->disk_sb.sb->version)) { 874 + SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, le16_to_cpu(c->disk_sb.sb->version)); 875 + write_sb = true; 876 + } 877 + 878 + if (!test_bit(BCH_FS_ERROR, &c->flags) && 879 + !(c->disk_sb.sb->compat[0] & cpu_to_le64(1ULL << BCH_COMPAT_alloc_info))) { 880 + c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_alloc_info); 956 881 write_sb = true; 957 882 } 958 883 959 884 if (!test_bit(BCH_FS_ERROR, &c->flags)) { 960 - c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_alloc_info); 961 - write_sb = true; 885 + struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext); 886 + if (ext && 887 + (!bch2_is_zero(ext->recovery_passes_required, sizeof(ext->recovery_passes_required)) || 888 + !bch2_is_zero(ext->errors_silent, sizeof(ext->errors_silent)))) { 889 + memset(ext->recovery_passes_required, 0, sizeof(ext->recovery_passes_required)); 890 + memset(ext->errors_silent, 0, sizeof(ext->errors_silent)); 891 + write_sb = true; 892 + } 962 893 } 963 894 964 895 if (c->opts.fsck && ··· 1044 947 c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_extents_above_btree_updates_done); 1045 948 c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_bformat_overflow_done); 1046 949 1047 - bch2_sb_maybe_downgrade(c); 950 + bch2_check_version_downgrade(c); 1048 951 1049 952 if (c->opts.version_upgrade != BCH_VERSION_UPGRADE_none) { 1050 953 bch2_sb_upgrade(c, bcachefs_metadata_version_current);
+3
fs/bcachefs/recovery.h
··· 4 4 5 5 extern const char * const bch2_recovery_passes[]; 6 6 7 + u64 bch2_recovery_passes_to_stable(u64 v); 8 + u64 bch2_recovery_passes_from_stable(u64 v); 9 + 7 10 /* 8 11 * For when we need to rewind recovery passes and run a pass we skipped: 9 12 */
+49 -37
fs/bcachefs/recovery_types.h
··· 7 7 #define PASS_UNCLEAN BIT(2) 8 8 #define PASS_ALWAYS BIT(3) 9 9 10 - #define BCH_RECOVERY_PASSES() \ 11 - x(alloc_read, PASS_ALWAYS) \ 12 - x(stripes_read, PASS_ALWAYS) \ 13 - x(initialize_subvolumes, 0) \ 14 - x(snapshots_read, PASS_ALWAYS) \ 15 - x(check_topology, 0) \ 16 - x(check_allocations, PASS_FSCK) \ 17 - x(trans_mark_dev_sbs, PASS_ALWAYS|PASS_SILENT) \ 18 - x(fs_journal_alloc, PASS_ALWAYS|PASS_SILENT) \ 19 - x(set_may_go_rw, PASS_ALWAYS|PASS_SILENT) \ 20 - x(journal_replay, PASS_ALWAYS) \ 21 - x(check_alloc_info, PASS_FSCK) \ 22 - x(check_lrus, PASS_FSCK) \ 23 - x(check_btree_backpointers, PASS_FSCK) \ 24 - x(check_backpointers_to_extents,PASS_FSCK) \ 25 - x(check_extents_to_backpointers,PASS_FSCK) \ 26 - x(check_alloc_to_lru_refs, PASS_FSCK) \ 27 - x(fs_freespace_init, PASS_ALWAYS|PASS_SILENT) \ 28 - x(bucket_gens_init, 0) \ 29 - x(check_snapshot_trees, PASS_FSCK) \ 30 - x(check_snapshots, PASS_FSCK) \ 31 - x(check_subvols, PASS_FSCK) \ 32 - x(delete_dead_snapshots, PASS_FSCK) \ 33 - x(fs_upgrade_for_subvolumes, 0) \ 34 - x(resume_logged_ops, PASS_ALWAYS) \ 35 - x(check_inodes, PASS_FSCK) \ 36 - x(check_extents, PASS_FSCK) \ 37 - x(check_indirect_extents, PASS_FSCK) \ 38 - x(check_dirents, PASS_FSCK) \ 39 - x(check_xattrs, PASS_FSCK) \ 40 - x(check_root, PASS_FSCK) \ 41 - x(check_directory_structure, PASS_FSCK) \ 42 - x(check_nlinks, PASS_FSCK) \ 43 - x(delete_dead_inodes, PASS_FSCK|PASS_UNCLEAN) \ 44 - x(fix_reflink_p, 0) \ 45 - x(set_fs_needs_rebalance, 0) \ 10 + /* 11 + * Passes may be reordered, but the second field is a persistent identifier and 12 + * must never change: 13 + */ 14 + #define BCH_RECOVERY_PASSES() \ 15 + x(alloc_read, 0, PASS_ALWAYS) \ 16 + x(stripes_read, 1, PASS_ALWAYS) \ 17 + x(initialize_subvolumes, 2, 0) \ 18 + x(snapshots_read, 3, PASS_ALWAYS) \ 19 + x(check_topology, 4, 0) \ 20 + x(check_allocations, 5, PASS_FSCK) \ 21 + x(trans_mark_dev_sbs, 6, PASS_ALWAYS|PASS_SILENT) \ 22 + x(fs_journal_alloc, 7, PASS_ALWAYS|PASS_SILENT) \ 23 + x(set_may_go_rw, 8, PASS_ALWAYS|PASS_SILENT) \ 24 + x(journal_replay, 9, PASS_ALWAYS) \ 25 + x(check_alloc_info, 10, PASS_FSCK) \ 26 + x(check_lrus, 11, PASS_FSCK) \ 27 + x(check_btree_backpointers, 12, PASS_FSCK) \ 28 + x(check_backpointers_to_extents, 13, PASS_FSCK) \ 29 + x(check_extents_to_backpointers, 14, PASS_FSCK) \ 30 + x(check_alloc_to_lru_refs, 15, PASS_FSCK) \ 31 + x(fs_freespace_init, 16, PASS_ALWAYS|PASS_SILENT) \ 32 + x(bucket_gens_init, 17, 0) \ 33 + x(check_snapshot_trees, 18, PASS_FSCK) \ 34 + x(check_snapshots, 19, PASS_FSCK) \ 35 + x(check_subvols, 20, PASS_FSCK) \ 36 + x(delete_dead_snapshots, 21, PASS_FSCK) \ 37 + x(fs_upgrade_for_subvolumes, 22, 0) \ 38 + x(resume_logged_ops, 23, PASS_ALWAYS) \ 39 + x(check_inodes, 24, PASS_FSCK) \ 40 + x(check_extents, 25, PASS_FSCK) \ 41 + x(check_indirect_extents, 26, PASS_FSCK) \ 42 + x(check_dirents, 27, PASS_FSCK) \ 43 + x(check_xattrs, 28, PASS_FSCK) \ 44 + x(check_root, 29, PASS_FSCK) \ 45 + x(check_directory_structure, 30, PASS_FSCK) \ 46 + x(check_nlinks, 31, PASS_FSCK) \ 47 + x(delete_dead_inodes, 32, PASS_FSCK|PASS_UNCLEAN) \ 48 + x(fix_reflink_p, 33, 0) \ 49 + x(set_fs_needs_rebalance, 34, 0) \ 46 50 51 + /* We normally enumerate recovery passes in the order we run them: */ 47 52 enum bch_recovery_pass { 48 - #define x(n, when) BCH_RECOVERY_PASS_##n, 53 + #define x(n, id, when) BCH_RECOVERY_PASS_##n, 54 + BCH_RECOVERY_PASSES() 55 + #undef x 56 + }; 57 + 58 + /* But we also need stable identifiers that can be used in the superblock */ 59 + enum bch_recovery_pass_stable { 60 + #define x(n, id, when) BCH_RECOVERY_PASS_STABLE_##n = id, 49 61 BCH_RECOVERY_PASSES() 50 62 #undef x 51 63 };
-2
fs/bcachefs/sb-clean.c
··· 332 332 333 333 mutex_lock(&c->sb_lock); 334 334 SET_BCH_SB_CLEAN(c->disk_sb.sb, false); 335 - 336 - bch2_sb_maybe_downgrade(c); 337 335 c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALWAYS); 338 336 339 337 ret = bch2_write_super(c);
+188
fs/bcachefs/sb-downgrade.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * Superblock section that contains a list of recovery passes to run when 5 + * downgrading past a given version 6 + */ 7 + 8 + #include "bcachefs.h" 9 + #include "darray.h" 10 + #include "recovery.h" 11 + #include "sb-downgrade.h" 12 + #include "sb-errors.h" 13 + #include "super-io.h" 14 + 15 + /* 16 + * Downgrade table: 17 + * When dowgrading past certain versions, we need to run certain recovery passes 18 + * and fix certain errors: 19 + * 20 + * x(version, recovery_passes, errors...) 21 + */ 22 + 23 + #define DOWNGRADE_TABLE() 24 + 25 + struct downgrade_entry { 26 + u64 recovery_passes; 27 + u16 version; 28 + u16 nr_errors; 29 + const u16 *errors; 30 + }; 31 + 32 + #define x(ver, passes, ...) static const u16 ver_##errors[] = { __VA_ARGS__ }; 33 + DOWNGRADE_TABLE() 34 + #undef x 35 + 36 + static const struct downgrade_entry downgrade_table[] = { 37 + #define x(ver, passes, ...) { \ 38 + .recovery_passes = passes, \ 39 + .version = bcachefs_metadata_version_##ver,\ 40 + .nr_errors = ARRAY_SIZE(ver_##errors), \ 41 + .errors = ver_##errors, \ 42 + }, 43 + DOWNGRADE_TABLE() 44 + #undef x 45 + }; 46 + 47 + static inline const struct bch_sb_field_downgrade_entry * 48 + downgrade_entry_next_c(const struct bch_sb_field_downgrade_entry *e) 49 + { 50 + return (void *) &e->errors[le16_to_cpu(e->nr_errors)]; 51 + } 52 + 53 + #define for_each_downgrade_entry(_d, _i) \ 54 + for (const struct bch_sb_field_downgrade_entry *_i = (_d)->entries; \ 55 + (void *) _i < vstruct_end(&(_d)->field) && \ 56 + (void *) &_i->errors[0] < vstruct_end(&(_d)->field); \ 57 + _i = downgrade_entry_next_c(_i)) 58 + 59 + static int bch2_sb_downgrade_validate(struct bch_sb *sb, struct bch_sb_field *f, 60 + struct printbuf *err) 61 + { 62 + struct bch_sb_field_downgrade *e = field_to_type(f, downgrade); 63 + 64 + for_each_downgrade_entry(e, i) { 65 + if (BCH_VERSION_MAJOR(le16_to_cpu(i->version)) != 66 + BCH_VERSION_MAJOR(le16_to_cpu(sb->version))) { 67 + prt_printf(err, "downgrade entry with mismatched major version (%u != %u)", 68 + BCH_VERSION_MAJOR(le16_to_cpu(i->version)), 69 + BCH_VERSION_MAJOR(le16_to_cpu(sb->version))); 70 + return -BCH_ERR_invalid_sb_downgrade; 71 + } 72 + } 73 + 74 + return 0; 75 + } 76 + 77 + static void bch2_sb_downgrade_to_text(struct printbuf *out, struct bch_sb *sb, 78 + struct bch_sb_field *f) 79 + { 80 + struct bch_sb_field_downgrade *e = field_to_type(f, downgrade); 81 + 82 + if (out->nr_tabstops <= 1) 83 + printbuf_tabstop_push(out, 16); 84 + 85 + for_each_downgrade_entry(e, i) { 86 + prt_str(out, "version:"); 87 + prt_tab(out); 88 + bch2_version_to_text(out, le16_to_cpu(i->version)); 89 + prt_newline(out); 90 + 91 + prt_str(out, "recovery passes:"); 92 + prt_tab(out); 93 + prt_bitflags(out, bch2_recovery_passes, 94 + bch2_recovery_passes_from_stable(le64_to_cpu(i->recovery_passes[0]))); 95 + prt_newline(out); 96 + 97 + prt_str(out, "errors:"); 98 + prt_tab(out); 99 + bool first = true; 100 + for (unsigned j = 0; j < le16_to_cpu(i->nr_errors); j++) { 101 + if (!first) 102 + prt_char(out, ','); 103 + first = false; 104 + unsigned e = le16_to_cpu(i->errors[j]); 105 + prt_str(out, e < BCH_SB_ERR_MAX ? bch2_sb_error_strs[e] : "(unknown)"); 106 + } 107 + prt_newline(out); 108 + } 109 + } 110 + 111 + const struct bch_sb_field_ops bch_sb_field_ops_downgrade = { 112 + .validate = bch2_sb_downgrade_validate, 113 + .to_text = bch2_sb_downgrade_to_text, 114 + }; 115 + 116 + int bch2_sb_downgrade_update(struct bch_fs *c) 117 + { 118 + darray_char table = {}; 119 + int ret = 0; 120 + 121 + for (const struct downgrade_entry *src = downgrade_table; 122 + src < downgrade_table + ARRAY_SIZE(downgrade_table); 123 + src++) { 124 + if (BCH_VERSION_MAJOR(src->version) != BCH_VERSION_MAJOR(le16_to_cpu(c->disk_sb.sb->version))) 125 + continue; 126 + 127 + struct bch_sb_field_downgrade_entry *dst; 128 + unsigned bytes = sizeof(*dst) + sizeof(dst->errors[0]) * src->nr_errors; 129 + 130 + ret = darray_make_room(&table, bytes); 131 + if (ret) 132 + goto out; 133 + 134 + dst = (void *) &darray_top(table); 135 + dst->version = cpu_to_le16(src->version); 136 + dst->recovery_passes[0] = cpu_to_le64(src->recovery_passes); 137 + dst->recovery_passes[1] = 0; 138 + dst->nr_errors = cpu_to_le16(src->nr_errors); 139 + for (unsigned i = 0; i < src->nr_errors; i++) 140 + dst->errors[i] = cpu_to_le16(src->errors[i]); 141 + 142 + table.nr += bytes; 143 + } 144 + 145 + struct bch_sb_field_downgrade *d = bch2_sb_field_get(c->disk_sb.sb, downgrade); 146 + 147 + unsigned sb_u64s = DIV_ROUND_UP(sizeof(*d) + table.nr, sizeof(u64)); 148 + 149 + if (d && le32_to_cpu(d->field.u64s) > sb_u64s) 150 + goto out; 151 + 152 + d = bch2_sb_field_resize(&c->disk_sb, downgrade, sb_u64s); 153 + if (!d) { 154 + ret = -BCH_ERR_ENOSPC_sb_downgrade; 155 + goto out; 156 + } 157 + 158 + memcpy(d->entries, table.data, table.nr); 159 + memset_u64s_tail(d->entries, 0, table.nr); 160 + out: 161 + darray_exit(&table); 162 + return ret; 163 + } 164 + 165 + void bch2_sb_set_downgrade(struct bch_fs *c, unsigned new_minor, unsigned old_minor) 166 + { 167 + struct bch_sb_field_downgrade *d = bch2_sb_field_get(c->disk_sb.sb, downgrade); 168 + if (!d) 169 + return; 170 + 171 + struct bch_sb_field_ext *ext = bch2_sb_field_get(c->disk_sb.sb, ext); 172 + 173 + for_each_downgrade_entry(d, i) { 174 + unsigned minor = BCH_VERSION_MINOR(le16_to_cpu(i->version)); 175 + if (new_minor < minor && minor <= old_minor) { 176 + ext->recovery_passes_required[0] |= i->recovery_passes[0]; 177 + ext->recovery_passes_required[1] |= i->recovery_passes[1]; 178 + 179 + for (unsigned j = 0; j < le16_to_cpu(i->nr_errors); j++) { 180 + unsigned e = le16_to_cpu(i->errors[j]); 181 + if (e < BCH_SB_ERR_MAX) 182 + __set_bit(e, c->sb.errors_silent); 183 + if (e < sizeof(ext->errors_silent) * 8) 184 + ext->errors_silent[e / 64] |= cpu_to_le64(BIT_ULL(e % 64)); 185 + } 186 + } 187 + } 188 + }
+10
fs/bcachefs/sb-downgrade.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _BCACHEFS_SB_DOWNGRADE_H 3 + #define _BCACHEFS_SB_DOWNGRADE_H 4 + 5 + extern const struct bch_sb_field_ops bch_sb_field_ops_downgrade; 6 + 7 + int bch2_sb_downgrade_update(struct bch_fs *); 8 + void bch2_sb_set_downgrade(struct bch_fs *, unsigned, unsigned); 9 + 10 + #endif /* _BCACHEFS_SB_DOWNGRADE_H */
+2 -4
fs/bcachefs/sb-errors.c
··· 4 4 #include "sb-errors.h" 5 5 #include "super-io.h" 6 6 7 - static const char * const bch2_sb_error_strs[] = { 7 + const char * const bch2_sb_error_strs[] = { 8 8 #define x(t, n, ...) [n] = #t, 9 9 BCH_SB_ERRS() 10 10 NULL ··· 20 20 21 21 static inline unsigned bch2_sb_field_errors_nr_entries(struct bch_sb_field_errors *e) 22 22 { 23 - return e 24 - ? (bch2_sb_field_bytes(&e->field) - sizeof(*e)) / sizeof(e->entries[0]) 25 - : 0; 23 + return bch2_sb_field_nr_entries(e); 26 24 } 27 25 28 26 static inline unsigned bch2_sb_field_errors_u64s(unsigned nr)
+1 -252
fs/bcachefs/sb-errors.h
··· 4 4 5 5 #include "sb-errors_types.h" 6 6 7 - #define BCH_SB_ERRS() \ 8 - x(clean_but_journal_not_empty, 0) \ 9 - x(dirty_but_no_journal_entries, 1) \ 10 - x(dirty_but_no_journal_entries_post_drop_nonflushes, 2) \ 11 - x(sb_clean_journal_seq_mismatch, 3) \ 12 - x(sb_clean_btree_root_mismatch, 4) \ 13 - x(sb_clean_missing, 5) \ 14 - x(jset_unsupported_version, 6) \ 15 - x(jset_unknown_csum, 7) \ 16 - x(jset_last_seq_newer_than_seq, 8) \ 17 - x(jset_past_bucket_end, 9) \ 18 - x(jset_seq_blacklisted, 10) \ 19 - x(journal_entries_missing, 11) \ 20 - x(journal_entry_replicas_not_marked, 12) \ 21 - x(journal_entry_past_jset_end, 13) \ 22 - x(journal_entry_replicas_data_mismatch, 14) \ 23 - x(journal_entry_bkey_u64s_0, 15) \ 24 - x(journal_entry_bkey_past_end, 16) \ 25 - x(journal_entry_bkey_bad_format, 17) \ 26 - x(journal_entry_bkey_invalid, 18) \ 27 - x(journal_entry_btree_root_bad_size, 19) \ 28 - x(journal_entry_blacklist_bad_size, 20) \ 29 - x(journal_entry_blacklist_v2_bad_size, 21) \ 30 - x(journal_entry_blacklist_v2_start_past_end, 22) \ 31 - x(journal_entry_usage_bad_size, 23) \ 32 - x(journal_entry_data_usage_bad_size, 24) \ 33 - x(journal_entry_clock_bad_size, 25) \ 34 - x(journal_entry_clock_bad_rw, 26) \ 35 - x(journal_entry_dev_usage_bad_size, 27) \ 36 - x(journal_entry_dev_usage_bad_dev, 28) \ 37 - x(journal_entry_dev_usage_bad_pad, 29) \ 38 - x(btree_node_unreadable, 30) \ 39 - x(btree_node_fault_injected, 31) \ 40 - x(btree_node_bad_magic, 32) \ 41 - x(btree_node_bad_seq, 33) \ 42 - x(btree_node_unsupported_version, 34) \ 43 - x(btree_node_bset_older_than_sb_min, 35) \ 44 - x(btree_node_bset_newer_than_sb, 36) \ 45 - x(btree_node_data_missing, 37) \ 46 - x(btree_node_bset_after_end, 38) \ 47 - x(btree_node_replicas_sectors_written_mismatch, 39) \ 48 - x(btree_node_replicas_data_mismatch, 40) \ 49 - x(bset_unknown_csum, 41) \ 50 - x(bset_bad_csum, 42) \ 51 - x(bset_past_end_of_btree_node, 43) \ 52 - x(bset_wrong_sector_offset, 44) \ 53 - x(bset_empty, 45) \ 54 - x(bset_bad_seq, 46) \ 55 - x(bset_blacklisted_journal_seq, 47) \ 56 - x(first_bset_blacklisted_journal_seq, 48) \ 57 - x(btree_node_bad_btree, 49) \ 58 - x(btree_node_bad_level, 50) \ 59 - x(btree_node_bad_min_key, 51) \ 60 - x(btree_node_bad_max_key, 52) \ 61 - x(btree_node_bad_format, 53) \ 62 - x(btree_node_bkey_past_bset_end, 54) \ 63 - x(btree_node_bkey_bad_format, 55) \ 64 - x(btree_node_bad_bkey, 56) \ 65 - x(btree_node_bkey_out_of_order, 57) \ 66 - x(btree_root_bkey_invalid, 58) \ 67 - x(btree_root_read_error, 59) \ 68 - x(btree_root_bad_min_key, 50) \ 69 - x(btree_root_bad_max_key, 61) \ 70 - x(btree_node_read_error, 62) \ 71 - x(btree_node_topology_bad_min_key, 63) \ 72 - x(btree_node_topology_bad_max_key, 64) \ 73 - x(btree_node_topology_overwritten_by_prev_node, 65) \ 74 - x(btree_node_topology_overwritten_by_next_node, 66) \ 75 - x(btree_node_topology_interior_node_empty, 67) \ 76 - x(fs_usage_hidden_wrong, 68) \ 77 - x(fs_usage_btree_wrong, 69) \ 78 - x(fs_usage_data_wrong, 70) \ 79 - x(fs_usage_cached_wrong, 71) \ 80 - x(fs_usage_reserved_wrong, 72) \ 81 - x(fs_usage_persistent_reserved_wrong, 73) \ 82 - x(fs_usage_nr_inodes_wrong, 74) \ 83 - x(fs_usage_replicas_wrong, 75) \ 84 - x(dev_usage_buckets_wrong, 76) \ 85 - x(dev_usage_sectors_wrong, 77) \ 86 - x(dev_usage_fragmented_wrong, 78) \ 87 - x(dev_usage_buckets_ec_wrong, 79) \ 88 - x(bkey_version_in_future, 80) \ 89 - x(bkey_u64s_too_small, 81) \ 90 - x(bkey_invalid_type_for_btree, 82) \ 91 - x(bkey_extent_size_zero, 83) \ 92 - x(bkey_extent_size_greater_than_offset, 84) \ 93 - x(bkey_size_nonzero, 85) \ 94 - x(bkey_snapshot_nonzero, 86) \ 95 - x(bkey_snapshot_zero, 87) \ 96 - x(bkey_at_pos_max, 88) \ 97 - x(bkey_before_start_of_btree_node, 89) \ 98 - x(bkey_after_end_of_btree_node, 90) \ 99 - x(bkey_val_size_nonzero, 91) \ 100 - x(bkey_val_size_too_small, 92) \ 101 - x(alloc_v1_val_size_bad, 93) \ 102 - x(alloc_v2_unpack_error, 94) \ 103 - x(alloc_v3_unpack_error, 95) \ 104 - x(alloc_v4_val_size_bad, 96) \ 105 - x(alloc_v4_backpointers_start_bad, 97) \ 106 - x(alloc_key_data_type_bad, 98) \ 107 - x(alloc_key_empty_but_have_data, 99) \ 108 - x(alloc_key_dirty_sectors_0, 100) \ 109 - x(alloc_key_data_type_inconsistency, 101) \ 110 - x(alloc_key_to_missing_dev_bucket, 102) \ 111 - x(alloc_key_cached_inconsistency, 103) \ 112 - x(alloc_key_cached_but_read_time_zero, 104) \ 113 - x(alloc_key_to_missing_lru_entry, 105) \ 114 - x(alloc_key_data_type_wrong, 106) \ 115 - x(alloc_key_gen_wrong, 107) \ 116 - x(alloc_key_dirty_sectors_wrong, 108) \ 117 - x(alloc_key_cached_sectors_wrong, 109) \ 118 - x(alloc_key_stripe_wrong, 110) \ 119 - x(alloc_key_stripe_redundancy_wrong, 111) \ 120 - x(bucket_sector_count_overflow, 112) \ 121 - x(bucket_metadata_type_mismatch, 113) \ 122 - x(need_discard_key_wrong, 114) \ 123 - x(freespace_key_wrong, 115) \ 124 - x(freespace_hole_missing, 116) \ 125 - x(bucket_gens_val_size_bad, 117) \ 126 - x(bucket_gens_key_wrong, 118) \ 127 - x(bucket_gens_hole_wrong, 119) \ 128 - x(bucket_gens_to_invalid_dev, 120) \ 129 - x(bucket_gens_to_invalid_buckets, 121) \ 130 - x(bucket_gens_nonzero_for_invalid_buckets, 122) \ 131 - x(need_discard_freespace_key_to_invalid_dev_bucket, 123) \ 132 - x(need_discard_freespace_key_bad, 124) \ 133 - x(backpointer_pos_wrong, 125) \ 134 - x(backpointer_to_missing_device, 126) \ 135 - x(backpointer_to_missing_alloc, 127) \ 136 - x(backpointer_to_missing_ptr, 128) \ 137 - x(lru_entry_at_time_0, 129) \ 138 - x(lru_entry_to_invalid_bucket, 130) \ 139 - x(lru_entry_bad, 131) \ 140 - x(btree_ptr_val_too_big, 132) \ 141 - x(btree_ptr_v2_val_too_big, 133) \ 142 - x(btree_ptr_has_non_ptr, 134) \ 143 - x(extent_ptrs_invalid_entry, 135) \ 144 - x(extent_ptrs_no_ptrs, 136) \ 145 - x(extent_ptrs_too_many_ptrs, 137) \ 146 - x(extent_ptrs_redundant_crc, 138) \ 147 - x(extent_ptrs_redundant_stripe, 139) \ 148 - x(extent_ptrs_unwritten, 140) \ 149 - x(extent_ptrs_written_and_unwritten, 141) \ 150 - x(ptr_to_invalid_device, 142) \ 151 - x(ptr_to_duplicate_device, 143) \ 152 - x(ptr_after_last_bucket, 144) \ 153 - x(ptr_before_first_bucket, 145) \ 154 - x(ptr_spans_multiple_buckets, 146) \ 155 - x(ptr_to_missing_backpointer, 147) \ 156 - x(ptr_to_missing_alloc_key, 148) \ 157 - x(ptr_to_missing_replicas_entry, 149) \ 158 - x(ptr_to_missing_stripe, 150) \ 159 - x(ptr_to_incorrect_stripe, 151) \ 160 - x(ptr_gen_newer_than_bucket_gen, 152) \ 161 - x(ptr_too_stale, 153) \ 162 - x(stale_dirty_ptr, 154) \ 163 - x(ptr_bucket_data_type_mismatch, 155) \ 164 - x(ptr_cached_and_erasure_coded, 156) \ 165 - x(ptr_crc_uncompressed_size_too_small, 157) \ 166 - x(ptr_crc_csum_type_unknown, 158) \ 167 - x(ptr_crc_compression_type_unknown, 159) \ 168 - x(ptr_crc_redundant, 160) \ 169 - x(ptr_crc_uncompressed_size_too_big, 161) \ 170 - x(ptr_crc_nonce_mismatch, 162) \ 171 - x(ptr_stripe_redundant, 163) \ 172 - x(reservation_key_nr_replicas_invalid, 164) \ 173 - x(reflink_v_refcount_wrong, 165) \ 174 - x(reflink_p_to_missing_reflink_v, 166) \ 175 - x(stripe_pos_bad, 167) \ 176 - x(stripe_val_size_bad, 168) \ 177 - x(stripe_sector_count_wrong, 169) \ 178 - x(snapshot_tree_pos_bad, 170) \ 179 - x(snapshot_tree_to_missing_snapshot, 171) \ 180 - x(snapshot_tree_to_missing_subvol, 172) \ 181 - x(snapshot_tree_to_wrong_subvol, 173) \ 182 - x(snapshot_tree_to_snapshot_subvol, 174) \ 183 - x(snapshot_pos_bad, 175) \ 184 - x(snapshot_parent_bad, 176) \ 185 - x(snapshot_children_not_normalized, 177) \ 186 - x(snapshot_child_duplicate, 178) \ 187 - x(snapshot_child_bad, 179) \ 188 - x(snapshot_skiplist_not_normalized, 180) \ 189 - x(snapshot_skiplist_bad, 181) \ 190 - x(snapshot_should_not_have_subvol, 182) \ 191 - x(snapshot_to_bad_snapshot_tree, 183) \ 192 - x(snapshot_bad_depth, 184) \ 193 - x(snapshot_bad_skiplist, 185) \ 194 - x(subvol_pos_bad, 186) \ 195 - x(subvol_not_master_and_not_snapshot, 187) \ 196 - x(subvol_to_missing_root, 188) \ 197 - x(subvol_root_wrong_bi_subvol, 189) \ 198 - x(bkey_in_missing_snapshot, 190) \ 199 - x(inode_pos_inode_nonzero, 191) \ 200 - x(inode_pos_blockdev_range, 192) \ 201 - x(inode_unpack_error, 193) \ 202 - x(inode_str_hash_invalid, 194) \ 203 - x(inode_v3_fields_start_bad, 195) \ 204 - x(inode_snapshot_mismatch, 196) \ 205 - x(inode_unlinked_but_clean, 197) \ 206 - x(inode_unlinked_but_nlink_nonzero, 198) \ 207 - x(inode_checksum_type_invalid, 199) \ 208 - x(inode_compression_type_invalid, 200) \ 209 - x(inode_subvol_root_but_not_dir, 201) \ 210 - x(inode_i_size_dirty_but_clean, 202) \ 211 - x(inode_i_sectors_dirty_but_clean, 203) \ 212 - x(inode_i_sectors_wrong, 204) \ 213 - x(inode_dir_wrong_nlink, 205) \ 214 - x(inode_dir_multiple_links, 206) \ 215 - x(inode_multiple_links_but_nlink_0, 207) \ 216 - x(inode_wrong_backpointer, 208) \ 217 - x(inode_wrong_nlink, 209) \ 218 - x(inode_unreachable, 210) \ 219 - x(deleted_inode_but_clean, 211) \ 220 - x(deleted_inode_missing, 212) \ 221 - x(deleted_inode_is_dir, 213) \ 222 - x(deleted_inode_not_unlinked, 214) \ 223 - x(extent_overlapping, 215) \ 224 - x(extent_in_missing_inode, 216) \ 225 - x(extent_in_non_reg_inode, 217) \ 226 - x(extent_past_end_of_inode, 218) \ 227 - x(dirent_empty_name, 219) \ 228 - x(dirent_val_too_big, 220) \ 229 - x(dirent_name_too_long, 221) \ 230 - x(dirent_name_embedded_nul, 222) \ 231 - x(dirent_name_dot_or_dotdot, 223) \ 232 - x(dirent_name_has_slash, 224) \ 233 - x(dirent_d_type_wrong, 225) \ 234 - x(dirent_d_parent_subvol_wrong, 226) \ 235 - x(dirent_in_missing_dir_inode, 227) \ 236 - x(dirent_in_non_dir_inode, 228) \ 237 - x(dirent_to_missing_inode, 229) \ 238 - x(dirent_to_missing_subvol, 230) \ 239 - x(dirent_to_itself, 231) \ 240 - x(quota_type_invalid, 232) \ 241 - x(xattr_val_size_too_small, 233) \ 242 - x(xattr_val_size_too_big, 234) \ 243 - x(xattr_invalid_type, 235) \ 244 - x(xattr_name_invalid_chars, 236) \ 245 - x(xattr_in_missing_inode, 237) \ 246 - x(root_subvol_missing, 238) \ 247 - x(root_dir_missing, 239) \ 248 - x(root_inode_not_dir, 240) \ 249 - x(dir_loop, 241) \ 250 - x(hash_table_key_duplicate, 242) \ 251 - x(hash_table_key_wrong_offset, 243) 252 - 253 - enum bch_sb_error_id { 254 - #define x(t, n) BCH_FSCK_ERR_##t = n, 255 - BCH_SB_ERRS() 256 - #undef x 257 - BCH_SB_ERR_MAX 258 - }; 7 + extern const char * const bch2_sb_error_strs[]; 259 8 260 9 extern const struct bch_sb_field_ops bch_sb_field_ops_errors; 261 10
+253
fs/bcachefs/sb-errors_types.h
··· 4 4 5 5 #include "darray.h" 6 6 7 + #define BCH_SB_ERRS() \ 8 + x(clean_but_journal_not_empty, 0) \ 9 + x(dirty_but_no_journal_entries, 1) \ 10 + x(dirty_but_no_journal_entries_post_drop_nonflushes, 2) \ 11 + x(sb_clean_journal_seq_mismatch, 3) \ 12 + x(sb_clean_btree_root_mismatch, 4) \ 13 + x(sb_clean_missing, 5) \ 14 + x(jset_unsupported_version, 6) \ 15 + x(jset_unknown_csum, 7) \ 16 + x(jset_last_seq_newer_than_seq, 8) \ 17 + x(jset_past_bucket_end, 9) \ 18 + x(jset_seq_blacklisted, 10) \ 19 + x(journal_entries_missing, 11) \ 20 + x(journal_entry_replicas_not_marked, 12) \ 21 + x(journal_entry_past_jset_end, 13) \ 22 + x(journal_entry_replicas_data_mismatch, 14) \ 23 + x(journal_entry_bkey_u64s_0, 15) \ 24 + x(journal_entry_bkey_past_end, 16) \ 25 + x(journal_entry_bkey_bad_format, 17) \ 26 + x(journal_entry_bkey_invalid, 18) \ 27 + x(journal_entry_btree_root_bad_size, 19) \ 28 + x(journal_entry_blacklist_bad_size, 20) \ 29 + x(journal_entry_blacklist_v2_bad_size, 21) \ 30 + x(journal_entry_blacklist_v2_start_past_end, 22) \ 31 + x(journal_entry_usage_bad_size, 23) \ 32 + x(journal_entry_data_usage_bad_size, 24) \ 33 + x(journal_entry_clock_bad_size, 25) \ 34 + x(journal_entry_clock_bad_rw, 26) \ 35 + x(journal_entry_dev_usage_bad_size, 27) \ 36 + x(journal_entry_dev_usage_bad_dev, 28) \ 37 + x(journal_entry_dev_usage_bad_pad, 29) \ 38 + x(btree_node_unreadable, 30) \ 39 + x(btree_node_fault_injected, 31) \ 40 + x(btree_node_bad_magic, 32) \ 41 + x(btree_node_bad_seq, 33) \ 42 + x(btree_node_unsupported_version, 34) \ 43 + x(btree_node_bset_older_than_sb_min, 35) \ 44 + x(btree_node_bset_newer_than_sb, 36) \ 45 + x(btree_node_data_missing, 37) \ 46 + x(btree_node_bset_after_end, 38) \ 47 + x(btree_node_replicas_sectors_written_mismatch, 39) \ 48 + x(btree_node_replicas_data_mismatch, 40) \ 49 + x(bset_unknown_csum, 41) \ 50 + x(bset_bad_csum, 42) \ 51 + x(bset_past_end_of_btree_node, 43) \ 52 + x(bset_wrong_sector_offset, 44) \ 53 + x(bset_empty, 45) \ 54 + x(bset_bad_seq, 46) \ 55 + x(bset_blacklisted_journal_seq, 47) \ 56 + x(first_bset_blacklisted_journal_seq, 48) \ 57 + x(btree_node_bad_btree, 49) \ 58 + x(btree_node_bad_level, 50) \ 59 + x(btree_node_bad_min_key, 51) \ 60 + x(btree_node_bad_max_key, 52) \ 61 + x(btree_node_bad_format, 53) \ 62 + x(btree_node_bkey_past_bset_end, 54) \ 63 + x(btree_node_bkey_bad_format, 55) \ 64 + x(btree_node_bad_bkey, 56) \ 65 + x(btree_node_bkey_out_of_order, 57) \ 66 + x(btree_root_bkey_invalid, 58) \ 67 + x(btree_root_read_error, 59) \ 68 + x(btree_root_bad_min_key, 60) \ 69 + x(btree_root_bad_max_key, 61) \ 70 + x(btree_node_read_error, 62) \ 71 + x(btree_node_topology_bad_min_key, 63) \ 72 + x(btree_node_topology_bad_max_key, 64) \ 73 + x(btree_node_topology_overwritten_by_prev_node, 65) \ 74 + x(btree_node_topology_overwritten_by_next_node, 66) \ 75 + x(btree_node_topology_interior_node_empty, 67) \ 76 + x(fs_usage_hidden_wrong, 68) \ 77 + x(fs_usage_btree_wrong, 69) \ 78 + x(fs_usage_data_wrong, 70) \ 79 + x(fs_usage_cached_wrong, 71) \ 80 + x(fs_usage_reserved_wrong, 72) \ 81 + x(fs_usage_persistent_reserved_wrong, 73) \ 82 + x(fs_usage_nr_inodes_wrong, 74) \ 83 + x(fs_usage_replicas_wrong, 75) \ 84 + x(dev_usage_buckets_wrong, 76) \ 85 + x(dev_usage_sectors_wrong, 77) \ 86 + x(dev_usage_fragmented_wrong, 78) \ 87 + x(dev_usage_buckets_ec_wrong, 79) \ 88 + x(bkey_version_in_future, 80) \ 89 + x(bkey_u64s_too_small, 81) \ 90 + x(bkey_invalid_type_for_btree, 82) \ 91 + x(bkey_extent_size_zero, 83) \ 92 + x(bkey_extent_size_greater_than_offset, 84) \ 93 + x(bkey_size_nonzero, 85) \ 94 + x(bkey_snapshot_nonzero, 86) \ 95 + x(bkey_snapshot_zero, 87) \ 96 + x(bkey_at_pos_max, 88) \ 97 + x(bkey_before_start_of_btree_node, 89) \ 98 + x(bkey_after_end_of_btree_node, 90) \ 99 + x(bkey_val_size_nonzero, 91) \ 100 + x(bkey_val_size_too_small, 92) \ 101 + x(alloc_v1_val_size_bad, 93) \ 102 + x(alloc_v2_unpack_error, 94) \ 103 + x(alloc_v3_unpack_error, 95) \ 104 + x(alloc_v4_val_size_bad, 96) \ 105 + x(alloc_v4_backpointers_start_bad, 97) \ 106 + x(alloc_key_data_type_bad, 98) \ 107 + x(alloc_key_empty_but_have_data, 99) \ 108 + x(alloc_key_dirty_sectors_0, 100) \ 109 + x(alloc_key_data_type_inconsistency, 101) \ 110 + x(alloc_key_to_missing_dev_bucket, 102) \ 111 + x(alloc_key_cached_inconsistency, 103) \ 112 + x(alloc_key_cached_but_read_time_zero, 104) \ 113 + x(alloc_key_to_missing_lru_entry, 105) \ 114 + x(alloc_key_data_type_wrong, 106) \ 115 + x(alloc_key_gen_wrong, 107) \ 116 + x(alloc_key_dirty_sectors_wrong, 108) \ 117 + x(alloc_key_cached_sectors_wrong, 109) \ 118 + x(alloc_key_stripe_wrong, 110) \ 119 + x(alloc_key_stripe_redundancy_wrong, 111) \ 120 + x(bucket_sector_count_overflow, 112) \ 121 + x(bucket_metadata_type_mismatch, 113) \ 122 + x(need_discard_key_wrong, 114) \ 123 + x(freespace_key_wrong, 115) \ 124 + x(freespace_hole_missing, 116) \ 125 + x(bucket_gens_val_size_bad, 117) \ 126 + x(bucket_gens_key_wrong, 118) \ 127 + x(bucket_gens_hole_wrong, 119) \ 128 + x(bucket_gens_to_invalid_dev, 120) \ 129 + x(bucket_gens_to_invalid_buckets, 121) \ 130 + x(bucket_gens_nonzero_for_invalid_buckets, 122) \ 131 + x(need_discard_freespace_key_to_invalid_dev_bucket, 123) \ 132 + x(need_discard_freespace_key_bad, 124) \ 133 + x(backpointer_pos_wrong, 125) \ 134 + x(backpointer_to_missing_device, 126) \ 135 + x(backpointer_to_missing_alloc, 127) \ 136 + x(backpointer_to_missing_ptr, 128) \ 137 + x(lru_entry_at_time_0, 129) \ 138 + x(lru_entry_to_invalid_bucket, 130) \ 139 + x(lru_entry_bad, 131) \ 140 + x(btree_ptr_val_too_big, 132) \ 141 + x(btree_ptr_v2_val_too_big, 133) \ 142 + x(btree_ptr_has_non_ptr, 134) \ 143 + x(extent_ptrs_invalid_entry, 135) \ 144 + x(extent_ptrs_no_ptrs, 136) \ 145 + x(extent_ptrs_too_many_ptrs, 137) \ 146 + x(extent_ptrs_redundant_crc, 138) \ 147 + x(extent_ptrs_redundant_stripe, 139) \ 148 + x(extent_ptrs_unwritten, 140) \ 149 + x(extent_ptrs_written_and_unwritten, 141) \ 150 + x(ptr_to_invalid_device, 142) \ 151 + x(ptr_to_duplicate_device, 143) \ 152 + x(ptr_after_last_bucket, 144) \ 153 + x(ptr_before_first_bucket, 145) \ 154 + x(ptr_spans_multiple_buckets, 146) \ 155 + x(ptr_to_missing_backpointer, 147) \ 156 + x(ptr_to_missing_alloc_key, 148) \ 157 + x(ptr_to_missing_replicas_entry, 149) \ 158 + x(ptr_to_missing_stripe, 150) \ 159 + x(ptr_to_incorrect_stripe, 151) \ 160 + x(ptr_gen_newer_than_bucket_gen, 152) \ 161 + x(ptr_too_stale, 153) \ 162 + x(stale_dirty_ptr, 154) \ 163 + x(ptr_bucket_data_type_mismatch, 155) \ 164 + x(ptr_cached_and_erasure_coded, 156) \ 165 + x(ptr_crc_uncompressed_size_too_small, 157) \ 166 + x(ptr_crc_csum_type_unknown, 158) \ 167 + x(ptr_crc_compression_type_unknown, 159) \ 168 + x(ptr_crc_redundant, 160) \ 169 + x(ptr_crc_uncompressed_size_too_big, 161) \ 170 + x(ptr_crc_nonce_mismatch, 162) \ 171 + x(ptr_stripe_redundant, 163) \ 172 + x(reservation_key_nr_replicas_invalid, 164) \ 173 + x(reflink_v_refcount_wrong, 165) \ 174 + x(reflink_p_to_missing_reflink_v, 166) \ 175 + x(stripe_pos_bad, 167) \ 176 + x(stripe_val_size_bad, 168) \ 177 + x(stripe_sector_count_wrong, 169) \ 178 + x(snapshot_tree_pos_bad, 170) \ 179 + x(snapshot_tree_to_missing_snapshot, 171) \ 180 + x(snapshot_tree_to_missing_subvol, 172) \ 181 + x(snapshot_tree_to_wrong_subvol, 173) \ 182 + x(snapshot_tree_to_snapshot_subvol, 174) \ 183 + x(snapshot_pos_bad, 175) \ 184 + x(snapshot_parent_bad, 176) \ 185 + x(snapshot_children_not_normalized, 177) \ 186 + x(snapshot_child_duplicate, 178) \ 187 + x(snapshot_child_bad, 179) \ 188 + x(snapshot_skiplist_not_normalized, 180) \ 189 + x(snapshot_skiplist_bad, 181) \ 190 + x(snapshot_should_not_have_subvol, 182) \ 191 + x(snapshot_to_bad_snapshot_tree, 183) \ 192 + x(snapshot_bad_depth, 184) \ 193 + x(snapshot_bad_skiplist, 185) \ 194 + x(subvol_pos_bad, 186) \ 195 + x(subvol_not_master_and_not_snapshot, 187) \ 196 + x(subvol_to_missing_root, 188) \ 197 + x(subvol_root_wrong_bi_subvol, 189) \ 198 + x(bkey_in_missing_snapshot, 190) \ 199 + x(inode_pos_inode_nonzero, 191) \ 200 + x(inode_pos_blockdev_range, 192) \ 201 + x(inode_unpack_error, 193) \ 202 + x(inode_str_hash_invalid, 194) \ 203 + x(inode_v3_fields_start_bad, 195) \ 204 + x(inode_snapshot_mismatch, 196) \ 205 + x(inode_unlinked_but_clean, 197) \ 206 + x(inode_unlinked_but_nlink_nonzero, 198) \ 207 + x(inode_checksum_type_invalid, 199) \ 208 + x(inode_compression_type_invalid, 200) \ 209 + x(inode_subvol_root_but_not_dir, 201) \ 210 + x(inode_i_size_dirty_but_clean, 202) \ 211 + x(inode_i_sectors_dirty_but_clean, 203) \ 212 + x(inode_i_sectors_wrong, 204) \ 213 + x(inode_dir_wrong_nlink, 205) \ 214 + x(inode_dir_multiple_links, 206) \ 215 + x(inode_multiple_links_but_nlink_0, 207) \ 216 + x(inode_wrong_backpointer, 208) \ 217 + x(inode_wrong_nlink, 209) \ 218 + x(inode_unreachable, 210) \ 219 + x(deleted_inode_but_clean, 211) \ 220 + x(deleted_inode_missing, 212) \ 221 + x(deleted_inode_is_dir, 213) \ 222 + x(deleted_inode_not_unlinked, 214) \ 223 + x(extent_overlapping, 215) \ 224 + x(extent_in_missing_inode, 216) \ 225 + x(extent_in_non_reg_inode, 217) \ 226 + x(extent_past_end_of_inode, 218) \ 227 + x(dirent_empty_name, 219) \ 228 + x(dirent_val_too_big, 220) \ 229 + x(dirent_name_too_long, 221) \ 230 + x(dirent_name_embedded_nul, 222) \ 231 + x(dirent_name_dot_or_dotdot, 223) \ 232 + x(dirent_name_has_slash, 224) \ 233 + x(dirent_d_type_wrong, 225) \ 234 + x(dirent_d_parent_subvol_wrong, 226) \ 235 + x(dirent_in_missing_dir_inode, 227) \ 236 + x(dirent_in_non_dir_inode, 228) \ 237 + x(dirent_to_missing_inode, 229) \ 238 + x(dirent_to_missing_subvol, 230) \ 239 + x(dirent_to_itself, 231) \ 240 + x(quota_type_invalid, 232) \ 241 + x(xattr_val_size_too_small, 233) \ 242 + x(xattr_val_size_too_big, 234) \ 243 + x(xattr_invalid_type, 235) \ 244 + x(xattr_name_invalid_chars, 236) \ 245 + x(xattr_in_missing_inode, 237) \ 246 + x(root_subvol_missing, 238) \ 247 + x(root_dir_missing, 239) \ 248 + x(root_inode_not_dir, 240) \ 249 + x(dir_loop, 241) \ 250 + x(hash_table_key_duplicate, 242) \ 251 + x(hash_table_key_wrong_offset, 243) 252 + 253 + enum bch_sb_error_id { 254 + #define x(t, n) BCH_FSCK_ERR_##t = n, 255 + BCH_SB_ERRS() 256 + #undef x 257 + BCH_SB_ERR_MAX 258 + }; 259 + 7 260 struct bch_sb_error_entry_cpu { 8 261 u64 id:16, 9 262 nr:48;
+18
fs/bcachefs/subvolume.c
··· 146 146 return bch2_subvolume_get_inlined(trans, subvol, inconsistent_if_not_found, iter_flags, s); 147 147 } 148 148 149 + int bch2_subvol_is_ro_trans(struct btree_trans *trans, u32 subvol) 150 + { 151 + struct bch_subvolume s; 152 + int ret = bch2_subvolume_get_inlined(trans, subvol, true, 0, &s); 153 + if (ret) 154 + return ret; 155 + 156 + if (BCH_SUBVOLUME_RO(&s)) 157 + return -EROFS; 158 + return 0; 159 + } 160 + 161 + int bch2_subvol_is_ro(struct bch_fs *c, u32 subvol) 162 + { 163 + return bch2_trans_do(c, NULL, NULL, 0, 164 + bch2_subvol_is_ro_trans(trans, subvol)); 165 + } 166 + 149 167 int bch2_snapshot_get_subvol(struct btree_trans *trans, u32 snapshot, 150 168 struct bch_subvolume *subvol) 151 169 {
+3
fs/bcachefs/subvolume.h
··· 23 23 bool, int, struct bch_subvolume *); 24 24 int bch2_subvolume_get_snapshot(struct btree_trans *, u32, u32 *); 25 25 26 + int bch2_subvol_is_ro_trans(struct btree_trans *, u32); 27 + int bch2_subvol_is_ro(struct bch_fs *, u32); 28 + 26 29 int bch2_delete_dead_snapshots(struct bch_fs *); 27 30 void bch2_delete_dead_snapshots_async(struct bch_fs *); 28 31
+84 -2
fs/bcachefs/super-io.c
··· 13 13 #include "replicas.h" 14 14 #include "quota.h" 15 15 #include "sb-clean.h" 16 + #include "sb-downgrade.h" 16 17 #include "sb-errors.h" 17 18 #include "sb-members.h" 18 19 #include "super-io.h" ··· 265 264 return f; 266 265 } 267 266 267 + struct bch_sb_field *bch2_sb_field_get_minsize_id(struct bch_sb_handle *sb, 268 + enum bch_sb_field_type type, 269 + unsigned u64s) 270 + { 271 + struct bch_sb_field *f = bch2_sb_field_get_id(sb->sb, type); 272 + 273 + if (!f || le32_to_cpu(f->u64s) < u64s) 274 + f = bch2_sb_field_resize_id(sb, type, u64s); 275 + return f; 276 + } 277 + 268 278 /* Superblock validate: */ 269 279 270 280 static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out) ··· 496 484 497 485 /* device open: */ 498 486 487 + static unsigned long le_ulong_to_cpu(unsigned long v) 488 + { 489 + return sizeof(unsigned long) == 8 490 + ? le64_to_cpu(v) 491 + : le32_to_cpu(v); 492 + } 493 + 494 + static void le_bitvector_to_cpu(unsigned long *dst, unsigned long *src, unsigned nr) 495 + { 496 + BUG_ON(nr & (BITS_PER_TYPE(long) - 1)); 497 + 498 + for (unsigned i = 0; i < BITS_TO_LONGS(nr); i++) 499 + dst[i] = le_ulong_to_cpu(src[i]); 500 + } 501 + 499 502 static void bch2_sb_update(struct bch_fs *c) 500 503 { 501 504 struct bch_sb *src = c->disk_sb.sb; ··· 539 512 c->sb.features = le64_to_cpu(src->features[0]); 540 513 c->sb.compat = le64_to_cpu(src->compat[0]); 541 514 515 + memset(c->sb.errors_silent, 0, sizeof(c->sb.errors_silent)); 516 + 517 + struct bch_sb_field_ext *ext = bch2_sb_field_get(src, ext); 518 + if (ext) 519 + le_bitvector_to_cpu(c->sb.errors_silent, (void *) ext->errors_silent, 520 + sizeof(c->sb.errors_silent) * 8); 521 + 542 522 for_each_member_device(ca, c, i) { 543 - struct bch_member m = bch2_sb_member_get(src, i); 523 + struct bch_member m = bch2_sb_member_get(src, ca->dev_idx); 544 524 ca->mi = bch2_mi_to_cpu(&m); 545 525 } 546 526 } ··· 940 906 bch2_sb_members_from_cpu(c); 941 907 bch2_sb_members_cpy_v2_v1(&c->disk_sb); 942 908 bch2_sb_errors_from_cpu(c); 909 + bch2_sb_downgrade_update(c); 943 910 944 911 for_each_online_member(ca, c, i) 945 912 bch2_sb_from_fs(c, ca); ··· 1064 1029 } 1065 1030 1066 1031 /* Downgrade if superblock is at a higher version than currently supported: */ 1067 - void bch2_sb_maybe_downgrade(struct bch_fs *c) 1032 + bool bch2_check_version_downgrade(struct bch_fs *c) 1068 1033 { 1034 + bool ret = bcachefs_metadata_version_current < c->sb.version; 1035 + 1069 1036 lockdep_assert_held(&c->sb_lock); 1070 1037 1071 1038 /* ··· 1081 1044 if (c->sb.version_min > bcachefs_metadata_version_current) 1082 1045 c->disk_sb.sb->version_min = cpu_to_le16(bcachefs_metadata_version_current); 1083 1046 c->disk_sb.sb->compat[0] &= cpu_to_le64((1ULL << BCH_COMPAT_NR) - 1); 1047 + return ret; 1084 1048 } 1085 1049 1086 1050 void bch2_sb_upgrade(struct bch_fs *c, unsigned new_version) 1087 1051 { 1088 1052 lockdep_assert_held(&c->sb_lock); 1089 1053 1054 + if (BCH_VERSION_MAJOR(new_version) > 1055 + BCH_VERSION_MAJOR(le16_to_cpu(c->disk_sb.sb->version))) 1056 + bch2_sb_field_resize(&c->disk_sb, downgrade, 0); 1057 + 1090 1058 c->disk_sb.sb->version = cpu_to_le16(new_version); 1091 1059 c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL); 1092 1060 } 1061 + 1062 + static int bch2_sb_ext_validate(struct bch_sb *sb, struct bch_sb_field *f, 1063 + struct printbuf *err) 1064 + { 1065 + if (vstruct_bytes(f) < 88) { 1066 + prt_printf(err, "field too small (%zu < %u)", vstruct_bytes(f), 88); 1067 + return -BCH_ERR_invalid_sb_ext; 1068 + } 1069 + 1070 + return 0; 1071 + } 1072 + 1073 + static void bch2_sb_ext_to_text(struct printbuf *out, struct bch_sb *sb, 1074 + struct bch_sb_field *f) 1075 + { 1076 + struct bch_sb_field_ext *e = field_to_type(f, ext); 1077 + 1078 + prt_printf(out, "Recovery passes required:"); 1079 + prt_tab(out); 1080 + prt_bitflags(out, bch2_recovery_passes, 1081 + bch2_recovery_passes_from_stable(le64_to_cpu(e->recovery_passes_required[0]))); 1082 + prt_newline(out); 1083 + 1084 + unsigned long *errors_silent = kmalloc(sizeof(e->errors_silent), GFP_KERNEL); 1085 + if (errors_silent) { 1086 + le_bitvector_to_cpu(errors_silent, (void *) e->errors_silent, sizeof(e->errors_silent) * 8); 1087 + 1088 + prt_printf(out, "Errors to silently fix:"); 1089 + prt_tab(out); 1090 + prt_bitflags_vector(out, bch2_sb_error_strs, errors_silent, sizeof(e->errors_silent) * 8); 1091 + prt_newline(out); 1092 + 1093 + kfree(errors_silent); 1094 + } 1095 + } 1096 + 1097 + static const struct bch_sb_field_ops bch_sb_field_ops_ext = { 1098 + .validate = bch2_sb_ext_validate, 1099 + .to_text = bch2_sb_ext_to_text, 1100 + }; 1093 1101 1094 1102 static const struct bch_sb_field_ops *bch2_sb_field_ops[] = { 1095 1103 #define x(f, nr) \
+11 -1
fs/bcachefs/super-io.h
··· 40 40 #define bch2_sb_field_resize(_sb, _name, _u64s) \ 41 41 field_to_type(bch2_sb_field_resize_id(_sb, BCH_SB_FIELD_##_name, _u64s), _name) 42 42 43 + struct bch_sb_field *bch2_sb_field_get_minsize_id(struct bch_sb_handle *, 44 + enum bch_sb_field_type, unsigned); 45 + #define bch2_sb_field_get_minsize(_sb, _name, _u64s) \ 46 + field_to_type(bch2_sb_field_get_minsize_id(_sb, BCH_SB_FIELD_##_name, _u64s), _name) 47 + 48 + #define bch2_sb_field_nr_entries(_f) \ 49 + (_f ? ((bch2_sb_field_bytes(&_f->field) - sizeof(*_f)) / \ 50 + sizeof(_f->entries[0])) \ 51 + : 0) 52 + 43 53 void bch2_sb_field_delete(struct bch_sb_handle *, enum bch_sb_field_type); 44 54 45 55 extern const char * const bch2_sb_fields[]; ··· 93 83 __bch2_check_set_feature(c, feat); 94 84 } 95 85 96 - void bch2_sb_maybe_downgrade(struct bch_fs *); 86 + bool bch2_check_version_downgrade(struct bch_fs *); 97 87 void bch2_sb_upgrade(struct bch_fs *, unsigned); 98 88 99 89 void bch2_sb_field_to_text(struct printbuf *, struct bch_sb *,
+1
fs/bcachefs/util.h
··· 243 243 #define prt_units_s64(...) bch2_prt_units_s64(__VA_ARGS__) 244 244 #define prt_string_option(...) bch2_prt_string_option(__VA_ARGS__) 245 245 #define prt_bitflags(...) bch2_prt_bitflags(__VA_ARGS__) 246 + #define prt_bitflags_vector(...) bch2_prt_bitflags_vector(__VA_ARGS__) 246 247 247 248 void bch2_pr_time_units(struct printbuf *, u64); 248 249 void bch2_prt_datetime(struct printbuf *, time64_t);
+2 -1
fs/bcachefs/xattr.c
··· 176 176 struct btree_iter inode_iter = { NULL }; 177 177 int ret; 178 178 179 - ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_INTENT); 179 + ret = bch2_subvol_is_ro_trans(trans, inum.subvol) ?: 180 + bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_INTENT); 180 181 if (ret) 181 182 return ret; 182 183
+4 -2
fs/debugfs/file.c
··· 104 104 ~DEBUGFS_FSDATA_IS_REAL_FOPS_BIT); 105 105 refcount_set(&fsd->active_users, 1); 106 106 init_completion(&fsd->active_users_drained); 107 + INIT_LIST_HEAD(&fsd->cancellations); 108 + mutex_init(&fsd->cancellations_mtx); 109 + 107 110 if (cmpxchg(&dentry->d_fsdata, d_fsd, fsd) != d_fsd) { 111 + mutex_destroy(&fsd->cancellations_mtx); 108 112 kfree(fsd); 109 113 fsd = READ_ONCE(dentry->d_fsdata); 110 114 } 111 - INIT_LIST_HEAD(&fsd->cancellations); 112 - mutex_init(&fsd->cancellations_mtx); 113 115 } 114 116 115 117 /*
+12 -3
fs/smb/server/smb2misc.c
··· 106 106 break; 107 107 case SMB2_CREATE: 108 108 { 109 + unsigned short int name_off = 110 + le16_to_cpu(((struct smb2_create_req *)hdr)->NameOffset); 111 + unsigned short int name_len = 112 + le16_to_cpu(((struct smb2_create_req *)hdr)->NameLength); 113 + 109 114 if (((struct smb2_create_req *)hdr)->CreateContextsLength) { 110 115 *off = le32_to_cpu(((struct smb2_create_req *) 111 116 hdr)->CreateContextsOffset); 112 117 *len = le32_to_cpu(((struct smb2_create_req *) 113 118 hdr)->CreateContextsLength); 114 - break; 119 + if (!name_len) 120 + break; 121 + 122 + if (name_off + name_len < (u64)*off + *len) 123 + break; 115 124 } 116 125 117 - *off = le16_to_cpu(((struct smb2_create_req *)hdr)->NameOffset); 118 - *len = le16_to_cpu(((struct smb2_create_req *)hdr)->NameLength); 126 + *off = name_off; 127 + *len = name_len; 119 128 break; 120 129 } 121 130 case SMB2_QUERY_INFO:
+100 -9
fs/tracefs/event_inode.c
··· 113 113 * determined by the parent directory. 114 114 */ 115 115 if (dentry->d_inode->i_mode & S_IFDIR) { 116 - update_attr(&ei->attr, iattr); 116 + /* 117 + * The events directory dentry is never freed, unless its 118 + * part of an instance that is deleted. It's attr is the 119 + * default for its child files and directories. 120 + * Do not update it. It's not used for its own mode or ownership 121 + */ 122 + if (!ei->is_events) 123 + update_attr(&ei->attr, iattr); 117 124 118 125 } else { 119 126 name = dentry->d_name.name; ··· 155 148 .release = eventfs_release, 156 149 }; 157 150 158 - static void update_inode_attr(struct inode *inode, struct eventfs_attr *attr, umode_t mode) 151 + /* Return the evenfs_inode of the "events" directory */ 152 + static struct eventfs_inode *eventfs_find_events(struct dentry *dentry) 159 153 { 160 - if (!attr) { 161 - inode->i_mode = mode; 154 + struct eventfs_inode *ei; 155 + 156 + mutex_lock(&eventfs_mutex); 157 + do { 158 + /* The parent always has an ei, except for events itself */ 159 + ei = dentry->d_parent->d_fsdata; 160 + 161 + /* 162 + * If the ei is being freed, the ownership of the children 163 + * doesn't matter. 164 + */ 165 + if (ei->is_freed) { 166 + ei = NULL; 167 + break; 168 + } 169 + 170 + dentry = ei->dentry; 171 + } while (!ei->is_events); 172 + mutex_unlock(&eventfs_mutex); 173 + 174 + return ei; 175 + } 176 + 177 + static void update_inode_attr(struct dentry *dentry, struct inode *inode, 178 + struct eventfs_attr *attr, umode_t mode) 179 + { 180 + struct eventfs_inode *events_ei = eventfs_find_events(dentry); 181 + 182 + if (!events_ei) 162 183 return; 163 - } 184 + 185 + inode->i_mode = mode; 186 + inode->i_uid = events_ei->attr.uid; 187 + inode->i_gid = events_ei->attr.gid; 188 + 189 + if (!attr) 190 + return; 164 191 165 192 if (attr->mode & EVENTFS_SAVE_MODE) 166 193 inode->i_mode = attr->mode & EVENTFS_MODE_MASK; 167 - else 168 - inode->i_mode = mode; 169 194 170 195 if (attr->mode & EVENTFS_SAVE_UID) 171 196 inode->i_uid = attr->uid; 172 197 173 198 if (attr->mode & EVENTFS_SAVE_GID) 174 199 inode->i_gid = attr->gid; 200 + } 201 + 202 + static void update_gid(struct eventfs_inode *ei, kgid_t gid, int level) 203 + { 204 + struct eventfs_inode *ei_child; 205 + 206 + /* at most we have events/system/event */ 207 + if (WARN_ON_ONCE(level > 3)) 208 + return; 209 + 210 + ei->attr.gid = gid; 211 + 212 + if (ei->entry_attrs) { 213 + for (int i = 0; i < ei->nr_entries; i++) { 214 + ei->entry_attrs[i].gid = gid; 215 + } 216 + } 217 + 218 + /* 219 + * Only eventfs_inode with dentries are updated, make sure 220 + * all eventfs_inodes are updated. If one of the children 221 + * do not have a dentry, this function must traverse it. 222 + */ 223 + list_for_each_entry_srcu(ei_child, &ei->children, list, 224 + srcu_read_lock_held(&eventfs_srcu)) { 225 + if (!ei_child->dentry) 226 + update_gid(ei_child, gid, level + 1); 227 + } 228 + } 229 + 230 + void eventfs_update_gid(struct dentry *dentry, kgid_t gid) 231 + { 232 + struct eventfs_inode *ei = dentry->d_fsdata; 233 + int idx; 234 + 235 + idx = srcu_read_lock(&eventfs_srcu); 236 + update_gid(ei, gid, 0); 237 + srcu_read_unlock(&eventfs_srcu, idx); 175 238 } 176 239 177 240 /** ··· 283 206 return eventfs_failed_creating(dentry); 284 207 285 208 /* If the user updated the directory's attributes, use them */ 286 - update_inode_attr(inode, attr, mode); 209 + update_inode_attr(dentry, inode, attr, mode); 287 210 288 211 inode->i_op = &eventfs_file_inode_operations; 289 212 inode->i_fop = fop; ··· 319 242 return eventfs_failed_creating(dentry); 320 243 321 244 /* If the user updated the directory's attributes, use them */ 322 - update_inode_attr(inode, &ei->attr, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); 245 + update_inode_attr(dentry, inode, &ei->attr, 246 + S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); 323 247 324 248 inode->i_op = &eventfs_root_dir_inode_operations; 325 249 inode->i_fop = &eventfs_file_operations; ··· 932 854 struct eventfs_inode *ei; 933 855 struct tracefs_inode *ti; 934 856 struct inode *inode; 857 + kuid_t uid; 858 + kgid_t gid; 935 859 936 860 if (security_locked_down(LOCKDOWN_TRACEFS)) 937 861 return NULL; ··· 958 878 ei->dentry = dentry; 959 879 ei->entries = entries; 960 880 ei->nr_entries = size; 881 + ei->is_events = 1; 961 882 ei->data = data; 962 883 ei->name = kstrdup_const(name, GFP_KERNEL); 963 884 if (!ei->name) 964 885 goto fail; 886 + 887 + /* Save the ownership of this directory */ 888 + uid = d_inode(dentry->d_parent)->i_uid; 889 + gid = d_inode(dentry->d_parent)->i_gid; 890 + 891 + /* This is used as the default ownership of the files and directories */ 892 + ei->attr.uid = uid; 893 + ei->attr.gid = gid; 965 894 966 895 INIT_LIST_HEAD(&ei->children); 967 896 INIT_LIST_HEAD(&ei->list); ··· 980 891 ti->private = ei; 981 892 982 893 inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; 894 + inode->i_uid = uid; 895 + inode->i_gid = gid; 983 896 inode->i_op = &eventfs_root_dir_inode_operations; 984 897 inode->i_fop = &eventfs_file_operations; 985 898
+10
fs/tracefs/inode.c
··· 210 210 next = this_parent->d_subdirs.next; 211 211 resume: 212 212 while (next != &this_parent->d_subdirs) { 213 + struct tracefs_inode *ti; 213 214 struct list_head *tmp = next; 214 215 struct dentry *dentry = list_entry(tmp, struct dentry, d_child); 215 216 next = tmp->next; 216 217 218 + /* Note, getdents() can add a cursor dentry with no inode */ 219 + if (!dentry->d_inode) 220 + continue; 221 + 217 222 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 218 223 219 224 change_gid(dentry, gid); 225 + 226 + /* If this is the events directory, update that too */ 227 + ti = get_tracefs(dentry->d_inode); 228 + if (ti && (ti->flags & TRACEFS_EVENT_INODE)) 229 + eventfs_update_gid(dentry, gid); 220 230 221 231 if (!list_empty(&dentry->d_subdirs)) { 222 232 spin_unlock(&this_parent->d_lock);
+3 -1
fs/tracefs/internal.h
··· 62 62 struct rcu_head rcu; 63 63 }; 64 64 unsigned int is_freed:1; 65 - unsigned int nr_entries:31; 65 + unsigned int is_events:1; 66 + unsigned int nr_entries:30; 66 67 }; 67 68 68 69 static inline struct tracefs_inode *get_tracefs(const struct inode *inode) ··· 78 77 struct dentry *eventfs_start_creating(const char *name, struct dentry *parent); 79 78 struct dentry *eventfs_failed_creating(struct dentry *dentry); 80 79 struct dentry *eventfs_end_creating(struct dentry *dentry); 80 + void eventfs_update_gid(struct dentry *dentry, kgid_t gid); 81 81 void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry); 82 82 83 83 #endif /* _TRACEFS_INTERNAL_H */
+1 -1
include/linux/blkdev.h
··· 538 538 #define QUEUE_FLAG_ADD_RANDOM 10 /* Contributes to random pool */ 539 539 #define QUEUE_FLAG_SYNCHRONOUS 11 /* always completes in submit context */ 540 540 #define QUEUE_FLAG_SAME_FORCE 12 /* force complete on same CPU */ 541 - #define QUEUE_FLAG_HW_WC 18 /* Write back caching supported */ 541 + #define QUEUE_FLAG_HW_WC 13 /* Write back caching supported */ 542 542 #define QUEUE_FLAG_INIT_DONE 14 /* queue is initialized */ 543 543 #define QUEUE_FLAG_STABLE_WRITES 15 /* don't modify blks until WB is done */ 544 544 #define QUEUE_FLAG_POLL 16 /* IO polling enabled if set */
+2
include/linux/device.h
··· 1007 1007 mutex_unlock(&dev->mutex); 1008 1008 } 1009 1009 1010 + DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) 1011 + 1010 1012 static inline void device_lock_assert(struct device *dev) 1011 1013 { 1012 1014 lockdep_assert_held(&dev->mutex);
+5 -1
include/linux/export-internal.h
··· 16 16 * and eliminates the need for absolute relocations that require runtime 17 17 * processing on relocatable kernels. 18 18 */ 19 + #define __KSYM_ALIGN ".balign 4" 19 20 #define __KSYM_REF(sym) ".long " #sym "- ." 20 21 #elif defined(CONFIG_64BIT) 22 + #define __KSYM_ALIGN ".balign 8" 21 23 #define __KSYM_REF(sym) ".quad " #sym 22 24 #else 25 + #define __KSYM_ALIGN ".balign 4" 23 26 #define __KSYM_REF(sym) ".long " #sym 24 27 #endif 25 28 ··· 45 42 " .asciz \"" ns "\"" "\n" \ 46 43 " .previous" "\n" \ 47 44 " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ 48 - " .balign 4" "\n" \ 45 + __KSYM_ALIGN "\n" \ 49 46 "__ksymtab_" #name ":" "\n" \ 50 47 __KSYM_REF(sym) "\n" \ 51 48 __KSYM_REF(__kstrtab_ ##name) "\n" \ ··· 64 61 65 62 #define SYMBOL_CRC(sym, crc, sec) \ 66 63 asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \ 64 + ".balign 4" "\n" \ 67 65 "__crc_" #sym ":" "\n" \ 68 66 ".long " #crc "\n" \ 69 67 ".previous" "\n")
-4
include/linux/hid-sensor-ids.h
··· 21 21 #define HID_USAGE_SENSOR_ALS 0x200041 22 22 #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 23 23 #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 24 - #define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE 0x2004d2 25 - #define HID_USAGE_SENSOR_LIGHT_CHROMATICITY 0x2004d3 26 - #define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X 0x2004d4 27 - #define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y 0x2004d5 28 24 29 25 /* PROX (200011) */ 30 26 #define HID_USAGE_SENSOR_PROX 0x200011
+1
include/linux/key-type.h
··· 73 73 74 74 unsigned int flags; 75 75 #define KEY_TYPE_NET_DOMAIN 0x00000001 /* Keys of this type have a net namespace domain */ 76 + #define KEY_TYPE_INSTANT_REAP 0x00000002 /* Keys of this type don't have a delay after expiring */ 76 77 77 78 /* vet a description */ 78 79 int (*vet_description)(const char *description);
-5
include/linux/osq_lock.h
··· 6 6 * An MCS like lock especially tailored for optimistic spinning for sleeping 7 7 * lock implementations (mutex, rwsem, etc). 8 8 */ 9 - struct optimistic_spin_node { 10 - struct optimistic_spin_node *next, *prev; 11 - int locked; /* 1 if lock acquired */ 12 - int cpu; /* encoded CPU # + 1 value */ 13 - }; 14 9 15 10 struct optimistic_spin_queue { 16 11 /*
-1
include/linux/phy.h
··· 569 569 * - Bits [31:24] are reserved for defining generic 570 570 * PHY driver behavior. 571 571 * @irq: IRQ number of the PHY's interrupt (-1 if none) 572 - * @phy_timer: The timer for handling the state machine 573 572 * @phylink: Pointer to phylink instance for this PHY 574 573 * @sfp_bus_attached: Flag indicating whether the SFP bus has been attached 575 574 * @sfp_bus: SFP bus attached to this PHY's fiber port
+1 -1
include/net/netfilter/nf_tables_ipv4.h
··· 30 30 return -1; 31 31 32 32 len = iph_totlen(pkt->skb, iph); 33 - thoff = iph->ihl * 4; 33 + thoff = skb_network_offset(pkt->skb) + (iph->ihl * 4); 34 34 if (pkt->skb->len < len) 35 35 return -1; 36 36 else if (len < thoff)
-2
include/net/tcp.h
··· 1792 1792 const struct sock *addr_sk); 1793 1793 1794 1794 #ifdef CONFIG_TCP_MD5SIG 1795 - #include <linux/jump_label.h> 1796 - extern struct static_key_false_deferred tcp_md5_needed; 1797 1795 struct tcp_md5sig_key *__tcp_md5_do_lookup(const struct sock *sk, int l3index, 1798 1796 const union tcp_md5_addr *addr, 1799 1797 int family, bool any_l3index);
+23 -3
include/net/tcp_ao.h
··· 127 127 struct rcu_head rcu; 128 128 }; 129 129 130 + #ifdef CONFIG_TCP_MD5SIG 131 + #include <linux/jump_label.h> 132 + extern struct static_key_false_deferred tcp_md5_needed; 133 + #define static_branch_tcp_md5() static_branch_unlikely(&tcp_md5_needed.key) 134 + #else 135 + #define static_branch_tcp_md5() false 136 + #endif 137 + #ifdef CONFIG_TCP_AO 138 + /* TCP-AO structures and functions */ 139 + #include <linux/jump_label.h> 140 + extern struct static_key_false_deferred tcp_ao_needed; 141 + #define static_branch_tcp_ao() static_branch_unlikely(&tcp_ao_needed.key) 142 + #else 143 + #define static_branch_tcp_ao() false 144 + #endif 145 + 146 + static inline bool tcp_hash_should_produce_warnings(void) 147 + { 148 + return static_branch_tcp_md5() || static_branch_tcp_ao(); 149 + } 150 + 130 151 #define tcp_hash_fail(msg, family, skb, fmt, ...) \ 131 152 do { \ 132 153 const struct tcphdr *th = tcp_hdr(skb); \ 133 154 char hdr_flags[6]; \ 134 155 char *f = hdr_flags; \ 135 156 \ 157 + if (!tcp_hash_should_produce_warnings()) \ 158 + break; \ 136 159 if (th->fin) \ 137 160 *f++ = 'F'; \ 138 161 if (th->syn) \ ··· 182 159 183 160 #ifdef CONFIG_TCP_AO 184 161 /* TCP-AO structures and functions */ 185 - #include <linux/jump_label.h> 186 - extern struct static_key_false_deferred tcp_ao_needed; 187 - 188 162 struct tcp4_ao_context { 189 163 __be32 saddr; 190 164 __be32 daddr;
+7 -4
include/trace/events/9p.h
··· 178 178 __field( void *, clnt ) 179 179 __field( __u8, type ) 180 180 __field( __u16, tag ) 181 - __array( unsigned char, line, P9_PROTO_DUMP_SZ ) 181 + __dynamic_array(unsigned char, line, 182 + min_t(size_t, pdu->capacity, P9_PROTO_DUMP_SZ)) 182 183 ), 183 184 184 185 TP_fast_assign( 185 186 __entry->clnt = clnt; 186 187 __entry->type = pdu->id; 187 188 __entry->tag = pdu->tag; 188 - memcpy(__entry->line, pdu->sdata, P9_PROTO_DUMP_SZ); 189 + memcpy(__get_dynamic_array(line), pdu->sdata, 190 + __get_dynamic_array_len(line)); 189 191 ), 190 - TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n", 192 + TP_printk("clnt %lu %s(tag = %d)\n%*ph\n", 191 193 (unsigned long)__entry->clnt, show_9p_op(__entry->type), 192 - __entry->tag, 0, __entry->line, 16, __entry->line + 16) 194 + __entry->tag, __get_dynamic_array_len(line), 195 + __get_dynamic_array(line)) 193 196 ); 194 197 195 198
+2
kernel/Kconfig.kexec
··· 36 36 config KEXEC_FILE 37 37 bool "Enable kexec file based system call" 38 38 depends on ARCH_SUPPORTS_KEXEC_FILE 39 + select CRYPTO 40 + select CRYPTO_SHA256 39 41 select KEXEC_CORE 40 42 help 41 43 This is new version of kexec system call. This system call is
+20 -17
kernel/locking/osq_lock.c
··· 11 11 * called from interrupt context and we have preemption disabled while 12 12 * spinning. 13 13 */ 14 + 15 + struct optimistic_spin_node { 16 + struct optimistic_spin_node *next, *prev; 17 + int locked; /* 1 if lock acquired */ 18 + int cpu; /* encoded CPU # + 1 value */ 19 + }; 20 + 14 21 static DEFINE_PER_CPU_SHARED_ALIGNED(struct optimistic_spin_node, osq_node); 15 22 16 23 /* ··· 44 37 /* 45 38 * Get a stable @node->next pointer, either for unlock() or unqueue() purposes. 46 39 * Can return NULL in case we were the last queued and we updated @lock instead. 40 + * 41 + * If osq_lock() is being cancelled there must be a previous node 42 + * and 'old_cpu' is its CPU #. 43 + * For osq_unlock() there is never a previous node and old_cpu is 44 + * set to OSQ_UNLOCKED_VAL. 47 45 */ 48 46 static inline struct optimistic_spin_node * 49 47 osq_wait_next(struct optimistic_spin_queue *lock, 50 48 struct optimistic_spin_node *node, 51 - struct optimistic_spin_node *prev) 49 + int old_cpu) 52 50 { 53 - struct optimistic_spin_node *next = NULL; 54 51 int curr = encode_cpu(smp_processor_id()); 55 - int old; 56 - 57 - /* 58 - * If there is a prev node in queue, then the 'old' value will be 59 - * the prev node's CPU #, else it's set to OSQ_UNLOCKED_VAL since if 60 - * we're currently last in queue, then the queue will then become empty. 61 - */ 62 - old = prev ? prev->cpu : OSQ_UNLOCKED_VAL; 63 52 64 53 for (;;) { 65 54 if (atomic_read(&lock->tail) == curr && 66 - atomic_cmpxchg_acquire(&lock->tail, curr, old) == curr) { 55 + atomic_cmpxchg_acquire(&lock->tail, curr, old_cpu) == curr) { 67 56 /* 68 57 * We were the last queued, we moved @lock back. @prev 69 58 * will now observe @lock and will complete its 70 59 * unlock()/unqueue(). 71 60 */ 72 - break; 61 + return NULL; 73 62 } 74 63 75 64 /* ··· 79 76 * wait for a new @node->next from its Step-C. 80 77 */ 81 78 if (node->next) { 79 + struct optimistic_spin_node *next; 80 + 82 81 next = xchg(&node->next, NULL); 83 82 if (next) 84 - break; 83 + return next; 85 84 } 86 85 87 86 cpu_relax(); 88 87 } 89 - 90 - return next; 91 88 } 92 89 93 90 bool osq_lock(struct optimistic_spin_queue *lock) ··· 189 186 * back to @prev. 190 187 */ 191 188 192 - next = osq_wait_next(lock, node, prev); 189 + next = osq_wait_next(lock, node, prev->cpu); 193 190 if (!next) 194 191 return false; 195 192 ··· 229 226 return; 230 227 } 231 228 232 - next = osq_wait_next(lock, node, NULL); 229 + next = osq_wait_next(lock, node, OSQ_UNLOCKED_VAL); 233 230 if (next) 234 231 WRITE_ONCE(next->locked, 1); 235 232 }
+47 -53
kernel/trace/ftrace.c
··· 1183 1183 hash->count++; 1184 1184 } 1185 1185 1186 - static int add_hash_entry(struct ftrace_hash *hash, unsigned long ip) 1186 + static struct ftrace_func_entry * 1187 + add_hash_entry(struct ftrace_hash *hash, unsigned long ip) 1187 1188 { 1188 1189 struct ftrace_func_entry *entry; 1189 1190 1190 1191 entry = kmalloc(sizeof(*entry), GFP_KERNEL); 1191 1192 if (!entry) 1192 - return -ENOMEM; 1193 + return NULL; 1193 1194 1194 1195 entry->ip = ip; 1195 1196 __add_hash_entry(hash, entry); 1196 1197 1197 - return 0; 1198 + return entry; 1198 1199 } 1199 1200 1200 1201 static void ··· 1350 1349 struct ftrace_func_entry *entry; 1351 1350 struct ftrace_hash *new_hash; 1352 1351 int size; 1353 - int ret; 1354 1352 int i; 1355 1353 1356 1354 new_hash = alloc_ftrace_hash(size_bits); ··· 1366 1366 size = 1 << hash->size_bits; 1367 1367 for (i = 0; i < size; i++) { 1368 1368 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { 1369 - ret = add_hash_entry(new_hash, entry->ip); 1370 - if (ret < 0) 1369 + if (add_hash_entry(new_hash, entry->ip) == NULL) 1371 1370 goto free_hash; 1372 1371 } 1373 1372 } ··· 2535 2536 2536 2537 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 2537 2538 /* Protected by rcu_tasks for reading, and direct_mutex for writing */ 2538 - static struct ftrace_hash *direct_functions = EMPTY_HASH; 2539 + static struct ftrace_hash __rcu *direct_functions = EMPTY_HASH; 2539 2540 static DEFINE_MUTEX(direct_mutex); 2540 2541 int ftrace_direct_func_count; 2541 2542 ··· 2552 2553 return 0; 2553 2554 2554 2555 return entry->direct; 2555 - } 2556 - 2557 - static struct ftrace_func_entry* 2558 - ftrace_add_rec_direct(unsigned long ip, unsigned long addr, 2559 - struct ftrace_hash **free_hash) 2560 - { 2561 - struct ftrace_func_entry *entry; 2562 - 2563 - if (ftrace_hash_empty(direct_functions) || 2564 - direct_functions->count > 2 * (1 << direct_functions->size_bits)) { 2565 - struct ftrace_hash *new_hash; 2566 - int size = ftrace_hash_empty(direct_functions) ? 0 : 2567 - direct_functions->count + 1; 2568 - 2569 - if (size < 32) 2570 - size = 32; 2571 - 2572 - new_hash = dup_hash(direct_functions, size); 2573 - if (!new_hash) 2574 - return NULL; 2575 - 2576 - *free_hash = direct_functions; 2577 - direct_functions = new_hash; 2578 - } 2579 - 2580 - entry = kmalloc(sizeof(*entry), GFP_KERNEL); 2581 - if (!entry) 2582 - return NULL; 2583 - 2584 - entry->ip = ip; 2585 - entry->direct = addr; 2586 - __add_hash_entry(direct_functions, entry); 2587 - return entry; 2588 2556 } 2589 2557 2590 2558 static void call_direct_funcs(unsigned long ip, unsigned long pip, ··· 4189 4223 /* Do nothing if it exists */ 4190 4224 if (entry) 4191 4225 return 0; 4192 - 4193 - ret = add_hash_entry(hash, rec->ip); 4226 + if (add_hash_entry(hash, rec->ip) == NULL) 4227 + ret = -ENOMEM; 4194 4228 } 4195 4229 return ret; 4196 4230 } ··· 5232 5266 return 0; 5233 5267 } 5234 5268 5235 - return add_hash_entry(hash, ip); 5269 + entry = add_hash_entry(hash, ip); 5270 + return entry ? 0 : -ENOMEM; 5236 5271 } 5237 5272 5238 5273 static int ··· 5377 5410 */ 5378 5411 int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr) 5379 5412 { 5380 - struct ftrace_hash *hash, *free_hash = NULL; 5413 + struct ftrace_hash *hash, *new_hash = NULL, *free_hash = NULL; 5381 5414 struct ftrace_func_entry *entry, *new; 5382 5415 int err = -EBUSY, size, i; 5383 5416 ··· 5403 5436 } 5404 5437 } 5405 5438 5406 - /* ... and insert them to direct_functions hash. */ 5407 5439 err = -ENOMEM; 5440 + 5441 + /* Make a copy hash to place the new and the old entries in */ 5442 + size = hash->count + direct_functions->count; 5443 + if (size > 32) 5444 + size = 32; 5445 + new_hash = alloc_ftrace_hash(fls(size)); 5446 + if (!new_hash) 5447 + goto out_unlock; 5448 + 5449 + /* Now copy over the existing direct entries */ 5450 + size = 1 << direct_functions->size_bits; 5451 + for (i = 0; i < size; i++) { 5452 + hlist_for_each_entry(entry, &direct_functions->buckets[i], hlist) { 5453 + new = add_hash_entry(new_hash, entry->ip); 5454 + if (!new) 5455 + goto out_unlock; 5456 + new->direct = entry->direct; 5457 + } 5458 + } 5459 + 5460 + /* ... and add the new entries */ 5461 + size = 1 << hash->size_bits; 5408 5462 for (i = 0; i < size; i++) { 5409 5463 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { 5410 - new = ftrace_add_rec_direct(entry->ip, addr, &free_hash); 5464 + new = add_hash_entry(new_hash, entry->ip); 5411 5465 if (!new) 5412 - goto out_remove; 5466 + goto out_unlock; 5467 + /* Update both the copy and the hash entry */ 5468 + new->direct = addr; 5413 5469 entry->direct = addr; 5414 5470 } 5415 5471 } 5472 + 5473 + free_hash = direct_functions; 5474 + rcu_assign_pointer(direct_functions, new_hash); 5475 + new_hash = NULL; 5416 5476 5417 5477 ops->func = call_direct_funcs; 5418 5478 ops->flags = MULTI_FLAGS; ··· 5448 5454 5449 5455 err = register_ftrace_function_nolock(ops); 5450 5456 5451 - out_remove: 5452 - if (err) 5453 - remove_direct_functions_hash(hash, addr); 5454 - 5455 5457 out_unlock: 5456 5458 mutex_unlock(&direct_mutex); 5457 5459 5458 - if (free_hash) { 5460 + if (free_hash && free_hash != EMPTY_HASH) { 5459 5461 synchronize_rcu_tasks(); 5460 5462 free_ftrace_hash(free_hash); 5461 5463 } 5464 + 5465 + if (new_hash) 5466 + free_ftrace_hash(new_hash); 5467 + 5462 5468 return err; 5463 5469 } 5464 5470 EXPORT_SYMBOL_GPL(register_ftrace_direct); ··· 6303 6309 6304 6310 if (entry) 6305 6311 continue; 6306 - if (add_hash_entry(hash, rec->ip) < 0) 6312 + if (add_hash_entry(hash, rec->ip) == NULL) 6307 6313 goto out; 6308 6314 } else { 6309 6315 if (entry) {
+9 -3
kernel/trace/ring_buffer.c
··· 881 881 if (!nr_pages || !full) 882 882 return true; 883 883 884 - dirty = ring_buffer_nr_dirty_pages(buffer, cpu); 884 + /* 885 + * Add one as dirty will never equal nr_pages, as the sub-buffer 886 + * that the writer is on is not counted as dirty. 887 + * This is needed if "buffer_percent" is set to 100. 888 + */ 889 + dirty = ring_buffer_nr_dirty_pages(buffer, cpu) + 1; 885 890 886 - return (dirty * 100) > (full * nr_pages); 891 + return (dirty * 100) >= (full * nr_pages); 887 892 } 888 893 889 894 /* ··· 949 944 /* make sure the waiters see the new index */ 950 945 smp_wmb(); 951 946 952 - rb_wake_up_waiters(&rbwork->work); 947 + /* This can be called in any context */ 948 + irq_work_queue(&rbwork->work); 953 949 } 954 950 955 951 /**
+11
kernel/trace/synth_event_gen_test.c
··· 477 477 478 478 ret = test_trace_synth_event(); 479 479 WARN_ON(ret); 480 + 481 + /* Disable when done */ 482 + trace_array_set_clr_event(gen_synth_test->tr, 483 + "synthetic", 484 + "gen_synth_test", false); 485 + trace_array_set_clr_event(empty_synth_test->tr, 486 + "synthetic", 487 + "empty_synth_test", false); 488 + trace_array_set_clr_event(create_synth_test->tr, 489 + "synthetic", 490 + "create_synth_test", false); 480 491 out: 481 492 return ret; 482 493 }
+17 -3
kernel/trace/trace.c
··· 1894 1894 __update_max_tr(tr, tsk, cpu); 1895 1895 1896 1896 arch_spin_unlock(&tr->max_lock); 1897 + 1898 + /* Any waiters on the old snapshot buffer need to wake up */ 1899 + ring_buffer_wake_waiters(tr->array_buffer.buffer, RING_BUFFER_ALL_CPUS); 1897 1900 } 1898 1901 1899 1902 /** ··· 1948 1945 1949 1946 static int wait_on_pipe(struct trace_iterator *iter, int full) 1950 1947 { 1948 + int ret; 1949 + 1951 1950 /* Iterators are static, they should be filled or empty */ 1952 1951 if (trace_buffer_iter(iter, iter->cpu_file)) 1953 1952 return 0; 1954 1953 1955 - return ring_buffer_wait(iter->array_buffer->buffer, iter->cpu_file, 1956 - full); 1954 + ret = ring_buffer_wait(iter->array_buffer->buffer, iter->cpu_file, full); 1955 + 1956 + #ifdef CONFIG_TRACER_MAX_TRACE 1957 + /* 1958 + * Make sure this is still the snapshot buffer, as if a snapshot were 1959 + * to happen, this would now be the main buffer. 1960 + */ 1961 + if (iter->snapshot) 1962 + iter->array_buffer = &iter->tr->max_buffer; 1963 + #endif 1964 + return ret; 1957 1965 } 1958 1966 1959 1967 #ifdef CONFIG_FTRACE_STARTUP_TEST ··· 8531 8517 8532 8518 wait_index = READ_ONCE(iter->wait_index); 8533 8519 8534 - ret = wait_on_pipe(iter, iter->tr->buffer_percent); 8520 + ret = wait_on_pipe(iter, iter->snapshot ? 0 : iter->tr->buffer_percent); 8535 8521 if (ret) 8536 8522 goto out; 8537 8523
+2 -2
kernel/trace/trace_events_synth.c
··· 1137 1137 * @cmd: A pointer to the dynevent_cmd struct representing the new event 1138 1138 * @name: The name of the synthetic event 1139 1139 * @mod: The module creating the event, NULL if not created from a module 1140 - * @args: Variable number of arg (pairs), one pair for each field 1140 + * @...: Variable number of arg (pairs), one pair for each field 1141 1141 * 1142 1142 * NOTE: Users normally won't want to call this function directly, but 1143 1143 * rather use the synth_event_gen_cmd_start() wrapper, which ··· 1695 1695 * synth_event_trace - Trace a synthetic event 1696 1696 * @file: The trace_event_file representing the synthetic event 1697 1697 * @n_vals: The number of values in vals 1698 - * @args: Variable number of args containing the event values 1698 + * @...: Variable number of args containing the event values 1699 1699 * 1700 1700 * Trace a synthetic event using the values passed in the variable 1701 1701 * argument list.
+1 -1
lib/idr.c
··· 508 508 goto delete; 509 509 xas_store(&xas, xa_mk_value(v)); 510 510 } else { 511 - if (!test_bit(bit, bitmap->bitmap)) 511 + if (!bitmap || !test_bit(bit, bitmap->bitmap)) 512 512 goto err; 513 513 __clear_bit(bit, bitmap->bitmap); 514 514 xas_set_mark(&xas, XA_FREE_MARK);
+11
lib/maple_tree.c
··· 5501 5501 5502 5502 mas_wr_end_piv(&wr_mas); 5503 5503 node_size = mas_wr_new_end(&wr_mas); 5504 + 5505 + /* Slot store, does not require additional nodes */ 5506 + if (node_size == wr_mas.node_end) { 5507 + /* reuse node */ 5508 + if (!mt_in_rcu(mas->tree)) 5509 + return 0; 5510 + /* shifting boundary */ 5511 + if (wr_mas.offset_end - mas->offset == 1) 5512 + return 0; 5513 + } 5514 + 5504 5515 if (node_size >= mt_slots[wr_mas.type]) { 5505 5516 /* Split, worst case for now. */ 5506 5517 request = 1 + mas_mt_height(mas) * 2;
+40
lib/test_ida.c
··· 150 150 IDA_BUG_ON(ida, !ida_is_empty(ida)); 151 151 } 152 152 153 + /* 154 + * Check various situations where we attempt to free an ID we don't own. 155 + */ 156 + static void ida_check_bad_free(struct ida *ida) 157 + { 158 + unsigned long i; 159 + 160 + printk("vvv Ignore \"not allocated\" warnings\n"); 161 + /* IDA is empty; all of these will fail */ 162 + ida_free(ida, 0); 163 + for (i = 0; i < 31; i++) 164 + ida_free(ida, 1 << i); 165 + 166 + /* IDA contains a single value entry */ 167 + IDA_BUG_ON(ida, ida_alloc_min(ida, 3, GFP_KERNEL) != 3); 168 + ida_free(ida, 0); 169 + for (i = 0; i < 31; i++) 170 + ida_free(ida, 1 << i); 171 + 172 + /* IDA contains a single bitmap */ 173 + IDA_BUG_ON(ida, ida_alloc_min(ida, 1023, GFP_KERNEL) != 1023); 174 + ida_free(ida, 0); 175 + for (i = 0; i < 31; i++) 176 + ida_free(ida, 1 << i); 177 + 178 + /* IDA contains a tree */ 179 + IDA_BUG_ON(ida, ida_alloc_min(ida, (1 << 20) - 1, GFP_KERNEL) != (1 << 20) - 1); 180 + ida_free(ida, 0); 181 + for (i = 0; i < 31; i++) 182 + ida_free(ida, 1 << i); 183 + printk("^^^ \"not allocated\" warnings over\n"); 184 + 185 + ida_free(ida, 3); 186 + ida_free(ida, 1023); 187 + ida_free(ida, (1 << 20) - 1); 188 + 189 + IDA_BUG_ON(ida, !ida_is_empty(ida)); 190 + } 191 + 153 192 static DEFINE_IDA(ida); 154 193 155 194 static int ida_checks(void) ··· 201 162 ida_check_leaf(&ida, 1024 * 64); 202 163 ida_check_max(&ida); 203 164 ida_check_conv(&ida); 165 + ida_check_bad_free(&ida); 204 166 205 167 printk("IDA: %u of %u tests passed\n", tests_passed, tests_run); 206 168 return (tests_run != tests_passed) ? 0 : -EINVAL;
+8 -3
lib/vsprintf.c
··· 2111 2111 2112 2112 /* Loop starting from the root node to the current node. */ 2113 2113 for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) { 2114 - struct fwnode_handle *__fwnode = 2115 - fwnode_get_nth_parent(fwnode, depth); 2114 + /* 2115 + * Only get a reference for other nodes (i.e. parent nodes). 2116 + * fwnode refcount may be 0 here. 2117 + */ 2118 + struct fwnode_handle *__fwnode = depth ? 2119 + fwnode_get_nth_parent(fwnode, depth) : fwnode; 2116 2120 2117 2121 buf = string(buf, end, fwnode_get_name_prefix(__fwnode), 2118 2122 default_str_spec); 2119 2123 buf = string(buf, end, fwnode_get_name(__fwnode), 2120 2124 default_str_spec); 2121 2125 2122 - fwnode_handle_put(__fwnode); 2126 + if (depth) 2127 + fwnode_handle_put(__fwnode); 2123 2128 } 2124 2129 2125 2130 return buf;
+9
mm/filemap.c
··· 2608 2608 end_offset = min_t(loff_t, isize, iocb->ki_pos + iter->count); 2609 2609 2610 2610 /* 2611 + * Pairs with a barrier in 2612 + * block_write_end()->mark_buffer_dirty() or other page 2613 + * dirtying routines like iomap_write_end() to ensure 2614 + * changes to page contents are visible before we see 2615 + * increased inode size. 2616 + */ 2617 + smp_rmb(); 2618 + 2619 + /* 2611 2620 * Once we start copying data, we don't want to be touching any 2612 2621 * cachelines that might be contended: 2613 2622 */
+16 -4
mm/kasan/kasan_test.c
··· 493 493 { 494 494 char *ptr; 495 495 size_t size = 128 - KASAN_GRANULE_SIZE; 496 + size_t memset_size = 2; 496 497 497 498 KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); 498 499 499 500 ptr = kmalloc(size, GFP_KERNEL); 500 501 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 501 502 503 + OPTIMIZER_HIDE_VAR(ptr); 502 504 OPTIMIZER_HIDE_VAR(size); 503 - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2)); 505 + OPTIMIZER_HIDE_VAR(memset_size); 506 + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, memset_size)); 504 507 kfree(ptr); 505 508 } 506 509 ··· 511 508 { 512 509 char *ptr; 513 510 size_t size = 128 - KASAN_GRANULE_SIZE; 511 + size_t memset_size = 4; 514 512 515 513 KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); 516 514 517 515 ptr = kmalloc(size, GFP_KERNEL); 518 516 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 519 517 518 + OPTIMIZER_HIDE_VAR(ptr); 520 519 OPTIMIZER_HIDE_VAR(size); 521 - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4)); 520 + OPTIMIZER_HIDE_VAR(memset_size); 521 + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, memset_size)); 522 522 kfree(ptr); 523 523 } 524 524 ··· 529 523 { 530 524 char *ptr; 531 525 size_t size = 128 - KASAN_GRANULE_SIZE; 526 + size_t memset_size = 8; 532 527 533 528 KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); 534 529 535 530 ptr = kmalloc(size, GFP_KERNEL); 536 531 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 537 532 533 + OPTIMIZER_HIDE_VAR(ptr); 538 534 OPTIMIZER_HIDE_VAR(size); 539 - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8)); 535 + OPTIMIZER_HIDE_VAR(memset_size); 536 + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, memset_size)); 540 537 kfree(ptr); 541 538 } 542 539 ··· 547 538 { 548 539 char *ptr; 549 540 size_t size = 128 - KASAN_GRANULE_SIZE; 541 + size_t memset_size = 16; 550 542 551 543 KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); 552 544 553 545 ptr = kmalloc(size, GFP_KERNEL); 554 546 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); 555 547 548 + OPTIMIZER_HIDE_VAR(ptr); 556 549 OPTIMIZER_HIDE_VAR(size); 557 - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16)); 550 + OPTIMIZER_HIDE_VAR(memset_size); 551 + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, memset_size)); 558 552 kfree(ptr); 559 553 } 560 554
+16 -17
mm/memory-failure.c
··· 595 595 /* 596 596 * Collect processes when the error hit an anonymous page. 597 597 */ 598 - static void collect_procs_anon(struct page *page, struct list_head *to_kill, 599 - int force_early) 598 + static void collect_procs_anon(struct folio *folio, struct page *page, 599 + struct list_head *to_kill, int force_early) 600 600 { 601 - struct folio *folio = page_folio(page); 602 601 struct vm_area_struct *vma; 603 602 struct task_struct *tsk; 604 603 struct anon_vma *av; ··· 632 633 /* 633 634 * Collect processes when the error hit a file mapped page. 634 635 */ 635 - static void collect_procs_file(struct page *page, struct list_head *to_kill, 636 - int force_early) 636 + static void collect_procs_file(struct folio *folio, struct page *page, 637 + struct list_head *to_kill, int force_early) 637 638 { 638 639 struct vm_area_struct *vma; 639 640 struct task_struct *tsk; 640 - struct address_space *mapping = page->mapping; 641 + struct address_space *mapping = folio->mapping; 641 642 pgoff_t pgoff; 642 643 643 644 i_mmap_lock_read(mapping); ··· 703 704 /* 704 705 * Collect the processes who have the corrupted page mapped to kill. 705 706 */ 706 - static void collect_procs(struct page *page, struct list_head *tokill, 707 - int force_early) 707 + static void collect_procs(struct folio *folio, struct page *page, 708 + struct list_head *tokill, int force_early) 708 709 { 709 - if (!page->mapping) 710 + if (!folio->mapping) 710 711 return; 711 712 if (unlikely(PageKsm(page))) 712 713 collect_procs_ksm(page, tokill, force_early); 713 714 else if (PageAnon(page)) 714 - collect_procs_anon(page, tokill, force_early); 715 + collect_procs_anon(folio, page, tokill, force_early); 715 716 else 716 - collect_procs_file(page, tokill, force_early); 717 + collect_procs_file(folio, page, tokill, force_early); 717 718 } 718 719 719 720 struct hwpoison_walk { ··· 1570 1571 * This check implies we don't kill processes if their pages 1571 1572 * are in the swap cache early. Those are always late kills. 1572 1573 */ 1573 - if (!page_mapped(hpage)) 1574 + if (!page_mapped(p)) 1574 1575 return true; 1575 1576 1576 1577 if (PageSwapCache(p)) { ··· 1601 1602 * mapped in dirty form. This has to be done before try_to_unmap, 1602 1603 * because ttu takes the rmap data structures down. 1603 1604 */ 1604 - collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED); 1605 + collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); 1605 1606 1606 1607 if (PageHuge(hpage) && !PageAnon(hpage)) { 1607 1608 /* ··· 1621 1622 try_to_unmap(folio, ttu); 1622 1623 } 1623 1624 1624 - unmap_success = !page_mapped(hpage); 1625 + unmap_success = !page_mapped(p); 1625 1626 if (!unmap_success) 1626 1627 pr_err("%#lx: failed to unmap page (mapcount=%d)\n", 1627 - pfn, page_mapcount(hpage)); 1628 + pfn, page_mapcount(p)); 1628 1629 1629 1630 /* 1630 1631 * try_to_unmap() might put mlocked page in lru cache, so call ··· 1704 1705 * mapping being torn down is communicated in siginfo, see 1705 1706 * kill_proc() 1706 1707 */ 1707 - loff_t start = (index << PAGE_SHIFT) & ~(size - 1); 1708 + loff_t start = ((loff_t)index << PAGE_SHIFT) & ~(size - 1); 1708 1709 1709 1710 unmap_mapping_range(mapping, start, size, 0); 1710 1711 } ··· 1771 1772 * SIGBUS (i.e. MF_MUST_KILL) 1772 1773 */ 1773 1774 flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; 1774 - collect_procs(&folio->page, &to_kill, true); 1775 + collect_procs(folio, &folio->page, &to_kill, true); 1775 1776 1776 1777 unmap_and_kill(&to_kill, pfn, folio->mapping, folio->index, flags); 1777 1778 unlock:
+8 -1
mm/migrate.c
··· 405 405 int dirty; 406 406 int expected_count = folio_expected_refs(mapping, folio) + extra_count; 407 407 long nr = folio_nr_pages(folio); 408 + long entries, i; 408 409 409 410 if (!mapping) { 410 411 /* Anonymous page without mapping */ ··· 443 442 folio_set_swapcache(newfolio); 444 443 newfolio->private = folio_get_private(folio); 445 444 } 445 + entries = nr; 446 446 } else { 447 447 VM_BUG_ON_FOLIO(folio_test_swapcache(folio), folio); 448 + entries = 1; 448 449 } 449 450 450 451 /* Move dirty while page refs frozen and newpage not yet exposed */ ··· 456 453 folio_set_dirty(newfolio); 457 454 } 458 455 459 - xas_store(&xas, newfolio); 456 + /* Swap cache still stores N entries instead of a high-order entry */ 457 + for (i = 0; i < entries; i++) { 458 + xas_store(&xas, newfolio); 459 + xas_next(&xas); 460 + } 460 461 461 462 /* 462 463 * Drop cache reference from old page by unfreezing
+13 -4
net/9p/protocol.c
··· 394 394 uint16_t *nwname = va_arg(ap, uint16_t *); 395 395 char ***wnames = va_arg(ap, char ***); 396 396 397 + *wnames = NULL; 398 + 397 399 errcode = p9pdu_readf(pdu, proto_version, 398 400 "w", nwname); 399 401 if (!errcode) { ··· 405 403 GFP_NOFS); 406 404 if (!*wnames) 407 405 errcode = -ENOMEM; 406 + else 407 + (*wnames)[0] = NULL; 408 408 } 409 409 410 410 if (!errcode) { ··· 418 414 proto_version, 419 415 "s", 420 416 &(*wnames)[i]); 421 - if (errcode) 417 + if (errcode) { 418 + (*wnames)[i] = NULL; 422 419 break; 420 + } 423 421 } 424 422 } 425 423 ··· 429 423 if (*wnames) { 430 424 int i; 431 425 432 - for (i = 0; i < *nwname; i++) 426 + for (i = 0; i < *nwname; i++) { 427 + if (!(*wnames)[i]) 428 + break; 433 429 kfree((*wnames)[i]); 430 + } 431 + kfree(*wnames); 432 + *wnames = NULL; 434 433 } 435 - kfree(*wnames); 436 - *wnames = NULL; 437 434 } 438 435 } 439 436 break;
+10 -2
net/core/sock.c
··· 1707 1707 break; 1708 1708 1709 1709 case SO_TIMESTAMPING_OLD: 1710 + case SO_TIMESTAMPING_NEW: 1710 1711 lv = sizeof(v.timestamping); 1711 - v.timestamping.flags = READ_ONCE(sk->sk_tsflags); 1712 - v.timestamping.bind_phc = READ_ONCE(sk->sk_bind_phc); 1712 + /* For the later-added case SO_TIMESTAMPING_NEW: Be strict about only 1713 + * returning the flags when they were set through the same option. 1714 + * Don't change the beviour for the old case SO_TIMESTAMPING_OLD. 1715 + */ 1716 + if (optname == SO_TIMESTAMPING_OLD || sock_flag(sk, SOCK_TSTAMP_NEW)) { 1717 + v.timestamping.flags = READ_ONCE(sk->sk_tsflags); 1718 + v.timestamping.bind_phc = READ_ONCE(sk->sk_bind_phc); 1719 + } 1713 1720 break; 1714 1721 1715 1722 case SO_RCVTIMEO_OLD: ··· 2809 2802 sockc->mark = *(u32 *)CMSG_DATA(cmsg); 2810 2803 break; 2811 2804 case SO_TIMESTAMPING_OLD: 2805 + case SO_TIMESTAMPING_NEW: 2812 2806 if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32))) 2813 2807 return -EINVAL; 2814 2808
+16 -9
net/dns_resolver/dns_key.c
··· 91 91 static int 92 92 dns_resolver_preparse(struct key_preparsed_payload *prep) 93 93 { 94 - const struct dns_payload_header *bin; 95 94 struct user_key_payload *upayload; 96 95 unsigned long derrno; 97 96 int ret; ··· 101 102 return -EINVAL; 102 103 103 104 if (data[0] == 0) { 105 + const struct dns_server_list_v1_header *v1; 106 + 104 107 /* It may be a server list. */ 105 - if (datalen <= sizeof(*bin)) 108 + if (datalen <= sizeof(*v1)) 106 109 return -EINVAL; 107 110 108 - bin = (const struct dns_payload_header *)data; 109 - kenter("[%u,%u],%u", bin->content, bin->version, datalen); 110 - if (bin->content != DNS_PAYLOAD_IS_SERVER_LIST) { 111 + v1 = (const struct dns_server_list_v1_header *)data; 112 + kenter("[%u,%u],%u", v1->hdr.content, v1->hdr.version, datalen); 113 + if (v1->hdr.content != DNS_PAYLOAD_IS_SERVER_LIST) { 111 114 pr_warn_ratelimited( 112 115 "dns_resolver: Unsupported content type (%u)\n", 113 - bin->content); 116 + v1->hdr.content); 114 117 return -EINVAL; 115 118 } 116 119 117 - if (bin->version != 1) { 120 + if (v1->hdr.version != 1) { 118 121 pr_warn_ratelimited( 119 122 "dns_resolver: Unsupported server list version (%u)\n", 120 - bin->version); 123 + v1->hdr.version); 121 124 return -EINVAL; 125 + } 126 + 127 + if ((v1->status != DNS_LOOKUP_GOOD && 128 + v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) { 129 + if (prep->expiry == TIME64_MAX) 130 + prep->expiry = ktime_get_real_seconds() + 1; 122 131 } 123 132 124 133 result_len = datalen; ··· 321 314 322 315 struct key_type key_type_dns_resolver = { 323 316 .name = "dns_resolver", 324 - .flags = KEY_TYPE_NET_DOMAIN, 317 + .flags = KEY_TYPE_NET_DOMAIN | KEY_TYPE_INSTANT_REAP, 325 318 .preparse = dns_resolver_preparse, 326 319 .free_preparse = dns_resolver_free_preparse, 327 320 .instantiate = generic_key_instantiate,
+2 -3
net/ipv4/tcp_sigpool.c
··· 162 162 if (strcmp(cpool[i].alg, alg)) 163 163 continue; 164 164 165 - if (kref_read(&cpool[i].kref) > 0) 166 - kref_get(&cpool[i].kref); 167 - else 165 + /* pairs with tcp_sigpool_release() */ 166 + if (!kref_get_unless_zero(&cpool[i].kref)) 168 167 kref_init(&cpool[i].kref); 169 168 ret = i; 170 169 goto out;
+5 -13
net/ipv6/addrconf.c
··· 1407 1407 1408 1408 write_unlock_bh(&idev->lock); 1409 1409 1410 - /* From RFC 4941: 1411 - * 1412 - * A temporary address is created only if this calculated Preferred 1413 - * Lifetime is greater than REGEN_ADVANCE time units. In 1414 - * particular, an implementation must not create a temporary address 1415 - * with a zero Preferred Lifetime. 1416 - * 1417 - * Clamp the preferred lifetime to a minimum of regen_advance, unless 1418 - * that would exceed valid_lft. 1419 - * 1410 + /* A temporary address is created only if this calculated Preferred 1411 + * Lifetime is greater than REGEN_ADVANCE time units. In particular, 1412 + * an implementation must not create a temporary address with a zero 1413 + * Preferred Lifetime. 1420 1414 * Use age calculation as in addrconf_verify to avoid unnecessary 1421 1415 * temporary addresses being generated. 1422 1416 */ 1423 1417 age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; 1424 - if (cfg.preferred_lft <= regen_advance + age) 1425 - cfg.preferred_lft = regen_advance + age + 1; 1426 - if (cfg.preferred_lft > cfg.valid_lft) { 1418 + if (cfg.preferred_lft <= regen_advance + age) { 1427 1419 in6_ifa_put(ifp); 1428 1420 in6_dev_put(idev); 1429 1421 ret = -1;
+6 -3
net/mac80211/debugfs_netdev.c
··· 1043 1043 { 1044 1044 ieee80211_debugfs_remove_netdev(sdata); 1045 1045 ieee80211_debugfs_add_netdev(sdata, mld_vif); 1046 - drv_vif_add_debugfs(sdata->local, sdata); 1047 - if (!mld_vif) 1048 - ieee80211_link_debugfs_drv_add(&sdata->deflink); 1046 + 1047 + if (sdata->flags & IEEE80211_SDATA_IN_DRIVER) { 1048 + drv_vif_add_debugfs(sdata->local, sdata); 1049 + if (!mld_vif) 1050 + ieee80211_link_debugfs_drv_add(&sdata->deflink); 1051 + } 1049 1052 } 1050 1053 1051 1054 void ieee80211_link_debugfs_add(struct ieee80211_link_data *link)
+9 -5
net/mac80211/driver-ops.c
··· 75 75 if (ret) 76 76 return ret; 77 77 78 - sdata->flags |= IEEE80211_SDATA_IN_DRIVER; 78 + if (!(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) { 79 + sdata->flags |= IEEE80211_SDATA_IN_DRIVER; 79 80 80 - if (!local->in_reconfig) { 81 81 drv_vif_add_debugfs(local, sdata); 82 82 /* initially vif is not MLD */ 83 83 ieee80211_link_debugfs_drv_add(&sdata->deflink); ··· 113 113 if (!check_sdata_in_driver(sdata)) 114 114 return; 115 115 116 + sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; 117 + 118 + /* Remove driver debugfs entries */ 119 + ieee80211_debugfs_recreate_netdev(sdata, sdata->vif.valid_links); 120 + 116 121 trace_drv_remove_interface(local, sdata); 117 122 local->ops->remove_interface(&local->hw, &sdata->vif); 118 - sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; 119 123 trace_drv_return_void(local); 120 124 } 121 125 ··· 538 534 if (ret) 539 535 return ret; 540 536 541 - if (!local->in_reconfig) { 537 + if (!local->in_reconfig && !local->resuming) { 542 538 for_each_set_bit(link_id, &links_to_add, 543 539 IEEE80211_MLD_MAX_NUM_LINKS) { 544 540 link = rcu_access_pointer(sdata->link[link_id]); ··· 594 590 return ret; 595 591 596 592 /* during reconfig don't add it to debugfs again */ 597 - if (local->in_reconfig) 593 + if (local->in_reconfig || local->resuming) 598 594 return 0; 599 595 600 596 for_each_set_bit(link_id, &links_to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
+13
net/mptcp/subflow.c
··· 1982 1982 tcp_release_cb(ssk); 1983 1983 } 1984 1984 1985 + static int tcp_abort_override(struct sock *ssk, int err) 1986 + { 1987 + /* closing a listener subflow requires a great deal of care. 1988 + * keep it simple and just prevent such operation 1989 + */ 1990 + if (inet_sk_state_load(ssk) == TCP_LISTEN) 1991 + return -EINVAL; 1992 + 1993 + return tcp_abort(ssk, err); 1994 + } 1995 + 1985 1996 static struct tcp_ulp_ops subflow_ulp_ops __read_mostly = { 1986 1997 .name = "mptcp", 1987 1998 .owner = THIS_MODULE, ··· 2037 2026 2038 2027 tcp_prot_override = tcp_prot; 2039 2028 tcp_prot_override.release_cb = tcp_release_cb_override; 2029 + tcp_prot_override.diag_destroy = tcp_abort_override; 2040 2030 2041 2031 #if IS_ENABLED(CONFIG_MPTCP_IPV6) 2042 2032 /* In struct mptcp_subflow_request_sock, we assume the TCP request sock ··· 2073 2061 2074 2062 tcpv6_prot_override = tcpv6_prot; 2075 2063 tcpv6_prot_override.release_cb = tcp_release_cb_override; 2064 + tcpv6_prot_override.diag_destroy = tcp_abort_override; 2076 2065 #endif 2077 2066 2078 2067 mptcp_diag_subflow_init(&subflow_ulp_ops);
+2 -1
net/netfilter/nf_nat_ovs.c
··· 75 75 } 76 76 77 77 err = nf_nat_packet(ct, ctinfo, hooknum, skb); 78 + out: 78 79 if (err == NF_ACCEPT) 79 80 *action |= BIT(maniptype); 80 - out: 81 + 81 82 return err; 82 83 } 83 84
+1 -1
net/netfilter/nf_tables_api.c
··· 9977 9977 list_for_each_entry_safe(set, next, set_update_list, pending_update) { 9978 9978 list_del_init(&set->pending_update); 9979 9979 9980 - if (!set->ops->commit) 9980 + if (!set->ops->commit || set->dead) 9981 9981 continue; 9982 9982 9983 9983 set->ops->commit(set);
+1 -1
net/netfilter/nf_tables_core.c
··· 158 158 else { 159 159 if (!(pkt->flags & NFT_PKTINFO_L4PROTO)) 160 160 return false; 161 - ptr = skb_network_header(skb) + nft_thoff(pkt); 161 + ptr = skb->data + nft_thoff(pkt); 162 162 } 163 163 164 164 ptr += priv->offset;
+1 -1
net/netfilter/nft_immediate.c
··· 78 78 case NFT_GOTO: 79 79 err = nf_tables_bind_chain(ctx, chain); 80 80 if (err < 0) 81 - return err; 81 + goto err1; 82 82 break; 83 83 default: 84 84 break;
+36 -3
net/nfc/llcp_core.c
··· 145 145 146 146 static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) 147 147 { 148 + /* Since using nfc_llcp_local may result in usage of nfc_dev, whenever 149 + * we hold a reference to local, we also need to hold a reference to 150 + * the device to avoid UAF. 151 + */ 152 + if (!nfc_get_device(local->dev->idx)) 153 + return NULL; 154 + 148 155 kref_get(&local->ref); 149 156 150 157 return local; ··· 184 177 185 178 int nfc_llcp_local_put(struct nfc_llcp_local *local) 186 179 { 180 + struct nfc_dev *dev; 181 + int ret; 182 + 187 183 if (local == NULL) 188 184 return 0; 189 185 190 - return kref_put(&local->ref, local_release); 186 + dev = local->dev; 187 + 188 + ret = kref_put(&local->ref, local_release); 189 + nfc_put_device(dev); 190 + 191 + return ret; 191 192 } 192 193 193 194 static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, ··· 974 959 } 975 960 976 961 new_sock = nfc_llcp_sock(new_sk); 977 - new_sock->dev = local->dev; 962 + 978 963 new_sock->local = nfc_llcp_local_get(local); 964 + if (!new_sock->local) { 965 + reason = LLCP_DM_REJ; 966 + sock_put(&new_sock->sk); 967 + release_sock(&sock->sk); 968 + sock_put(&sock->sk); 969 + goto fail; 970 + } 971 + 972 + new_sock->dev = local->dev; 979 973 new_sock->rw = sock->rw; 980 974 new_sock->miux = sock->miux; 981 975 new_sock->nfc_protocol = sock->nfc_protocol; ··· 1621 1597 if (local == NULL) 1622 1598 return -ENOMEM; 1623 1599 1624 - local->dev = ndev; 1600 + /* As we are going to initialize local's refcount, we need to get the 1601 + * nfc_dev to avoid UAF, otherwise there is no point in continuing. 1602 + * See nfc_llcp_local_get(). 1603 + */ 1604 + local->dev = nfc_get_device(ndev->idx); 1605 + if (!local->dev) { 1606 + kfree(local); 1607 + return -ENODEV; 1608 + } 1609 + 1625 1610 INIT_LIST_HEAD(&local->list); 1626 1611 kref_init(&local->ref); 1627 1612 mutex_init(&local->sdp_lock);
+5
net/nfc/llcp_sock.c
··· 796 796 } 797 797 798 798 if (sk->sk_type == SOCK_DGRAM) { 799 + if (sk->sk_state != LLCP_BOUND) { 800 + release_sock(sk); 801 + return -ENOTCONN; 802 + } 803 + 799 804 DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, 800 805 msg->msg_name); 801 806
+3 -1
net/qrtr/ns.c
··· 512 512 if (!node) 513 513 return -ENOENT; 514 514 515 - return server_del(node, port, true); 515 + server_del(node, port, true); 516 + 517 + return 0; 516 518 } 517 519 518 520 static int ctrl_cmd_new_lookup(struct sockaddr_qrtr *from,
+3 -1
net/sched/em_text.c
··· 97 97 98 98 static void em_text_destroy(struct tcf_ematch *m) 99 99 { 100 - if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config) 100 + if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config) { 101 101 textsearch_destroy(EM_TEXT_PRIV(m)->config); 102 + kfree(EM_TEXT_PRIV(m)); 103 + } 102 104 } 103 105 104 106 static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
+1 -2
net/smc/smc_diag.c
··· 154 154 .lnk[0].link_id = link->link_id, 155 155 }; 156 156 157 - memcpy(linfo.lnk[0].ibname, 158 - smc->conn.lgr->lnk[0].smcibdev->ibdev->name, 157 + memcpy(linfo.lnk[0].ibname, link->smcibdev->ibdev->name, 159 158 sizeof(link->smcibdev->ibdev->name)); 160 159 smc_gid_be16_convert(linfo.lnk[0].gid, link->gid); 161 160 smc_gid_be16_convert(linfo.lnk[0].peer_gid, link->peer_gid);
+2
net/socket.c
··· 757 757 { 758 758 struct sockaddr_storage *save_addr = (struct sockaddr_storage *)msg->msg_name; 759 759 struct sockaddr_storage address; 760 + int save_len = msg->msg_namelen; 760 761 int ret; 761 762 762 763 if (msg->msg_name) { ··· 767 766 768 767 ret = __sock_sendmsg(sock, msg); 769 768 msg->msg_name = save_addr; 769 + msg->msg_namelen = save_len; 770 770 771 771 return ret; 772 772 }
+1 -1
scripts/Makefile.vdsoinst
··· 22 22 23 23 # Some architectures create .build-id symlinks 24 24 ifneq ($(filter arm sparc x86, $(SRCARCH)),) 25 - link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') 25 + link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug 26 26 27 27 __default: $$(link) 28 28 $$(link): $$(dest) FORCE
+3 -3
scripts/clang-tools/gen_compile_commands.py
··· 64 64 args = parser.parse_args() 65 65 66 66 return (args.log_level, 67 - os.path.abspath(args.directory), 67 + os.path.realpath(args.directory), 68 68 args.output, 69 69 args.ar, 70 70 args.paths if len(args.paths) > 0 else [args.directory]) ··· 172 172 # by Make, so this code replaces the escaped version with '#'. 173 173 prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') 174 174 175 - # Use os.path.abspath() to normalize the path resolving '.' and '..' . 176 - abs_path = os.path.abspath(os.path.join(root_directory, file_path)) 175 + # Return the canonical path, eliminating any symbolic links encountered in the path. 176 + abs_path = os.path.realpath(os.path.join(root_directory, file_path)) 177 177 if not os.path.exists(abs_path): 178 178 raise ValueError('File %s not found' % abs_path) 179 179 return {
+28 -20
scripts/get_maintainer.pl
··· 20 20 use Cwd; 21 21 use File::Find; 22 22 use File::Spec::Functions; 23 + use open qw(:std :encoding(UTF-8)); 23 24 24 25 my $cur_path = fastgetcwd() . '/'; 25 26 my $lk_path = "./"; ··· 446 445 my $text = do { local($/) ; <$f> }; 447 446 close($f); 448 447 449 - my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g; 448 + my @poss_addr = $text =~ m$[\p{L}\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g; 450 449 push(@file_emails, clean_file_emails(@poss_addr)); 451 450 } 452 451 } ··· 1153 1152 return 0; 1154 1153 } 1155 1154 1155 + sub escape_name { 1156 + my ($name) = @_; 1157 + 1158 + if ($name =~ /[^\w \-]/ai) { ##has "must quote" chars 1159 + $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 1160 + $name = "\"$name\""; 1161 + } 1162 + 1163 + return $name; 1164 + } 1165 + 1156 1166 sub parse_email { 1157 1167 my ($formatted_email) = @_; 1158 1168 ··· 1181 1169 1182 1170 $name =~ s/^\s+|\s+$//g; 1183 1171 $name =~ s/^\"|\"$//g; 1172 + $name = escape_name($name); 1184 1173 $address =~ s/^\s+|\s+$//g; 1185 - 1186 - if ($name =~ /[^\w \-]/i) { ##has "must quote" chars 1187 - $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 1188 - $name = "\"$name\""; 1189 - } 1190 1174 1191 1175 return ($name, $address); 1192 1176 } ··· 1194 1186 1195 1187 $name =~ s/^\s+|\s+$//g; 1196 1188 $name =~ s/^\"|\"$//g; 1189 + $name = escape_name($name); 1197 1190 $address =~ s/^\s+|\s+$//g; 1198 - 1199 - if ($name =~ /[^\w \-]/i) { ##has "must quote" chars 1200 - $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 1201 - $name = "\"$name\""; 1202 - } 1203 1191 1204 1192 if ($usename) { 1205 1193 if ("$name" eq "") { ··· 2462 2458 foreach my $email (@file_emails) { 2463 2459 $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g; 2464 2460 my ($name, $address) = parse_email($email); 2465 - if ($name eq '"[,\.]"') { 2466 - $name = ""; 2467 - } 2468 2461 2469 - my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name); 2462 + # Strip quotes for easier processing, format_email will add them back 2463 + $name =~ s/^"(.*)"$/$1/; 2464 + 2465 + # Split into name-like parts and remove stray punctuation particles 2466 + my @nw = split(/[^\p{L}\'\,\.\+-]/, $name); 2467 + @nw = grep(!/^[\'\,\.\+-]$/, @nw); 2468 + 2469 + # Make a best effort to extract the name, and only the name, by taking 2470 + # only the last two names, or in the case of obvious initials, the last 2471 + # three names. 2470 2472 if (@nw > 2) { 2471 2473 my $first = $nw[@nw - 3]; 2472 2474 my $middle = $nw[@nw - 2]; 2473 2475 my $last = $nw[@nw - 1]; 2474 2476 2475 - if (((length($first) == 1 && $first =~ m/[A-Za-z]/) || 2477 + if (((length($first) == 1 && $first =~ m/\p{L}/) || 2476 2478 (length($first) == 2 && substr($first, -1) eq ".")) || 2477 2479 (length($middle) == 1 || 2478 2480 (length($middle) == 2 && substr($middle, -1) eq "."))) { ··· 2486 2476 } else { 2487 2477 $name = "$middle $last"; 2488 2478 } 2479 + } else { 2480 + $name = "@nw"; 2489 2481 } 2490 2482 2491 2483 if (substr($name, -1) =~ /[,\.]/) { 2492 2484 $name = substr($name, 0, length($name) - 1); 2493 - } elsif (substr($name, -2) =~ /[,\.]"/) { 2494 - $name = substr($name, 0, length($name) - 2) . '"'; 2495 2485 } 2496 2486 2497 2487 if (substr($name, 0, 1) =~ /[,\.]/) { 2498 2488 $name = substr($name, 1, length($name) - 1); 2499 - } elsif (substr($name, 0, 2) =~ /"[,\.]/) { 2500 - $name = '"' . substr($name, 2, length($name) - 2); 2501 2489 } 2502 2490 2503 2491 my $fmt_email = format_email($name, $address, $email_usename);
+1
security/apparmor/apparmorfs.c
··· 2373 2373 2374 2374 static struct aa_sfs_entry aa_sfs_entry_mount[] = { 2375 2375 AA_SFS_FILE_STRING("mask", "mount umount pivot_root"), 2376 + AA_SFS_FILE_STRING("move_mount", "detached"), 2376 2377 { } 2377 2378 }; 2378 2379
+4
security/apparmor/mount.c
··· 499 499 error = -ENOMEM; 500 500 if (!to_buffer || !from_buffer) 501 501 goto out; 502 + 503 + if (!our_mnt(from_path->mnt)) 504 + /* moving a mount detached from the namespace */ 505 + from_path = NULL; 502 506 error = fn_for_each_confined(label, profile, 503 507 match_mnt(subj_cred, profile, to_path, to_buffer, 504 508 from_path, from_buffer,
+21 -10
security/keys/gc.c
··· 67 67 } 68 68 69 69 /* 70 + * Set the expiration time on a key. 71 + */ 72 + void key_set_expiry(struct key *key, time64_t expiry) 73 + { 74 + key->expiry = expiry; 75 + if (expiry != TIME64_MAX) { 76 + if (!(key->type->flags & KEY_TYPE_INSTANT_REAP)) 77 + expiry += key_gc_delay; 78 + key_schedule_gc(expiry); 79 + } 80 + } 81 + 82 + /* 70 83 * Schedule a dead links collection run. 71 84 */ 72 85 void key_schedule_gc_links(void) ··· 189 176 static u8 gc_state; /* Internal persistent state */ 190 177 #define KEY_GC_REAP_AGAIN 0x01 /* - Need another cycle */ 191 178 #define KEY_GC_REAPING_LINKS 0x02 /* - We need to reap links */ 192 - #define KEY_GC_SET_TIMER 0x04 /* - We need to restart the timer */ 193 179 #define KEY_GC_REAPING_DEAD_1 0x10 /* - We need to mark dead keys */ 194 180 #define KEY_GC_REAPING_DEAD_2 0x20 /* - We need to reap dead key links */ 195 181 #define KEY_GC_REAPING_DEAD_3 0x40 /* - We need to reap dead keys */ ··· 196 184 197 185 struct rb_node *cursor; 198 186 struct key *key; 199 - time64_t new_timer, limit; 187 + time64_t new_timer, limit, expiry; 200 188 201 189 kenter("[%lx,%x]", key_gc_flags, gc_state); 202 190 203 191 limit = ktime_get_real_seconds(); 204 - if (limit > key_gc_delay) 205 - limit -= key_gc_delay; 206 - else 207 - limit = key_gc_delay; 208 192 209 193 /* Work out what we're going to be doing in this pass */ 210 194 gc_state &= KEY_GC_REAPING_DEAD_1 | KEY_GC_REAPING_DEAD_2; 211 195 gc_state <<= 1; 212 196 if (test_and_clear_bit(KEY_GC_KEY_EXPIRED, &key_gc_flags)) 213 - gc_state |= KEY_GC_REAPING_LINKS | KEY_GC_SET_TIMER; 197 + gc_state |= KEY_GC_REAPING_LINKS; 214 198 215 199 if (test_and_clear_bit(KEY_GC_REAP_KEYTYPE, &key_gc_flags)) 216 200 gc_state |= KEY_GC_REAPING_DEAD_1; ··· 241 233 } 242 234 } 243 235 244 - if (gc_state & KEY_GC_SET_TIMER) { 245 - if (key->expiry > limit && key->expiry < new_timer) { 236 + expiry = key->expiry; 237 + if (expiry != TIME64_MAX) { 238 + if (!(key->type->flags & KEY_TYPE_INSTANT_REAP)) 239 + expiry += key_gc_delay; 240 + if (expiry > limit && expiry < new_timer) { 246 241 kdebug("will expire %x in %lld", 247 242 key_serial(key), key->expiry - limit); 248 243 new_timer = key->expiry; ··· 287 276 */ 288 277 kdebug("pass complete"); 289 278 290 - if (gc_state & KEY_GC_SET_TIMER && new_timer != (time64_t)TIME64_MAX) { 279 + if (new_timer != TIME64_MAX) { 291 280 new_timer += key_gc_delay; 292 281 key_schedule_gc(new_timer); 293 282 }
+10 -1
security/keys/internal.h
··· 167 167 extern void keyring_gc(struct key *keyring, time64_t limit); 168 168 extern void keyring_restriction_gc(struct key *keyring, 169 169 struct key_type *dead_type); 170 + void key_set_expiry(struct key *key, time64_t expiry); 170 171 extern void key_schedule_gc(time64_t gc_at); 171 172 extern void key_schedule_gc_links(void); 172 173 extern void key_gc_keytype(struct key_type *ktype); ··· 216 215 */ 217 216 static inline bool key_is_dead(const struct key *key, time64_t limit) 218 217 { 218 + time64_t expiry = key->expiry; 219 + 220 + if (expiry != TIME64_MAX) { 221 + if (!(key->type->flags & KEY_TYPE_INSTANT_REAP)) 222 + expiry += key_gc_delay; 223 + if (expiry <= limit) 224 + return true; 225 + } 226 + 219 227 return 220 228 key->flags & ((1 << KEY_FLAG_DEAD) | 221 229 (1 << KEY_FLAG_INVALIDATED)) || 222 - (key->expiry > 0 && key->expiry <= limit) || 223 230 key->domain_tag->removed; 224 231 } 225 232
+5 -10
security/keys/key.c
··· 294 294 key->uid = uid; 295 295 key->gid = gid; 296 296 key->perm = perm; 297 + key->expiry = TIME64_MAX; 297 298 key->restrict_link = restrict_link; 298 299 key->last_used_at = ktime_get_real_seconds(); 299 300 ··· 464 463 if (authkey) 465 464 key_invalidate(authkey); 466 465 467 - if (prep->expiry != TIME64_MAX) { 468 - key->expiry = prep->expiry; 469 - key_schedule_gc(prep->expiry + key_gc_delay); 470 - } 466 + key_set_expiry(key, prep->expiry); 471 467 } 472 468 } 473 469 ··· 604 606 atomic_inc(&key->user->nikeys); 605 607 mark_key_instantiated(key, -error); 606 608 notify_key(key, NOTIFY_KEY_INSTANTIATED, -error); 607 - key->expiry = ktime_get_real_seconds() + timeout; 608 - key_schedule_gc(key->expiry + key_gc_delay); 609 + key_set_expiry(key, ktime_get_real_seconds() + timeout); 609 610 610 611 if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) 611 612 awaken = 1; ··· 720 723 721 724 void key_set_timeout(struct key *key, unsigned timeout) 722 725 { 723 - time64_t expiry = 0; 726 + time64_t expiry = TIME64_MAX; 724 727 725 728 /* make the changes with the locks held to prevent races */ 726 729 down_write(&key->sem); 727 730 728 731 if (timeout > 0) 729 732 expiry = ktime_get_real_seconds() + timeout; 730 - 731 - key->expiry = expiry; 732 - key_schedule_gc(key->expiry + key_gc_delay); 733 + key_set_expiry(key, expiry); 733 734 734 735 up_write(&key->sem); 735 736 }
+1 -1
security/keys/proc.c
··· 198 198 199 199 /* come up with a suitable timeout value */ 200 200 expiry = READ_ONCE(key->expiry); 201 - if (expiry == 0) { 201 + if (expiry == TIME64_MAX) { 202 202 memcpy(xbuf, "perm", 5); 203 203 } else if (now >= expiry) { 204 204 memcpy(xbuf, "expd", 5);
+2
sound/pci/hda/cs35l41_hda.c
··· 1826 1826 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) 1827 1827 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); 1828 1828 gpiod_put(cs35l41->reset_gpio); 1829 + gpiod_put(cs35l41->cs_gpio); 1829 1830 acpi_dev_put(cs35l41->dacpi); 1830 1831 kfree(cs35l41->acpi_subsystem_id); 1831 1832 ··· 1854 1853 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) 1855 1854 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); 1856 1855 gpiod_put(cs35l41->reset_gpio); 1856 + gpiod_put(cs35l41->cs_gpio); 1857 1857 kfree(cs35l41->acpi_subsystem_id); 1858 1858 } 1859 1859 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_remove, SND_HDA_SCODEC_CS35L41);
+3 -2
sound/pci/hda/cs35l41_hda.h
··· 35 35 } __packed; 36 36 37 37 enum cs35l41_hda_spk_pos { 38 - CS35l41_LEFT, 39 - CS35l41_RIGHT, 38 + CS35L41_LEFT, 39 + CS35L41_RIGHT, 40 40 }; 41 41 42 42 enum cs35l41_hda_gpio_function { ··· 50 50 struct device *dev; 51 51 struct regmap *regmap; 52 52 struct gpio_desc *reset_gpio; 53 + struct gpio_desc *cs_gpio; 53 54 struct cs35l41_hw_cfg hw_cfg; 54 55 struct hda_codec *codec; 55 56
+323 -40
sound/pci/hda/cs35l41_hda_property.c
··· 6 6 // 7 7 // Author: Stefan Binding <sbinding@opensource.cirrus.com> 8 8 9 + #include <linux/acpi.h> 9 10 #include <linux/gpio/consumer.h> 10 11 #include <linux/string.h> 11 12 #include "cs35l41_hda_property.h" 13 + #include <linux/spi/spi.h> 14 + 15 + #define MAX_AMPS 4 16 + 17 + struct cs35l41_config { 18 + const char *ssid; 19 + enum { 20 + SPI, 21 + I2C 22 + } bus; 23 + int num_amps; 24 + enum { 25 + INTERNAL, 26 + EXTERNAL 27 + } boost_type; 28 + u8 channel[MAX_AMPS]; 29 + int reset_gpio_index; /* -1 if no reset gpio */ 30 + int spkid_gpio_index; /* -1 if no spkid gpio */ 31 + int cs_gpio_index; /* -1 if no cs gpio, or cs-gpios already exists, max num amps == 2 */ 32 + int boost_ind_nanohenry; /* Required if boost_type == Internal */ 33 + int boost_peak_milliamp; /* Required if boost_type == Internal */ 34 + int boost_cap_microfarad; /* Required if boost_type == Internal */ 35 + }; 36 + 37 + static const struct cs35l41_config cs35l41_config_table[] = { 38 + /* 39 + * Device 103C89C6 does have _DSD, however it is setup to use the wrong boost type. 40 + * We can override the _DSD to correct the boost type here. 41 + * Since this laptop has valid ACPI, we do not need to handle cs-gpios, since that already exists 42 + * in the ACPI. The Reset GPIO is also valid, so we can use the Reset defined in _DSD. 43 + */ 44 + { "103C89C6", SPI, 2, INTERNAL, { CS35L41_RIGHT, CS35L41_LEFT, 0, 0 }, -1, -1, -1, 1000, 4500, 24 }, 45 + { "104312AF", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 46 + { "10431433", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 47 + { "10431463", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 48 + { "10431473", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, -1, 0, 1000, 4500, 24 }, 49 + { "10431483", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, -1, 0, 1000, 4500, 24 }, 50 + { "10431493", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 51 + { "104314D3", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 52 + { "104314E3", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 53 + { "10431503", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 54 + { "10431533", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 55 + { "10431573", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 56 + { "10431663", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, -1, 0, 1000, 4500, 24 }, 57 + { "104316D3", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 0, 0, 0 }, 58 + { "104316F3", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 0, 0, 0 }, 59 + { "104317F3", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 60 + { "10431863", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 61 + { "104318D3", I2C, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 }, 62 + { "10431C9F", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 63 + { "10431CAF", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 64 + { "10431CCF", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 65 + { "10431CDF", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 66 + { "10431CEF", SPI, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 1000, 4500, 24 }, 67 + { "10431D1F", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 68 + { "10431DA2", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 0, 0, 0 }, 69 + { "10431E02", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 0, 0, 0 }, 70 + { "10431EE2", I2C, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, -1, -1, 0, 0, 0 }, 71 + { "10431F12", I2C, 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4500, 24 }, 72 + { "10431F1F", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, -1, 0, 0, 0, 0 }, 73 + { "10431F62", SPI, 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 1, 2, 0, 0, 0, 0 }, 74 + {} 75 + }; 76 + 77 + static int cs35l41_add_gpios(struct cs35l41_hda *cs35l41, struct device *physdev, int reset_gpio, 78 + int spkid_gpio, int cs_gpio_index, int num_amps) 79 + { 80 + struct acpi_gpio_mapping *gpio_mapping = NULL; 81 + struct acpi_gpio_params *reset_gpio_params = NULL; 82 + struct acpi_gpio_params *spkid_gpio_params = NULL; 83 + struct acpi_gpio_params *cs_gpio_params = NULL; 84 + unsigned int num_entries = 0; 85 + unsigned int reset_index, spkid_index, csgpio_index; 86 + int i; 87 + 88 + /* 89 + * GPIO Mapping only needs to be done once, since it would be available for subsequent amps 90 + */ 91 + if (cs35l41->dacpi->driver_gpios) 92 + return 0; 93 + 94 + if (reset_gpio >= 0) { 95 + reset_index = num_entries; 96 + num_entries++; 97 + } 98 + 99 + if (spkid_gpio >= 0) { 100 + spkid_index = num_entries; 101 + num_entries++; 102 + } 103 + 104 + if ((cs_gpio_index >= 0) && (num_amps == 2)) { 105 + csgpio_index = num_entries; 106 + num_entries++; 107 + } 108 + 109 + if (!num_entries) 110 + return 0; 111 + 112 + /* must include termination entry */ 113 + num_entries++; 114 + 115 + gpio_mapping = devm_kcalloc(physdev, num_entries, sizeof(struct acpi_gpio_mapping), 116 + GFP_KERNEL); 117 + 118 + if (!gpio_mapping) 119 + goto err; 120 + 121 + if (reset_gpio >= 0) { 122 + gpio_mapping[reset_index].name = "reset-gpios"; 123 + reset_gpio_params = devm_kcalloc(physdev, num_amps, sizeof(struct acpi_gpio_params), 124 + GFP_KERNEL); 125 + if (!reset_gpio_params) 126 + goto err; 127 + 128 + for (i = 0; i < num_amps; i++) 129 + reset_gpio_params[i].crs_entry_index = reset_gpio; 130 + 131 + gpio_mapping[reset_index].data = reset_gpio_params; 132 + gpio_mapping[reset_index].size = num_amps; 133 + } 134 + 135 + if (spkid_gpio >= 0) { 136 + gpio_mapping[spkid_index].name = "spk-id-gpios"; 137 + spkid_gpio_params = devm_kcalloc(physdev, num_amps, sizeof(struct acpi_gpio_params), 138 + GFP_KERNEL); 139 + if (!spkid_gpio_params) 140 + goto err; 141 + 142 + for (i = 0; i < num_amps; i++) 143 + spkid_gpio_params[i].crs_entry_index = spkid_gpio; 144 + 145 + gpio_mapping[spkid_index].data = spkid_gpio_params; 146 + gpio_mapping[spkid_index].size = num_amps; 147 + } 148 + 149 + if ((cs_gpio_index >= 0) && (num_amps == 2)) { 150 + gpio_mapping[csgpio_index].name = "cs-gpios"; 151 + /* only one GPIO CS is supported without using _DSD, obtained using index 0 */ 152 + cs_gpio_params = devm_kzalloc(physdev, sizeof(struct acpi_gpio_params), GFP_KERNEL); 153 + if (!cs_gpio_params) 154 + goto err; 155 + 156 + cs_gpio_params->crs_entry_index = cs_gpio_index; 157 + 158 + gpio_mapping[csgpio_index].data = cs_gpio_params; 159 + gpio_mapping[csgpio_index].size = 1; 160 + } 161 + 162 + return devm_acpi_dev_add_driver_gpios(physdev, gpio_mapping); 163 + err: 164 + devm_kfree(physdev, gpio_mapping); 165 + devm_kfree(physdev, reset_gpio_params); 166 + devm_kfree(physdev, spkid_gpio_params); 167 + devm_kfree(physdev, cs_gpio_params); 168 + return -ENOMEM; 169 + } 170 + 171 + static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physdev, int id, 172 + const char *hid) 173 + { 174 + struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; 175 + const struct cs35l41_config *cfg; 176 + struct gpio_desc *cs_gpiod; 177 + struct spi_device *spi; 178 + bool dsd_found; 179 + int ret; 180 + 181 + for (cfg = cs35l41_config_table; cfg->ssid; cfg++) { 182 + if (!strcasecmp(cfg->ssid, cs35l41->acpi_subsystem_id)) 183 + break; 184 + } 185 + 186 + if (!cfg->ssid) 187 + return -ENOENT; 188 + 189 + if (!cs35l41->dacpi || cs35l41->dacpi != ACPI_COMPANION(physdev)) { 190 + dev_err(cs35l41->dev, "ACPI Device does not match, cannot override _DSD.\n"); 191 + return -ENODEV; 192 + } 193 + 194 + dev_info(cs35l41->dev, "Adding DSD properties for %s\n", cs35l41->acpi_subsystem_id); 195 + 196 + dsd_found = acpi_dev_has_props(cs35l41->dacpi); 197 + 198 + if (!dsd_found) { 199 + ret = cs35l41_add_gpios(cs35l41, physdev, cfg->reset_gpio_index, 200 + cfg->spkid_gpio_index, cfg->cs_gpio_index, 201 + cfg->num_amps); 202 + if (ret) { 203 + dev_err(cs35l41->dev, "Error adding GPIO mapping: %d\n", ret); 204 + return ret; 205 + } 206 + } else if (cfg->reset_gpio_index >= 0 || cfg->spkid_gpio_index >= 0) { 207 + dev_warn(cs35l41->dev, "Cannot add Reset/Speaker ID/SPI CS GPIO Mapping, " 208 + "_DSD already exists.\n"); 209 + } 210 + 211 + if (cfg->bus == SPI) { 212 + cs35l41->index = id; 213 + 214 + /* 215 + * Manually set the Chip Select for the second amp <cs_gpio_index> in the node. 216 + * This is only supported for systems with 2 amps, since we cannot expand the 217 + * default number of chip selects without using cs-gpios 218 + * The CS GPIO must be set high prior to communicating with the first amp (which 219 + * uses a native chip select), to ensure the second amp does not clash with the 220 + * first. 221 + */ 222 + if (IS_ENABLED(CONFIG_SPI) && cfg->cs_gpio_index >= 0) { 223 + spi = to_spi_device(cs35l41->dev); 224 + 225 + if (cfg->num_amps != 2) { 226 + dev_warn(cs35l41->dev, 227 + "Cannot update SPI CS, Number of Amps (%d) != 2\n", 228 + cfg->num_amps); 229 + } else if (dsd_found) { 230 + dev_warn(cs35l41->dev, 231 + "Cannot update SPI CS, _DSD already exists.\n"); 232 + } else { 233 + /* 234 + * This is obtained using driver_gpios, since only one GPIO for CS 235 + * exists, this can be obtained using index 0. 236 + */ 237 + cs_gpiod = gpiod_get_index(physdev, "cs", 0, GPIOD_OUT_LOW); 238 + if (IS_ERR(cs_gpiod)) { 239 + dev_err(cs35l41->dev, 240 + "Unable to get Chip Select GPIO descriptor\n"); 241 + return PTR_ERR(cs_gpiod); 242 + } 243 + if (id == 1) { 244 + spi_set_csgpiod(spi, 0, cs_gpiod); 245 + cs35l41->cs_gpio = cs_gpiod; 246 + } else { 247 + gpiod_set_value_cansleep(cs_gpiod, true); 248 + gpiod_put(cs_gpiod); 249 + } 250 + spi_setup(spi); 251 + } 252 + } 253 + } else { 254 + if (cfg->num_amps > 2) 255 + /* 256 + * i2c addresses for 3/4 amps are used in order: 0x40, 0x41, 0x42, 0x43, 257 + * subtracting 0x40 would give zero-based index 258 + */ 259 + cs35l41->index = id - 0x40; 260 + else 261 + /* i2c addr 0x40 for first amp (always), 0x41/0x42 for 2nd amp */ 262 + cs35l41->index = id == 0x40 ? 0 : 1; 263 + } 264 + 265 + if (cfg->num_amps == 3) 266 + /* 3 amps means a center channel, so no duplicate channels */ 267 + cs35l41->channel_index = 0; 268 + else 269 + /* 270 + * if 4 amps, there are duplicate channels, so they need different indexes 271 + * if 2 amps, no duplicate channels, channel_index would be 0 272 + */ 273 + cs35l41->channel_index = cs35l41->index / 2; 274 + 275 + cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset", 276 + cs35l41->index, GPIOD_OUT_LOW, 277 + "cs35l41-reset"); 278 + cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, cs35l41->index, cfg->num_amps, -1); 279 + 280 + hw_cfg->spk_pos = cfg->channel[cs35l41->index]; 281 + 282 + if (cfg->boost_type == INTERNAL) { 283 + hw_cfg->bst_type = CS35L41_INT_BOOST; 284 + hw_cfg->bst_ind = cfg->boost_ind_nanohenry; 285 + hw_cfg->bst_ipk = cfg->boost_peak_milliamp; 286 + hw_cfg->bst_cap = cfg->boost_cap_microfarad; 287 + hw_cfg->gpio1.func = CS35L41_NOT_USED; 288 + hw_cfg->gpio1.valid = true; 289 + } else { 290 + hw_cfg->bst_type = CS35L41_EXT_BOOST; 291 + hw_cfg->bst_ind = -1; 292 + hw_cfg->bst_ipk = -1; 293 + hw_cfg->bst_cap = -1; 294 + hw_cfg->gpio1.func = CS35l41_VSPK_SWITCH; 295 + hw_cfg->gpio1.valid = true; 296 + } 297 + 298 + hw_cfg->gpio2.func = CS35L41_INTERRUPT; 299 + hw_cfg->gpio2.valid = true; 300 + hw_cfg->valid = true; 301 + 302 + return 0; 303 + } 12 304 13 305 /* 14 306 * Device CLSA010(0/1) doesn't have _DSD so a gpiod_get by the label reset won't work. ··· 335 43 return 0; 336 44 } 337 45 338 - /* 339 - * Device 103C89C6 does have _DSD, however it is setup to use the wrong boost type. 340 - * We can override the _DSD to correct the boost type here. 341 - * Since this laptop has valid ACPI, we do not need to handle cs-gpios, since that already exists 342 - * in the ACPI. 343 - */ 344 - static int hp_vision_acpi_fix(struct cs35l41_hda *cs35l41, struct device *physdev, int id, 345 - const char *hid) 346 - { 347 - struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; 348 - 349 - dev_info(cs35l41->dev, "Adding DSD properties for %s\n", cs35l41->acpi_subsystem_id); 350 - 351 - cs35l41->index = id; 352 - cs35l41->channel_index = 0; 353 - 354 - /* 355 - * This system has _DSD, it just contains an error, so we can still get the reset using 356 - * the "reset" label. 357 - */ 358 - cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset", 359 - cs35l41->index, GPIOD_OUT_LOW, 360 - "cs35l41-reset"); 361 - cs35l41->speaker_id = -ENOENT; 362 - hw_cfg->spk_pos = cs35l41->index ? 0 : 1; // right:left 363 - hw_cfg->gpio1.func = CS35L41_NOT_USED; 364 - hw_cfg->gpio1.valid = true; 365 - hw_cfg->gpio2.func = CS35L41_INTERRUPT; 366 - hw_cfg->gpio2.valid = true; 367 - hw_cfg->bst_type = CS35L41_INT_BOOST; 368 - hw_cfg->bst_ind = 1000; 369 - hw_cfg->bst_ipk = 4500; 370 - hw_cfg->bst_cap = 24; 371 - hw_cfg->valid = true; 372 - 373 - return 0; 374 - } 375 - 376 46 struct cs35l41_prop_model { 377 47 const char *hid; 378 48 const char *ssid; ··· 345 91 static const struct cs35l41_prop_model cs35l41_prop_model_table[] = { 346 92 { "CLSA0100", NULL, lenovo_legion_no_acpi }, 347 93 { "CLSA0101", NULL, lenovo_legion_no_acpi }, 348 - { "CSC3551", "103C89C6", hp_vision_acpi_fix }, 94 + { "CSC3551", "103C89C6", generic_dsd_config }, 95 + { "CSC3551", "104312AF", generic_dsd_config }, 96 + { "CSC3551", "10431433", generic_dsd_config }, 97 + { "CSC3551", "10431463", generic_dsd_config }, 98 + { "CSC3551", "10431473", generic_dsd_config }, 99 + { "CSC3551", "10431483", generic_dsd_config }, 100 + { "CSC3551", "10431493", generic_dsd_config }, 101 + { "CSC3551", "104314D3", generic_dsd_config }, 102 + { "CSC3551", "104314E3", generic_dsd_config }, 103 + { "CSC3551", "10431503", generic_dsd_config }, 104 + { "CSC3551", "10431533", generic_dsd_config }, 105 + { "CSC3551", "10431573", generic_dsd_config }, 106 + { "CSC3551", "10431663", generic_dsd_config }, 107 + { "CSC3551", "104316D3", generic_dsd_config }, 108 + { "CSC3551", "104316F3", generic_dsd_config }, 109 + { "CSC3551", "104317F3", generic_dsd_config }, 110 + { "CSC3551", "10431863", generic_dsd_config }, 111 + { "CSC3551", "104318D3", generic_dsd_config }, 112 + { "CSC3551", "10431C9F", generic_dsd_config }, 113 + { "CSC3551", "10431CAF", generic_dsd_config }, 114 + { "CSC3551", "10431CCF", generic_dsd_config }, 115 + { "CSC3551", "10431CDF", generic_dsd_config }, 116 + { "CSC3551", "10431CEF", generic_dsd_config }, 117 + { "CSC3551", "10431D1F", generic_dsd_config }, 118 + { "CSC3551", "10431DA2", generic_dsd_config }, 119 + { "CSC3551", "10431E02", generic_dsd_config }, 120 + { "CSC3551", "10431EE2", generic_dsd_config }, 121 + { "CSC3551", "10431F12", generic_dsd_config }, 122 + { "CSC3551", "10431F1F", generic_dsd_config }, 123 + { "CSC3551", "10431F62", generic_dsd_config }, 349 124 {} 350 125 }; 351 126 ··· 387 104 if (!strcmp(model->hid, hid) && 388 105 (!model->ssid || 389 106 (cs35l41->acpi_subsystem_id && 390 - !strcmp(model->ssid, cs35l41->acpi_subsystem_id)))) 107 + !strcasecmp(model->ssid, cs35l41->acpi_subsystem_id)))) 391 108 return model->add_prop(cs35l41, physdev, id, hid); 392 109 } 393 110
+29 -12
sound/pci/hda/patch_realtek.c
··· 9799 9799 SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN), 9800 9800 SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), 9801 9801 SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360), 9802 + SND_PCI_QUIRK(0x103c, 0x8537, "HP ProBook 440 G6", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9802 9803 SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9803 9804 SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9804 9805 SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED), ··· 9882 9881 SND_PCI_QUIRK(0x103c, 0x89c6, "Zbook Fury 17 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), 9883 9882 SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9884 9883 SND_PCI_QUIRK(0x103c, 0x89d3, "HP EliteBook 645 G9 (MB 89D2)", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9884 + SND_PCI_QUIRK(0x103c, 0x8a0f, "HP Pavilion 14-ec1xxx", ALC287_FIXUP_HP_GPIO_LED), 9885 9885 SND_PCI_QUIRK(0x103c, 0x8a20, "HP Laptop 15s-fq5xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2), 9886 9886 SND_PCI_QUIRK(0x103c, 0x8a25, "HP Victus 16-d1xxx (MB 8A25)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 9887 9887 SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), ··· 9927 9925 SND_PCI_QUIRK(0x103c, 0x8c70, "HP EliteBook 835 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED), 9928 9926 SND_PCI_QUIRK(0x103c, 0x8c71, "HP EliteBook 845 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED), 9929 9927 SND_PCI_QUIRK(0x103c, 0x8c72, "HP EliteBook 865 G11", ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED), 9928 + SND_PCI_QUIRK(0x103c, 0x8c96, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9930 9929 SND_PCI_QUIRK(0x103c, 0x8ca4, "HP ZBook Fury", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), 9931 9930 SND_PCI_QUIRK(0x103c, 0x8ca7, "HP ZBook Fury", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), 9932 9931 SND_PCI_QUIRK(0x103c, 0x8cf5, "HP ZBook Studio 16", ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED), ··· 9951 9948 SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE), 9952 9949 SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC), 9953 9950 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK), 9954 - SND_PCI_QUIRK(0x1043, 0x1433, "ASUS GX650P", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC), 9955 - SND_PCI_QUIRK(0x1043, 0x1463, "Asus GA402X", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC), 9956 - SND_PCI_QUIRK(0x1043, 0x1473, "ASUS GU604V", ALC285_FIXUP_ASUS_HEADSET_MIC), 9957 - SND_PCI_QUIRK(0x1043, 0x1483, "ASUS GU603V", ALC285_FIXUP_ASUS_HEADSET_MIC), 9958 - SND_PCI_QUIRK(0x1043, 0x1493, "ASUS GV601V", ALC285_FIXUP_ASUS_HEADSET_MIC), 9951 + SND_PCI_QUIRK(0x1043, 0x1433, "ASUS GX650PY/PZ/PV/PU/PYV/PZV/PIV/PVV", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC), 9952 + SND_PCI_QUIRK(0x1043, 0x1463, "Asus GA402X/GA402N", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC), 9953 + SND_PCI_QUIRK(0x1043, 0x1473, "ASUS GU604VI/VC/VE/VG/VJ/VQ/VU/VV/VY/VZ", ALC285_FIXUP_ASUS_HEADSET_MIC), 9954 + SND_PCI_QUIRK(0x1043, 0x1483, "ASUS GU603VQ/VU/VV/VJ/VI", ALC285_FIXUP_ASUS_HEADSET_MIC), 9955 + SND_PCI_QUIRK(0x1043, 0x1493, "ASUS GV601VV/VU/VJ/VQ/VI", ALC285_FIXUP_ASUS_HEADSET_MIC), 9956 + SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G614JY/JZ/JG", ALC245_FIXUP_CS35L41_SPI_2), 9957 + SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS G513PI/PU/PV", ALC287_FIXUP_CS35L41_I2C_2), 9958 + SND_PCI_QUIRK(0x1043, 0x1503, "ASUS G733PY/PZ/PZV/PYV", ALC287_FIXUP_CS35L41_I2C_2), 9959 9959 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A), 9960 - SND_PCI_QUIRK(0x1043, 0x1573, "ASUS GZ301V", ALC285_FIXUP_ASUS_HEADSET_MIC), 9960 + SND_PCI_QUIRK(0x1043, 0x1533, "ASUS GV302XA/XJ/XQ/XU/XV/XI", ALC287_FIXUP_CS35L41_I2C_2), 9961 + SND_PCI_QUIRK(0x1043, 0x1573, "ASUS GZ301VV/VQ/VU/VJ/VA/VC/VE/VVC/VQC/VUC/VJC/VEC/VCC", ALC285_FIXUP_ASUS_HEADSET_MIC), 9961 9962 SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK), 9962 - SND_PCI_QUIRK(0x1043, 0x1663, "ASUS GU603ZV", ALC285_FIXUP_ASUS_HEADSET_MIC), 9963 + SND_PCI_QUIRK(0x1043, 0x1663, "ASUS GU603ZI/ZJ/ZQ/ZU/ZV", ALC285_FIXUP_ASUS_HEADSET_MIC), 9963 9964 SND_PCI_QUIRK(0x1043, 0x1683, "ASUS UM3402YAR", ALC287_FIXUP_CS35L41_I2C_2), 9964 9965 SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401), 9966 + SND_PCI_QUIRK(0x1043, 0x16d3, "ASUS UX5304VA", ALC245_FIXUP_CS35L41_SPI_2), 9965 9967 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), 9968 + SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS UX7602VI/BZ", ALC245_FIXUP_CS35L41_SPI_2), 9966 9969 SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS), 9967 9970 SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK), 9968 - SND_PCI_QUIRK(0x1043, 0x17f3, "ROG Ally RC71L_RC71L", ALC294_FIXUP_ASUS_ALLY), 9971 + SND_PCI_QUIRK(0x1043, 0x17f3, "ROG Ally NR2301L/X", ALC294_FIXUP_ASUS_ALLY), 9972 + SND_PCI_QUIRK(0x1043, 0x1863, "ASUS UX6404VI/VV", ALC245_FIXUP_CS35L41_SPI_2), 9969 9973 SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS), 9970 9974 SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC), 9971 9975 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS UM3504DA", ALC294_FIXUP_CS35L41_I2C_2), ··· 9997 9987 SND_PCI_QUIRK(0x1043, 0x1c43, "ASUS UX8406MA", ALC245_FIXUP_CS35L41_SPI_2), 9998 9988 SND_PCI_QUIRK(0x1043, 0x1c62, "ASUS GU603", ALC289_FIXUP_ASUS_GA401), 9999 9989 SND_PCI_QUIRK(0x1043, 0x1c92, "ASUS ROG Strix G15", ALC285_FIXUP_ASUS_G533Z_PINS), 10000 - SND_PCI_QUIRK(0x1043, 0x1c9f, "ASUS G614JI", ALC285_FIXUP_ASUS_HEADSET_MIC), 10001 - SND_PCI_QUIRK(0x1043, 0x1caf, "ASUS G634JYR/JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), 9990 + SND_PCI_QUIRK(0x1043, 0x1c9f, "ASUS G614JU/JV/JI", ALC285_FIXUP_ASUS_HEADSET_MIC), 9991 + SND_PCI_QUIRK(0x1043, 0x1caf, "ASUS G634JY/JZ/JI/JG", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), 10002 9992 SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC), 10003 - SND_PCI_QUIRK(0x1043, 0x1d1f, "ASUS ROG Strix G17 2023 (G713PV)", ALC287_FIXUP_CS35L41_I2C_2), 9993 + SND_PCI_QUIRK(0x1043, 0x1ccf, "ASUS G814JU/JV/JI", ALC245_FIXUP_CS35L41_SPI_2), 9994 + SND_PCI_QUIRK(0x1043, 0x1cdf, "ASUS G814JY/JZ/JG", ALC245_FIXUP_CS35L41_SPI_2), 9995 + SND_PCI_QUIRK(0x1043, 0x1cef, "ASUS G834JY/JZ/JI/JG", ALC285_FIXUP_ASUS_HEADSET_MIC), 9996 + SND_PCI_QUIRK(0x1043, 0x1d1f, "ASUS G713PI/PU/PV/PVN", ALC287_FIXUP_CS35L41_I2C_2), 10004 9997 SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401), 10005 9998 SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE), 9999 + SND_PCI_QUIRK(0x1043, 0x1da2, "ASUS UP6502ZA/ZD", ALC245_FIXUP_CS35L41_SPI_2), 10006 10000 SND_PCI_QUIRK(0x1043, 0x1e02, "ASUS UX3402ZA", ALC245_FIXUP_CS35L41_SPI_2), 10007 10001 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS UX3402VA", ALC245_FIXUP_CS35L41_SPI_2), 10008 10002 SND_PCI_QUIRK(0x1043, 0x1f62, "ASUS UX7602ZM", ALC245_FIXUP_CS35L41_SPI_2), 10009 10003 SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502), 10010 - SND_PCI_QUIRK(0x1043, 0x1e12, "ASUS UM3402", ALC287_FIXUP_CS35L41_I2C_2), 10004 + SND_PCI_QUIRK(0x1043, 0x1e12, "ASUS UM6702RA/RC", ALC287_FIXUP_CS35L41_I2C_2), 10011 10005 SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS), 10012 10006 SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS), 10013 10007 SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401), 10008 + SND_PCI_QUIRK(0x1043, 0x1ee2, "ASUS UM3402", ALC287_FIXUP_CS35L41_I2C_2), 10014 10009 SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401), 10015 10010 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401), 10016 10011 SND_PCI_QUIRK(0x1043, 0x1f12, "ASUS UM5302", ALC287_FIXUP_CS35L41_I2C_2), 10012 + SND_PCI_QUIRK(0x1043, 0x1f1f, "ASUS H7604JI/JV/J3D", ALC245_FIXUP_CS35L41_SPI_2), 10013 + SND_PCI_QUIRK(0x1043, 0x1f62, "ASUS UX7602ZM", ALC245_FIXUP_CS35L41_SPI_2), 10017 10014 SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401), 10018 10015 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 10019 10016 SND_PCI_QUIRK(0x1043, 0x3a20, "ASUS G614JZR", ALC245_FIXUP_CS35L41_SPI_2),
+138 -110
sound/pci/hda/tas2781_hda_i2c.c
··· 65 65 CALIB_MAX 66 66 }; 67 67 68 + struct tas2781_hda { 69 + struct device *dev; 70 + struct tasdevice_priv *priv; 71 + struct snd_kcontrol *dsp_prog_ctl; 72 + struct snd_kcontrol *dsp_conf_ctl; 73 + struct snd_kcontrol *prof_ctl; 74 + struct snd_kcontrol *snd_ctls[3]; 75 + }; 76 + 68 77 static int tas2781_get_i2c_res(struct acpi_resource *ares, void *data) 69 78 { 70 79 struct tasdevice_priv *tas_priv = data; ··· 134 125 135 126 static void tas2781_hda_playback_hook(struct device *dev, int action) 136 127 { 137 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 128 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 138 129 139 - dev_dbg(tas_priv->dev, "%s: action = %d\n", __func__, action); 130 + dev_dbg(tas_hda->dev, "%s: action = %d\n", __func__, action); 140 131 switch (action) { 141 132 case HDA_GEN_PCM_ACT_OPEN: 142 133 pm_runtime_get_sync(dev); 143 - mutex_lock(&tas_priv->codec_lock); 144 - tasdevice_tuning_switch(tas_priv, 0); 145 - mutex_unlock(&tas_priv->codec_lock); 134 + mutex_lock(&tas_hda->priv->codec_lock); 135 + tasdevice_tuning_switch(tas_hda->priv, 0); 136 + mutex_unlock(&tas_hda->priv->codec_lock); 146 137 break; 147 138 case HDA_GEN_PCM_ACT_CLOSE: 148 - mutex_lock(&tas_priv->codec_lock); 149 - tasdevice_tuning_switch(tas_priv, 1); 150 - mutex_unlock(&tas_priv->codec_lock); 139 + mutex_lock(&tas_hda->priv->codec_lock); 140 + tasdevice_tuning_switch(tas_hda->priv, 1); 141 + mutex_unlock(&tas_hda->priv->codec_lock); 151 142 152 143 pm_runtime_mark_last_busy(dev); 153 144 pm_runtime_put_autosuspend(dev); 154 145 break; 155 146 default: 156 - dev_dbg(tas_priv->dev, "Playback action not supported: %d\n", 147 + dev_dbg(tas_hda->dev, "Playback action not supported: %d\n", 157 148 action); 158 149 break; 159 150 } ··· 430 421 } 431 422 } 432 423 433 - /* Update the calibrate data, including speaker impedance, f0, etc, into algo. 424 + /* Update the calibration data, including speaker impedance, f0, etc, into algo. 434 425 * Calibrate data is done by manufacturer in the factory. These data are used 435 - * by Algo for calucating the speaker temperature, speaker membrance excursion 426 + * by Algo for calculating the speaker temperature, speaker membrane excursion 436 427 * and f0 in real time during playback. 437 428 */ 438 429 static int tas2781_save_calibration(struct tasdevice_priv *tas_priv) ··· 486 477 return 0; 487 478 } 488 479 480 + static void tas2781_hda_remove_controls(struct tas2781_hda *tas_hda) 481 + { 482 + struct hda_codec *codec = tas_hda->priv->codec; 483 + 484 + if (tas_hda->dsp_prog_ctl) 485 + snd_ctl_remove(codec->card, tas_hda->dsp_prog_ctl); 486 + 487 + if (tas_hda->dsp_conf_ctl) 488 + snd_ctl_remove(codec->card, tas_hda->dsp_conf_ctl); 489 + 490 + for (int i = ARRAY_SIZE(tas_hda->snd_ctls) - 1; i >= 0; i--) 491 + if (tas_hda->snd_ctls[i]) 492 + snd_ctl_remove(codec->card, tas_hda->snd_ctls[i]); 493 + 494 + if (tas_hda->prof_ctl) 495 + snd_ctl_remove(codec->card, tas_hda->prof_ctl); 496 + } 497 + 489 498 static void tasdev_fw_ready(const struct firmware *fmw, void *context) 490 499 { 491 500 struct tasdevice_priv *tas_priv = context; 501 + struct tas2781_hda *tas_hda = dev_get_drvdata(tas_priv->dev); 492 502 struct hda_codec *codec = tas_priv->codec; 493 503 int i, ret; 494 504 ··· 518 490 if (ret) 519 491 goto out; 520 492 521 - ret = snd_ctl_add(codec->card, 522 - snd_ctl_new1(&tas2781_prof_ctrl, tas_priv)); 493 + tas_hda->prof_ctl = snd_ctl_new1(&tas2781_prof_ctrl, tas_priv); 494 + ret = snd_ctl_add(codec->card, tas_hda->prof_ctl); 523 495 if (ret) { 524 496 dev_err(tas_priv->dev, 525 497 "Failed to add KControl %s = %d\n", ··· 528 500 } 529 501 530 502 for (i = 0; i < ARRAY_SIZE(tas2781_snd_controls); i++) { 531 - ret = snd_ctl_add(codec->card, 532 - snd_ctl_new1(&tas2781_snd_controls[i], tas_priv)); 503 + tas_hda->snd_ctls[i] = snd_ctl_new1(&tas2781_snd_controls[i], 504 + tas_priv); 505 + ret = snd_ctl_add(codec->card, tas_hda->snd_ctls[i]); 533 506 if (ret) { 534 507 dev_err(tas_priv->dev, 535 508 "Failed to add KControl %s = %d\n", ··· 552 523 goto out; 553 524 } 554 525 555 - ret = snd_ctl_add(codec->card, 556 - snd_ctl_new1(&tas2781_dsp_prog_ctrl, tas_priv)); 526 + tas_hda->dsp_prog_ctl = snd_ctl_new1(&tas2781_dsp_prog_ctrl, 527 + tas_priv); 528 + ret = snd_ctl_add(codec->card, tas_hda->dsp_prog_ctl); 557 529 if (ret) { 558 530 dev_err(tas_priv->dev, 559 531 "Failed to add KControl %s = %d\n", ··· 562 532 goto out; 563 533 } 564 534 565 - ret = snd_ctl_add(codec->card, 566 - snd_ctl_new1(&tas2781_dsp_conf_ctrl, tas_priv)); 535 + tas_hda->dsp_conf_ctl = snd_ctl_new1(&tas2781_dsp_conf_ctrl, 536 + tas_priv); 537 + ret = snd_ctl_add(codec->card, tas_hda->dsp_conf_ctl); 567 538 if (ret) { 568 539 dev_err(tas_priv->dev, 569 540 "Failed to add KControl %s = %d\n", ··· 574 543 575 544 tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; 576 545 tasdevice_prmg_load(tas_priv, 0); 546 + if (tas_priv->fmw->nr_programs > 0) 547 + tas_priv->cur_prog = 0; 548 + if (tas_priv->fmw->nr_configurations > 0) 549 + tas_priv->cur_conf = 0; 577 550 578 551 /* If calibrated data occurs error, dsp will still works with default 579 552 * calibrated data inside algo. ··· 585 550 tas2781_save_calibration(tas_priv); 586 551 587 552 out: 588 - mutex_unlock(&tas_priv->codec_lock); 553 + mutex_unlock(&tas_hda->priv->codec_lock); 589 554 if (fmw) 590 555 release_firmware(fmw); 591 - pm_runtime_mark_last_busy(tas_priv->dev); 592 - pm_runtime_put_autosuspend(tas_priv->dev); 556 + pm_runtime_mark_last_busy(tas_hda->dev); 557 + pm_runtime_put_autosuspend(tas_hda->dev); 593 558 } 594 559 595 560 static int tas2781_hda_bind(struct device *dev, struct device *master, 596 561 void *master_data) 597 562 { 598 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 563 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 599 564 struct hda_component *comps = master_data; 600 565 struct hda_codec *codec; 601 566 unsigned int subid; 602 567 int ret; 603 568 604 - if (!comps || tas_priv->index < 0 || 605 - tas_priv->index >= HDA_MAX_COMPONENTS) 569 + if (!comps || tas_hda->priv->index < 0 || 570 + tas_hda->priv->index >= HDA_MAX_COMPONENTS) 606 571 return -EINVAL; 607 572 608 - comps = &comps[tas_priv->index]; 573 + comps = &comps[tas_hda->priv->index]; 609 574 if (comps->dev) 610 575 return -EBUSY; 611 576 ··· 614 579 615 580 switch (subid) { 616 581 case 0x17aa: 617 - tas_priv->catlog_id = LENOVO; 582 + tas_hda->priv->catlog_id = LENOVO; 618 583 break; 619 584 default: 620 - tas_priv->catlog_id = OTHERS; 585 + tas_hda->priv->catlog_id = OTHERS; 621 586 break; 622 587 } 623 588 ··· 627 592 628 593 strscpy(comps->name, dev_name(dev), sizeof(comps->name)); 629 594 630 - ret = tascodec_init(tas_priv, codec, tasdev_fw_ready); 595 + ret = tascodec_init(tas_hda->priv, codec, tasdev_fw_ready); 631 596 if (!ret) 632 597 comps->playback_hook = tas2781_hda_playback_hook; 633 598 ··· 640 605 static void tas2781_hda_unbind(struct device *dev, 641 606 struct device *master, void *master_data) 642 607 { 643 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 608 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 644 609 struct hda_component *comps = master_data; 645 - comps = &comps[tas_priv->index]; 610 + comps = &comps[tas_hda->priv->index]; 646 611 647 612 if (comps->dev == dev) { 648 613 comps->dev = NULL; ··· 650 615 comps->playback_hook = NULL; 651 616 } 652 617 653 - tasdevice_config_info_remove(tas_priv); 654 - tasdevice_dsp_remove(tas_priv); 618 + tas2781_hda_remove_controls(tas_hda); 655 619 656 - tas_priv->fw_state = TASDEVICE_DSP_FW_PENDING; 620 + tasdevice_config_info_remove(tas_hda->priv); 621 + tasdevice_dsp_remove(tas_hda->priv); 622 + 623 + tas_hda->priv->fw_state = TASDEVICE_DSP_FW_PENDING; 657 624 } 658 625 659 626 static const struct component_ops tas2781_hda_comp_ops = { ··· 665 628 666 629 static void tas2781_hda_remove(struct device *dev) 667 630 { 668 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 631 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 669 632 670 - pm_runtime_get_sync(tas_priv->dev); 671 - pm_runtime_disable(tas_priv->dev); 633 + pm_runtime_get_sync(tas_hda->dev); 634 + pm_runtime_disable(tas_hda->dev); 672 635 673 - component_del(tas_priv->dev, &tas2781_hda_comp_ops); 636 + component_del(tas_hda->dev, &tas2781_hda_comp_ops); 674 637 675 - pm_runtime_put_noidle(tas_priv->dev); 638 + pm_runtime_put_noidle(tas_hda->dev); 676 639 677 - tasdevice_remove(tas_priv); 640 + tasdevice_remove(tas_hda->priv); 678 641 } 679 642 680 643 static int tas2781_hda_i2c_probe(struct i2c_client *clt) 681 644 { 682 - struct tasdevice_priv *tas_priv; 645 + struct tas2781_hda *tas_hda; 683 646 const char *device_name; 684 647 int ret; 685 648 ··· 688 651 else 689 652 return -ENODEV; 690 653 691 - tas_priv = tasdevice_kzalloc(clt); 692 - if (!tas_priv) 654 + tas_hda = devm_kzalloc(&clt->dev, sizeof(*tas_hda), GFP_KERNEL); 655 + if (!tas_hda) 693 656 return -ENOMEM; 694 657 695 - tas_priv->irq_info.irq = clt->irq; 696 - ret = tas2781_read_acpi(tas_priv, device_name); 658 + dev_set_drvdata(&clt->dev, tas_hda); 659 + tas_hda->dev = &clt->dev; 660 + 661 + tas_hda->priv = tasdevice_kzalloc(clt); 662 + if (!tas_hda->priv) 663 + return -ENOMEM; 664 + 665 + tas_hda->priv->irq_info.irq = clt->irq; 666 + ret = tas2781_read_acpi(tas_hda->priv, device_name); 697 667 if (ret) 698 - return dev_err_probe(tas_priv->dev, ret, 668 + return dev_err_probe(tas_hda->dev, ret, 699 669 "Platform not supported\n"); 700 670 701 - ret = tasdevice_init(tas_priv); 671 + ret = tasdevice_init(tas_hda->priv); 702 672 if (ret) 703 673 goto err; 704 674 705 - pm_runtime_set_autosuspend_delay(tas_priv->dev, 3000); 706 - pm_runtime_use_autosuspend(tas_priv->dev); 707 - pm_runtime_mark_last_busy(tas_priv->dev); 708 - pm_runtime_set_active(tas_priv->dev); 709 - pm_runtime_get_noresume(tas_priv->dev); 710 - pm_runtime_enable(tas_priv->dev); 675 + pm_runtime_set_autosuspend_delay(tas_hda->dev, 3000); 676 + pm_runtime_use_autosuspend(tas_hda->dev); 677 + pm_runtime_mark_last_busy(tas_hda->dev); 678 + pm_runtime_set_active(tas_hda->dev); 679 + pm_runtime_get_noresume(tas_hda->dev); 680 + pm_runtime_enable(tas_hda->dev); 711 681 712 - pm_runtime_put_autosuspend(tas_priv->dev); 682 + pm_runtime_put_autosuspend(tas_hda->dev); 713 683 714 - tas2781_reset(tas_priv); 684 + tas2781_reset(tas_hda->priv); 715 685 716 - ret = component_add(tas_priv->dev, &tas2781_hda_comp_ops); 686 + ret = component_add(tas_hda->dev, &tas2781_hda_comp_ops); 717 687 if (ret) { 718 - dev_err(tas_priv->dev, "Register component failed: %d\n", ret); 719 - pm_runtime_disable(tas_priv->dev); 688 + dev_err(tas_hda->dev, "Register component failed: %d\n", ret); 689 + pm_runtime_disable(tas_hda->dev); 720 690 } 721 691 722 692 err: ··· 739 695 740 696 static int tas2781_runtime_suspend(struct device *dev) 741 697 { 742 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 698 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 743 699 int i; 744 700 745 - dev_dbg(tas_priv->dev, "Runtime Suspend\n"); 701 + dev_dbg(tas_hda->dev, "Runtime Suspend\n"); 746 702 747 - mutex_lock(&tas_priv->codec_lock); 703 + mutex_lock(&tas_hda->priv->codec_lock); 748 704 749 - if (tas_priv->playback_started) { 750 - tasdevice_tuning_switch(tas_priv, 1); 751 - tas_priv->playback_started = false; 705 + if (tas_hda->priv->playback_started) { 706 + tasdevice_tuning_switch(tas_hda->priv, 1); 707 + tas_hda->priv->playback_started = false; 752 708 } 753 709 754 - for (i = 0; i < tas_priv->ndev; i++) { 755 - tas_priv->tasdevice[i].cur_book = -1; 756 - tas_priv->tasdevice[i].cur_prog = -1; 757 - tas_priv->tasdevice[i].cur_conf = -1; 710 + for (i = 0; i < tas_hda->priv->ndev; i++) { 711 + tas_hda->priv->tasdevice[i].cur_book = -1; 712 + tas_hda->priv->tasdevice[i].cur_prog = -1; 713 + tas_hda->priv->tasdevice[i].cur_conf = -1; 758 714 } 759 715 760 - regcache_cache_only(tas_priv->regmap, true); 761 - regcache_mark_dirty(tas_priv->regmap); 762 - 763 - mutex_unlock(&tas_priv->codec_lock); 716 + mutex_unlock(&tas_hda->priv->codec_lock); 764 717 765 718 return 0; 766 719 } 767 720 768 721 static int tas2781_runtime_resume(struct device *dev) 769 722 { 770 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 723 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 771 724 unsigned long calib_data_sz = 772 - tas_priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE; 773 - int ret; 725 + tas_hda->priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE; 774 726 775 - dev_dbg(tas_priv->dev, "Runtime Resume\n"); 727 + dev_dbg(tas_hda->dev, "Runtime Resume\n"); 776 728 777 - mutex_lock(&tas_priv->codec_lock); 729 + mutex_lock(&tas_hda->priv->codec_lock); 778 730 779 - regcache_cache_only(tas_priv->regmap, false); 780 - ret = regcache_sync(tas_priv->regmap); 781 - if (ret) { 782 - dev_err(tas_priv->dev, 783 - "Failed to restore register cache: %d\n", ret); 784 - goto out; 785 - } 786 - 787 - tasdevice_prmg_load(tas_priv, tas_priv->cur_prog); 731 + tasdevice_prmg_load(tas_hda->priv, tas_hda->priv->cur_prog); 788 732 789 733 /* If calibrated data occurs error, dsp will still works with default 790 734 * calibrated data inside algo. 791 735 */ 792 - if (tas_priv->cali_data.total_sz > calib_data_sz) 793 - tas2781_apply_calib(tas_priv); 736 + if (tas_hda->priv->cali_data.total_sz > calib_data_sz) 737 + tas2781_apply_calib(tas_hda->priv); 794 738 795 - out: 796 - mutex_unlock(&tas_priv->codec_lock); 739 + mutex_unlock(&tas_hda->priv->codec_lock); 797 740 798 - return ret; 741 + return 0; 799 742 } 800 743 801 744 static int tas2781_system_suspend(struct device *dev) 802 745 { 803 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 746 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 804 747 int ret; 805 748 806 - dev_dbg(tas_priv->dev, "System Suspend\n"); 749 + dev_dbg(tas_hda->priv->dev, "System Suspend\n"); 807 750 808 751 ret = pm_runtime_force_suspend(dev); 809 752 if (ret) 810 753 return ret; 811 754 812 755 /* Shutdown chip before system suspend */ 813 - regcache_cache_only(tas_priv->regmap, false); 814 - tasdevice_tuning_switch(tas_priv, 1); 815 - regcache_cache_only(tas_priv->regmap, true); 816 - regcache_mark_dirty(tas_priv->regmap); 756 + tasdevice_tuning_switch(tas_hda->priv, 1); 817 757 818 758 /* 819 759 * Reset GPIO may be shared, so cannot reset here. ··· 808 780 809 781 static int tas2781_system_resume(struct device *dev) 810 782 { 811 - struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); 783 + struct tas2781_hda *tas_hda = dev_get_drvdata(dev); 812 784 unsigned long calib_data_sz = 813 - tas_priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE; 785 + tas_hda->priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE; 814 786 int i, ret; 815 787 816 - dev_dbg(tas_priv->dev, "System Resume\n"); 788 + dev_info(tas_hda->priv->dev, "System Resume\n"); 817 789 818 790 ret = pm_runtime_force_resume(dev); 819 791 if (ret) 820 792 return ret; 821 793 822 - mutex_lock(&tas_priv->codec_lock); 794 + mutex_lock(&tas_hda->priv->codec_lock); 823 795 824 - for (i = 0; i < tas_priv->ndev; i++) { 825 - tas_priv->tasdevice[i].cur_book = -1; 826 - tas_priv->tasdevice[i].cur_prog = -1; 827 - tas_priv->tasdevice[i].cur_conf = -1; 796 + for (i = 0; i < tas_hda->priv->ndev; i++) { 797 + tas_hda->priv->tasdevice[i].cur_book = -1; 798 + tas_hda->priv->tasdevice[i].cur_prog = -1; 799 + tas_hda->priv->tasdevice[i].cur_conf = -1; 828 800 } 829 - tas2781_reset(tas_priv); 830 - tasdevice_prmg_load(tas_priv, tas_priv->cur_prog); 801 + tas2781_reset(tas_hda->priv); 802 + tasdevice_prmg_load(tas_hda->priv, tas_hda->priv->cur_prog); 831 803 832 804 /* If calibrated data occurs error, dsp will still work with default 833 805 * calibrated data inside algo. 834 806 */ 835 - if (tas_priv->cali_data.total_sz > calib_data_sz) 836 - tas2781_apply_calib(tas_priv); 837 - mutex_unlock(&tas_priv->codec_lock); 807 + if (tas_hda->priv->cali_data.total_sz > calib_data_sz) 808 + tas2781_apply_calib(tas_hda->priv); 809 + mutex_unlock(&tas_hda->priv->codec_lock); 838 810 839 811 return 0; 840 812 }
+1 -1
sound/soc/codecs/cs35l45-i2c.c
··· 62 62 .driver = { 63 63 .name = "cs35l45", 64 64 .of_match_table = cs35l45_of_match, 65 - .pm = &cs35l45_pm_ops, 65 + .pm = pm_ptr(&cs35l45_pm_ops), 66 66 }, 67 67 .id_table = cs35l45_id_i2c, 68 68 .probe = cs35l45_i2c_probe,
+1 -1
sound/soc/codecs/cs35l45-spi.c
··· 64 64 .driver = { 65 65 .name = "cs35l45", 66 66 .of_match_table = cs35l45_of_match, 67 - .pm = &cs35l45_pm_ops, 67 + .pm = pm_ptr(&cs35l45_pm_ops), 68 68 }, 69 69 .id_table = cs35l45_id_spi, 70 70 .probe = cs35l45_spi_probe,
+51 -5
sound/soc/codecs/cs35l45.c
··· 947 947 948 948 cs35l45_setup_hibernate(cs35l45); 949 949 950 + regmap_set_bits(cs35l45->regmap, CS35L45_IRQ1_MASK_2, CS35L45_DSP_VIRT2_MBOX_MASK); 951 + 950 952 // Don't wait for ACK since bus activity would wake the device 951 953 regmap_write(cs35l45->regmap, CS35L45_DSP_VIRT1_MBOX_1, CSPL_MBOX_CMD_HIBERNATE); 952 954 ··· 969 967 CSPL_MBOX_CMD_OUT_OF_HIBERNATE); 970 968 if (!ret) { 971 969 dev_dbg(cs35l45->dev, "Wake success at cycle: %d\n", j); 970 + regmap_clear_bits(cs35l45->regmap, CS35L45_IRQ1_MASK_2, 971 + CS35L45_DSP_VIRT2_MBOX_MASK); 972 972 return 0; 973 973 } 974 974 usleep_range(100, 200); ··· 986 982 return -ETIMEDOUT; 987 983 } 988 984 989 - static int __maybe_unused cs35l45_runtime_suspend(struct device *dev) 985 + static int cs35l45_runtime_suspend(struct device *dev) 990 986 { 991 987 struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 992 988 ··· 1003 999 return 0; 1004 1000 } 1005 1001 1006 - static int __maybe_unused cs35l45_runtime_resume(struct device *dev) 1002 + static int cs35l45_runtime_resume(struct device *dev) 1007 1003 { 1008 1004 struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 1009 1005 int ret; ··· 1028 1024 regmap_set_bits(cs35l45->regmap, CS35L45_ERROR_RELEASE, CS35L45_GLOBAL_ERR_RLS_MASK); 1029 1025 regmap_clear_bits(cs35l45->regmap, CS35L45_ERROR_RELEASE, CS35L45_GLOBAL_ERR_RLS_MASK); 1030 1026 return ret; 1027 + } 1028 + 1029 + static int cs35l45_sys_suspend(struct device *dev) 1030 + { 1031 + struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 1032 + 1033 + dev_dbg(cs35l45->dev, "System suspend, disabling IRQ\n"); 1034 + disable_irq(cs35l45->irq); 1035 + 1036 + return 0; 1037 + } 1038 + 1039 + static int cs35l45_sys_suspend_noirq(struct device *dev) 1040 + { 1041 + struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 1042 + 1043 + dev_dbg(cs35l45->dev, "Late system suspend, reenabling IRQ\n"); 1044 + enable_irq(cs35l45->irq); 1045 + 1046 + return 0; 1047 + } 1048 + 1049 + static int cs35l45_sys_resume_noirq(struct device *dev) 1050 + { 1051 + struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 1052 + 1053 + dev_dbg(cs35l45->dev, "Early system resume, disabling IRQ\n"); 1054 + disable_irq(cs35l45->irq); 1055 + 1056 + return 0; 1057 + } 1058 + 1059 + static int cs35l45_sys_resume(struct device *dev) 1060 + { 1061 + struct cs35l45_private *cs35l45 = dev_get_drvdata(dev); 1062 + 1063 + dev_dbg(cs35l45->dev, "System resume, reenabling IRQ\n"); 1064 + enable_irq(cs35l45->irq); 1065 + 1066 + return 0; 1031 1067 } 1032 1068 1033 1069 static int cs35l45_apply_property_config(struct cs35l45_private *cs35l45) ··· 1510 1466 } 1511 1467 EXPORT_SYMBOL_NS_GPL(cs35l45_remove, SND_SOC_CS35L45); 1512 1468 1513 - const struct dev_pm_ops cs35l45_pm_ops = { 1514 - SET_RUNTIME_PM_OPS(cs35l45_runtime_suspend, cs35l45_runtime_resume, NULL) 1469 + EXPORT_GPL_DEV_PM_OPS(cs35l45_pm_ops) = { 1470 + RUNTIME_PM_OPS(cs35l45_runtime_suspend, cs35l45_runtime_resume, NULL) 1471 + 1472 + SYSTEM_SLEEP_PM_OPS(cs35l45_sys_suspend, cs35l45_sys_resume) 1473 + NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l45_sys_suspend_noirq, cs35l45_sys_resume_noirq) 1515 1474 }; 1516 - EXPORT_SYMBOL_NS_GPL(cs35l45_pm_ops, SND_SOC_CS35L45); 1517 1475 1518 1476 MODULE_DESCRIPTION("ASoC CS35L45 driver"); 1519 1477 MODULE_AUTHOR("James Schulman, Cirrus Logic Inc, <james.schulman@cirrus.com>");
+11 -10
sound/soc/codecs/cs42l43-jack.c
··· 237 237 return ret; 238 238 } 239 239 240 - static void cs42l43_start_hs_bias(struct cs42l43_codec *priv, bool force_high) 240 + static void cs42l43_start_hs_bias(struct cs42l43_codec *priv, bool type_detect) 241 241 { 242 242 struct cs42l43 *cs42l43 = priv->core; 243 243 unsigned int val = 0x3 << CS42L43_HSBIAS_MODE_SHIFT; ··· 247 247 regmap_update_bits(cs42l43->regmap, CS42L43_HS2, 248 248 CS42L43_HS_CLAMP_DISABLE_MASK, CS42L43_HS_CLAMP_DISABLE_MASK); 249 249 250 - if (!force_high && priv->bias_low) 251 - val = 0x2 << CS42L43_HSBIAS_MODE_SHIFT; 250 + if (!type_detect) { 251 + if (priv->bias_low) 252 + val = 0x2 << CS42L43_HSBIAS_MODE_SHIFT; 252 253 253 - if (priv->bias_sense_ua) { 254 - regmap_update_bits(cs42l43->regmap, 255 - CS42L43_HS_BIAS_SENSE_AND_CLAMP_AUTOCONTROL, 256 - CS42L43_HSBIAS_SENSE_EN_MASK | 257 - CS42L43_AUTO_HSBIAS_CLAMP_EN_MASK, 258 - CS42L43_HSBIAS_SENSE_EN_MASK | 259 - CS42L43_AUTO_HSBIAS_CLAMP_EN_MASK); 254 + if (priv->bias_sense_ua) 255 + regmap_update_bits(cs42l43->regmap, 256 + CS42L43_HS_BIAS_SENSE_AND_CLAMP_AUTOCONTROL, 257 + CS42L43_HSBIAS_SENSE_EN_MASK | 258 + CS42L43_AUTO_HSBIAS_CLAMP_EN_MASK, 259 + CS42L43_HSBIAS_SENSE_EN_MASK | 260 + CS42L43_AUTO_HSBIAS_CLAMP_EN_MASK); 260 261 } 261 262 262 263 regmap_update_bits(cs42l43->regmap, CS42L43_MIC_DETECT_CONTROL_1,
+10 -2
sound/soc/codecs/hdmi-codec.c
··· 850 850 static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, 851 851 unsigned int jack_status) 852 852 { 853 - if (hcp->jack && jack_status != hcp->jack_status) { 854 - snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); 853 + if (jack_status != hcp->jack_status) { 854 + if (hcp->jack) 855 + snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); 855 856 hcp->jack_status = jack_status; 856 857 } 857 858 } ··· 881 880 882 881 if (hcp->hcd.ops->hook_plugged_cb) { 883 882 hcp->jack = jack; 883 + 884 + /* 885 + * Report the initial jack status which may have been provided 886 + * by the parent hdmi driver while the hpd hook was registered. 887 + */ 888 + snd_soc_jack_report(jack, hcp->jack_status, SND_JACK_LINEOUT); 889 + 884 890 return 0; 885 891 } 886 892
+1 -3
sound/soc/codecs/tas2781-comlib.c
··· 39 39 static const struct regmap_config tasdevice_regmap = { 40 40 .reg_bits = 8, 41 41 .val_bits = 8, 42 - .cache_type = REGCACHE_RBTREE, 42 + .cache_type = REGCACHE_NONE, 43 43 .ranges = tasdevice_ranges, 44 44 .num_ranges = ARRAY_SIZE(tasdevice_ranges), 45 45 .max_register = 256 * 128, ··· 315 315 tas_priv->tasdevice[i].cur_prog = -1; 316 316 tas_priv->tasdevice[i].cur_conf = -1; 317 317 } 318 - 319 - dev_set_drvdata(tas_priv->dev, tas_priv); 320 318 321 319 mutex_init(&tas_priv->codec_lock); 322 320
+8 -6
sound/soc/codecs/tas2781-fmwlib.c
··· 2189 2189 goto out; 2190 2190 } 2191 2191 2192 - conf = &(tas_fmw->configs[cfg_no]); 2193 2192 for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) { 2194 2193 if (cfg_info[rca_conf_no]->active_dev & (1 << i)) { 2195 - if (tas_priv->tasdevice[i].cur_prog != prm_no 2196 - || tas_priv->force_fwload_status) { 2194 + if (prm_no >= 0 2195 + && (tas_priv->tasdevice[i].cur_prog != prm_no 2196 + || tas_priv->force_fwload_status)) { 2197 2197 tas_priv->tasdevice[i].cur_conf = -1; 2198 2198 tas_priv->tasdevice[i].is_loading = true; 2199 2199 prog_status++; ··· 2228 2228 } 2229 2229 2230 2230 for (i = 0, status = 0; i < tas_priv->ndev; i++) { 2231 - if (tas_priv->tasdevice[i].cur_conf != cfg_no 2231 + if (cfg_no >= 0 2232 + && tas_priv->tasdevice[i].cur_conf != cfg_no 2232 2233 && (cfg_info[rca_conf_no]->active_dev & (1 << i)) 2233 2234 && (tas_priv->tasdevice[i].is_loaderr == false)) { 2234 2235 status++; ··· 2239 2238 } 2240 2239 2241 2240 if (status) { 2241 + conf = &(tas_fmw->configs[cfg_no]); 2242 2242 status = 0; 2243 2243 tasdevice_load_data(tas_priv, &(conf->dev_data)); 2244 2244 for (i = 0; i < tas_priv->ndev; i++) { ··· 2283 2281 } 2284 2282 2285 2283 for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) { 2286 - if (tas_priv->tasdevice[i].cur_prog != prm_no) { 2284 + if (prm_no >= 0 && tas_priv->tasdevice[i].cur_prog != prm_no) { 2287 2285 tas_priv->tasdevice[i].cur_conf = -1; 2288 2286 tas_priv->tasdevice[i].is_loading = true; 2289 2287 prog_status++; ··· 2328 2326 } 2329 2327 2330 2328 for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) { 2331 - if (tas_priv->tasdevice[i].cur_prog != prm_no) { 2329 + if (prm_no >= 0 && tas_priv->tasdevice[i].cur_prog != prm_no) { 2332 2330 tas_priv->tasdevice[i].cur_conf = -1; 2333 2331 tas_priv->tasdevice[i].is_loading = true; 2334 2332 prog_status++;
+2
sound/soc/codecs/tas2781-i2c.c
··· 689 689 if (!tas_priv) 690 690 return -ENOMEM; 691 691 692 + dev_set_drvdata(&i2c->dev, tas_priv); 693 + 692 694 if (ACPI_HANDLE(&i2c->dev)) { 693 695 acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, 694 696 &i2c->dev);
+8 -2
sound/soc/fsl/fsl_rpmsg.c
··· 238 238 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component, 239 239 &fsl_rpmsg_dai, 1); 240 240 if (ret) 241 - return ret; 241 + goto err_pm_disable; 242 242 243 243 rpmsg->card_pdev = platform_device_register_data(&pdev->dev, 244 244 "imx-audio-rpmsg", ··· 248 248 if (IS_ERR(rpmsg->card_pdev)) { 249 249 dev_err(&pdev->dev, "failed to register rpmsg card\n"); 250 250 ret = PTR_ERR(rpmsg->card_pdev); 251 - return ret; 251 + goto err_pm_disable; 252 252 } 253 253 254 254 return 0; 255 + 256 + err_pm_disable: 257 + pm_runtime_disable(&pdev->dev); 258 + return ret; 255 259 } 256 260 257 261 static void fsl_rpmsg_remove(struct platform_device *pdev) 258 262 { 259 263 struct fsl_rpmsg *rpmsg = platform_get_drvdata(pdev); 264 + 265 + pm_runtime_disable(&pdev->dev); 260 266 261 267 if (rpmsg->card_pdev) 262 268 platform_device_unregister(rpmsg->card_pdev);
+3
sound/soc/fsl/fsl_sai.c
··· 714 714 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 715 715 unsigned int ofs = sai->soc_data->reg_offset; 716 716 717 + /* Clear xMR to avoid channel swap with mclk_with_tere enabled case */ 718 + regmap_write(sai->regmap, FSL_SAI_xMR(tx), 0); 719 + 717 720 regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx, ofs), 718 721 FSL_SAI_CR3_TRCE_MASK, 0); 719 722
+25 -6
sound/soc/intel/boards/bytcr_rt5640.c
··· 83 83 #define BYT_RT5640_HSMIC2_ON_IN1 BIT(27) 84 84 #define BYT_RT5640_JD_HP_ELITEP_1000G2 BIT(28) 85 85 #define BYT_RT5640_USE_AMCR0F28 BIT(29) 86 + #define BYT_RT5640_SWAPPED_SPEAKERS BIT(30) 86 87 87 88 #define BYTCR_INPUT_DEFAULTS \ 88 89 (BYT_RT5640_IN3_MAP | \ ··· 158 157 dev_info(dev, "quirk MONO_SPEAKER enabled\n"); 159 158 if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) 160 159 dev_info(dev, "quirk NO_SPEAKERS enabled\n"); 160 + if (byt_rt5640_quirk & BYT_RT5640_SWAPPED_SPEAKERS) 161 + dev_info(dev, "quirk SWAPPED_SPEAKERS enabled\n"); 161 162 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT) 162 163 dev_info(dev, "quirk LINEOUT enabled\n"); 163 164 if (byt_rt5640_quirk & BYT_RT5640_LINEOUT_AS_HP2) ··· 897 894 BYT_RT5640_SSP0_AIF1 | 898 895 BYT_RT5640_MCLK_EN), 899 896 }, 897 + { 898 + /* Medion Lifetab S10346 */ 899 + .matches = { 900 + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 901 + DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 902 + /* Above strings are much too generic, also match on BIOS date */ 903 + DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"), 904 + }, 905 + .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | 906 + BYT_RT5640_SWAPPED_SPEAKERS | 907 + BYT_RT5640_SSP0_AIF1 | 908 + BYT_RT5640_MCLK_EN), 909 + }, 900 910 { /* Mele PCG03 Mini PC */ 901 911 .matches = { 902 912 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"), ··· 1635 1619 const char *platform_name; 1636 1620 struct acpi_device *adev; 1637 1621 struct device *codec_dev; 1622 + const char *cfg_spk; 1638 1623 bool sof_parent; 1639 1624 int ret_val = 0; 1640 1625 int dai_index = 0; 1641 - int i, cfg_spk; 1642 - int aif; 1626 + int i, aif; 1643 1627 1644 1628 is_bytcr = false; 1645 1629 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ··· 1799 1783 } 1800 1784 1801 1785 if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) { 1802 - cfg_spk = 0; 1786 + cfg_spk = "0"; 1803 1787 spk_type = "none"; 1804 1788 } else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) { 1805 - cfg_spk = 1; 1789 + cfg_spk = "1"; 1806 1790 spk_type = "mono"; 1791 + } else if (byt_rt5640_quirk & BYT_RT5640_SWAPPED_SPEAKERS) { 1792 + cfg_spk = "swapped"; 1793 + spk_type = "swapped"; 1807 1794 } else { 1808 - cfg_spk = 2; 1795 + cfg_spk = "2"; 1809 1796 spk_type = "stereo"; 1810 1797 } 1811 1798 ··· 1823 1804 headset2_string = " cfg-hs2:in1"; 1824 1805 1825 1806 snprintf(byt_rt5640_components, sizeof(byt_rt5640_components), 1826 - "cfg-spk:%d cfg-mic:%s aif:%d%s%s", cfg_spk, 1807 + "cfg-spk:%s cfg-mic:%s aif:%d%s%s", cfg_spk, 1827 1808 map_name[BYT_RT5640_MAP(byt_rt5640_quirk)], aif, 1828 1809 lineout_string, headset2_string); 1829 1810 byt_rt5640_card.components = byt_rt5640_components;
+4 -4
sound/soc/intel/common/soc-acpi-intel-mtl-match.c
··· 306 306 .adr = 0x00013701FA355601ull, 307 307 .num_endpoints = 1, 308 308 .endpoints = &spk_r_endpoint, 309 - .name_prefix = "cs35l56-8" 309 + .name_prefix = "AMP8" 310 310 }, 311 311 { 312 312 .adr = 0x00013601FA355601ull, 313 313 .num_endpoints = 1, 314 314 .endpoints = &spk_3_endpoint, 315 - .name_prefix = "cs35l56-7" 315 + .name_prefix = "AMP7" 316 316 } 317 317 }; 318 318 ··· 321 321 .adr = 0x00023301FA355601ull, 322 322 .num_endpoints = 1, 323 323 .endpoints = &spk_l_endpoint, 324 - .name_prefix = "cs35l56-1" 324 + .name_prefix = "AMP1" 325 325 }, 326 326 { 327 327 .adr = 0x00023201FA355601ull, 328 328 .num_endpoints = 1, 329 329 .endpoints = &spk_2_endpoint, 330 - .name_prefix = "cs35l56-2" 330 + .name_prefix = "AMP2" 331 331 } 332 332 }; 333 333
+1 -1
sound/soc/mediatek/mt8186/mt8186-dai-adda.c
··· 499 499 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 500 500 501 501 SND_SOC_DAPM_SUPPLY_S("AUD_PAD_TOP", SUPPLY_SEQ_ADDA_AUD_PAD_TOP, 502 - 0, 0, 0, 502 + AFE_AUD_PAD_TOP, RG_RX_FIFO_ON_SFT, 0, 503 503 mtk_adda_pad_top_event, 504 504 SND_SOC_DAPM_PRE_PMU), 505 505 SND_SOC_DAPM_SUPPLY_S("ADDA_MTKAIF_CFG", SUPPLY_SEQ_ADDA_MTKAIF_CFG,
+4 -1
sound/soc/meson/g12a-toacodec.c
··· 71 71 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 72 72 unsigned int mux, reg; 73 73 74 + if (ucontrol->value.enumerated.item[0] >= e->items) 75 + return -EINVAL; 76 + 74 77 mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]); 75 78 regmap_field_read(priv->field_dat_sel, &reg); 76 79 ··· 104 101 105 102 snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL); 106 103 107 - return 0; 104 + return 1; 108 105 } 109 106 110 107 static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0,
+7 -1
sound/soc/meson/g12a-tohdmitx.c
··· 45 45 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 46 46 unsigned int mux, changed; 47 47 48 + if (ucontrol->value.enumerated.item[0] >= e->items) 49 + return -EINVAL; 50 + 48 51 mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]); 49 52 changed = snd_soc_component_test_bits(component, e->reg, 50 53 CTRL0_I2S_DAT_SEL, ··· 96 93 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 97 94 unsigned int mux, changed; 98 95 96 + if (ucontrol->value.enumerated.item[0] >= e->items) 97 + return -EINVAL; 98 + 99 99 mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]); 100 100 changed = snd_soc_component_test_bits(component, TOHDMITX_CTRL0, 101 101 CTRL0_SPDIF_SEL, ··· 118 112 119 113 snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL); 120 114 121 - return 0; 115 + return 1; 122 116 } 123 117 124 118 static SOC_ENUM_SINGLE_DECL(g12a_tohdmitx_spdif_mux_enum, TOHDMITX_CTRL0,
+9 -9
sound/soc/sof/intel/hda-codec.c
··· 54 54 55 55 static int hda_codec_load_module(struct hda_codec *codec) 56 56 { 57 - int ret = request_codec_module(codec); 57 + int ret; 58 58 59 + ret = snd_hdac_device_register(&codec->core); 60 + if (ret) { 61 + dev_err(&codec->core.dev, "failed to register hdac device\n"); 62 + put_device(&codec->core.dev); 63 + return ret; 64 + } 65 + 66 + ret = request_codec_module(codec); 59 67 if (ret <= 0) { 60 68 codec->probe_id = HDA_CODEC_ID_GENERIC; 61 69 ret = request_codec_module(codec); ··· 124 116 static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, int type) 125 117 { 126 118 struct hda_codec *codec; 127 - int ret; 128 119 129 120 codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "ehdaudio%dD%d", bus->idx, addr); 130 121 if (IS_ERR(codec)) { ··· 132 125 } 133 126 134 127 codec->core.type = type; 135 - 136 - ret = snd_hdac_device_register(&codec->core); 137 - if (ret) { 138 - dev_err(bus->dev, "failed to register hdac device\n"); 139 - put_device(&codec->core.dev); 140 - return ERR_PTR(ret); 141 - } 142 128 143 129 return codec; 144 130 }
-3
sound/soc/sof/mediatek/mt8186/mt8186.c
··· 597 597 598 598 static struct snd_sof_of_mach sof_mt8186_machs[] = { 599 599 { 600 - .compatible = "google,steelix", 601 - .sof_tplg_filename = "sof-mt8186-google-steelix.tplg" 602 - }, { 603 600 .compatible = "mediatek,mt8186", 604 601 .sof_tplg_filename = "sof-mt8186.tplg", 605 602 },
+2 -2
sound/usb/mixer_scarlett2.c
··· 1966 1966 __le16 num_meters; 1967 1967 __le32 magic; 1968 1968 } __packed req; 1969 - u32 resp[SCARLETT2_MAX_METERS]; 1969 + __le32 resp[SCARLETT2_MAX_METERS]; 1970 1970 int i, err; 1971 1971 1972 1972 req.pad = 0; ··· 1979 1979 1980 1980 /* copy, convert to u16 */ 1981 1981 for (i = 0; i < num_meters; i++) 1982 - levels[i] = resp[i]; 1982 + levels[i] = le32_to_cpu(resp[i]); 1983 1983 1984 1984 return 0; 1985 1985 }
+2 -2
sound/usb/quirks.c
··· 1387 1387 1388 1388 static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) 1389 1389 { 1390 - msleep(2000); 1390 + msleep(4000); 1391 1391 1392 1392 return 0; 1393 1393 } ··· 1630 1630 unsigned int id) 1631 1631 { 1632 1632 switch (id) { 1633 - case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ 1633 + case USB_ID(0x07fd, 0x0008): /* MOTU M Series, 1st hardware version */ 1634 1634 return snd_usb_motu_m_series_boot_quirk(dev); 1635 1635 } 1636 1636
+1 -1
tools/testing/radix-tree/maple.c
··· 35538 35538 MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0); 35539 35539 allocated = mas_allocated(&mas); 35540 35540 height = mas_mt_height(&mas); 35541 - MT_BUG_ON(mt, allocated != 1); 35541 + MT_BUG_ON(mt, allocated != 0); 35542 35542 mas_store_prealloc(&mas, ptr); 35543 35543 MT_BUG_ON(mt, mas_allocated(&mas) != 0); 35544 35544
+1 -1
tools/testing/selftests/alsa/mixer-test.c
··· 138 138 err = snd_ctl_elem_info(card_data->handle, 139 139 ctl_data->info); 140 140 if (err < 0) { 141 - ksft_print_msg("%s getting info for %d\n", 141 + ksft_print_msg("%s getting info for %s\n", 142 142 snd_strerror(err), 143 143 ctl_data->name); 144 144 }
+3 -3
tools/testing/selftests/drivers/net/bonding/bond-arp-interval-causes-panic.sh
··· 30 30 31 31 ip netns exec client ip link add dev bond0 down type bond mode 1 \ 32 32 miimon 100 all_slaves_active 1 33 - ip netns exec client ip link set dev eth0 down master bond0 33 + ip netns exec client ip link set dev eth0 master bond0 34 34 ip netns exec client ip link set dev bond0 up 35 35 ip netns exec client ip addr add ${client_ip4}/24 dev bond0 36 36 ip netns exec client ping -c 5 $server_ip4 >/dev/null 37 37 38 - ip netns exec client ip link set dev eth0 down nomaster 38 + ip netns exec client ip link set dev eth0 nomaster 39 39 ip netns exec client ip link set dev bond0 down 40 40 ip netns exec client ip link set dev bond0 type bond mode 0 \ 41 41 arp_interval 1000 arp_ip_target "+${server_ip4}" 42 - ip netns exec client ip link set dev eth0 down master bond0 42 + ip netns exec client ip link set dev eth0 master bond0 43 43 ip netns exec client ip link set dev bond0 up 44 44 ip netns exec client ping -c 5 $server_ip4 >/dev/null 45 45
+16 -10
tools/testing/selftests/kvm/Makefile
··· 17 17 ARCH_DIR := $(ARCH) 18 18 endif 19 19 20 - ifeq ($(ARCH),arm64) 21 - tools_dir := $(top_srcdir)/tools 22 - arm64_tools_dir := $(tools_dir)/arch/arm64/tools/ 23 - GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/ 24 - CFLAGS += -I$(GEN_HDRS) 25 - 26 - $(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*) 27 - $(MAKE) -C $(arm64_tools_dir) O=$(tools_dir) 28 - endif 29 - 30 20 LIBKVM += lib/assert.c 31 21 LIBKVM += lib/elf.c 32 22 LIBKVM += lib/guest_modes.c ··· 223 233 $(KHDR_INCLUDES) 224 234 ifeq ($(ARCH),s390) 225 235 CFLAGS += -march=z10 236 + endif 237 + ifeq ($(ARCH),arm64) 238 + tools_dir := $(top_srcdir)/tools 239 + arm64_tools_dir := $(tools_dir)/arch/arm64/tools/ 240 + 241 + ifneq ($(abs_objdir),) 242 + arm64_hdr_outdir := $(abs_objdir)/tools/ 243 + else 244 + arm64_hdr_outdir := $(tools_dir)/ 245 + endif 246 + 247 + GEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/ 248 + CFLAGS += -I$(GEN_HDRS) 249 + 250 + $(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*) 251 + $(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir) 226 252 endif 227 253 228 254 no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
+5 -4
tools/testing/selftests/kvm/get-reg-list.c
··· 71 71 for_each_sublist(c, s) { 72 72 if (!strcmp(s->name, "base")) 73 73 continue; 74 - strcat(c->name + len, s->name); 75 - len += strlen(s->name) + 1; 76 - c->name[len - 1] = '+'; 74 + if (len) 75 + c->name[len++] = '+'; 76 + strcpy(c->name + len, s->name); 77 + len += strlen(s->name); 77 78 } 78 - c->name[len - 1] = '\0'; 79 + c->name[len] = '\0'; 79 80 80 81 return c->name; 81 82 }
+6 -4
tools/testing/selftests/kvm/riscv/get-reg-list.c
··· 458 458 reg_size = "KVM_REG_SIZE_U128"; 459 459 break; 460 460 default: 461 - printf("\tKVM_REG_RISCV | (%lld << KVM_REG_SIZE_SHIFT) | 0x%llx /* UNKNOWN */,", 462 - (id & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT, id & REG_MASK); 461 + printf("\tKVM_REG_RISCV | (%lld << KVM_REG_SIZE_SHIFT) | 0x%llx /* UNKNOWN */,\n", 462 + (id & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT, id & ~REG_MASK); 463 + return; 463 464 } 464 465 465 466 switch (id & KVM_REG_RISCV_TYPE_MASK) { ··· 497 496 reg_size, sbi_ext_id_to_str(prefix, id)); 498 497 break; 499 498 default: 500 - printf("\tKVM_REG_RISCV | %s | 0x%llx /* UNKNOWN */,", 501 - reg_size, id & REG_MASK); 499 + printf("\tKVM_REG_RISCV | %s | 0x%llx /* UNKNOWN */,\n", 500 + reg_size, id & ~REG_MASK); 501 + return; 502 502 } 503 503 } 504 504
+3
tools/testing/selftests/mm/memfd_secret.c
··· 62 62 char *mem; 63 63 64 64 len = mlock_limit_cur; 65 + if (len % page_size != 0) 66 + len = (len/page_size) * page_size; 67 + 65 68 mem = mmap(NULL, len, prot, mode, fd, 0); 66 69 if (mem == MAP_FAILED) { 67 70 fail("unable to mmap secret memory\n");
+2 -1
virt/kvm/kvm_main.c
··· 5540 5540 return r < 0 ? r : 0; 5541 5541 } 5542 5542 5543 - /* Caller must hold slots_lock. */ 5544 5543 int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, 5545 5544 int len, struct kvm_io_device *dev) 5546 5545 { 5547 5546 int i; 5548 5547 struct kvm_io_bus *new_bus, *bus; 5549 5548 struct kvm_io_range range; 5549 + 5550 + lockdep_assert_held(&kvm->slots_lock); 5550 5551 5551 5552 bus = kvm_get_bus(kvm, bus_idx); 5552 5553 if (!bus)