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

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

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

No conflicts.

Adjacent changes:

drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
9536fbe10c9d ("net/mlx5e: Add PSP steering in local NIC RX")
7601a0a46216 ("net/mlx5e: Add a miss level for ipsec crypto offload")

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

+2557 -1342
+4
Documentation/devicetree/bindings/dma/qcom,bam-dma.yaml
··· 92 92 anyOf: 93 93 - required: 94 94 - qcom,powered-remotely 95 + - num-channels 96 + - qcom,num-ees 95 97 - required: 96 98 - qcom,controlled-remotely 99 + - num-channels 100 + - qcom,num-ees 97 101 - required: 98 102 - clocks 99 103 - clock-names
+21 -8
Documentation/devicetree/bindings/phy/marvell,comphy-cp110.yaml
··· 47 47 const: 0 48 48 49 49 clocks: 50 + minItems: 1 50 51 maxItems: 3 51 - description: Reference clocks for CP110; MG clock, MG Core clock, AXI clock 52 52 53 53 clock-names: 54 - items: 55 - - const: mg_clk 56 - - const: mg_core_clk 57 - - const: axi_clk 54 + minItems: 1 55 + maxItems: 3 58 56 59 57 marvell,system-controller: 60 58 description: Phandle to the Marvell system controller (CP110 only) 61 59 $ref: /schemas/types.yaml#/definitions/phandle 62 60 63 61 patternProperties: 64 - '^phy@[0-2]$': 62 + '^phy@[0-5]$': 65 63 description: A COMPHY lane child node 66 64 type: object 67 65 additionalProperties: false ··· 67 69 properties: 68 70 reg: 69 71 description: COMPHY lane number 72 + maximum: 5 70 73 71 74 '#phy-cells': 72 75 const: 1 76 + 77 + connector: 78 + type: object 73 79 74 80 required: 75 81 - reg ··· 93 91 94 92 then: 95 93 properties: 96 - clocks: false 97 - clock-names: false 94 + clocks: 95 + maxItems: 1 96 + clock-names: 97 + const: xtal 98 98 99 99 required: 100 100 - reg-names 101 101 102 102 else: 103 + properties: 104 + clocks: 105 + minItems: 3 106 + clock-names: 107 + items: 108 + - const: mg_clk 109 + - const: mg_core_clk 110 + - const: axi_clk 111 + 103 112 required: 104 113 - marvell,system-controller 105 114
+2 -2
Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-pcie-phy.yaml
··· 176 176 compatible: 177 177 contains: 178 178 enum: 179 + - qcom,sa8775p-qmp-gen4x2-pcie-phy 180 + - qcom,sa8775p-qmp-gen4x4-pcie-phy 179 181 - qcom,sc8280xp-qmp-gen3x1-pcie-phy 180 182 - qcom,sc8280xp-qmp-gen3x2-pcie-phy 181 183 - qcom,sc8280xp-qmp-gen3x4-pcie-phy ··· 199 197 contains: 200 198 enum: 201 199 - qcom,qcs8300-qmp-gen4x2-pcie-phy 202 - - qcom,sa8775p-qmp-gen4x2-pcie-phy 203 - - qcom,sa8775p-qmp-gen4x4-pcie-phy 204 200 then: 205 201 properties: 206 202 clocks:
+31 -25
Documentation/devicetree/bindings/serial/8250.yaml
··· 48 48 oneOf: 49 49 - required: [ clock-frequency ] 50 50 - required: [ clocks ] 51 - 52 51 - if: 53 52 properties: 54 53 compatible: ··· 59 60 items: 60 61 - const: uartclk 61 62 - const: reg 62 - else: 63 + - if: 64 + properties: 65 + compatible: 66 + contains: 67 + const: spacemit,k1-uart 68 + then: 63 69 properties: 64 70 clock-names: 65 71 items: 66 72 - const: core 67 73 - const: bus 74 + - if: 75 + properties: 76 + compatible: 77 + contains: 78 + enum: 79 + - spacemit,k1-uart 80 + - nxp,lpc1850-uart 81 + then: 82 + required: 83 + - clocks 84 + - clock-names 85 + properties: 86 + clocks: 87 + minItems: 2 88 + clock-names: 89 + minItems: 2 90 + else: 91 + properties: 92 + clocks: 93 + maxItems: 1 94 + clock-names: 95 + maxItems: 1 68 96 69 97 properties: 70 98 compatible: ··· 188 162 minItems: 1 189 163 maxItems: 2 190 164 oneOf: 165 + - enum: 166 + - main 167 + - uart 191 168 - items: 192 169 - const: core 193 170 - const: bus ··· 292 263 required: 293 264 - reg 294 265 - interrupts 295 - 296 - if: 297 - properties: 298 - compatible: 299 - contains: 300 - enum: 301 - - spacemit,k1-uart 302 - - nxp,lpc1850-uart 303 - then: 304 - required: 305 - - clocks 306 - - clock-names 307 - properties: 308 - clocks: 309 - minItems: 2 310 - clock-names: 311 - minItems: 2 312 - else: 313 - properties: 314 - clocks: 315 - maxItems: 1 316 - clock-names: 317 - maxItems: 1 318 266 319 267 unevaluatedProperties: false 320 268
+1 -1
Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
··· 41 41 - const: dma_intr2 42 42 43 43 clocks: 44 - minItems: 1 44 + maxItems: 1 45 45 46 46 clock-names: 47 47 const: sw_baud
+4 -5
Documentation/netlink/specs/conntrack.yaml
··· 575 575 - nat-dst 576 576 - timeout 577 577 - mark 578 - - counter-orig 579 - - counter-reply 578 + - counters-orig 579 + - counters-reply 580 580 - use 581 581 - id 582 582 - nat-dst ··· 591 591 request: 592 592 value: 0x101 593 593 attributes: 594 - - nfgen-family 595 594 - mark 596 595 - filter 597 596 - status ··· 607 608 - nat-dst 608 609 - timeout 609 610 - mark 610 - - counter-orig 611 - - counter-reply 611 + - counters-orig 612 + - counters-reply 612 613 - use 613 614 - id 614 615 - nat-dst
+2 -2
Documentation/netlink/specs/mptcp_pm.yaml
··· 28 28 traffic-patterns it can take a long time until the 29 29 MPTCP_EVENT_ESTABLISHED is sent. 30 30 Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, sport, 31 - dport, server-side. 31 + dport, server-side, [flags]. 32 32 - 33 33 name: established 34 34 doc: >- 35 35 A MPTCP connection is established (can start new subflows). 36 36 Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, sport, 37 - dport, server-side. 37 + dport, server-side, [flags]. 38 38 - 39 39 name: closed 40 40 doc: >-
+17 -13
MAINTAINERS
··· 7238 7238 F: kernel/dma/ 7239 7239 7240 7240 DMA MAPPING HELPERS DEVICE DRIVER API [RUST] 7241 - M: Abdiel Janulgue <abdiel.janulgue@gmail.com> 7242 7241 M: Danilo Krummrich <dakr@kernel.org> 7242 + R: Abdiel Janulgue <abdiel.janulgue@gmail.com> 7243 7243 R: Daniel Almeida <daniel.almeida@collabora.com> 7244 7244 R: Robin Murphy <robin.murphy@arm.com> 7245 7245 R: Andreas Hindborg <a.hindborg@kernel.org> 7246 7246 L: rust-for-linux@vger.kernel.org 7247 7247 S: Supported 7248 7248 W: https://rust-for-linux.com 7249 - T: git https://github.com/Rust-for-Linux/linux.git alloc-next 7249 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git 7250 7250 F: rust/helpers/dma.c 7251 7251 F: rust/kernel/dma.rs 7252 7252 F: samples/rust/rust_dma.rs ··· 7431 7431 F: Documentation/devicetree/bindings/dpll/dpll-device.yaml 7432 7432 F: Documentation/devicetree/bindings/dpll/dpll-pin.yaml 7433 7433 F: Documentation/driver-api/dpll.rst 7434 - F: drivers/dpll/* 7434 + F: drivers/dpll/ 7435 7435 F: include/linux/dpll.h 7436 7436 F: include/uapi/linux/dpll.h 7437 7437 ··· 8079 8079 F: Documentation/gpu/ 8080 8080 F: drivers/gpu/drm/ 8081 8081 F: drivers/gpu/vga/ 8082 - F: rust/kernel/drm/ 8083 8082 F: include/drm/drm 8084 8083 F: include/linux/vga* 8085 8084 F: include/uapi/drm/ ··· 8090 8091 X: drivers/gpu/drm/kmb/ 8091 8092 X: drivers/gpu/drm/mediatek/ 8092 8093 X: drivers/gpu/drm/msm/ 8093 - X: drivers/gpu/drm/nouveau/ 8094 + X: drivers/gpu/drm/nova/ 8094 8095 X: drivers/gpu/drm/radeon/ 8095 8096 X: drivers/gpu/drm/tegra/ 8096 8097 X: drivers/gpu/drm/xe/ 8098 + 8099 + DRM DRIVERS AND COMMON INFRASTRUCTURE [RUST] 8100 + M: Danilo Krummrich <dakr@kernel.org> 8101 + M: Alice Ryhl <aliceryhl@google.com> 8102 + S: Supported 8103 + W: https://drm.pages.freedesktop.org/maintainer-tools/drm-rust.html 8104 + T: git https://gitlab.freedesktop.org/drm/rust/kernel.git 8105 + F: drivers/gpu/drm/nova/ 8106 + F: drivers/gpu/nova-core/ 8107 + F: rust/kernel/drm/ 8097 8108 8098 8109 DRM DRIVERS FOR ALLWINNER A10 8099 8110 M: Maxime Ripard <mripard@kernel.org> ··· 15747 15738 W: http://www.melexis.com 15748 15739 F: drivers/iio/temperature/mlx90635.c 15749 15740 15750 - MELFAS MIP4 TOUCHSCREEN DRIVER 15751 - M: Sangwon Jee <jeesw@melfas.com> 15752 - S: Supported 15753 - W: http://www.melfas.com 15754 - F: Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt 15755 - F: drivers/input/touchscreen/melfas_mip4.c 15756 - 15757 15741 MELLANOX BLUEFIELD I2C DRIVER 15758 15742 M: Khalil Blaiech <kblaiech@nvidia.com> 15759 15743 M: Asmaa Mnebhi <asmaa@nvidia.com> ··· 16195 16193 R: Liam R. Howlett <Liam.Howlett@oracle.com> 16196 16194 R: Vlastimil Babka <vbabka@suse.cz> 16197 16195 R: Harry Yoo <harry.yoo@oracle.com> 16196 + R: Jann Horn <jannh@google.com> 16198 16197 L: linux-mm@kvack.org 16199 16198 S: Maintained 16200 16199 F: include/linux/rmap.h ··· 16240 16237 R: Ryan Roberts <ryan.roberts@arm.com> 16241 16238 R: Dev Jain <dev.jain@arm.com> 16242 16239 R: Barry Song <baohua@kernel.org> 16240 + R: Lance Yang <lance.yang@linux.dev> 16243 16241 L: linux-mm@kvack.org 16244 16242 S: Maintained 16245 16243 W: http://www.linux-mm.org ··· 24275 24271 F: drivers/input/keyboard/sun4i-lradc-keys.c 24276 24272 24277 24273 SUNDANCE NETWORK DRIVER 24278 - M: Denis Kirjanov <dkirjanov@suse.de> 24274 + M: Denis Kirjanov <kirjanov@gmail.com> 24279 24275 L: netdev@vger.kernel.org 24280 24276 S: Maintained 24281 24277 F: drivers/net/ethernet/dlink/sundance.c
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 17 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc5 5 + EXTRAVERSION = -rc6 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+1
arch/arm64/include/asm/kvm_host.h
··· 1369 1369 } 1370 1370 1371 1371 void kvm_init_host_debug_data(void); 1372 + void kvm_debug_init_vhe(void); 1372 1373 void kvm_vcpu_load_debug(struct kvm_vcpu *vcpu); 1373 1374 void kvm_vcpu_put_debug(struct kvm_vcpu *vcpu); 1374 1375 void kvm_debug_set_guest_ownership(struct kvm_vcpu *vcpu);
-30
arch/arm64/include/asm/kvm_pgtable.h
··· 355 355 return pteref; 356 356 } 357 357 358 - static inline kvm_pte_t *kvm_dereference_pteref_raw(kvm_pteref_t pteref) 359 - { 360 - return pteref; 361 - } 362 - 363 358 static inline int kvm_pgtable_walk_begin(struct kvm_pgtable_walker *walker) 364 359 { 365 360 /* ··· 382 387 kvm_pteref_t pteref) 383 388 { 384 389 return rcu_dereference_check(pteref, !(walker->flags & KVM_PGTABLE_WALK_SHARED)); 385 - } 386 - 387 - static inline kvm_pte_t *kvm_dereference_pteref_raw(kvm_pteref_t pteref) 388 - { 389 - return rcu_dereference_raw(pteref); 390 390 } 391 391 392 392 static inline int kvm_pgtable_walk_begin(struct kvm_pgtable_walker *walker) ··· 550 560 * to freeing and therefore no TLB invalidation is performed. 551 561 */ 552 562 void kvm_pgtable_stage2_destroy(struct kvm_pgtable *pgt); 553 - 554 - /** 555 - * kvm_pgtable_stage2_destroy_range() - Destroy the unlinked range of addresses. 556 - * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*(). 557 - * @addr: Intermediate physical address at which to place the mapping. 558 - * @size: Size of the mapping. 559 - * 560 - * The page-table is assumed to be unreachable by any hardware walkers prior 561 - * to freeing and therefore no TLB invalidation is performed. 562 - */ 563 - void kvm_pgtable_stage2_destroy_range(struct kvm_pgtable *pgt, 564 - u64 addr, u64 size); 565 - 566 - /** 567 - * kvm_pgtable_stage2_destroy_pgd() - Destroy the PGD of guest stage-2 page-table. 568 - * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*(). 569 - * 570 - * It is assumed that the rest of the page-table is freed before this operation. 571 - */ 572 - void kvm_pgtable_stage2_destroy_pgd(struct kvm_pgtable *pgt); 573 563 574 564 /** 575 565 * kvm_pgtable_stage2_free_unlinked() - Free an unlinked stage-2 paging structure.
+1 -3
arch/arm64/include/asm/kvm_pkvm.h
··· 179 179 180 180 int pkvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm_s2_mmu *mmu, 181 181 struct kvm_pgtable_mm_ops *mm_ops); 182 - void pkvm_pgtable_stage2_destroy_range(struct kvm_pgtable *pgt, 183 - u64 addr, u64 size); 184 - void pkvm_pgtable_stage2_destroy_pgd(struct kvm_pgtable *pgt); 182 + void pkvm_pgtable_stage2_destroy(struct kvm_pgtable *pgt); 185 183 int pkvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, u64 phys, 186 184 enum kvm_pgtable_prot prot, void *mc, 187 185 enum kvm_pgtable_walk_flags flags);
+3 -1
arch/arm64/kvm/arm.c
··· 2113 2113 { 2114 2114 cpu_set_hyp_vector(); 2115 2115 2116 - if (is_kernel_in_hyp_mode()) 2116 + if (is_kernel_in_hyp_mode()) { 2117 2117 kvm_timer_init_vhe(); 2118 + kvm_debug_init_vhe(); 2119 + } 2118 2120 2119 2121 if (vgic_present) 2120 2122 kvm_vgic_init_cpu_hardware();
+13
arch/arm64/kvm/debug.c
··· 96 96 } 97 97 } 98 98 99 + void kvm_debug_init_vhe(void) 100 + { 101 + /* Clear PMSCR_EL1.E{0,1}SPE which reset to UNKNOWN values. */ 102 + if (SYS_FIELD_GET(ID_AA64DFR0_EL1, PMSVer, read_sysreg(id_aa64dfr0_el1))) 103 + write_sysreg_el1(0, SYS_PMSCR); 104 + } 105 + 99 106 /* 100 107 * Configures the 'external' MDSCR_EL1 value for the guest, i.e. when the host 101 108 * has taken over MDSCR_EL1. ··· 144 137 145 138 /* Must be called before kvm_vcpu_load_vhe() */ 146 139 KVM_BUG_ON(vcpu_get_flag(vcpu, SYSREGS_ON_CPU), vcpu->kvm); 140 + 141 + if (has_vhe()) 142 + *host_data_ptr(host_debug_state.mdcr_el2) = read_sysreg(mdcr_el2); 147 143 148 144 /* 149 145 * Determine which of the possible debug states we're in: ··· 194 184 195 185 void kvm_vcpu_put_debug(struct kvm_vcpu *vcpu) 196 186 { 187 + if (has_vhe()) 188 + write_sysreg(*host_data_ptr(host_debug_state.mdcr_el2), mdcr_el2); 189 + 197 190 if (likely(!(vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP))) 198 191 return; 199 192
-5
arch/arm64/kvm/hyp/include/hyp/switch.h
··· 431 431 vcpu_set_flag(vcpu, PMUSERENR_ON_CPU); 432 432 } 433 433 434 - *host_data_ptr(host_debug_state.mdcr_el2) = read_sysreg(mdcr_el2); 435 - write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); 436 - 437 434 if (cpus_have_final_cap(ARM64_HAS_HCX)) { 438 435 u64 hcrx = vcpu->arch.hcrx_el2; 439 436 if (is_nested_ctxt(vcpu)) { ··· 450 453 static inline void __deactivate_traps_common(struct kvm_vcpu *vcpu) 451 454 { 452 455 struct kvm_cpu_context *hctxt = host_data_ptr(host_ctxt); 453 - 454 - write_sysreg(*host_data_ptr(host_debug_state.mdcr_el2), mdcr_el2); 455 456 456 457 write_sysreg(0, hstr_el2); 457 458 if (system_supports_pmuv3()) {
+6
arch/arm64/kvm/hyp/nvhe/switch.c
··· 50 50 static void __activate_traps(struct kvm_vcpu *vcpu) 51 51 { 52 52 ___activate_traps(vcpu, vcpu->arch.hcr_el2); 53 + 54 + *host_data_ptr(host_debug_state.mdcr_el2) = read_sysreg(mdcr_el2); 55 + write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); 56 + 53 57 __activate_traps_common(vcpu); 54 58 __activate_cptr_traps(vcpu); 55 59 ··· 96 92 write_sysreg_el1(val | SCTLR_ELx_M, SYS_SCTLR); 97 93 isb(); 98 94 } 95 + 96 + write_sysreg(*host_data_ptr(host_debug_state.mdcr_el2), mdcr_el2); 99 97 100 98 __deactivate_traps_common(vcpu); 101 99
+1 -1
arch/arm64/kvm/hyp/nvhe/sys_regs.c
··· 253 253 254 254 *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); 255 255 *vcpu_cpsr(vcpu) = read_sysreg_el2(SYS_SPSR); 256 - __vcpu_assign_sys_reg(vcpu, read_sysreg_el1(SYS_VBAR), VBAR_EL1); 256 + __vcpu_assign_sys_reg(vcpu, VBAR_EL1, read_sysreg_el1(SYS_VBAR)); 257 257 258 258 kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC); 259 259
+4 -21
arch/arm64/kvm/hyp/pgtable.c
··· 1551 1551 return 0; 1552 1552 } 1553 1553 1554 - void kvm_pgtable_stage2_destroy_range(struct kvm_pgtable *pgt, 1555 - u64 addr, u64 size) 1554 + void kvm_pgtable_stage2_destroy(struct kvm_pgtable *pgt) 1556 1555 { 1556 + size_t pgd_sz; 1557 1557 struct kvm_pgtable_walker walker = { 1558 1558 .cb = stage2_free_walker, 1559 1559 .flags = KVM_PGTABLE_WALK_LEAF | 1560 1560 KVM_PGTABLE_WALK_TABLE_POST, 1561 1561 }; 1562 1562 1563 - WARN_ON(kvm_pgtable_walk(pgt, addr, size, &walker)); 1564 - } 1565 - 1566 - void kvm_pgtable_stage2_destroy_pgd(struct kvm_pgtable *pgt) 1567 - { 1568 - size_t pgd_sz; 1569 - 1563 + WARN_ON(kvm_pgtable_walk(pgt, 0, BIT(pgt->ia_bits), &walker)); 1570 1564 pgd_sz = kvm_pgd_pages(pgt->ia_bits, pgt->start_level) * PAGE_SIZE; 1571 - 1572 - /* 1573 - * Since the pgtable is unlinked at this point, and not shared with 1574 - * other walkers, safely deference pgd with kvm_dereference_pteref_raw() 1575 - */ 1576 - pgt->mm_ops->free_pages_exact(kvm_dereference_pteref_raw(pgt->pgd), pgd_sz); 1565 + pgt->mm_ops->free_pages_exact(kvm_dereference_pteref(&walker, pgt->pgd), pgd_sz); 1577 1566 pgt->pgd = NULL; 1578 - } 1579 - 1580 - void kvm_pgtable_stage2_destroy(struct kvm_pgtable *pgt) 1581 - { 1582 - kvm_pgtable_stage2_destroy_range(pgt, 0, BIT(pgt->ia_bits)); 1583 - kvm_pgtable_stage2_destroy_pgd(pgt); 1584 1567 } 1585 1568 1586 1569 void kvm_pgtable_stage2_free_unlinked(struct kvm_pgtable_mm_ops *mm_ops, void *pgtable, s8 level)
+6 -39
arch/arm64/kvm/mmu.c
··· 904 904 return 0; 905 905 } 906 906 907 - /* 908 - * Assume that @pgt is valid and unlinked from the KVM MMU to free the 909 - * page-table without taking the kvm_mmu_lock and without performing any 910 - * TLB invalidations. 911 - * 912 - * Also, the range of addresses can be large enough to cause need_resched 913 - * warnings, for instance on CONFIG_PREEMPT_NONE kernels. Hence, invoke 914 - * cond_resched() periodically to prevent hogging the CPU for a long time 915 - * and schedule something else, if required. 916 - */ 917 - static void stage2_destroy_range(struct kvm_pgtable *pgt, phys_addr_t addr, 918 - phys_addr_t end) 919 - { 920 - u64 next; 921 - 922 - do { 923 - next = stage2_range_addr_end(addr, end); 924 - KVM_PGT_FN(kvm_pgtable_stage2_destroy_range)(pgt, addr, 925 - next - addr); 926 - if (next != end) 927 - cond_resched(); 928 - } while (addr = next, addr != end); 929 - } 930 - 931 - static void kvm_stage2_destroy(struct kvm_pgtable *pgt) 932 - { 933 - unsigned int ia_bits = VTCR_EL2_IPA(pgt->mmu->vtcr); 934 - 935 - stage2_destroy_range(pgt, 0, BIT(ia_bits)); 936 - KVM_PGT_FN(kvm_pgtable_stage2_destroy_pgd)(pgt); 937 - } 938 - 939 907 /** 940 908 * kvm_init_stage2_mmu - Initialise a S2 MMU structure 941 909 * @kvm: The pointer to the KVM structure ··· 980 1012 return 0; 981 1013 982 1014 out_destroy_pgtable: 983 - kvm_stage2_destroy(pgt); 1015 + KVM_PGT_FN(kvm_pgtable_stage2_destroy)(pgt); 984 1016 out_free_pgtable: 985 1017 kfree(pgt); 986 1018 return err; ··· 1074 1106 mmu->pgt = NULL; 1075 1107 free_percpu(mmu->last_vcpu_ran); 1076 1108 } 1109 + 1110 + if (kvm_is_nested_s2_mmu(kvm, mmu)) 1111 + kvm_init_nested_s2_mmu(mmu); 1112 + 1077 1113 write_unlock(&kvm->mmu_lock); 1078 1114 1079 1115 if (pgt) { 1080 - kvm_stage2_destroy(pgt); 1116 + KVM_PGT_FN(kvm_pgtable_stage2_destroy)(pgt); 1081 1117 kfree(pgt); 1082 1118 } 1083 1119 } ··· 1512 1540 write_fault = kvm_is_write_fault(vcpu); 1513 1541 exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu); 1514 1542 VM_BUG_ON(write_fault && exec_fault); 1515 - 1516 - if (fault_is_perm && !write_fault && !exec_fault) { 1517 - kvm_err("Unexpected L2 read permission error\n"); 1518 - return -EFAULT; 1519 - } 1520 1543 1521 1544 if (!is_protected_kvm_enabled()) 1522 1545 memcache = &vcpu->arch.mmu_page_cache;
+3 -3
arch/arm64/kvm/nested.c
··· 847 847 848 848 ipa_size = ttl_to_size(pgshift_level_to_ttl(vt->wi.pgshift, 849 849 vt->wr.level)); 850 - ipa_start = vt->wr.pa & (ipa_size - 1); 850 + ipa_start = vt->wr.pa & ~(ipa_size - 1); 851 851 ipa_end = ipa_start + ipa_size; 852 852 853 853 if (ipa_end <= start || ipa_start >= end) ··· 887 887 888 888 va_size = ttl_to_size(pgshift_level_to_ttl(vt->wi.pgshift, 889 889 vt->wr.level)); 890 - va_start = vt->gva & (va_size - 1); 890 + va_start = vt->gva & ~(va_size - 1); 891 891 va_end = va_start + va_size; 892 892 893 893 switch (scope->type) { ··· 1276 1276 !(tcr & TCR_ASID16)) 1277 1277 asid &= GENMASK(7, 0); 1278 1278 1279 - return asid != vt->wr.asid; 1279 + return asid == vt->wr.asid; 1280 1280 } 1281 1281 1282 1282 return true;
+2 -9
arch/arm64/kvm/pkvm.c
··· 316 316 return 0; 317 317 } 318 318 319 - void pkvm_pgtable_stage2_destroy_range(struct kvm_pgtable *pgt, 320 - u64 addr, u64 size) 319 + void pkvm_pgtable_stage2_destroy(struct kvm_pgtable *pgt) 321 320 { 322 - __pkvm_pgtable_stage2_unmap(pgt, addr, addr + size); 323 - } 324 - 325 - void pkvm_pgtable_stage2_destroy_pgd(struct kvm_pgtable *pgt) 326 - { 327 - /* Expected to be called after all pKVM mappings have been released. */ 328 - WARN_ON_ONCE(!RB_EMPTY_ROOT(&pgt->pkvm_mappings.rb_root)); 321 + __pkvm_pgtable_stage2_unmap(pgt, 0, ~(0ULL)); 329 322 } 330 323 331 324 int pkvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size,
+1 -1
arch/arm64/kvm/vgic/vgic-debug.c
··· 69 69 int nr_lpis = 0; 70 70 71 71 xa_for_each(&dist->lpi_xa, intid, irq) { 72 - if (!vgic_try_get_irq_kref(irq)) 72 + if (!vgic_try_get_irq_ref(irq)) 73 73 continue; 74 74 75 75 xa_set_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER);
+3 -3
arch/arm64/kvm/vgic/vgic-init.c
··· 53 53 { 54 54 struct vgic_dist *dist = &kvm->arch.vgic; 55 55 56 - xa_init_flags(&dist->lpi_xa, XA_FLAGS_LOCK_IRQ); 56 + xa_init(&dist->lpi_xa); 57 57 } 58 58 59 59 /* CREATION */ ··· 208 208 raw_spin_lock_init(&irq->irq_lock); 209 209 irq->vcpu = NULL; 210 210 irq->target_vcpu = vcpu0; 211 - kref_init(&irq->refcount); 211 + refcount_set(&irq->refcount, 0); 212 212 switch (dist->vgic_model) { 213 213 case KVM_DEV_TYPE_ARM_VGIC_V2: 214 214 irq->targets = 0; ··· 277 277 irq->intid = i; 278 278 irq->vcpu = NULL; 279 279 irq->target_vcpu = vcpu; 280 - kref_init(&irq->refcount); 280 + refcount_set(&irq->refcount, 0); 281 281 if (vgic_irq_is_sgi(i)) { 282 282 /* SGIs */ 283 283 irq->enabled = 1;
+7 -8
arch/arm64/kvm/vgic/vgic-its.c
··· 78 78 { 79 79 struct vgic_dist *dist = &kvm->arch.vgic; 80 80 struct vgic_irq *irq = vgic_get_irq(kvm, intid), *oldirq; 81 - unsigned long flags; 82 81 int ret; 83 82 84 83 /* In this case there is no put, since we keep the reference. */ ··· 88 89 if (!irq) 89 90 return ERR_PTR(-ENOMEM); 90 91 91 - ret = xa_reserve_irq(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT); 92 + ret = xa_reserve(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT); 92 93 if (ret) { 93 94 kfree(irq); 94 95 return ERR_PTR(ret); ··· 98 99 raw_spin_lock_init(&irq->irq_lock); 99 100 100 101 irq->config = VGIC_CONFIG_EDGE; 101 - kref_init(&irq->refcount); 102 + refcount_set(&irq->refcount, 1); 102 103 irq->intid = intid; 103 104 irq->target_vcpu = vcpu; 104 105 irq->group = 1; 105 106 106 - xa_lock_irqsave(&dist->lpi_xa, flags); 107 + xa_lock(&dist->lpi_xa); 107 108 108 109 /* 109 110 * There could be a race with another vgic_add_lpi(), so we need to 110 111 * check that we don't add a second list entry with the same LPI. 111 112 */ 112 113 oldirq = xa_load(&dist->lpi_xa, intid); 113 - if (vgic_try_get_irq_kref(oldirq)) { 114 + if (vgic_try_get_irq_ref(oldirq)) { 114 115 /* Someone was faster with adding this LPI, lets use that. */ 115 116 kfree(irq); 116 117 irq = oldirq; ··· 125 126 } 126 127 127 128 out_unlock: 128 - xa_unlock_irqrestore(&dist->lpi_xa, flags); 129 + xa_unlock(&dist->lpi_xa); 129 130 130 131 if (ret) 131 132 return ERR_PTR(ret); ··· 546 547 rcu_read_lock(); 547 548 548 549 irq = xa_load(&its->translation_cache, cache_key); 549 - if (!vgic_try_get_irq_kref(irq)) 550 + if (!vgic_try_get_irq_ref(irq)) 550 551 irq = NULL; 551 552 552 553 rcu_read_unlock(); ··· 570 571 * its_lock, as the ITE (and the reference it holds) cannot be freed. 571 572 */ 572 573 lockdep_assert_held(&its->its_lock); 573 - vgic_get_irq_kref(irq); 574 + vgic_get_irq_ref(irq); 574 575 575 576 old = xa_store(&its->translation_cache, cache_key, irq, GFP_KERNEL_ACCOUNT); 576 577
+1 -1
arch/arm64/kvm/vgic/vgic-v4.c
··· 518 518 if (!irq->hw || irq->host_irq != host_irq) 519 519 continue; 520 520 521 - if (!vgic_try_get_irq_kref(irq)) 521 + if (!vgic_try_get_irq_ref(irq)) 522 522 return NULL; 523 523 524 524 return irq;
+58 -22
arch/arm64/kvm/vgic/vgic.c
··· 28 28 * kvm->arch.config_lock (mutex) 29 29 * its->cmd_lock (mutex) 30 30 * its->its_lock (mutex) 31 - * vgic_cpu->ap_list_lock must be taken with IRQs disabled 32 - * vgic_dist->lpi_xa.xa_lock must be taken with IRQs disabled 31 + * vgic_dist->lpi_xa.xa_lock 32 + * vgic_cpu->ap_list_lock must be taken with IRQs disabled 33 33 * vgic_irq->irq_lock must be taken with IRQs disabled 34 34 * 35 35 * As the ap_list_lock might be taken from the timer interrupt handler, ··· 71 71 rcu_read_lock(); 72 72 73 73 irq = xa_load(&dist->lpi_xa, intid); 74 - if (!vgic_try_get_irq_kref(irq)) 74 + if (!vgic_try_get_irq_ref(irq)) 75 75 irq = NULL; 76 76 77 77 rcu_read_unlock(); ··· 114 114 return vgic_get_irq(vcpu->kvm, intid); 115 115 } 116 116 117 - /* 118 - * We can't do anything in here, because we lack the kvm pointer to 119 - * lock and remove the item from the lpi_list. So we keep this function 120 - * empty and use the return value of kref_put() to trigger the freeing. 121 - */ 122 - static void vgic_irq_release(struct kref *ref) 117 + static void vgic_release_lpi_locked(struct vgic_dist *dist, struct vgic_irq *irq) 123 118 { 119 + lockdep_assert_held(&dist->lpi_xa.xa_lock); 120 + __xa_erase(&dist->lpi_xa, irq->intid); 121 + kfree_rcu(irq, rcu); 122 + } 123 + 124 + static __must_check bool __vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) 125 + { 126 + if (irq->intid < VGIC_MIN_LPI) 127 + return false; 128 + 129 + return refcount_dec_and_test(&irq->refcount); 130 + } 131 + 132 + static __must_check bool vgic_put_irq_norelease(struct kvm *kvm, struct vgic_irq *irq) 133 + { 134 + if (!__vgic_put_irq(kvm, irq)) 135 + return false; 136 + 137 + irq->pending_release = true; 138 + return true; 124 139 } 125 140 126 141 void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) 127 142 { 128 143 struct vgic_dist *dist = &kvm->arch.vgic; 129 - unsigned long flags; 130 144 131 - if (irq->intid < VGIC_MIN_LPI) 145 + if (irq->intid >= VGIC_MIN_LPI) 146 + might_lock(&dist->lpi_xa.xa_lock); 147 + 148 + if (!__vgic_put_irq(kvm, irq)) 132 149 return; 133 150 134 - if (!kref_put(&irq->refcount, vgic_irq_release)) 135 - return; 151 + xa_lock(&dist->lpi_xa); 152 + vgic_release_lpi_locked(dist, irq); 153 + xa_unlock(&dist->lpi_xa); 154 + } 136 155 137 - xa_lock_irqsave(&dist->lpi_xa, flags); 138 - __xa_erase(&dist->lpi_xa, irq->intid); 139 - xa_unlock_irqrestore(&dist->lpi_xa, flags); 156 + static void vgic_release_deleted_lpis(struct kvm *kvm) 157 + { 158 + struct vgic_dist *dist = &kvm->arch.vgic; 159 + unsigned long intid; 160 + struct vgic_irq *irq; 140 161 141 - kfree_rcu(irq, rcu); 162 + xa_lock(&dist->lpi_xa); 163 + 164 + xa_for_each(&dist->lpi_xa, intid, irq) { 165 + if (irq->pending_release) 166 + vgic_release_lpi_locked(dist, irq); 167 + } 168 + 169 + xa_unlock(&dist->lpi_xa); 142 170 } 143 171 144 172 void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu) 145 173 { 146 174 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 147 175 struct vgic_irq *irq, *tmp; 176 + bool deleted = false; 148 177 unsigned long flags; 149 178 150 179 raw_spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags); ··· 184 155 list_del(&irq->ap_list); 185 156 irq->vcpu = NULL; 186 157 raw_spin_unlock(&irq->irq_lock); 187 - vgic_put_irq(vcpu->kvm, irq); 158 + deleted |= vgic_put_irq_norelease(vcpu->kvm, irq); 188 159 } 189 160 } 190 161 191 162 raw_spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags); 163 + 164 + if (deleted) 165 + vgic_release_deleted_lpis(vcpu->kvm); 192 166 } 193 167 194 168 void vgic_irq_set_phys_pending(struct vgic_irq *irq, bool pending) ··· 431 399 * now in the ap_list. This is safe as the caller must already hold a 432 400 * reference on the irq. 433 401 */ 434 - vgic_get_irq_kref(irq); 402 + vgic_get_irq_ref(irq); 435 403 list_add_tail(&irq->ap_list, &vcpu->arch.vgic_cpu.ap_list_head); 436 404 irq->vcpu = vcpu; 437 405 ··· 662 630 { 663 631 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 664 632 struct vgic_irq *irq, *tmp; 633 + bool deleted_lpis = false; 665 634 666 635 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); 667 636 ··· 690 657 691 658 /* 692 659 * This vgic_put_irq call matches the 693 - * vgic_get_irq_kref in vgic_queue_irq_unlock, 660 + * vgic_get_irq_ref in vgic_queue_irq_unlock, 694 661 * where we added the LPI to the ap_list. As 695 662 * we remove the irq from the list, we drop 696 663 * also drop the refcount. 697 664 */ 698 - vgic_put_irq(vcpu->kvm, irq); 665 + deleted_lpis |= vgic_put_irq_norelease(vcpu->kvm, irq); 699 666 continue; 700 667 } 701 668 ··· 758 725 } 759 726 760 727 raw_spin_unlock(&vgic_cpu->ap_list_lock); 728 + 729 + if (unlikely(deleted_lpis)) 730 + vgic_release_deleted_lpis(vcpu->kvm); 761 731 } 762 732 763 733 static inline void vgic_fold_lr_state(struct kvm_vcpu *vcpu) ··· 854 818 * the AP list has been sorted already. 855 819 */ 856 820 if (multi_sgi && irq->priority > prio) { 857 - _raw_spin_unlock(&irq->irq_lock); 821 + raw_spin_unlock(&irq->irq_lock); 858 822 break; 859 823 } 860 824
+4 -4
arch/arm64/kvm/vgic/vgic.h
··· 267 267 void vgic_v2_save_state(struct kvm_vcpu *vcpu); 268 268 void vgic_v2_restore_state(struct kvm_vcpu *vcpu); 269 269 270 - static inline bool vgic_try_get_irq_kref(struct vgic_irq *irq) 270 + static inline bool vgic_try_get_irq_ref(struct vgic_irq *irq) 271 271 { 272 272 if (!irq) 273 273 return false; ··· 275 275 if (irq->intid < VGIC_MIN_LPI) 276 276 return true; 277 277 278 - return kref_get_unless_zero(&irq->refcount); 278 + return refcount_inc_not_zero(&irq->refcount); 279 279 } 280 280 281 - static inline void vgic_get_irq_kref(struct vgic_irq *irq) 281 + static inline void vgic_get_irq_ref(struct vgic_irq *irq) 282 282 { 283 - WARN_ON_ONCE(!vgic_try_get_irq_kref(irq)); 283 + WARN_ON_ONCE(!vgic_try_get_irq_ref(irq)); 284 284 } 285 285 286 286 void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu);
+11 -4
arch/s390/kvm/interrupt.c
··· 2778 2778 2779 2779 static struct page *get_map_page(struct kvm *kvm, u64 uaddr) 2780 2780 { 2781 + struct mm_struct *mm = kvm->mm; 2781 2782 struct page *page = NULL; 2783 + int locked = 1; 2782 2784 2783 - mmap_read_lock(kvm->mm); 2784 - get_user_pages_remote(kvm->mm, uaddr, 1, FOLL_WRITE, 2785 - &page, NULL); 2786 - mmap_read_unlock(kvm->mm); 2785 + if (mmget_not_zero(mm)) { 2786 + mmap_read_lock(mm); 2787 + get_user_pages_remote(mm, uaddr, 1, FOLL_WRITE, 2788 + &page, &locked); 2789 + if (locked) 2790 + mmap_read_unlock(mm); 2791 + mmput(mm); 2792 + } 2793 + 2787 2794 return page; 2788 2795 } 2789 2796
+12 -12
arch/s390/kvm/kvm-s390.c
··· 4864 4864 * @vcpu: the vCPU whose gmap is to be fixed up 4865 4865 * @gfn: the guest frame number used for memslots (including fake memslots) 4866 4866 * @gaddr: the gmap address, does not have to match @gfn for ucontrol gmaps 4867 - * @flags: FOLL_* flags 4867 + * @foll: FOLL_* flags 4868 4868 * 4869 4869 * Return: 0 on success, < 0 in case of error. 4870 4870 * Context: The mm lock must not be held before calling. May sleep. 4871 4871 */ 4872 - int __kvm_s390_handle_dat_fault(struct kvm_vcpu *vcpu, gfn_t gfn, gpa_t gaddr, unsigned int flags) 4872 + int __kvm_s390_handle_dat_fault(struct kvm_vcpu *vcpu, gfn_t gfn, gpa_t gaddr, unsigned int foll) 4873 4873 { 4874 4874 struct kvm_memory_slot *slot; 4875 4875 unsigned int fault_flags; ··· 4883 4883 if (!slot || slot->flags & KVM_MEMSLOT_INVALID) 4884 4884 return vcpu_post_run_addressing_exception(vcpu); 4885 4885 4886 - fault_flags = flags & FOLL_WRITE ? FAULT_FLAG_WRITE : 0; 4886 + fault_flags = foll & FOLL_WRITE ? FAULT_FLAG_WRITE : 0; 4887 4887 if (vcpu->arch.gmap->pfault_enabled) 4888 - flags |= FOLL_NOWAIT; 4888 + foll |= FOLL_NOWAIT; 4889 4889 vmaddr = __gfn_to_hva_memslot(slot, gfn); 4890 4890 4891 4891 try_again: 4892 - pfn = __kvm_faultin_pfn(slot, gfn, flags, &writable, &page); 4892 + pfn = __kvm_faultin_pfn(slot, gfn, foll, &writable, &page); 4893 4893 4894 4894 /* Access outside memory, inject addressing exception */ 4895 4895 if (is_noslot_pfn(pfn)) ··· 4905 4905 return 0; 4906 4906 vcpu->stat.pfault_sync++; 4907 4907 /* Could not setup async pfault, try again synchronously */ 4908 - flags &= ~FOLL_NOWAIT; 4908 + foll &= ~FOLL_NOWAIT; 4909 4909 goto try_again; 4910 4910 } 4911 4911 /* Any other error */ ··· 4925 4925 return rc; 4926 4926 } 4927 4927 4928 - static int vcpu_dat_fault_handler(struct kvm_vcpu *vcpu, unsigned long gaddr, unsigned int flags) 4928 + static int vcpu_dat_fault_handler(struct kvm_vcpu *vcpu, unsigned long gaddr, unsigned int foll) 4929 4929 { 4930 4930 unsigned long gaddr_tmp; 4931 4931 gfn_t gfn; ··· 4950 4950 } 4951 4951 gfn = gpa_to_gfn(gaddr_tmp); 4952 4952 } 4953 - return __kvm_s390_handle_dat_fault(vcpu, gfn, gaddr, flags); 4953 + return __kvm_s390_handle_dat_fault(vcpu, gfn, gaddr, foll); 4954 4954 } 4955 4955 4956 4956 static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) 4957 4957 { 4958 - unsigned int flags = 0; 4958 + unsigned int foll = 0; 4959 4959 unsigned long gaddr; 4960 4960 int rc; 4961 4961 4962 4962 gaddr = current->thread.gmap_teid.addr * PAGE_SIZE; 4963 4963 if (kvm_s390_cur_gmap_fault_is_write()) 4964 - flags = FAULT_FLAG_WRITE; 4964 + foll = FOLL_WRITE; 4965 4965 4966 4966 switch (current->thread.gmap_int_code & PGM_INT_CODE_MASK) { 4967 4967 case 0: ··· 5003 5003 send_sig(SIGSEGV, current, 0); 5004 5004 if (rc != -ENXIO) 5005 5005 break; 5006 - flags = FAULT_FLAG_WRITE; 5006 + foll = FOLL_WRITE; 5007 5007 fallthrough; 5008 5008 case PGM_PROTECTION: 5009 5009 case PGM_SEGMENT_TRANSLATION: ··· 5013 5013 case PGM_REGION_SECOND_TRANS: 5014 5014 case PGM_REGION_THIRD_TRANS: 5015 5015 kvm_s390_assert_primary_as(vcpu); 5016 - return vcpu_dat_fault_handler(vcpu, gaddr, flags); 5016 + return vcpu_dat_fault_handler(vcpu, gaddr, foll); 5017 5017 default: 5018 5018 KVM_BUG(1, vcpu->kvm, "Unexpected program interrupt 0x%x, TEID 0x%016lx", 5019 5019 current->thread.gmap_int_code, current->thread.gmap_teid.val);
+11 -5
arch/s390/kvm/pv.c
··· 624 624 int cc, ret; 625 625 u16 dummy; 626 626 627 + /* Add the notifier only once. No races because we hold kvm->lock */ 628 + if (kvm->arch.pv.mmu_notifier.ops != &kvm_s390_pv_mmu_notifier_ops) { 629 + /* The notifier will be unregistered when the VM is destroyed */ 630 + kvm->arch.pv.mmu_notifier.ops = &kvm_s390_pv_mmu_notifier_ops; 631 + ret = mmu_notifier_register(&kvm->arch.pv.mmu_notifier, kvm->mm); 632 + if (ret) { 633 + kvm->arch.pv.mmu_notifier.ops = NULL; 634 + return ret; 635 + } 636 + } 637 + 627 638 ret = kvm_s390_pv_alloc_vm(kvm); 628 639 if (ret) 629 640 return ret; ··· 670 659 return -EIO; 671 660 } 672 661 kvm->arch.gmap->guest_handle = uvcb.guest_handle; 673 - /* Add the notifier only once. No races because we hold kvm->lock */ 674 - if (kvm->arch.pv.mmu_notifier.ops != &kvm_s390_pv_mmu_notifier_ops) { 675 - kvm->arch.pv.mmu_notifier.ops = &kvm_s390_pv_mmu_notifier_ops; 676 - mmu_notifier_register(&kvm->arch.pv.mmu_notifier, kvm->mm); 677 - } 678 662 return 0; 679 663 } 680 664
+4 -2
arch/um/drivers/virtio_uml.c
··· 1250 1250 device_set_wakeup_capable(&vu_dev->vdev.dev, true); 1251 1251 1252 1252 rc = register_virtio_device(&vu_dev->vdev); 1253 - if (rc) 1253 + if (rc) { 1254 1254 put_device(&vu_dev->vdev.dev); 1255 + return rc; 1256 + } 1255 1257 vu_dev->registered = 1; 1256 - return rc; 1258 + return 0; 1257 1259 1258 1260 error_init: 1259 1261 os_close_file(vu_dev->sock);
+1 -1
arch/um/os-Linux/file.c
··· 535 535 cmsg->cmsg_type != SCM_RIGHTS) 536 536 return n; 537 537 538 - memcpy(fds, CMSG_DATA(cmsg), cmsg->cmsg_len); 538 + memcpy(fds, CMSG_DATA(cmsg), cmsg->cmsg_len - CMSG_LEN(0)); 539 539 return n; 540 540 } 541 541
+1 -2
arch/um/os-Linux/util.c
··· 20 20 21 21 void stack_protections(unsigned long address) 22 22 { 23 - if (mprotect((void *) address, UM_THREAD_SIZE, 24 - PROT_READ | PROT_WRITE | PROT_EXEC) < 0) 23 + if (mprotect((void *) address, UM_THREAD_SIZE, PROT_READ | PROT_WRITE) < 0) 25 24 panic("protecting stack failed, errno = %d", errno); 26 25 } 27 26
+14 -11
arch/x86/kernel/cpu/topology_amd.c
··· 175 175 176 176 static void parse_topology_amd(struct topo_scan *tscan) 177 177 { 178 - bool has_topoext = false; 179 - 180 178 /* 181 - * If the extended topology leaf 0x8000_001e is available 182 - * try to get SMT, CORE, TILE, and DIE shifts from extended 179 + * Try to get SMT, CORE, TILE, and DIE shifts from extended 183 180 * CPUID leaf 0x8000_0026 on supported processors first. If 184 181 * extended CPUID leaf 0x8000_0026 is not supported, try to 185 - * get SMT and CORE shift from leaf 0xb first, then try to 186 - * get the CORE shift from leaf 0x8000_0008. 182 + * get SMT and CORE shift from leaf 0xb. If either leaf is 183 + * available, cpu_parse_topology_ext() will return true. 187 184 */ 188 - if (cpu_feature_enabled(X86_FEATURE_TOPOEXT)) 189 - has_topoext = cpu_parse_topology_ext(tscan); 185 + bool has_xtopology = cpu_parse_topology_ext(tscan); 190 186 191 187 if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) 192 188 tscan->c->topo.cpu_type = cpuid_ebx(0x80000026); 193 189 194 - if (!has_topoext && !parse_8000_0008(tscan)) 190 + /* 191 + * If XTOPOLOGY leaves (0x26/0xb) are not available, try to 192 + * get the CORE shift from leaf 0x8000_0008 first. 193 + */ 194 + if (!has_xtopology && !parse_8000_0008(tscan)) 195 195 return; 196 196 197 - /* Prefer leaf 0x8000001e if available */ 198 - if (parse_8000_001e(tscan, has_topoext)) 197 + /* 198 + * Prefer leaf 0x8000001e if available to get the SMT shift and 199 + * the initial APIC ID if XTOPOLOGY leaves are not available. 200 + */ 201 + if (parse_8000_001e(tscan, has_xtopology)) 199 202 return; 200 203 201 204 /* Try the NODEID MSR */
+1 -2
arch/x86/kvm/svm/svm.c
··· 4046 4046 struct vcpu_svm *svm = to_svm(vcpu); 4047 4047 u64 cr8; 4048 4048 4049 - if (nested_svm_virtualize_tpr(vcpu) || 4050 - kvm_vcpu_apicv_active(vcpu)) 4049 + if (nested_svm_virtualize_tpr(vcpu)) 4051 4050 return; 4052 4051 4053 4052 cr8 = kvm_get_cr8(vcpu);
+3 -5
drivers/block/zram/zram_drv.c
··· 1795 1795 u32 index) 1796 1796 { 1797 1797 zram_slot_lock(zram, index); 1798 + zram_free_page(zram, index); 1798 1799 zram_set_flag(zram, index, ZRAM_SAME); 1799 1800 zram_set_handle(zram, index, fill); 1800 1801 zram_slot_unlock(zram, index); ··· 1833 1832 kunmap_local(src); 1834 1833 1835 1834 zram_slot_lock(zram, index); 1835 + zram_free_page(zram, index); 1836 1836 zram_set_flag(zram, index, ZRAM_HUGE); 1837 1837 zram_set_handle(zram, index, handle); 1838 1838 zram_set_obj_size(zram, index, PAGE_SIZE); ··· 1856 1854 struct zcomp_strm *zstrm; 1857 1855 unsigned long element; 1858 1856 bool same_filled; 1859 - 1860 - /* First, free memory allocated to this slot (if any) */ 1861 - zram_slot_lock(zram, index); 1862 - zram_free_page(zram, index); 1863 - zram_slot_unlock(zram, index); 1864 1857 1865 1858 mem = kmap_local_page(page); 1866 1859 same_filled = page_same_filled(mem, &element); ··· 1898 1901 zcomp_stream_put(zstrm); 1899 1902 1900 1903 zram_slot_lock(zram, index); 1904 + zram_free_page(zram, index); 1901 1905 zram_set_handle(zram, index, handle); 1902 1906 zram_set_obj_size(zram, index, comp_len); 1903 1907 zram_slot_unlock(zram, index);
+11 -4
drivers/dma/dw/rzn1-dmamux.c
··· 48 48 u32 mask; 49 49 int ret; 50 50 51 - if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) 52 - return ERR_PTR(-EINVAL); 51 + if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) { 52 + ret = -EINVAL; 53 + goto put_device; 54 + } 53 55 54 56 map = kzalloc(sizeof(*map), GFP_KERNEL); 55 - if (!map) 56 - return ERR_PTR(-ENOMEM); 57 + if (!map) { 58 + ret = -ENOMEM; 59 + goto put_device; 60 + } 57 61 58 62 chan = dma_spec->args[0]; 59 63 map->req_idx = dma_spec->args[4]; ··· 98 94 if (ret) 99 95 goto clear_bitmap; 100 96 97 + put_device(&pdev->dev); 101 98 return map; 102 99 103 100 clear_bitmap: 104 101 clear_bit(map->req_idx, dmamux->used_chans); 105 102 free_map: 106 103 kfree(map); 104 + put_device: 105 + put_device(&pdev->dev); 107 106 108 107 return ERR_PTR(ret); 109 108 }
+21 -18
drivers/dma/idxd/init.c
··· 189 189 idxd->wq_enable_map = bitmap_zalloc_node(idxd->max_wqs, GFP_KERNEL, dev_to_node(dev)); 190 190 if (!idxd->wq_enable_map) { 191 191 rc = -ENOMEM; 192 - goto err_bitmap; 192 + goto err_free_wqs; 193 193 } 194 194 195 195 for (i = 0; i < idxd->max_wqs; i++) { 196 196 wq = kzalloc_node(sizeof(*wq), GFP_KERNEL, dev_to_node(dev)); 197 197 if (!wq) { 198 198 rc = -ENOMEM; 199 - goto err; 199 + goto err_unwind; 200 200 } 201 201 202 202 idxd_dev_set_type(&wq->idxd_dev, IDXD_DEV_WQ); 203 203 conf_dev = wq_confdev(wq); 204 204 wq->id = i; 205 205 wq->idxd = idxd; 206 - device_initialize(wq_confdev(wq)); 206 + device_initialize(conf_dev); 207 207 conf_dev->parent = idxd_confdev(idxd); 208 208 conf_dev->bus = &dsa_bus_type; 209 209 conf_dev->type = &idxd_wq_device_type; 210 210 rc = dev_set_name(conf_dev, "wq%d.%d", idxd->id, wq->id); 211 - if (rc < 0) 212 - goto err; 211 + if (rc < 0) { 212 + put_device(conf_dev); 213 + kfree(wq); 214 + goto err_unwind; 215 + } 213 216 214 217 mutex_init(&wq->wq_lock); 215 218 init_waitqueue_head(&wq->err_queue); ··· 223 220 wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES; 224 221 wq->wqcfg = kzalloc_node(idxd->wqcfg_size, GFP_KERNEL, dev_to_node(dev)); 225 222 if (!wq->wqcfg) { 223 + put_device(conf_dev); 224 + kfree(wq); 226 225 rc = -ENOMEM; 227 - goto err; 226 + goto err_unwind; 228 227 } 229 228 230 229 if (idxd->hw.wq_cap.op_config) { 231 230 wq->opcap_bmap = bitmap_zalloc(IDXD_MAX_OPCAP_BITS, GFP_KERNEL); 232 231 if (!wq->opcap_bmap) { 232 + kfree(wq->wqcfg); 233 + put_device(conf_dev); 234 + kfree(wq); 233 235 rc = -ENOMEM; 234 - goto err_opcap_bmap; 236 + goto err_unwind; 235 237 } 236 238 bitmap_copy(wq->opcap_bmap, idxd->opcap_bmap, IDXD_MAX_OPCAP_BITS); 237 239 } ··· 247 239 248 240 return 0; 249 241 250 - err_opcap_bmap: 251 - kfree(wq->wqcfg); 252 - 253 - err: 254 - put_device(conf_dev); 255 - kfree(wq); 256 - 242 + err_unwind: 257 243 while (--i >= 0) { 258 244 wq = idxd->wqs[i]; 259 245 if (idxd->hw.wq_cap.op_config) ··· 256 254 conf_dev = wq_confdev(wq); 257 255 put_device(conf_dev); 258 256 kfree(wq); 259 - 260 257 } 261 258 bitmap_free(idxd->wq_enable_map); 262 259 263 - err_bitmap: 260 + err_free_wqs: 264 261 kfree(idxd->wqs); 265 262 266 263 return rc; ··· 1292 1291 device_unregister(idxd_confdev(idxd)); 1293 1292 idxd_shutdown(pdev); 1294 1293 idxd_device_remove_debugfs(idxd); 1295 - idxd_cleanup(idxd); 1294 + perfmon_pmu_remove(idxd); 1295 + idxd_cleanup_interrupts(idxd); 1296 + if (device_pasid_enabled(idxd)) 1297 + idxd_disable_system_pasid(idxd); 1296 1298 pci_iounmap(pdev, idxd->reg_base); 1297 1299 put_device(idxd_confdev(idxd)); 1298 - idxd_free(idxd); 1299 1300 pci_disable_device(pdev); 1300 1301 } 1301 1302
+6 -2
drivers/dma/qcom/bam_dma.c
··· 1283 1283 if (!bdev->bamclk) { 1284 1284 ret = of_property_read_u32(pdev->dev.of_node, "num-channels", 1285 1285 &bdev->num_channels); 1286 - if (ret) 1286 + if (ret) { 1287 1287 dev_err(bdev->dev, "num-channels unspecified in dt\n"); 1288 + return ret; 1289 + } 1288 1290 1289 1291 ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees", 1290 1292 &bdev->num_ees); 1291 - if (ret) 1293 + if (ret) { 1292 1294 dev_err(bdev->dev, "num-ees unspecified in dt\n"); 1295 + return ret; 1296 + } 1293 1297 } 1294 1298 1295 1299 ret = clk_prepare_enable(bdev->bamclk);
+2 -2
drivers/dma/ti/edma.c
··· 2064 2064 * priority. So Q0 is the highest priority queue and the last queue has 2065 2065 * the lowest priority. 2066 2066 */ 2067 - queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, sizeof(s8), 2068 - GFP_KERNEL); 2067 + queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, 2068 + sizeof(*queue_priority_map), GFP_KERNEL); 2069 2069 if (!queue_priority_map) 2070 2070 return -ENOMEM; 2071 2071
+2 -2
drivers/dpll/dpll_netlink.c
··· 211 211 dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll, 212 212 struct netlink_ext_ack *extack) 213 213 { 214 + DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 }; 214 215 const struct dpll_device_ops *ops = dpll_device_ops(dpll); 215 - DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 }; 216 216 enum dpll_clock_quality_level ql; 217 217 int ret; 218 218 ··· 221 221 ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls, extack); 222 222 if (ret) 223 223 return ret; 224 - for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) 224 + for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) 225 225 if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql)) 226 226 return -EMSGSIZE; 227 227
+32 -12
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 213 213 spin_lock(&kfd_mem_limit.mem_limit_lock); 214 214 215 215 if (kfd_mem_limit.system_mem_used + system_mem_needed > 216 - kfd_mem_limit.max_system_mem_limit) 216 + kfd_mem_limit.max_system_mem_limit) { 217 217 pr_debug("Set no_system_mem_limit=1 if using shared memory\n"); 218 + if (!no_system_mem_limit) { 219 + ret = -ENOMEM; 220 + goto release; 221 + } 222 + } 218 223 219 - if ((kfd_mem_limit.system_mem_used + system_mem_needed > 220 - kfd_mem_limit.max_system_mem_limit && !no_system_mem_limit) || 221 - (kfd_mem_limit.ttm_mem_used + ttm_mem_needed > 222 - kfd_mem_limit.max_ttm_mem_limit) || 223 - (adev && xcp_id >= 0 && adev->kfd.vram_used[xcp_id] + vram_needed > 224 - vram_size - reserved_for_pt - reserved_for_ras - atomic64_read(&adev->vram_pin_size))) { 224 + if (kfd_mem_limit.ttm_mem_used + ttm_mem_needed > 225 + kfd_mem_limit.max_ttm_mem_limit) { 225 226 ret = -ENOMEM; 226 227 goto release; 228 + } 229 + 230 + /*if is_app_apu is false and apu_prefer_gtt is true, it is an APU with 231 + * carve out < gtt. In that case, VRAM allocation will go to gtt domain, skip 232 + * VRAM check since ttm_mem_limit check already cover this allocation 233 + */ 234 + 235 + if (adev && xcp_id >= 0 && (!adev->apu_prefer_gtt || adev->gmc.is_app_apu)) { 236 + uint64_t vram_available = 237 + vram_size - reserved_for_pt - reserved_for_ras - 238 + atomic64_read(&adev->vram_pin_size); 239 + if (adev->kfd.vram_used[xcp_id] + vram_needed > vram_available) { 240 + ret = -ENOMEM; 241 + goto release; 242 + } 227 243 } 228 244 229 245 /* Update memory accounting by decreasing available system ··· 1642 1626 uint64_t vram_available, system_mem_available, ttm_mem_available; 1643 1627 1644 1628 spin_lock(&kfd_mem_limit.mem_limit_lock); 1645 - vram_available = KFD_XCP_MEMORY_SIZE(adev, xcp_id) 1646 - - adev->kfd.vram_used_aligned[xcp_id] 1647 - - atomic64_read(&adev->vram_pin_size) 1648 - - reserved_for_pt 1649 - - reserved_for_ras; 1629 + if (adev->apu_prefer_gtt && !adev->gmc.is_app_apu) 1630 + vram_available = KFD_XCP_MEMORY_SIZE(adev, xcp_id) 1631 + - adev->kfd.vram_used_aligned[xcp_id]; 1632 + else 1633 + vram_available = KFD_XCP_MEMORY_SIZE(adev, xcp_id) 1634 + - adev->kfd.vram_used_aligned[xcp_id] 1635 + - atomic64_read(&adev->vram_pin_size) 1636 + - reserved_for_pt 1637 + - reserved_for_ras; 1650 1638 1651 1639 if (adev->apu_prefer_gtt) { 1652 1640 system_mem_available = no_system_mem_limit ?
-2
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
··· 421 421 dma_fence_put(ring->vmid_wait); 422 422 ring->vmid_wait = NULL; 423 423 ring->me = 0; 424 - 425 - ring->adev->rings[ring->idx] = NULL; 426 424 } 427 425 428 426 /**
+2
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
··· 29 29 #include "amdgpu.h" 30 30 #include "isp_v4_1_1.h" 31 31 32 + MODULE_FIRMWARE("amdgpu/isp_4_1_1.bin"); 33 + 32 34 #define ISP_PERFORMANCE_STATE_LOW 0 33 35 #define ISP_PERFORMANCE_STATE_HIGH 1 34 36
+4 -15
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
··· 149 149 int ret; 150 150 int retry_loop; 151 151 152 - for (retry_loop = 0; retry_loop < 10; retry_loop++) { 152 + for (retry_loop = 0; retry_loop < 20; retry_loop++) { 153 153 /* Wait for bootloader to signify that is 154 154 ready having bit 31 of C2PMSG_35 set to 1 */ 155 155 ret = psp_wait_for( 156 156 psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35), 157 - 0x80000000, 0x80000000, PSP_WAITREG_NOVERBOSE); 157 + 0x80000000, 0x8000FFFF, PSP_WAITREG_NOVERBOSE); 158 158 159 159 if (ret == 0) 160 160 return 0; ··· 396 396 WREG32(offset, GFX_CTRL_CMD_ID_MODE1_RST); 397 397 398 398 msleep(500); 399 - 400 - offset = SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_33); 401 - 402 - ret = psp_wait_for(psp, offset, MBOX_TOS_RESP_FLAG, MBOX_TOS_RESP_MASK, 403 - 0); 404 - 405 - if (ret) { 406 - DRM_INFO("psp mode 1 reset failed!\n"); 407 - return -EINVAL; 408 - } 409 - 410 - DRM_INFO("psp mode1 reset succeed \n"); 411 399 412 400 return 0; 413 401 } ··· 653 665 .ring_get_wptr = psp_v11_0_ring_get_wptr, 654 666 .ring_set_wptr = psp_v11_0_ring_set_wptr, 655 667 .load_usbc_pd_fw = psp_v11_0_load_usbc_pd_fw, 656 - .read_usbc_pd_fw = psp_v11_0_read_usbc_pd_fw 668 + .read_usbc_pd_fw = psp_v11_0_read_usbc_pd_fw, 669 + .wait_for_bootloader = psp_v11_0_wait_for_bootloader 657 670 }; 658 671 659 672 void psp_v11_0_set_psp_funcs(struct psp_context *psp)
+8 -4
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
··· 1888 1888 struct amdgpu_job *job) 1889 1889 { 1890 1890 struct drm_gpu_scheduler **scheds; 1891 - 1892 - /* The create msg must be in the first IB submitted */ 1893 - if (atomic_read(&job->base.entity->fence_seq)) 1894 - return -EINVAL; 1891 + struct dma_fence *fence; 1895 1892 1896 1893 /* if VCN0 is harvested, we can't support AV1 */ 1897 1894 if (p->adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0) 1898 1895 return -EINVAL; 1896 + 1897 + /* wait for all jobs to finish before switching to instance 0 */ 1898 + fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull); 1899 + if (fence) { 1900 + dma_fence_wait(fence, false); 1901 + dma_fence_put(fence); 1902 + } 1899 1903 1900 1904 scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC] 1901 1905 [AMDGPU_RING_PRIO_DEFAULT].sched;
+27 -33
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
··· 1808 1808 struct amdgpu_job *job) 1809 1809 { 1810 1810 struct drm_gpu_scheduler **scheds; 1811 - 1812 - /* The create msg must be in the first IB submitted */ 1813 - if (atomic_read(&job->base.entity->fence_seq)) 1814 - return -EINVAL; 1811 + struct dma_fence *fence; 1815 1812 1816 1813 /* if VCN0 is harvested, we can't support AV1 */ 1817 1814 if (p->adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0) 1818 1815 return -EINVAL; 1816 + 1817 + /* wait for all jobs to finish before switching to instance 0 */ 1818 + fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull); 1819 + if (fence) { 1820 + dma_fence_wait(fence, false); 1821 + dma_fence_put(fence); 1822 + } 1819 1823 1820 1824 scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_ENC] 1821 1825 [AMDGPU_RING_PRIO_0].sched; ··· 1911 1907 1912 1908 #define RADEON_VCN_ENGINE_TYPE_ENCODE (0x00000002) 1913 1909 #define RADEON_VCN_ENGINE_TYPE_DECODE (0x00000003) 1914 - 1915 1910 #define RADEON_VCN_ENGINE_INFO (0x30000001) 1916 - #define RADEON_VCN_ENGINE_INFO_MAX_OFFSET 16 1917 - 1918 1911 #define RENCODE_ENCODE_STANDARD_AV1 2 1919 1912 #define RENCODE_IB_PARAM_SESSION_INIT 0x00000003 1920 - #define RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET 64 1921 1913 1922 - /* return the offset in ib if id is found, -1 otherwise 1923 - * to speed up the searching we only search upto max_offset 1924 - */ 1925 - static int vcn_v4_0_enc_find_ib_param(struct amdgpu_ib *ib, uint32_t id, int max_offset) 1914 + /* return the offset in ib if id is found, -1 otherwise */ 1915 + static int vcn_v4_0_enc_find_ib_param(struct amdgpu_ib *ib, uint32_t id, int start) 1926 1916 { 1927 1917 int i; 1928 1918 1929 - for (i = 0; i < ib->length_dw && i < max_offset && ib->ptr[i] >= 8; i += ib->ptr[i]/4) { 1919 + for (i = start; i < ib->length_dw && ib->ptr[i] >= 8; i += ib->ptr[i] / 4) { 1930 1920 if (ib->ptr[i + 1] == id) 1931 1921 return i; 1932 1922 } ··· 1935 1937 struct amdgpu_vcn_decode_buffer *decode_buffer; 1936 1938 uint64_t addr; 1937 1939 uint32_t val; 1938 - int idx; 1940 + int idx = 0, sidx; 1939 1941 1940 1942 /* The first instance can decode anything */ 1941 1943 if (!ring->me) 1942 1944 return 0; 1943 1945 1944 - /* RADEON_VCN_ENGINE_INFO is at the top of ib block */ 1945 - idx = vcn_v4_0_enc_find_ib_param(ib, RADEON_VCN_ENGINE_INFO, 1946 - RADEON_VCN_ENGINE_INFO_MAX_OFFSET); 1947 - if (idx < 0) /* engine info is missing */ 1948 - return 0; 1946 + while ((idx = vcn_v4_0_enc_find_ib_param(ib, RADEON_VCN_ENGINE_INFO, idx)) >= 0) { 1947 + val = amdgpu_ib_get_value(ib, idx + 2); /* RADEON_VCN_ENGINE_TYPE */ 1948 + if (val == RADEON_VCN_ENGINE_TYPE_DECODE) { 1949 + decode_buffer = (struct amdgpu_vcn_decode_buffer *)&ib->ptr[idx + 6]; 1949 1950 1950 - val = amdgpu_ib_get_value(ib, idx + 2); /* RADEON_VCN_ENGINE_TYPE */ 1951 - if (val == RADEON_VCN_ENGINE_TYPE_DECODE) { 1952 - decode_buffer = (struct amdgpu_vcn_decode_buffer *)&ib->ptr[idx + 6]; 1951 + if (!(decode_buffer->valid_buf_flag & 0x1)) 1952 + return 0; 1953 1953 1954 - if (!(decode_buffer->valid_buf_flag & 0x1)) 1955 - return 0; 1956 - 1957 - addr = ((u64)decode_buffer->msg_buffer_address_hi) << 32 | 1958 - decode_buffer->msg_buffer_address_lo; 1959 - return vcn_v4_0_dec_msg(p, job, addr); 1960 - } else if (val == RADEON_VCN_ENGINE_TYPE_ENCODE) { 1961 - idx = vcn_v4_0_enc_find_ib_param(ib, RENCODE_IB_PARAM_SESSION_INIT, 1962 - RENCODE_IB_PARAM_SESSION_INIT_MAX_OFFSET); 1963 - if (idx >= 0 && ib->ptr[idx + 2] == RENCODE_ENCODE_STANDARD_AV1) 1964 - return vcn_v4_0_limit_sched(p, job); 1954 + addr = ((u64)decode_buffer->msg_buffer_address_hi) << 32 | 1955 + decode_buffer->msg_buffer_address_lo; 1956 + return vcn_v4_0_dec_msg(p, job, addr); 1957 + } else if (val == RADEON_VCN_ENGINE_TYPE_ENCODE) { 1958 + sidx = vcn_v4_0_enc_find_ib_param(ib, RENCODE_IB_PARAM_SESSION_INIT, idx); 1959 + if (sidx >= 0 && ib->ptr[sidx + 2] == RENCODE_ENCODE_STANDARD_AV1) 1960 + return vcn_v4_0_limit_sched(p, job); 1961 + } 1962 + idx += ib->ptr[idx] / 4; 1965 1963 } 1966 1964 return 0; 1967 1965 }
+2 -1
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
··· 1587 1587 break; 1588 1588 if (!dev->gpu || !dev->gpu->adev || 1589 1589 (dev->gpu->kfd->hive_id && 1590 - dev->gpu->kfd->hive_id == new_dev->gpu->kfd->hive_id)) 1590 + dev->gpu->kfd->hive_id == new_dev->gpu->kfd->hive_id && 1591 + amdgpu_xgmi_get_is_sharing_enabled(dev->gpu->adev, new_dev->gpu->adev))) 1591 1592 goto next; 1592 1593 1593 1594 /* check if node(s) is/are peer accessible in one direction or bi-direction */
+12 -22
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 2913 2913 return 0; 2914 2914 } 2915 2915 2916 + static void dm_oem_i2c_hw_fini(struct amdgpu_device *adev) 2917 + { 2918 + struct amdgpu_display_manager *dm = &adev->dm; 2919 + 2920 + if (dm->oem_i2c) { 2921 + i2c_del_adapter(&dm->oem_i2c->base); 2922 + kfree(dm->oem_i2c); 2923 + dm->oem_i2c = NULL; 2924 + } 2925 + } 2926 + 2916 2927 /** 2917 2928 * dm_hw_init() - Initialize DC device 2918 2929 * @ip_block: Pointer to the amdgpu_ip_block for this hw instance. ··· 2974 2963 { 2975 2964 struct amdgpu_device *adev = ip_block->adev; 2976 2965 2977 - kfree(adev->dm.oem_i2c); 2966 + dm_oem_i2c_hw_fini(adev); 2978 2967 2979 2968 amdgpu_dm_hpd_fini(adev); 2980 2969 ··· 3136 3125 drm_atomic_helper_resume(ddev, dm->cached_state); 3137 3126 3138 3127 dm->cached_state = NULL; 3139 - } 3140 - 3141 - static void dm_complete(struct amdgpu_ip_block *ip_block) 3142 - { 3143 - struct amdgpu_device *adev = ip_block->adev; 3144 - 3145 - dm_destroy_cached_state(adev); 3146 - } 3147 - 3148 - static int dm_prepare_suspend(struct amdgpu_ip_block *ip_block) 3149 - { 3150 - struct amdgpu_device *adev = ip_block->adev; 3151 - 3152 - if (amdgpu_in_reset(adev)) 3153 - return 0; 3154 - 3155 - WARN_ON(adev->dm.cached_state); 3156 - 3157 - return dm_cache_state(adev); 3158 3128 } 3159 3129 3160 3130 static int dm_suspend(struct amdgpu_ip_block *ip_block) ··· 3563 3571 .early_fini = amdgpu_dm_early_fini, 3564 3572 .hw_init = dm_hw_init, 3565 3573 .hw_fini = dm_hw_fini, 3566 - .prepare_suspend = dm_prepare_suspend, 3567 3574 .suspend = dm_suspend, 3568 3575 .resume = dm_resume, 3569 - .complete = dm_complete, 3570 3576 .is_idle = dm_is_idle, 3571 3577 .wait_for_idle = dm_wait_for_idle, 3572 3578 .check_soft_reset = dm_check_soft_reset,
+1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
··· 809 809 drm_dp_aux_init(&aconnector->dm_dp_aux.aux); 810 810 drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux, 811 811 &aconnector->base); 812 + drm_dp_dpcd_set_probe(&aconnector->dm_dp_aux.aux, false); 812 813 813 814 if (aconnector->base.connector_type == DRM_MODE_CONNECTOR_eDP) 814 815 return;
+1
drivers/gpu/drm/amd/display/dc/dc.h
··· 1145 1145 bool enable_hblank_borrow; 1146 1146 bool force_subvp_df_throttle; 1147 1147 uint32_t acpi_transition_bitmasks[MAX_PIPES]; 1148 + bool enable_pg_cntl_debug_logs; 1148 1149 }; 1149 1150 1150 1151
+39 -35
drivers/gpu/drm/amd/display/dc/dccg/dcn35/dcn35_dccg.c
··· 133 133 }; 134 134 135 135 136 - static void dccg35_set_dsc_clk_rcg(struct dccg *dccg, int inst, bool enable) 136 + static void dccg35_set_dsc_clk_rcg(struct dccg *dccg, int inst, bool allow_rcg) 137 137 { 138 138 struct dcn_dccg *dccg_dcn = TO_DCN_DCCG(dccg); 139 139 140 - if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dsc && enable) 140 + if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dsc && allow_rcg) 141 141 return; 142 142 143 143 switch (inst) { 144 144 case 0: 145 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK0_ROOT_GATE_DISABLE, enable ? 0 : 1); 145 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK0_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 146 146 break; 147 147 case 1: 148 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK1_ROOT_GATE_DISABLE, enable ? 0 : 1); 148 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK1_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 149 149 break; 150 150 case 2: 151 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK2_ROOT_GATE_DISABLE, enable ? 0 : 1); 151 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK2_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 152 152 break; 153 153 case 3: 154 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK3_ROOT_GATE_DISABLE, enable ? 0 : 1); 154 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK3_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 155 155 break; 156 156 default: 157 157 BREAK_TO_DEBUGGER(); 158 158 return; 159 159 } 160 + 161 + /* Wait for clock to ramp */ 162 + if (!allow_rcg) 163 + udelay(10); 160 164 } 161 165 162 166 static void dccg35_set_symclk32_se_rcg( ··· 389 385 } 390 386 } 391 387 392 - static void dccg35_set_dppclk_rcg(struct dccg *dccg, 393 - int inst, bool enable) 388 + static void dccg35_set_dppclk_rcg(struct dccg *dccg, int inst, bool allow_rcg) 394 389 { 395 - 396 390 struct dcn_dccg *dccg_dcn = TO_DCN_DCCG(dccg); 397 391 398 - 399 - if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dpp && enable) 392 + if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dpp && allow_rcg) 400 393 return; 401 394 402 395 switch (inst) { 403 396 case 0: 404 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK0_ROOT_GATE_DISABLE, enable ? 0 : 1); 397 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK0_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 405 398 break; 406 399 case 1: 407 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK1_ROOT_GATE_DISABLE, enable ? 0 : 1); 400 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK1_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 408 401 break; 409 402 case 2: 410 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK2_ROOT_GATE_DISABLE, enable ? 0 : 1); 403 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK2_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 411 404 break; 412 405 case 3: 413 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK3_ROOT_GATE_DISABLE, enable ? 0 : 1); 406 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK3_ROOT_GATE_DISABLE, allow_rcg ? 0 : 1); 414 407 break; 415 408 default: 416 409 BREAK_TO_DEBUGGER(); 417 410 break; 418 411 } 419 - //DC_LOG_DEBUG("%s: inst(%d) DPPCLK rcg_disable: %d\n", __func__, inst, enable ? 0 : 1); 420 412 413 + /* Wait for clock to ramp */ 414 + if (!allow_rcg) 415 + udelay(10); 421 416 } 422 417 423 418 static void dccg35_set_dpstreamclk_rcg( ··· 1180 1177 } 1181 1178 1182 1179 static void dccg35_set_dppclk_root_clock_gating(struct dccg *dccg, 1183 - uint32_t dpp_inst, uint32_t enable) 1180 + uint32_t dpp_inst, uint32_t disallow_rcg) 1184 1181 { 1185 1182 struct dcn_dccg *dccg_dcn = TO_DCN_DCCG(dccg); 1186 1183 1187 - if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dpp) 1184 + if (!dccg->ctx->dc->debug.root_clock_optimization.bits.dpp && !disallow_rcg) 1188 1185 return; 1189 1186 1190 1187 1191 1188 switch (dpp_inst) { 1192 1189 case 0: 1193 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK0_ROOT_GATE_DISABLE, enable); 1190 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK0_ROOT_GATE_DISABLE, disallow_rcg); 1194 1191 break; 1195 1192 case 1: 1196 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK1_ROOT_GATE_DISABLE, enable); 1193 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK1_ROOT_GATE_DISABLE, disallow_rcg); 1197 1194 break; 1198 1195 case 2: 1199 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK2_ROOT_GATE_DISABLE, enable); 1196 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK2_ROOT_GATE_DISABLE, disallow_rcg); 1200 1197 break; 1201 1198 case 3: 1202 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK3_ROOT_GATE_DISABLE, enable); 1199 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DPPCLK3_ROOT_GATE_DISABLE, disallow_rcg); 1203 1200 break; 1204 1201 default: 1205 1202 break; 1206 1203 } 1207 - //DC_LOG_DEBUG("%s: dpp_inst(%d) rcg: %d\n", __func__, dpp_inst, enable); 1208 1204 1205 + /* Wait for clock to ramp */ 1206 + if (disallow_rcg) 1207 + udelay(10); 1209 1208 } 1210 1209 1211 1210 static void dccg35_get_pixel_rate_div( ··· 1787 1782 //Disable DTO 1788 1783 switch (inst) { 1789 1784 case 0: 1790 - if (dccg->ctx->dc->debug.root_clock_optimization.bits.dsc) 1791 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK0_ROOT_GATE_DISABLE, 1); 1785 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK0_ROOT_GATE_DISABLE, 1); 1792 1786 1793 1787 REG_UPDATE_2(DSCCLK0_DTO_PARAM, 1794 1788 DSCCLK0_DTO_PHASE, 0, ··· 1795 1791 REG_UPDATE(DSCCLK_DTO_CTRL, DSCCLK0_EN, 1); 1796 1792 break; 1797 1793 case 1: 1798 - if (dccg->ctx->dc->debug.root_clock_optimization.bits.dsc) 1799 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK1_ROOT_GATE_DISABLE, 1); 1794 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK1_ROOT_GATE_DISABLE, 1); 1800 1795 1801 1796 REG_UPDATE_2(DSCCLK1_DTO_PARAM, 1802 1797 DSCCLK1_DTO_PHASE, 0, ··· 1803 1800 REG_UPDATE(DSCCLK_DTO_CTRL, DSCCLK1_EN, 1); 1804 1801 break; 1805 1802 case 2: 1806 - if (dccg->ctx->dc->debug.root_clock_optimization.bits.dsc) 1807 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK2_ROOT_GATE_DISABLE, 1); 1803 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK2_ROOT_GATE_DISABLE, 1); 1808 1804 1809 1805 REG_UPDATE_2(DSCCLK2_DTO_PARAM, 1810 1806 DSCCLK2_DTO_PHASE, 0, ··· 1811 1809 REG_UPDATE(DSCCLK_DTO_CTRL, DSCCLK2_EN, 1); 1812 1810 break; 1813 1811 case 3: 1814 - if (dccg->ctx->dc->debug.root_clock_optimization.bits.dsc) 1815 - REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK3_ROOT_GATE_DISABLE, 1); 1812 + REG_UPDATE(DCCG_GATE_DISABLE_CNTL6, DSCCLK3_ROOT_GATE_DISABLE, 1); 1816 1813 1817 1814 REG_UPDATE_2(DSCCLK3_DTO_PARAM, 1818 1815 DSCCLK3_DTO_PHASE, 0, ··· 1822 1821 BREAK_TO_DEBUGGER(); 1823 1822 return; 1824 1823 } 1824 + 1825 + /* Wait for clock to ramp */ 1826 + udelay(10); 1825 1827 } 1826 1828 1827 1829 static void dccg35_disable_dscclk(struct dccg *dccg, ··· 1868 1864 default: 1869 1865 return; 1870 1866 } 1867 + 1868 + /* Wait for clock ramp */ 1869 + udelay(10); 1871 1870 } 1872 1871 1873 1872 static void dccg35_enable_symclk_se(struct dccg *dccg, uint32_t stream_enc_inst, uint32_t link_enc_inst) ··· 2356 2349 2357 2350 void dccg35_root_gate_disable_control(struct dccg *dccg, uint32_t pipe_idx, uint32_t disable_clock_gating) 2358 2351 { 2359 - 2360 - if (dccg->ctx->dc->debug.root_clock_optimization.bits.dpp) { 2361 - dccg35_set_dppclk_root_clock_gating(dccg, pipe_idx, disable_clock_gating); 2362 - } 2352 + dccg35_set_dppclk_root_clock_gating(dccg, pipe_idx, disable_clock_gating); 2363 2353 } 2364 2354 2365 2355 static const struct dccg_funcs dccg35_funcs_new = {
+1 -1
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
··· 955 955 return DC_ERROR_UNEXPECTED; 956 956 } 957 957 958 - fsleep(stream->timing.v_total * (stream->timing.h_total * 10000u / stream->timing.pix_clk_100hz)); 958 + udelay(stream->timing.v_total * (stream->timing.h_total * 10000u / stream->timing.pix_clk_100hz)); 959 959 960 960 params.vertical_total_min = stream->adjust.v_total_min; 961 961 params.vertical_total_max = stream->adjust.v_total_max;
+20 -95
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c
··· 113 113 } 114 114 #endif 115 115 116 + static void print_pg_status(struct dc *dc, const char *debug_func, const char *debug_log) 117 + { 118 + if (dc->debug.enable_pg_cntl_debug_logs && dc->res_pool->pg_cntl) { 119 + if (dc->res_pool->pg_cntl->funcs->print_pg_status) 120 + dc->res_pool->pg_cntl->funcs->print_pg_status(dc->res_pool->pg_cntl, debug_func, debug_log); 121 + } 122 + } 123 + 116 124 void dcn35_set_dmu_fgcg(struct dce_hwseq *hws, bool enable) 117 125 { 118 126 REG_UPDATE_3(DMU_CLK_CNTL, ··· 144 136 uint32_t backlight = MAX_BACKLIGHT_LEVEL; 145 137 uint32_t user_level = MAX_BACKLIGHT_LEVEL; 146 138 int i; 139 + 140 + print_pg_status(dc, __func__, ": start"); 147 141 148 142 if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) 149 143 dc->clk_mgr->funcs->init_clocks(dc->clk_mgr); ··· 210 200 211 201 /* we want to turn off all dp displays before doing detection */ 212 202 dc->link_srv->blank_all_dp_displays(dc); 213 - /* 214 - if (hws->funcs.enable_power_gating_plane) 215 - hws->funcs.enable_power_gating_plane(dc->hwseq, true); 216 - */ 203 + 217 204 if (res_pool->hubbub && res_pool->hubbub->funcs->dchubbub_init) 218 205 res_pool->hubbub->funcs->dchubbub_init(dc->res_pool->hubbub); 219 206 /* If taking control over from VBIOS, we may want to optimize our first ··· 243 236 } 244 237 245 238 hws->funcs.init_pipes(dc, dc->current_state); 239 + print_pg_status(dc, __func__, ": after init_pipes"); 240 + 246 241 if (dc->res_pool->hubbub->funcs->allow_self_refresh_control && 247 242 !dc->res_pool->hubbub->ctx->dc->debug.disable_stutter) 248 243 dc->res_pool->hubbub->funcs->allow_self_refresh_control(dc->res_pool->hubbub, ··· 321 312 if (dc->res_pool->pg_cntl->funcs->init_pg_status) 322 313 dc->res_pool->pg_cntl->funcs->init_pg_status(dc->res_pool->pg_cntl); 323 314 } 315 + print_pg_status(dc, __func__, ": after init_pg_status"); 324 316 } 325 317 326 318 static void update_dsc_on_stream(struct pipe_ctx *pipe_ctx, bool enable) ··· 508 498 hws->ctx->dc->res_pool->dccg->funcs->set_physymclk_root_clock_gating( 509 499 hws->ctx->dc->res_pool->dccg, phy_inst, clock_on); 510 500 } 511 - } 512 - 513 - void dcn35_dsc_pg_control( 514 - struct dce_hwseq *hws, 515 - unsigned int dsc_inst, 516 - bool power_on) 517 - { 518 - uint32_t power_gate = power_on ? 0 : 1; 519 - uint32_t pwr_status = power_on ? 0 : 2; 520 - uint32_t org_ip_request_cntl = 0; 521 - 522 - if (hws->ctx->dc->debug.disable_dsc_power_gate) 523 - return; 524 - if (hws->ctx->dc->debug.ignore_pg) 525 - return; 526 - REG_GET(DC_IP_REQUEST_CNTL, IP_REQUEST_EN, &org_ip_request_cntl); 527 - if (org_ip_request_cntl == 0) 528 - REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 1); 529 - 530 - switch (dsc_inst) { 531 - case 0: /* DSC0 */ 532 - REG_UPDATE(DOMAIN16_PG_CONFIG, 533 - DOMAIN_POWER_GATE, power_gate); 534 - 535 - REG_WAIT(DOMAIN16_PG_STATUS, 536 - DOMAIN_PGFSM_PWR_STATUS, pwr_status, 537 - 1, 1000); 538 - break; 539 - case 1: /* DSC1 */ 540 - REG_UPDATE(DOMAIN17_PG_CONFIG, 541 - DOMAIN_POWER_GATE, power_gate); 542 - 543 - REG_WAIT(DOMAIN17_PG_STATUS, 544 - DOMAIN_PGFSM_PWR_STATUS, pwr_status, 545 - 1, 1000); 546 - break; 547 - case 2: /* DSC2 */ 548 - REG_UPDATE(DOMAIN18_PG_CONFIG, 549 - DOMAIN_POWER_GATE, power_gate); 550 - 551 - REG_WAIT(DOMAIN18_PG_STATUS, 552 - DOMAIN_PGFSM_PWR_STATUS, pwr_status, 553 - 1, 1000); 554 - break; 555 - case 3: /* DSC3 */ 556 - REG_UPDATE(DOMAIN19_PG_CONFIG, 557 - DOMAIN_POWER_GATE, power_gate); 558 - 559 - REG_WAIT(DOMAIN19_PG_STATUS, 560 - DOMAIN_PGFSM_PWR_STATUS, pwr_status, 561 - 1, 1000); 562 - break; 563 - default: 564 - BREAK_TO_DEBUGGER(); 565 - break; 566 - } 567 - 568 - if (org_ip_request_cntl == 0) 569 - REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 0); 570 - } 571 - 572 - void dcn35_enable_power_gating_plane(struct dce_hwseq *hws, bool enable) 573 - { 574 - bool force_on = true; /* disable power gating */ 575 - uint32_t org_ip_request_cntl = 0; 576 - 577 - if (hws->ctx->dc->debug.disable_hubp_power_gate) 578 - return; 579 - if (hws->ctx->dc->debug.ignore_pg) 580 - return; 581 - REG_GET(DC_IP_REQUEST_CNTL, IP_REQUEST_EN, &org_ip_request_cntl); 582 - if (org_ip_request_cntl == 0) 583 - REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 1); 584 - /* DCHUBP0/1/2/3/4/5 */ 585 - REG_UPDATE(DOMAIN0_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 586 - REG_UPDATE(DOMAIN2_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 587 - /* DPP0/1/2/3/4/5 */ 588 - REG_UPDATE(DOMAIN1_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 589 - REG_UPDATE(DOMAIN3_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 590 - 591 - force_on = true; /* disable power gating */ 592 - if (enable && !hws->ctx->dc->debug.disable_dsc_power_gate) 593 - force_on = false; 594 - 595 - /* DCS0/1/2/3/4 */ 596 - REG_UPDATE(DOMAIN16_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 597 - REG_UPDATE(DOMAIN17_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 598 - REG_UPDATE(DOMAIN18_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 599 - REG_UPDATE(DOMAIN19_PG_CONFIG, DOMAIN_POWER_FORCEON, force_on); 600 - 601 - 602 501 } 603 502 604 503 /* In headless boot cases, DIG may be turned ··· 1372 1453 } 1373 1454 1374 1455 dcn20_prepare_bandwidth(dc, context); 1456 + 1457 + print_pg_status(dc, __func__, ": after rcg and power up"); 1375 1458 } 1376 1459 1377 1460 void dcn35_optimize_bandwidth( ··· 1381 1460 struct dc_state *context) 1382 1461 { 1383 1462 struct pg_block_update pg_update_state; 1463 + 1464 + print_pg_status(dc, __func__, ": before rcg and power up"); 1384 1465 1385 1466 dcn20_optimize_bandwidth(dc, context); 1386 1467 ··· 1395 1472 if (dc->hwss.root_clock_control) 1396 1473 dc->hwss.root_clock_control(dc, &pg_update_state, false); 1397 1474 } 1475 + 1476 + print_pg_status(dc, __func__, ": after rcg and power up"); 1398 1477 } 1399 1478 1400 1479 void dcn35_set_drr(struct pipe_ctx **pipe_ctx,
-3
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c
··· 115 115 .exit_optimized_pwr_state = dcn21_exit_optimized_pwr_state, 116 116 .update_visual_confirm_color = dcn10_update_visual_confirm_color, 117 117 .apply_idle_power_optimizations = dcn35_apply_idle_power_optimizations, 118 - .update_dsc_pg = dcn32_update_dsc_pg, 119 118 .calc_blocks_to_gate = dcn35_calc_blocks_to_gate, 120 119 .calc_blocks_to_ungate = dcn35_calc_blocks_to_ungate, 121 120 .hw_block_power_up = dcn35_hw_block_power_up, ··· 149 150 .plane_atomic_disable = dcn35_plane_atomic_disable, 150 151 //.plane_atomic_disable = dcn20_plane_atomic_disable,/*todo*/ 151 152 //.hubp_pg_control = dcn35_hubp_pg_control, 152 - .enable_power_gating_plane = dcn35_enable_power_gating_plane, 153 153 .dpp_root_clock_control = dcn35_dpp_root_clock_control, 154 154 .dpstream_root_clock_control = dcn35_dpstream_root_clock_control, 155 155 .physymclk_root_clock_control = dcn35_physymclk_root_clock_control, ··· 163 165 .calculate_dccg_k1_k2_values = dcn32_calculate_dccg_k1_k2_values, 164 166 .resync_fifo_dccg_dio = dcn314_resync_fifo_dccg_dio, 165 167 .is_dp_dig_pixel_rate_div_policy = dcn35_is_dp_dig_pixel_rate_div_policy, 166 - .dsc_pg_control = dcn35_dsc_pg_control, 167 168 .dsc_pg_status = dcn32_dsc_pg_status, 168 169 .enable_plane = dcn35_enable_plane, 169 170 .wait_for_pipe_update_if_needed = dcn10_wait_for_pipe_update_if_needed,
-3
drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c
··· 114 114 .exit_optimized_pwr_state = dcn21_exit_optimized_pwr_state, 115 115 .update_visual_confirm_color = dcn10_update_visual_confirm_color, 116 116 .apply_idle_power_optimizations = dcn35_apply_idle_power_optimizations, 117 - .update_dsc_pg = dcn32_update_dsc_pg, 118 117 .calc_blocks_to_gate = dcn351_calc_blocks_to_gate, 119 118 .calc_blocks_to_ungate = dcn351_calc_blocks_to_ungate, 120 119 .hw_block_power_up = dcn351_hw_block_power_up, ··· 144 145 .plane_atomic_disable = dcn35_plane_atomic_disable, 145 146 //.plane_atomic_disable = dcn20_plane_atomic_disable,/*todo*/ 146 147 //.hubp_pg_control = dcn35_hubp_pg_control, 147 - .enable_power_gating_plane = dcn35_enable_power_gating_plane, 148 148 .dpp_root_clock_control = dcn35_dpp_root_clock_control, 149 149 .dpstream_root_clock_control = dcn35_dpstream_root_clock_control, 150 150 .physymclk_root_clock_control = dcn35_physymclk_root_clock_control, ··· 157 159 .setup_hpo_hw_control = dcn35_setup_hpo_hw_control, 158 160 .calculate_dccg_k1_k2_values = dcn32_calculate_dccg_k1_k2_values, 159 161 .is_dp_dig_pixel_rate_div_policy = dcn35_is_dp_dig_pixel_rate_div_policy, 160 - .dsc_pg_control = dcn35_dsc_pg_control, 161 162 .dsc_pg_status = dcn32_dsc_pg_status, 162 163 .enable_plane = dcn35_enable_plane, 163 164 .wait_for_pipe_update_if_needed = dcn10_wait_for_pipe_update_if_needed,
+1
drivers/gpu/drm/amd/display/dc/inc/hw/pg_cntl.h
··· 49 49 void (*mem_pg_control)(struct pg_cntl *pg_cntl, bool power_on); 50 50 void (*dio_pg_control)(struct pg_cntl *pg_cntl, bool power_on); 51 51 void (*init_pg_status)(struct pg_cntl *pg_cntl); 52 + void (*print_pg_status)(struct pg_cntl *pg_cntl, const char *debug_func, const char *debug_log); 52 53 }; 53 54 54 55 #endif //__DC_PG_CNTL_H__
+50 -28
drivers/gpu/drm/amd/display/dc/pg/dcn35/dcn35_pg_cntl.c
··· 79 79 uint32_t power_gate = power_on ? 0 : 1; 80 80 uint32_t pwr_status = power_on ? 0 : 2; 81 81 uint32_t org_ip_request_cntl = 0; 82 - bool block_enabled; 82 + bool block_enabled = false; 83 + bool skip_pg = pg_cntl->ctx->dc->debug.ignore_pg || 84 + pg_cntl->ctx->dc->debug.disable_dsc_power_gate || 85 + pg_cntl->ctx->dc->idle_optimizations_allowed; 83 86 84 - /*need to enable dscclk regardless DSC_PG*/ 85 - if (pg_cntl->ctx->dc->res_pool->dccg->funcs->enable_dsc && power_on) 86 - pg_cntl->ctx->dc->res_pool->dccg->funcs->enable_dsc( 87 - pg_cntl->ctx->dc->res_pool->dccg, dsc_inst); 88 - 89 - if (pg_cntl->ctx->dc->debug.ignore_pg || 90 - pg_cntl->ctx->dc->debug.disable_dsc_power_gate || 91 - pg_cntl->ctx->dc->idle_optimizations_allowed) 87 + if (skip_pg && !power_on) 92 88 return; 93 89 94 90 block_enabled = pg_cntl35_dsc_pg_status(pg_cntl, dsc_inst); ··· 107 111 108 112 REG_WAIT(DOMAIN16_PG_STATUS, 109 113 DOMAIN_PGFSM_PWR_STATUS, pwr_status, 110 - 1, 1000); 114 + 1, 10000); 111 115 break; 112 116 case 1: /* DSC1 */ 113 117 REG_UPDATE(DOMAIN17_PG_CONFIG, ··· 115 119 116 120 REG_WAIT(DOMAIN17_PG_STATUS, 117 121 DOMAIN_PGFSM_PWR_STATUS, pwr_status, 118 - 1, 1000); 122 + 1, 10000); 119 123 break; 120 124 case 2: /* DSC2 */ 121 125 REG_UPDATE(DOMAIN18_PG_CONFIG, ··· 123 127 124 128 REG_WAIT(DOMAIN18_PG_STATUS, 125 129 DOMAIN_PGFSM_PWR_STATUS, pwr_status, 126 - 1, 1000); 130 + 1, 10000); 127 131 break; 128 132 case 3: /* DSC3 */ 129 133 REG_UPDATE(DOMAIN19_PG_CONFIG, ··· 131 135 132 136 REG_WAIT(DOMAIN19_PG_STATUS, 133 137 DOMAIN_PGFSM_PWR_STATUS, pwr_status, 134 - 1, 1000); 138 + 1, 10000); 135 139 break; 136 140 default: 137 141 BREAK_TO_DEBUGGER(); ··· 140 144 141 145 if (dsc_inst < MAX_PIPES) 142 146 pg_cntl->pg_pipe_res_enable[PG_DSC][dsc_inst] = power_on; 143 - 144 - if (pg_cntl->ctx->dc->res_pool->dccg->funcs->disable_dsc && !power_on) { 145 - /*this is to disable dscclk*/ 146 - pg_cntl->ctx->dc->res_pool->dccg->funcs->disable_dsc( 147 - pg_cntl->ctx->dc->res_pool->dccg, dsc_inst); 148 - } 149 147 } 150 148 151 149 static bool pg_cntl35_hubp_dpp_pg_status(struct pg_cntl *pg_cntl, unsigned int hubp_dpp_inst) ··· 179 189 uint32_t pwr_status = power_on ? 0 : 2; 180 190 uint32_t org_ip_request_cntl; 181 191 bool block_enabled; 192 + bool skip_pg = pg_cntl->ctx->dc->debug.ignore_pg || 193 + pg_cntl->ctx->dc->debug.disable_hubp_power_gate || 194 + pg_cntl->ctx->dc->debug.disable_dpp_power_gate || 195 + pg_cntl->ctx->dc->idle_optimizations_allowed; 182 196 183 - if (pg_cntl->ctx->dc->debug.ignore_pg || 184 - pg_cntl->ctx->dc->debug.disable_hubp_power_gate || 185 - pg_cntl->ctx->dc->debug.disable_dpp_power_gate || 186 - pg_cntl->ctx->dc->idle_optimizations_allowed) 197 + if (skip_pg && !power_on) 187 198 return; 188 199 189 200 block_enabled = pg_cntl35_hubp_dpp_pg_status(pg_cntl, hubp_dpp_inst); ··· 204 213 case 0: 205 214 /* DPP0 & HUBP0 */ 206 215 REG_UPDATE(DOMAIN0_PG_CONFIG, DOMAIN_POWER_GATE, power_gate); 207 - REG_WAIT(DOMAIN0_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 1000); 216 + REG_WAIT(DOMAIN0_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 10000); 208 217 break; 209 218 case 1: 210 219 /* DPP1 & HUBP1 */ 211 220 REG_UPDATE(DOMAIN1_PG_CONFIG, DOMAIN_POWER_GATE, power_gate); 212 - REG_WAIT(DOMAIN1_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 1000); 221 + REG_WAIT(DOMAIN1_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 10000); 213 222 break; 214 223 case 2: 215 224 /* DPP2 & HUBP2 */ 216 225 REG_UPDATE(DOMAIN2_PG_CONFIG, DOMAIN_POWER_GATE, power_gate); 217 - REG_WAIT(DOMAIN2_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 1000); 226 + REG_WAIT(DOMAIN2_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 10000); 218 227 break; 219 228 case 3: 220 229 /* DPP3 & HUBP3 */ 221 230 REG_UPDATE(DOMAIN3_PG_CONFIG, DOMAIN_POWER_GATE, power_gate); 222 - REG_WAIT(DOMAIN3_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 1000); 231 + REG_WAIT(DOMAIN3_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, pwr_status, 1, 10000); 223 232 break; 224 233 default: 225 234 BREAK_TO_DEBUGGER(); ··· 492 501 pg_cntl->pg_res_enable[PG_DWB] = block_enabled; 493 502 } 494 503 504 + static void pg_cntl35_print_pg_status(struct pg_cntl *pg_cntl, const char *debug_func, const char *debug_log) 505 + { 506 + int i = 0; 507 + bool block_enabled = false; 508 + 509 + DC_LOG_DEBUG("%s: %s", debug_func, debug_log); 510 + 511 + DC_LOG_DEBUG("PG_CNTL status:\n"); 512 + 513 + block_enabled = pg_cntl35_io_clk_status(pg_cntl); 514 + DC_LOG_DEBUG("ONO0=%d (DCCG, DIO, DCIO)\n", block_enabled ? 1 : 0); 515 + 516 + block_enabled = pg_cntl35_mem_status(pg_cntl); 517 + DC_LOG_DEBUG("ONO1=%d (DCHUBBUB, DCHVM, DCHUBBUBMEM)\n", block_enabled ? 1 : 0); 518 + 519 + block_enabled = pg_cntl35_plane_otg_status(pg_cntl); 520 + DC_LOG_DEBUG("ONO2=%d (MPC, OPP, OPTC, DWB)\n", block_enabled ? 1 : 0); 521 + 522 + block_enabled = pg_cntl35_hpo_pg_status(pg_cntl); 523 + DC_LOG_DEBUG("ONO3=%d (HPO)\n", block_enabled ? 1 : 0); 524 + 525 + for (i = 0; i < pg_cntl->ctx->dc->res_pool->pipe_count; i++) { 526 + block_enabled = pg_cntl35_hubp_dpp_pg_status(pg_cntl, i); 527 + DC_LOG_DEBUG("ONO%d=%d (DCHUBP%d, DPP%d)\n", 4 + i * 2, block_enabled ? 1 : 0, i, i); 528 + 529 + block_enabled = pg_cntl35_dsc_pg_status(pg_cntl, i); 530 + DC_LOG_DEBUG("ONO%d=%d (DSC%d)\n", 5 + i * 2, block_enabled ? 1 : 0, i); 531 + } 532 + } 533 + 495 534 static const struct pg_cntl_funcs pg_cntl35_funcs = { 496 535 .init_pg_status = pg_cntl35_init_pg_status, 497 536 .dsc_pg_control = pg_cntl35_dsc_pg_control, ··· 532 511 .mpcc_pg_control = pg_cntl35_mpcc_pg_control, 533 512 .opp_pg_control = pg_cntl35_opp_pg_control, 534 513 .optc_pg_control = pg_cntl35_optc_pg_control, 535 - .dwb_pg_control = pg_cntl35_dwb_pg_control 514 + .dwb_pg_control = pg_cntl35_dwb_pg_control, 515 + .print_pg_status = pg_cntl35_print_pg_status 536 516 }; 537 517 538 518 struct pg_cntl *pg_cntl35_create(
+3 -3
drivers/gpu/drm/i915/display/intel_display_power.c
··· 1172 1172 if (DISPLAY_VER(display) == 12) 1173 1173 abox_regs |= BIT(0); 1174 1174 1175 - for_each_set_bit(i, &abox_regs, sizeof(abox_regs)) 1175 + for_each_set_bit(i, &abox_regs, BITS_PER_TYPE(abox_regs)) 1176 1176 intel_de_rmw(display, MBUS_ABOX_CTL(i), mask, val); 1177 1177 } 1178 1178 ··· 1629 1629 if (table[config].page_mask == 0) { 1630 1630 drm_dbg_kms(display->drm, 1631 1631 "Unknown memory configuration; disabling address buddy logic.\n"); 1632 - for_each_set_bit(i, &abox_mask, sizeof(abox_mask)) 1632 + for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask)) 1633 1633 intel_de_write(display, BW_BUDDY_CTL(i), 1634 1634 BW_BUDDY_DISABLE); 1635 1635 } else { 1636 - for_each_set_bit(i, &abox_mask, sizeof(abox_mask)) { 1636 + for_each_set_bit(i, &abox_mask, BITS_PER_TYPE(abox_mask)) { 1637 1637 intel_de_write(display, BW_BUDDY_PAGE_MASK(i), 1638 1638 table[config].page_mask); 1639 1639
+9 -14
drivers/gpu/drm/mediatek/mtk_drm_drv.c
··· 387 387 388 388 of_id = of_match_node(mtk_drm_of_ids, node); 389 389 if (!of_id) 390 - goto next_put_node; 390 + continue; 391 391 392 392 pdev = of_find_device_by_node(node); 393 393 if (!pdev) 394 - goto next_put_node; 394 + continue; 395 395 396 396 drm_dev = device_find_child(&pdev->dev, NULL, mtk_drm_match); 397 + put_device(&pdev->dev); 397 398 if (!drm_dev) 398 - goto next_put_device_pdev_dev; 399 + continue; 399 400 400 401 temp_drm_priv = dev_get_drvdata(drm_dev); 402 + put_device(drm_dev); 401 403 if (!temp_drm_priv) 402 - goto next_put_device_drm_dev; 404 + continue; 403 405 404 406 if (temp_drm_priv->data->main_len) 405 407 all_drm_priv[CRTC_MAIN] = temp_drm_priv; ··· 413 411 if (temp_drm_priv->mtk_drm_bound) 414 412 cnt++; 415 413 416 - next_put_device_drm_dev: 417 - put_device(drm_dev); 418 - 419 - next_put_device_pdev_dev: 420 - put_device(&pdev->dev); 421 - 422 - next_put_node: 423 - of_node_put(node); 424 - 425 - if (cnt == MAX_CRTC) 414 + if (cnt == MAX_CRTC) { 415 + of_node_put(node); 426 416 break; 417 + } 427 418 } 428 419 429 420 if (drm_priv->data->mmsys_dev_num == cnt) {
-15
drivers/gpu/drm/nouveau/nouveau_fence.c
··· 240 240 return ret; 241 241 } 242 242 243 - void 244 - nouveau_fence_cancel(struct nouveau_fence *fence) 245 - { 246 - struct nouveau_fence_chan *fctx = nouveau_fctx(fence); 247 - unsigned long flags; 248 - 249 - spin_lock_irqsave(&fctx->lock, flags); 250 - if (!dma_fence_is_signaled_locked(&fence->base)) { 251 - dma_fence_set_error(&fence->base, -ECANCELED); 252 - if (nouveau_fence_signal(fence)) 253 - nvif_event_block(&fctx->event); 254 - } 255 - spin_unlock_irqrestore(&fctx->lock, flags); 256 - } 257 - 258 243 bool 259 244 nouveau_fence_done(struct nouveau_fence *fence) 260 245 {
-1
drivers/gpu/drm/nouveau/nouveau_fence.h
··· 29 29 30 30 int nouveau_fence_emit(struct nouveau_fence *); 31 31 bool nouveau_fence_done(struct nouveau_fence *); 32 - void nouveau_fence_cancel(struct nouveau_fence *fence); 33 32 int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr); 34 33 int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr); 35 34
+14 -21
drivers/gpu/drm/nouveau/nouveau_sched.c
··· 11 11 #include "nouveau_exec.h" 12 12 #include "nouveau_abi16.h" 13 13 #include "nouveau_sched.h" 14 - #include "nouveau_chan.h" 15 14 16 15 #define NOUVEAU_SCHED_JOB_TIMEOUT_MS 10000 17 16 ··· 121 122 { 122 123 struct nouveau_sched *sched = job->sched; 123 124 124 - spin_lock(&sched->job_list.lock); 125 + spin_lock(&sched->job.list.lock); 125 126 list_del(&job->entry); 126 - spin_unlock(&sched->job_list.lock); 127 + spin_unlock(&sched->job.list.lock); 128 + 129 + wake_up(&sched->job.wq); 127 130 } 128 131 129 132 void ··· 306 305 } 307 306 308 307 /* Submit was successful; add the job to the schedulers job list. */ 309 - spin_lock(&sched->job_list.lock); 310 - list_add(&job->entry, &sched->job_list.head); 311 - spin_unlock(&sched->job_list.lock); 308 + spin_lock(&sched->job.list.lock); 309 + list_add(&job->entry, &sched->job.list.head); 310 + spin_unlock(&sched->job.list.lock); 312 311 313 312 drm_sched_job_arm(&job->base); 314 313 job->done_fence = dma_fence_get(&job->base.s_fence->finished); ··· 393 392 nouveau_job_fini(job); 394 393 } 395 394 396 - static void 397 - nouveau_sched_cancel_job(struct drm_sched_job *sched_job) 398 - { 399 - struct nouveau_fence *fence; 400 - struct nouveau_job *job; 401 - 402 - job = to_nouveau_job(sched_job); 403 - fence = to_nouveau_fence(job->done_fence); 404 - 405 - nouveau_fence_cancel(fence); 406 - } 407 - 408 395 static const struct drm_sched_backend_ops nouveau_sched_ops = { 409 396 .run_job = nouveau_sched_run_job, 410 397 .timedout_job = nouveau_sched_timedout_job, 411 398 .free_job = nouveau_sched_free_job, 412 - .cancel_job = nouveau_sched_cancel_job, 413 399 }; 414 400 415 401 static int ··· 446 458 goto fail_sched; 447 459 448 460 mutex_init(&sched->mutex); 449 - spin_lock_init(&sched->job_list.lock); 450 - INIT_LIST_HEAD(&sched->job_list.head); 461 + spin_lock_init(&sched->job.list.lock); 462 + INIT_LIST_HEAD(&sched->job.list.head); 463 + init_waitqueue_head(&sched->job.wq); 451 464 452 465 return 0; 453 466 ··· 482 493 return 0; 483 494 } 484 495 496 + 485 497 static void 486 498 nouveau_sched_fini(struct nouveau_sched *sched) 487 499 { 488 500 struct drm_gpu_scheduler *drm_sched = &sched->base; 489 501 struct drm_sched_entity *entity = &sched->entity; 502 + 503 + rmb(); /* for list_empty to work without lock */ 504 + wait_event(sched->job.wq, list_empty(&sched->job.list.head)); 490 505 491 506 drm_sched_entity_fini(entity); 492 507 drm_sched_fini(drm_sched);
+6 -3
drivers/gpu/drm/nouveau/nouveau_sched.h
··· 103 103 struct mutex mutex; 104 104 105 105 struct { 106 - struct list_head head; 107 - spinlock_t lock; 108 - } job_list; 106 + struct { 107 + struct list_head head; 108 + spinlock_t lock; 109 + } list; 110 + struct wait_queue_head wq; 111 + } job; 109 112 }; 110 113 111 114 int nouveau_sched_create(struct nouveau_sched **psched, struct nouveau_drm *drm,
+4 -4
drivers/gpu/drm/nouveau/nouveau_uvmm.c
··· 1019 1019 u64 end = addr + range; 1020 1020 1021 1021 again: 1022 - spin_lock(&sched->job_list.lock); 1023 - list_for_each_entry(__job, &sched->job_list.head, entry) { 1022 + spin_lock(&sched->job.list.lock); 1023 + list_for_each_entry(__job, &sched->job.list.head, entry) { 1024 1024 struct nouveau_uvmm_bind_job *bind_job = to_uvmm_bind_job(__job); 1025 1025 1026 1026 list_for_each_op(op, &bind_job->ops) { ··· 1030 1030 1031 1031 if (!(end <= op_addr || addr >= op_end)) { 1032 1032 nouveau_uvmm_bind_job_get(bind_job); 1033 - spin_unlock(&sched->job_list.lock); 1033 + spin_unlock(&sched->job.list.lock); 1034 1034 wait_for_completion(&bind_job->complete); 1035 1035 nouveau_uvmm_bind_job_put(bind_job); 1036 1036 goto again; ··· 1038 1038 } 1039 1039 } 1040 1040 } 1041 - spin_unlock(&sched->job_list.lock); 1041 + spin_unlock(&sched->job.list.lock); 1042 1042 } 1043 1043 1044 1044 static int
+1 -1
drivers/gpu/drm/panthor/panthor_drv.c
··· 1094 1094 struct drm_panthor_queue_create *queue_args; 1095 1095 int ret; 1096 1096 1097 - if (!args->queues.count) 1097 + if (!args->queues.count || args->queues.count > MAX_CS_PER_CSG) 1098 1098 return -EINVAL; 1099 1099 1100 1100 ret = PANTHOR_UOBJ_GET_ARRAY(queue_args, &args->queues);
+1 -1
drivers/gpu/drm/xe/tests/xe_bo.c
··· 236 236 } 237 237 238 238 xe_bo_lock(external, false); 239 - err = xe_bo_pin_external(external); 239 + err = xe_bo_pin_external(external, false); 240 240 xe_bo_unlock(external); 241 241 if (err) { 242 242 KUNIT_FAIL(test, "external bo pin err=%pe\n",
+1 -9
drivers/gpu/drm/xe/tests/xe_dma_buf.c
··· 89 89 return; 90 90 } 91 91 92 - /* 93 - * If on different devices, the exporter is kept in system if 94 - * possible, saving a migration step as the transfer is just 95 - * likely as fast from system memory. 96 - */ 97 - if (params->mem_mask & XE_BO_FLAG_SYSTEM) 98 - KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(exported, XE_PL_TT)); 99 - else 100 - KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(exported, mem_type)); 92 + KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(exported, mem_type)); 101 93 102 94 if (params->force_different_devices) 103 95 KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(imported, XE_PL_TT));
+12 -4
drivers/gpu/drm/xe/xe_bo.c
··· 186 186 187 187 bo->placements[*c] = (struct ttm_place) { 188 188 .mem_type = XE_PL_TT, 189 + .flags = (bo_flags & XE_BO_FLAG_VRAM_MASK) ? 190 + TTM_PL_FLAG_FALLBACK : 0, 189 191 }; 190 192 *c += 1; 191 193 } ··· 2271 2269 /** 2272 2270 * xe_bo_pin_external - pin an external BO 2273 2271 * @bo: buffer object to be pinned 2272 + * @in_place: Pin in current placement, don't attempt to migrate. 2274 2273 * 2275 2274 * Pin an external (not tied to a VM, can be exported via dma-buf / prime FD) 2276 2275 * BO. Unique call compared to xe_bo_pin as this function has it own set of ··· 2279 2276 * 2280 2277 * Returns 0 for success, negative error code otherwise. 2281 2278 */ 2282 - int xe_bo_pin_external(struct xe_bo *bo) 2279 + int xe_bo_pin_external(struct xe_bo *bo, bool in_place) 2283 2280 { 2284 2281 struct xe_device *xe = xe_bo_device(bo); 2285 2282 int err; ··· 2288 2285 xe_assert(xe, xe_bo_is_user(bo)); 2289 2286 2290 2287 if (!xe_bo_is_pinned(bo)) { 2291 - err = xe_bo_validate(bo, NULL, false); 2292 - if (err) 2293 - return err; 2288 + if (!in_place) { 2289 + err = xe_bo_validate(bo, NULL, false); 2290 + if (err) 2291 + return err; 2292 + } 2294 2293 2295 2294 spin_lock(&xe->pinned.lock); 2296 2295 list_add_tail(&bo->pinned_link, &xe->pinned.late.external); ··· 2444 2439 .gfp_retry_mayfail = true, 2445 2440 }; 2446 2441 int ret; 2442 + 2443 + if (xe_bo_is_pinned(bo)) 2444 + return 0; 2447 2445 2448 2446 if (vm) { 2449 2447 lockdep_assert_held(&vm->lock);
+1 -1
drivers/gpu/drm/xe/xe_bo.h
··· 198 198 } 199 199 } 200 200 201 - int xe_bo_pin_external(struct xe_bo *bo); 201 + int xe_bo_pin_external(struct xe_bo *bo, bool in_place); 202 202 int xe_bo_pin(struct xe_bo *bo); 203 203 void xe_bo_unpin_external(struct xe_bo *bo); 204 204 void xe_bo_unpin(struct xe_bo *bo);
+6
drivers/gpu/drm/xe/xe_device_types.h
··· 553 553 554 554 /** @pm_notifier: Our PM notifier to perform actions in response to various PM events. */ 555 555 struct notifier_block pm_notifier; 556 + /** @pm_block: Completion to block validating tasks on suspend / hibernate prepare */ 557 + struct completion pm_block; 558 + /** @rebind_resume_list: List of wq items to kick on resume. */ 559 + struct list_head rebind_resume_list; 560 + /** @rebind_resume_lock: Lock to protect the rebind_resume_list */ 561 + struct mutex rebind_resume_lock; 556 562 557 563 /** @pmt: Support the PMT driver callback interface */ 558 564 struct {
+1 -1
drivers/gpu/drm/xe/xe_dma_buf.c
··· 72 72 return ret; 73 73 } 74 74 75 - ret = xe_bo_pin_external(bo); 75 + ret = xe_bo_pin_external(bo, true); 76 76 xe_assert(xe, !ret); 77 77 78 78 return 0;
+9
drivers/gpu/drm/xe/xe_exec.c
··· 237 237 goto err_unlock_list; 238 238 } 239 239 240 + /* 241 + * It's OK to block interruptible here with the vm lock held, since 242 + * on task freezing during suspend / hibernate, the call will 243 + * return -ERESTARTSYS and the IOCTL will be rerun. 244 + */ 245 + err = wait_for_completion_interruptible(&xe->pm_block); 246 + if (err) 247 + goto err_unlock_list; 248 + 240 249 vm_exec.vm = &vm->gpuvm; 241 250 vm_exec.flags = DRM_EXEC_INTERRUPTIBLE_WAIT; 242 251 if (xe_vm_in_lr_mode(vm)) {
+32 -10
drivers/gpu/drm/xe/xe_pm.c
··· 24 24 #include "xe_pcode.h" 25 25 #include "xe_pxp.h" 26 26 #include "xe_trace.h" 27 + #include "xe_vm.h" 27 28 #include "xe_wa.h" 28 29 29 30 /** ··· 291 290 return DEFAULT_VRAM_THRESHOLD; 292 291 } 293 292 293 + static void xe_pm_wake_rebind_workers(struct xe_device *xe) 294 + { 295 + struct xe_vm *vm, *next; 296 + 297 + mutex_lock(&xe->rebind_resume_lock); 298 + list_for_each_entry_safe(vm, next, &xe->rebind_resume_list, 299 + preempt.pm_activate_link) { 300 + list_del_init(&vm->preempt.pm_activate_link); 301 + xe_vm_resume_rebind_worker(vm); 302 + } 303 + mutex_unlock(&xe->rebind_resume_lock); 304 + } 305 + 294 306 static int xe_pm_notifier_callback(struct notifier_block *nb, 295 307 unsigned long action, void *data) 296 308 { ··· 313 299 switch (action) { 314 300 case PM_HIBERNATION_PREPARE: 315 301 case PM_SUSPEND_PREPARE: 302 + reinit_completion(&xe->pm_block); 316 303 xe_pm_runtime_get(xe); 317 304 err = xe_bo_evict_all_user(xe); 318 - if (err) { 305 + if (err) 319 306 drm_dbg(&xe->drm, "Notifier evict user failed (%d)\n", err); 320 - xe_pm_runtime_put(xe); 321 - break; 322 - } 323 307 324 308 err = xe_bo_notifier_prepare_all_pinned(xe); 325 - if (err) { 309 + if (err) 326 310 drm_dbg(&xe->drm, "Notifier prepare pin failed (%d)\n", err); 327 - xe_pm_runtime_put(xe); 328 - } 311 + /* 312 + * Keep the runtime pm reference until post hibernation / post suspend to 313 + * avoid a runtime suspend interfering with evicted objects or backup 314 + * allocations. 315 + */ 329 316 break; 330 317 case PM_POST_HIBERNATION: 331 318 case PM_POST_SUSPEND: 319 + complete_all(&xe->pm_block); 320 + xe_pm_wake_rebind_workers(xe); 332 321 xe_bo_notifier_unprepare_all_pinned(xe); 333 322 xe_pm_runtime_put(xe); 334 323 break; 335 324 } 336 - 337 - if (err) 338 - return NOTIFY_BAD; 339 325 340 326 return NOTIFY_DONE; 341 327 } ··· 357 343 err = register_pm_notifier(&xe->pm_notifier); 358 344 if (err) 359 345 return err; 346 + 347 + err = drmm_mutex_init(&xe->drm, &xe->rebind_resume_lock); 348 + if (err) 349 + goto err_unregister; 350 + 351 + init_completion(&xe->pm_block); 352 + complete_all(&xe->pm_block); 353 + INIT_LIST_HEAD(&xe->rebind_resume_list); 360 354 361 355 /* For now suspend/resume is only allowed with GuC */ 362 356 if (!xe_device_uc_enabled(xe))
+2 -1
drivers/gpu/drm/xe/xe_survivability_mode.c
··· 41 41 * 42 42 * # echo 1 > /sys/kernel/config/xe/0000:03:00.0/survivability_mode 43 43 * 44 + * It is the responsibility of the user to clear the mode once firmware flash is complete. 45 + * 44 46 * Refer :ref:`xe_configfs` for more details on how to use configfs 45 47 * 46 48 * Survivability mode is indicated by the below admin-only readable sysfs which provides additional ··· 149 147 struct pci_dev *pdev = to_pci_dev(xe->drm.dev); 150 148 struct device *dev = &pdev->dev; 151 149 152 - xe_configfs_clear_survivability_mode(pdev); 153 150 sysfs_remove_file(&dev->kobj, &dev_attr_survivability_mode.attr); 154 151 } 155 152
+41 -1
drivers/gpu/drm/xe/xe_vm.c
··· 393 393 list_move_tail(&gpuva_to_vma(gpuva)->combined_links.rebind, 394 394 &vm->rebind_list); 395 395 396 + if (!try_wait_for_completion(&vm->xe->pm_block)) 397 + return -EAGAIN; 398 + 396 399 ret = xe_bo_validate(gem_to_xe_bo(vm_bo->obj), vm, false); 397 400 if (ret) 398 401 return ret; ··· 482 479 return xe_vm_validate_rebind(vm, exec, vm->preempt.num_exec_queues); 483 480 } 484 481 482 + static bool vm_suspend_rebind_worker(struct xe_vm *vm) 483 + { 484 + struct xe_device *xe = vm->xe; 485 + bool ret = false; 486 + 487 + mutex_lock(&xe->rebind_resume_lock); 488 + if (!try_wait_for_completion(&vm->xe->pm_block)) { 489 + ret = true; 490 + list_move_tail(&vm->preempt.pm_activate_link, &xe->rebind_resume_list); 491 + } 492 + mutex_unlock(&xe->rebind_resume_lock); 493 + 494 + return ret; 495 + } 496 + 497 + /** 498 + * xe_vm_resume_rebind_worker() - Resume the rebind worker. 499 + * @vm: The vm whose preempt worker to resume. 500 + * 501 + * Resume a preempt worker that was previously suspended by 502 + * vm_suspend_rebind_worker(). 503 + */ 504 + void xe_vm_resume_rebind_worker(struct xe_vm *vm) 505 + { 506 + queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work); 507 + } 508 + 485 509 static void preempt_rebind_work_func(struct work_struct *w) 486 510 { 487 511 struct xe_vm *vm = container_of(w, struct xe_vm, preempt.rebind_work); ··· 532 502 } 533 503 534 504 retry: 505 + if (!try_wait_for_completion(&vm->xe->pm_block) && vm_suspend_rebind_worker(vm)) { 506 + up_write(&vm->lock); 507 + return; 508 + } 509 + 535 510 if (xe_vm_userptr_check_repin(vm)) { 536 511 err = xe_vm_userptr_pin(vm); 537 512 if (err) ··· 1749 1714 if (flags & XE_VM_FLAG_LR_MODE) { 1750 1715 INIT_WORK(&vm->preempt.rebind_work, preempt_rebind_work_func); 1751 1716 xe_pm_runtime_get_noresume(xe); 1717 + INIT_LIST_HEAD(&vm->preempt.pm_activate_link); 1752 1718 } 1753 1719 1754 1720 if (flags & XE_VM_FLAG_FAULT_MODE) { ··· 1931 1895 xe_assert(xe, !vm->preempt.num_exec_queues); 1932 1896 1933 1897 xe_vm_close(vm); 1934 - if (xe_vm_in_preempt_fence_mode(vm)) 1898 + if (xe_vm_in_preempt_fence_mode(vm)) { 1899 + mutex_lock(&xe->rebind_resume_lock); 1900 + list_del_init(&vm->preempt.pm_activate_link); 1901 + mutex_unlock(&xe->rebind_resume_lock); 1935 1902 flush_work(&vm->preempt.rebind_work); 1903 + } 1936 1904 if (xe_vm_in_fault_mode(vm)) 1937 1905 xe_svm_close(vm); 1938 1906
+2
drivers/gpu/drm/xe/xe_vm.h
··· 273 273 struct xe_exec_queue *q, u64 addr, 274 274 enum xe_cache_level cache_lvl); 275 275 276 + void xe_vm_resume_rebind_worker(struct xe_vm *vm); 277 + 276 278 /** 277 279 * xe_vm_resv() - Return's the vm's reservation object 278 280 * @vm: The vm
+5
drivers/gpu/drm/xe/xe_vm_types.h
··· 293 293 * BOs 294 294 */ 295 295 struct work_struct rebind_work; 296 + /** 297 + * @preempt.pm_activate_link: Link to list of rebind workers to be 298 + * kicked on resume. 299 + */ 300 + struct list_head pm_activate_link; 296 301 } preempt; 297 302 298 303 /** @um: unified memory state */
+2 -1
drivers/gpu/drm/xe/xe_wa_oob.rules
··· 30 30 16022287689 GRAPHICS_VERSION(2001) 31 31 GRAPHICS_VERSION(2004) 32 32 13011645652 GRAPHICS_VERSION(2004) 33 - GRAPHICS_VERSION(3001) 33 + GRAPHICS_VERSION_RANGE(3000, 3001) 34 + GRAPHICS_VERSION(3003) 34 35 14022293748 GRAPHICS_VERSION_RANGE(2001, 2002) 35 36 GRAPHICS_VERSION(2004) 36 37 GRAPHICS_VERSION_RANGE(3000, 3001)
+1
drivers/gpu/nova-core/Kconfig
··· 1 1 config NOVA_CORE 2 2 tristate "Nova Core GPU driver" 3 + depends on 64BIT 3 4 depends on PCI 4 5 depends on RUST 5 6 depends on RUST_FW_LOADER_ABSTRACTIONS
+2
drivers/input/joystick/xpad.c
··· 422 422 { 0x3537, 0x1010, "GameSir G7 SE", 0, XTYPE_XBOXONE }, 423 423 { 0x366c, 0x0005, "ByoWave Proteus Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE, FLAG_DELAY_INIT }, 424 424 { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, 425 + { 0x37d7, 0x2501, "Flydigi Apex 5", 0, XTYPE_XBOX360 }, 425 426 { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 }, 426 427 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 427 428 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } ··· 579 578 XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ 580 579 XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ 581 580 XPAD_XBOXONE_VENDOR(0x366c), /* ByoWave controllers */ 581 + XPAD_XBOX360_VENDOR(0x37d7), /* Flydigi Controllers */ 582 582 XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */ 583 583 { } 584 584 };
+4 -1
drivers/input/keyboard/mtk-pmic-keys.c
··· 55 55 const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT]; 56 56 u32 pmic_rst_reg; 57 57 u32 rst_lprst_mask; /* Long-press reset timeout bitmask */ 58 + bool key_release_irq; 58 59 }; 59 60 60 61 static const struct mtk_pmic_regs mt6397_regs = { ··· 117 116 MTK_PMIC_HOMEKEY_RST), 118 117 .pmic_rst_reg = MT6358_TOP_RST_MISC, 119 118 .rst_lprst_mask = MTK_PMIC_RST_DU_MASK, 119 + .key_release_irq = true, 120 120 }; 121 121 122 122 static const struct mtk_pmic_regs mt6359_regs = { ··· 131 129 MTK_PMIC_HOMEKEY_RST), 132 130 .pmic_rst_reg = MT6359_TOP_RST_MISC, 133 131 .rst_lprst_mask = MTK_PMIC_RST_DU_MASK, 132 + .key_release_irq = true, 134 133 }; 135 134 136 135 struct mtk_pmic_keys_info { ··· 371 368 if (keys->keys[index].irq < 0) 372 369 return keys->keys[index].irq; 373 370 374 - if (of_device_is_compatible(node, "mediatek,mt6358-keys")) { 371 + if (mtk_pmic_regs->key_release_irq) { 375 372 keys->keys[index].irq_r = platform_get_irq_byname(pdev, 376 373 irqnames_r[index]); 377 374
+3
drivers/input/misc/iqs7222.c
··· 2427 2427 if (error) 2428 2428 return error; 2429 2429 2430 + if (!iqs7222->kp_type[chan_index][i]) 2431 + continue; 2432 + 2430 2433 if (!dev_desc->event_offset) 2431 2434 continue; 2432 2435
+14
drivers/input/serio/i8042-acpipnpio.h
··· 1155 1155 .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | 1156 1156 SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) 1157 1157 }, 1158 + { 1159 + .matches = { 1160 + DMI_MATCH(DMI_BOARD_NAME, "XxHP4NAx"), 1161 + }, 1162 + .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | 1163 + SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) 1164 + }, 1165 + { 1166 + .matches = { 1167 + DMI_MATCH(DMI_BOARD_NAME, "XxKK4NAx_XxSP4NAx"), 1168 + }, 1169 + .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | 1170 + SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) 1171 + }, 1158 1172 /* 1159 1173 * A lot of modern Clevo barebones have touchpad and/or keyboard issues 1160 1174 * after suspend fixable with the forcenorestore quirk.
+1 -1
drivers/md/dm-integrity.c
··· 133 133 commit_id_t commit_id; 134 134 }; 135 135 136 - #define MAX_TAG_SIZE (JOURNAL_SECTOR_DATA - JOURNAL_MAC_PER_SECTOR - offsetof(struct journal_entry, last_bytes[MAX_SECTORS_PER_BLOCK])) 136 + #define MAX_TAG_SIZE 255 137 137 138 138 #define METADATA_PADDING_SECTORS 8 139 139
+4 -2
drivers/md/dm-raid.c
··· 3813 3813 struct raid_set *rs = ti->private; 3814 3814 unsigned int chunk_size_bytes = to_bytes(rs->md.chunk_sectors); 3815 3815 3816 - limits->io_min = chunk_size_bytes; 3817 - limits->io_opt = chunk_size_bytes * mddev_data_stripes(rs); 3816 + if (chunk_size_bytes) { 3817 + limits->io_min = chunk_size_bytes; 3818 + limits->io_opt = chunk_size_bytes * mddev_data_stripes(rs); 3819 + } 3818 3820 } 3819 3821 3820 3822 static void raid_presuspend(struct dm_target *ti)
+7 -3
drivers/md/dm-stripe.c
··· 456 456 struct queue_limits *limits) 457 457 { 458 458 struct stripe_c *sc = ti->private; 459 - unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT; 459 + unsigned int io_min, io_opt; 460 460 461 461 limits->chunk_sectors = sc->chunk_size; 462 - limits->io_min = chunk_size; 463 - limits->io_opt = chunk_size * sc->stripes; 462 + 463 + if (!check_shl_overflow(sc->chunk_size, SECTOR_SHIFT, &io_min) && 464 + !check_mul_overflow(io_min, sc->stripes, &io_opt)) { 465 + limits->io_min = io_min; 466 + limits->io_opt = io_opt; 467 + } 464 468 } 465 469 466 470 static struct target_type stripe_target = {
+2 -2
drivers/mtd/devices/Kconfig
··· 185 185 186 186 config MTD_INTEL_DG 187 187 tristate "Intel Discrete Graphics non-volatile memory driver" 188 - depends on AUXILIARY_BUS 189 - depends on MTD 188 + depends on AUXILIARY_BUS && MTD 189 + depends on DRM_I915!=n || DRM_XE!=n || COMPILE_TEST 190 190 help 191 191 This provides an MTD device to access Intel Discrete Graphics 192 192 non-volatile memory.
+13 -3
drivers/mtd/nand/raw/atmel/nand-controller.c
··· 1378 1378 return ret; 1379 1379 1380 1380 /* 1381 + * Read setup timing depends on the operation done on the NAND: 1382 + * 1383 + * NRD_SETUP = max(tAR, tCLR) 1384 + */ 1385 + timeps = max(conf->timings.sdr.tAR_min, conf->timings.sdr.tCLR_min); 1386 + ncycles = DIV_ROUND_UP(timeps, mckperiodps); 1387 + totalcycles += ncycles; 1388 + ret = atmel_smc_cs_conf_set_setup(smcconf, ATMEL_SMC_NRD_SHIFT, ncycles); 1389 + if (ret) 1390 + return ret; 1391 + 1392 + /* 1381 1393 * The read cycle timing is directly matching tRC, but is also 1382 1394 * dependent on the setup and hold timings we calculated earlier, 1383 1395 * which gives: 1384 1396 * 1385 - * NRD_CYCLE = max(tRC, NRD_PULSE + NRD_HOLD) 1386 - * 1387 - * NRD_SETUP is always 0. 1397 + * NRD_CYCLE = max(tRC, NRD_SETUP + NRD_PULSE + NRD_HOLD) 1388 1398 */ 1389 1399 ncycles = DIV_ROUND_UP(conf->timings.sdr.tRC_min, mckperiodps); 1390 1400 ncycles = max(totalcycles, ncycles);
+2 -2
drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c
··· 935 935 936 936 static int ma35_nand_chips_init(struct device *dev, struct ma35_nand_info *nand) 937 937 { 938 - struct device_node *np = dev->of_node, *nand_np; 938 + struct device_node *np = dev->of_node; 939 939 int ret; 940 940 941 - for_each_child_of_node(np, nand_np) { 941 + for_each_child_of_node_scoped(np, nand_np) { 942 942 ret = ma35_nand_chip_init(dev, nand, nand_np); 943 943 if (ret) { 944 944 ma35_chips_cleanup(nand);
+24 -22
drivers/mtd/nand/raw/stm32_fmc2_nand.c
··· 272 272 struct sg_table dma_data_sg; 273 273 struct sg_table dma_ecc_sg; 274 274 u8 *ecc_buf; 275 + dma_addr_t dma_ecc_addr; 275 276 int dma_ecc_len; 276 277 u32 tx_dma_max_burst; 277 278 u32 rx_dma_max_burst; ··· 903 902 904 903 if (!write_data && !raw) { 905 904 /* Configure DMA ECC status */ 906 - p = nfc->ecc_buf; 907 905 for_each_sg(nfc->dma_ecc_sg.sgl, sg, eccsteps, s) { 908 - sg_set_buf(sg, p, nfc->dma_ecc_len); 909 - p += nfc->dma_ecc_len; 910 - } 911 - 912 - ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl, 913 - eccsteps, dma_data_dir); 914 - if (!ret) { 915 - ret = -EIO; 916 - goto err_unmap_data; 906 + sg_dma_address(sg) = nfc->dma_ecc_addr + 907 + s * nfc->dma_ecc_len; 908 + sg_dma_len(sg) = nfc->dma_ecc_len; 917 909 } 918 910 919 911 desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch, ··· 915 921 DMA_PREP_INTERRUPT); 916 922 if (!desc_ecc) { 917 923 ret = -ENOMEM; 918 - goto err_unmap_ecc; 924 + goto err_unmap_data; 919 925 } 920 926 921 927 reinit_completion(&nfc->dma_ecc_complete); ··· 923 929 desc_ecc->callback_param = &nfc->dma_ecc_complete; 924 930 ret = dma_submit_error(dmaengine_submit(desc_ecc)); 925 931 if (ret) 926 - goto err_unmap_ecc; 932 + goto err_unmap_data; 927 933 928 934 dma_async_issue_pending(nfc->dma_ecc_ch); 929 935 } ··· 943 949 if (!write_data && !raw) 944 950 dmaengine_terminate_all(nfc->dma_ecc_ch); 945 951 ret = -ETIMEDOUT; 946 - goto err_unmap_ecc; 952 + goto err_unmap_data; 947 953 } 948 954 949 955 /* Wait DMA data transfer completion */ ··· 962 968 ret = -ETIMEDOUT; 963 969 } 964 970 } 965 - 966 - err_unmap_ecc: 967 - if (!write_data && !raw) 968 - dma_unmap_sg(nfc->dev, nfc->dma_ecc_sg.sgl, 969 - eccsteps, dma_data_dir); 970 971 971 972 err_unmap_data: 972 973 dma_unmap_sg(nfc->dev, nfc->dma_data_sg.sgl, eccsteps, dma_data_dir); ··· 985 996 986 997 /* Write oob */ 987 998 if (oob_required) { 988 - ret = nand_change_write_column_op(chip, mtd->writesize, 989 - chip->oob_poi, mtd->oobsize, 990 - false); 999 + unsigned int offset_in_page = mtd->writesize; 1000 + const void *buf = chip->oob_poi; 1001 + unsigned int len = mtd->oobsize; 1002 + 1003 + if (!raw) { 1004 + struct mtd_oob_region oob_free; 1005 + 1006 + mtd_ooblayout_free(mtd, 0, &oob_free); 1007 + offset_in_page += oob_free.offset; 1008 + buf += oob_free.offset; 1009 + len = oob_free.length; 1010 + } 1011 + 1012 + ret = nand_change_write_column_op(chip, offset_in_page, 1013 + buf, len, false); 991 1014 if (ret) 992 1015 return ret; 993 1016 } ··· 1611 1610 return ret; 1612 1611 1613 1612 /* Allocate a buffer to store ECC status registers */ 1614 - nfc->ecc_buf = devm_kzalloc(nfc->dev, FMC2_MAX_ECC_BUF_LEN, GFP_KERNEL); 1613 + nfc->ecc_buf = dmam_alloc_coherent(nfc->dev, FMC2_MAX_ECC_BUF_LEN, 1614 + &nfc->dma_ecc_addr, GFP_KERNEL); 1615 1615 if (!nfc->ecc_buf) 1616 1616 return -ENOMEM; 1617 1617
+36 -1
drivers/mtd/nand/spi/winbond.c
··· 176 176 .free = w25n02kv_ooblayout_free, 177 177 }; 178 178 179 + static int w25n01jw_ooblayout_ecc(struct mtd_info *mtd, int section, 180 + struct mtd_oob_region *region) 181 + { 182 + if (section > 3) 183 + return -ERANGE; 184 + 185 + region->offset = (16 * section) + 12; 186 + region->length = 4; 187 + 188 + return 0; 189 + } 190 + 191 + static int w25n01jw_ooblayout_free(struct mtd_info *mtd, int section, 192 + struct mtd_oob_region *region) 193 + { 194 + if (section > 3) 195 + return -ERANGE; 196 + 197 + region->offset = (16 * section); 198 + region->length = 12; 199 + 200 + /* Extract BBM */ 201 + if (!section) { 202 + region->offset += 2; 203 + region->length -= 2; 204 + } 205 + 206 + return 0; 207 + } 208 + 179 209 static int w35n01jw_ooblayout_ecc(struct mtd_info *mtd, int section, 180 210 struct mtd_oob_region *region) 181 211 { ··· 235 205 236 206 return 0; 237 207 } 208 + 209 + static const struct mtd_ooblayout_ops w25n01jw_ooblayout = { 210 + .ecc = w25n01jw_ooblayout_ecc, 211 + .free = w25n01jw_ooblayout_free, 212 + }; 238 213 239 214 static const struct mtd_ooblayout_ops w35n01jw_ooblayout = { 240 215 .ecc = w35n01jw_ooblayout_ecc, ··· 429 394 &write_cache_variants, 430 395 &update_cache_variants), 431 396 0, 432 - SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL), 397 + SPINAND_ECCINFO(&w25n01jw_ooblayout, NULL), 433 398 SPINAND_CONFIGURE_CHIP(w25n0xjw_hs_cfg)), 434 399 SPINAND_INFO("W25N01KV", /* 3.3V */ 435 400 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae, 0x21),
+1 -1
drivers/net/bonding/bond_main.c
··· 2053 2053 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); 2054 2054 } else if (bond->params.fail_over_mac == BOND_FOM_FOLLOW && 2055 2055 BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP && 2056 + bond_has_slaves(bond) && 2056 2057 memcmp(slave_dev->dev_addr, bond_dev->dev_addr, bond_dev->addr_len) == 0) { 2057 2058 /* Set slave to random address to avoid duplicate mac 2058 2059 * address in later fail over. ··· 3258 3257 /* Find out through which dev should the packet go */ 3259 3258 memset(&fl6, 0, sizeof(struct flowi6)); 3260 3259 fl6.daddr = targets[i]; 3261 - fl6.flowi6_oif = bond->dev->ifindex; 3262 3260 3263 3261 dst = ip6_route_output(dev_net(bond->dev), NULL, &fl6); 3264 3262 if (dst->error) {
+1 -2
drivers/net/ethernet/broadcom/cnic.c
··· 4230 4230 4231 4231 cnic_bnx2x_delete_wait(dev, 0); 4232 4232 4233 - cancel_delayed_work(&cp->delete_task); 4234 - flush_workqueue(cnic_wq); 4233 + cancel_delayed_work_sync(&cp->delete_task); 4235 4234 4236 4235 if (atomic_read(&cp->iscsi_conn) != 0) 4237 4236 netdev_warn(dev->netdev, "%d iSCSI connections not destroyed\n",
+1 -1
drivers/net/ethernet/cavium/liquidio/request_manager.c
··· 126 126 oct->io_qmask.iq |= BIT_ULL(iq_no); 127 127 128 128 /* Set the 32B/64B mode for each input queue */ 129 - oct->io_qmask.iq64B |= ((conf->instr_type == 64) << iq_no); 129 + oct->io_qmask.iq64B |= ((u64)(conf->instr_type == 64) << iq_no); 130 130 iq->iqcmd_64B = (conf->instr_type == 64); 131 131 132 132 oct->fn_list.setup_iq_regs(oct, iq_no);
+1 -1
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
··· 2736 2736 dev_err(dev, "dpsw_ctrl_if_set_pools() failed\n"); 2737 2737 goto err_get_attr; 2738 2738 } 2739 - ethsw->bpid = dpbp_attrs.id; 2739 + ethsw->bpid = dpbp_attrs.bpid; 2740 2740 2741 2741 return 0; 2742 2742
-3
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 948 948 if (!eop_desc) 949 949 break; 950 950 951 - /* prevent any other reads prior to eop_desc */ 952 - smp_rmb(); 953 - 954 951 i40e_trace(clean_tx_irq, tx_ring, tx_desc, tx_buf); 955 952 /* we have caught up to head, no work left to do */ 956 953 if (tx_head == tx_desc)
+34 -46
drivers/net/ethernet/intel/ice/ice_txrx.c
··· 894 894 __skb_fill_page_desc_noacc(sinfo, sinfo->nr_frags++, rx_buf->page, 895 895 rx_buf->page_offset, size); 896 896 sinfo->xdp_frags_size += size; 897 - /* remember frag count before XDP prog execution; bpf_xdp_adjust_tail() 898 - * can pop off frags but driver has to handle it on its own 899 - */ 900 - rx_ring->nr_frags = sinfo->nr_frags; 901 897 902 898 if (page_is_pfmemalloc(rx_buf->page)) 903 899 xdp_buff_set_frag_pfmemalloc(xdp); ··· 964 968 /** 965 969 * ice_get_pgcnts - grab page_count() for gathered fragments 966 970 * @rx_ring: Rx descriptor ring to store the page counts on 971 + * @ntc: the next to clean element (not included in this frame!) 967 972 * 968 973 * This function is intended to be called right before running XDP 969 974 * program so that the page recycling mechanism will be able to take 970 975 * a correct decision regarding underlying pages; this is done in such 971 976 * way as XDP program can change the refcount of page 972 977 */ 973 - static void ice_get_pgcnts(struct ice_rx_ring *rx_ring) 978 + static void ice_get_pgcnts(struct ice_rx_ring *rx_ring, unsigned int ntc) 974 979 { 975 - u32 nr_frags = rx_ring->nr_frags + 1; 976 980 u32 idx = rx_ring->first_desc; 977 981 struct ice_rx_buf *rx_buf; 978 982 u32 cnt = rx_ring->count; 979 983 980 - for (int i = 0; i < nr_frags; i++) { 984 + while (idx != ntc) { 981 985 rx_buf = &rx_ring->rx_buf[idx]; 982 986 rx_buf->pgcnt = page_count(rx_buf->page); 983 987 ··· 1149 1153 } 1150 1154 1151 1155 /** 1152 - * ice_put_rx_mbuf - ice_put_rx_buf() caller, for all frame frags 1156 + * ice_put_rx_mbuf - ice_put_rx_buf() caller, for all buffers in frame 1153 1157 * @rx_ring: Rx ring with all the auxiliary data 1154 1158 * @xdp: XDP buffer carrying linear + frags part 1155 - * @xdp_xmit: XDP_TX/XDP_REDIRECT verdict storage 1156 - * @ntc: a current next_to_clean value to be stored at rx_ring 1159 + * @ntc: the next to clean element (not included in this frame!) 1157 1160 * @verdict: return code from XDP program execution 1158 1161 * 1159 - * Walk through gathered fragments and satisfy internal page 1160 - * recycle mechanism; we take here an action related to verdict 1161 - * returned by XDP program; 1162 + * Called after XDP program is completed, or on error with verdict set to 1163 + * ICE_XDP_CONSUMED. 1164 + * 1165 + * Walk through buffers from first_desc to the end of the frame, releasing 1166 + * buffers and satisfying internal page recycle mechanism. The action depends 1167 + * on verdict from XDP program. 1162 1168 */ 1163 1169 static void ice_put_rx_mbuf(struct ice_rx_ring *rx_ring, struct xdp_buff *xdp, 1164 - u32 *xdp_xmit, u32 ntc, u32 verdict) 1170 + u32 ntc, u32 verdict) 1165 1171 { 1166 - u32 nr_frags = rx_ring->nr_frags + 1; 1167 1172 u32 idx = rx_ring->first_desc; 1168 1173 u32 cnt = rx_ring->count; 1169 - u32 post_xdp_frags = 1; 1170 1174 struct ice_rx_buf *buf; 1171 - int i; 1175 + u32 xdp_frags = 0; 1176 + int i = 0; 1172 1177 1173 1178 if (unlikely(xdp_buff_has_frags(xdp))) 1174 - post_xdp_frags += xdp_get_shared_info_from_buff(xdp)->nr_frags; 1179 + xdp_frags = xdp_get_shared_info_from_buff(xdp)->nr_frags; 1175 1180 1176 - for (i = 0; i < post_xdp_frags; i++) { 1181 + while (idx != ntc) { 1177 1182 buf = &rx_ring->rx_buf[idx]; 1183 + if (++idx == cnt) 1184 + idx = 0; 1178 1185 1179 - if (verdict & (ICE_XDP_TX | ICE_XDP_REDIR)) { 1186 + /* An XDP program could release fragments from the end of the 1187 + * buffer. For these, we need to keep the pagecnt_bias as-is. 1188 + * To do this, only adjust pagecnt_bias for fragments up to 1189 + * the total remaining after the XDP program has run. 1190 + */ 1191 + if (verdict != ICE_XDP_CONSUMED) 1180 1192 ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz); 1181 - *xdp_xmit |= verdict; 1182 - } else if (verdict & ICE_XDP_CONSUMED) { 1193 + else if (i++ <= xdp_frags) 1183 1194 buf->pagecnt_bias++; 1184 - } else if (verdict == ICE_XDP_PASS) { 1185 - ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz); 1186 - } 1187 1195 1188 1196 ice_put_rx_buf(rx_ring, buf); 1189 - 1190 - if (++idx == cnt) 1191 - idx = 0; 1192 - } 1193 - /* handle buffers that represented frags released by XDP prog; 1194 - * for these we keep pagecnt_bias as-is; refcount from struct page 1195 - * has been decremented within XDP prog and we do not have to increase 1196 - * the biased refcnt 1197 - */ 1198 - for (; i < nr_frags; i++) { 1199 - buf = &rx_ring->rx_buf[idx]; 1200 - ice_put_rx_buf(rx_ring, buf); 1201 - if (++idx == cnt) 1202 - idx = 0; 1203 1197 } 1204 1198 1205 1199 xdp->data = NULL; 1206 1200 rx_ring->first_desc = ntc; 1207 - rx_ring->nr_frags = 0; 1208 1201 } 1209 1202 1210 1203 /** ··· 1301 1316 /* retrieve a buffer from the ring */ 1302 1317 rx_buf = ice_get_rx_buf(rx_ring, size, ntc); 1303 1318 1319 + /* Increment ntc before calls to ice_put_rx_mbuf() */ 1320 + if (++ntc == cnt) 1321 + ntc = 0; 1322 + 1304 1323 if (!xdp->data) { 1305 1324 void *hard_start; 1306 1325 ··· 1313 1324 xdp_prepare_buff(xdp, hard_start, offset, size, !!offset); 1314 1325 xdp_buff_clear_frags_flag(xdp); 1315 1326 } else if (ice_add_xdp_frag(rx_ring, xdp, rx_buf, size)) { 1316 - ice_put_rx_mbuf(rx_ring, xdp, NULL, ntc, ICE_XDP_CONSUMED); 1327 + ice_put_rx_mbuf(rx_ring, xdp, ntc, ICE_XDP_CONSUMED); 1317 1328 break; 1318 1329 } 1319 - if (++ntc == cnt) 1320 - ntc = 0; 1321 1330 1322 1331 /* skip if it is NOP desc */ 1323 1332 if (ice_is_non_eop(rx_ring, rx_desc)) 1324 1333 continue; 1325 1334 1326 - ice_get_pgcnts(rx_ring); 1335 + ice_get_pgcnts(rx_ring, ntc); 1327 1336 xdp_verdict = ice_run_xdp(rx_ring, xdp, xdp_prog, xdp_ring, rx_desc); 1328 1337 if (xdp_verdict == ICE_XDP_PASS) 1329 1338 goto construct_skb; 1330 1339 total_rx_bytes += xdp_get_buff_len(xdp); 1331 1340 total_rx_pkts++; 1332 1341 1333 - ice_put_rx_mbuf(rx_ring, xdp, &xdp_xmit, ntc, xdp_verdict); 1342 + ice_put_rx_mbuf(rx_ring, xdp, ntc, xdp_verdict); 1343 + xdp_xmit |= xdp_verdict & (ICE_XDP_TX | ICE_XDP_REDIR); 1334 1344 1335 1345 continue; 1336 1346 construct_skb: ··· 1342 1354 rx_ring->ring_stats->rx_stats.alloc_buf_failed++; 1343 1355 xdp_verdict = ICE_XDP_CONSUMED; 1344 1356 } 1345 - ice_put_rx_mbuf(rx_ring, xdp, &xdp_xmit, ntc, xdp_verdict); 1357 + ice_put_rx_mbuf(rx_ring, xdp, ntc, xdp_verdict); 1346 1358 1347 1359 if (!skb) 1348 1360 break;
-1
drivers/net/ethernet/intel/ice/ice_txrx.h
··· 358 358 struct ice_tx_ring *xdp_ring; 359 359 struct ice_rx_ring *next; /* pointer to next ring in q_vector */ 360 360 struct xsk_buff_pool *xsk_pool; 361 - u32 nr_frags; 362 361 u16 max_frame; 363 362 u16 rx_buf_len; 364 363 dma_addr_t dma; /* physical address of ring */
+1
drivers/net/ethernet/intel/igc/igc.h
··· 345 345 /* LEDs */ 346 346 struct mutex led_mutex; 347 347 struct igc_led_classdev *leds; 348 + bool leds_available; 348 349 }; 349 350 350 351 void igc_up(struct igc_adapter *adapter);
+9 -3
drivers/net/ethernet/intel/igc/igc_main.c
··· 7335 7335 7336 7336 if (IS_ENABLED(CONFIG_IGC_LEDS)) { 7337 7337 err = igc_led_setup(adapter); 7338 - if (err) 7339 - goto err_register; 7338 + if (err) { 7339 + netdev_warn_once(netdev, 7340 + "LED init failed (%d); continuing without LED support\n", 7341 + err); 7342 + adapter->leds_available = false; 7343 + } else { 7344 + adapter->leds_available = true; 7345 + } 7340 7346 } 7341 7347 7342 7348 return 0; ··· 7398 7392 cancel_work_sync(&adapter->watchdog_task); 7399 7393 hrtimer_cancel(&adapter->hrtimer); 7400 7394 7401 - if (IS_ENABLED(CONFIG_IGC_LEDS)) 7395 + if (IS_ENABLED(CONFIG_IGC_LEDS) && adapter->leds_available) 7402 7396 igc_led_free(adapter); 7403 7397 7404 7398 /* Release control of h/w to f/w. If f/w is AMT enabled, this
+12 -10
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 6978 6978 break; 6979 6979 } 6980 6980 6981 + /* Make sure the SWFW semaphore is in a valid state */ 6982 + if (hw->mac.ops.init_swfw_sync) 6983 + hw->mac.ops.init_swfw_sync(hw); 6984 + 6985 + if (hw->mac.type == ixgbe_mac_e610) 6986 + mutex_init(&hw->aci.lock); 6987 + 6981 6988 #ifdef IXGBE_FCOE 6982 6989 /* FCoE support exists, always init the FCoE lock */ 6983 6990 spin_lock_init(&adapter->fcoe.lock); ··· 11655 11648 if (err) 11656 11649 goto err_sw_init; 11657 11650 11658 - /* Make sure the SWFW semaphore is in a valid state */ 11659 - if (hw->mac.ops.init_swfw_sync) 11660 - hw->mac.ops.init_swfw_sync(hw); 11661 - 11662 11651 if (ixgbe_check_fw_error(adapter)) 11663 11652 return ixgbe_recovery_probe(adapter); 11664 11653 ··· 11858 11855 ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); 11859 11856 ixgbe_mac_set_default_filter(adapter); 11860 11857 11861 - if (hw->mac.type == ixgbe_mac_e610) 11862 - mutex_init(&hw->aci.lock); 11863 11858 timer_setup(&adapter->service_timer, ixgbe_service_timer, 0); 11864 11859 11865 11860 if (ixgbe_removed(hw->hw_addr)) { ··· 12017 12016 devl_unlock(adapter->devlink); 12018 12017 ixgbe_release_hw_control(adapter); 12019 12018 ixgbe_clear_interrupt_scheme(adapter); 12019 + err_sw_init: 12020 12020 if (hw->mac.type == ixgbe_mac_e610) 12021 12021 mutex_destroy(&adapter->hw.aci.lock); 12022 - err_sw_init: 12023 12022 ixgbe_disable_sriov(adapter); 12024 12023 adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; 12025 12024 iounmap(adapter->io_addr); ··· 12071 12070 set_bit(__IXGBE_REMOVING, &adapter->state); 12072 12071 cancel_work_sync(&adapter->service_task); 12073 12072 12074 - if (adapter->hw.mac.type == ixgbe_mac_e610) { 12073 + if (adapter->hw.mac.type == ixgbe_mac_e610) 12075 12074 ixgbe_disable_link_status_events(adapter); 12076 - mutex_destroy(&adapter->hw.aci.lock); 12077 - } 12078 12075 12079 12076 if (adapter->mii_bus) 12080 12077 mdiobus_unregister(adapter->mii_bus); ··· 12131 12132 bitmap_free(adapter->af_xdp_zc_qps); 12132 12133 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); 12133 12134 free_netdev(netdev); 12135 + 12136 + if (adapter->hw.mac.type == ixgbe_mac_e610) 12137 + mutex_destroy(&adapter->hw.aci.lock); 12134 12138 12135 12139 if (disable_dev) 12136 12140 pci_disable_device(pdev);
+16
drivers/net/ethernet/marvell/octeon_ep/octep_main.c
··· 1124 1124 return err; 1125 1125 } 1126 1126 1127 + static bool octep_is_vf_valid(struct octep_device *oct, int vf) 1128 + { 1129 + if (vf >= CFG_GET_ACTIVE_VFS(oct->conf)) { 1130 + netdev_err(oct->netdev, "Invalid VF ID %d\n", vf); 1131 + return false; 1132 + } 1133 + 1134 + return true; 1135 + } 1136 + 1127 1137 static int octep_get_vf_config(struct net_device *dev, int vf, 1128 1138 struct ifla_vf_info *ivi) 1129 1139 { 1130 1140 struct octep_device *oct = netdev_priv(dev); 1141 + 1142 + if (!octep_is_vf_valid(oct, vf)) 1143 + return -EINVAL; 1131 1144 1132 1145 ivi->vf = vf; 1133 1146 ether_addr_copy(ivi->mac, oct->vf_info[vf].mac_addr); ··· 1155 1142 { 1156 1143 struct octep_device *oct = netdev_priv(dev); 1157 1144 int err; 1145 + 1146 + if (!octep_is_vf_valid(oct, vf)) 1147 + return -EINVAL; 1158 1148 1159 1149 if (!is_valid_ether_addr(mac)) { 1160 1150 dev_err(&oct->pdev->dev, "Invalid MAC Address %pM\n", mac);
+3
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c
··· 196 196 vf_id); 197 197 return; 198 198 } 199 + ether_addr_copy(oct->vf_info[vf_id].mac_addr, rsp->s_set_mac.mac_addr); 199 200 rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK; 200 201 } 201 202 ··· 206 205 { 207 206 int err; 208 207 208 + /* Reset VF-specific information maintained by the PF */ 209 + memset(&oct->vf_info[vf_id], 0, sizeof(struct octep_pfvf_info)); 209 210 err = octep_ctrl_net_dev_remove(oct, vf_id); 210 211 if (err) { 211 212 rsp->s.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
+1 -1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c
··· 491 491 if (!ptp) 492 492 return; 493 493 494 - cancel_delayed_work(&pfvf->ptp->synctstamp_work); 494 + cancel_delayed_work_sync(&pfvf->ptp->synctstamp_work); 495 495 496 496 ptp_clock_unregister(ptp->ptp_clock); 497 497 kfree(ptp);
+1
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
··· 92 92 MLX5E_ACCEL_FS_ESP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1, 93 93 MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL, 94 94 MLX5E_ACCEL_FS_POL_FT_LEVEL, 95 + MLX5E_ACCEL_FS_POL_MISS_FT_LEVEL, 95 96 MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL, 96 97 #endif 97 98 };
+1
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
··· 185 185 u32 family; 186 186 int prio; 187 187 int pol_level; 188 + int pol_miss_level; 188 189 int sa_level; 189 190 int status_level; 190 191 enum mlx5_flow_namespace_type chains_ns;
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
··· 747 747 attr->family = family; 748 748 attr->prio = MLX5E_NIC_PRIO; 749 749 attr->pol_level = MLX5E_ACCEL_FS_POL_FT_LEVEL; 750 + attr->pol_miss_level = MLX5E_ACCEL_FS_POL_MISS_FT_LEVEL; 750 751 attr->sa_level = MLX5E_ACCEL_FS_ESP_FT_LEVEL; 751 752 attr->status_level = MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL; 752 753 attr->chains_ns = MLX5_FLOW_NAMESPACE_KERNEL; ··· 834 833 835 834 ft_attr.max_fte = 1; 836 835 ft_attr.autogroup.max_num_groups = 1; 837 - ft_attr.level = attr->pol_level; 836 + ft_attr.level = attr->pol_miss_level; 838 837 ft_attr.prio = attr->prio; 839 838 840 839 ft = mlx5_create_auto_grouped_flow_table(attr->ns, &ft_attr);
-2
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 140 140 if (up) { 141 141 netdev_info(priv->netdev, "Link up\n"); 142 142 netif_carrier_on(priv->netdev); 143 - mlx5e_port_manual_buffer_config(priv, 0, priv->netdev->mtu, 144 - NULL, NULL, NULL); 145 143 } else { 146 144 netdev_info(priv->netdev, "Link down\n"); 147 145 netif_carrier_off(priv->netdev);
+22 -5
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 1506 1506 static int 1507 1507 mlx5e_vport_uplink_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) 1508 1508 { 1509 - struct mlx5e_priv *priv = netdev_priv(mlx5_uplink_netdev_get(dev)); 1510 1509 struct mlx5e_rep_priv *rpriv = mlx5e_rep_to_rep_priv(rep); 1510 + struct net_device *netdev; 1511 + struct mlx5e_priv *priv; 1512 + int err; 1511 1513 1514 + netdev = mlx5_uplink_netdev_get(dev); 1515 + if (!netdev) 1516 + return 0; 1517 + 1518 + priv = netdev_priv(netdev); 1512 1519 rpriv->netdev = priv->netdev; 1513 - return mlx5e_netdev_change_profile(priv, &mlx5e_uplink_rep_profile, 1514 - rpriv); 1520 + err = mlx5e_netdev_change_profile(priv, &mlx5e_uplink_rep_profile, 1521 + rpriv); 1522 + mlx5_uplink_netdev_put(dev, netdev); 1523 + return err; 1515 1524 } 1516 1525 1517 1526 static void ··· 1647 1638 { 1648 1639 struct mlx5e_rep_priv *rpriv = mlx5e_rep_to_rep_priv(rep); 1649 1640 struct net_device *netdev = rpriv->netdev; 1650 - struct mlx5e_priv *priv = netdev_priv(netdev); 1651 - void *ppriv = priv->ppriv; 1641 + struct mlx5e_priv *priv; 1642 + void *ppriv; 1643 + 1644 + if (!netdev) { 1645 + ppriv = rpriv; 1646 + goto free_ppriv; 1647 + } 1648 + 1649 + priv = netdev_priv(netdev); 1650 + ppriv = priv->ppriv; 1652 1651 1653 1652 if (rep->vport == MLX5_VPORT_UPLINK) { 1654 1653 mlx5e_vport_uplink_rep_unload(rpriv);
+1
drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
··· 1515 1515 speed = lksettings.base.speed; 1516 1516 1517 1517 out: 1518 + mlx5_uplink_netdev_put(mdev, slave); 1518 1519 return speed; 1519 1520 } 1520 1521
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 114 114 #define ETHTOOL_NUM_PRIOS 11 115 115 #define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) 116 116 /* Vlan, mac, ttc, inner ttc, {UDP/ANY/aRFS/accel/{esp, esp_err}}, IPsec policy, 117 - * {IPsec RoCE MPV,Alias table},IPsec RoCE policy 117 + * IPsec policy miss, {IPsec RoCE MPV,Alias table},IPsec RoCE policy 118 118 */ 119 - #define KERNEL_NIC_PRIO_NUM_LEVELS 10 119 + #define KERNEL_NIC_PRIO_NUM_LEVELS 11 120 120 #define KERNEL_NIC_NUM_PRIOS 1 121 121 /* One more level for tc, and one more for promisc */ 122 122 #define KERNEL_MIN_LEVEL (KERNEL_NIC_PRIO_NUM_LEVELS + 2)
+14 -1
drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h
··· 47 47 48 48 static inline struct net_device *mlx5_uplink_netdev_get(struct mlx5_core_dev *mdev) 49 49 { 50 - return mdev->mlx5e_res.uplink_netdev; 50 + struct mlx5e_resources *mlx5e_res = &mdev->mlx5e_res; 51 + struct net_device *netdev; 52 + 53 + mutex_lock(&mlx5e_res->uplink_netdev_lock); 54 + netdev = mlx5e_res->uplink_netdev; 55 + netdev_hold(netdev, &mlx5e_res->tracker, GFP_KERNEL); 56 + mutex_unlock(&mlx5e_res->uplink_netdev_lock); 57 + return netdev; 58 + } 59 + 60 + static inline void mlx5_uplink_netdev_put(struct mlx5_core_dev *mdev, 61 + struct net_device *netdev) 62 + { 63 + netdev_put(netdev, &mdev->mlx5e_res.tracker); 51 64 } 52 65 53 66 struct mlx5_sd;
+5 -1
drivers/net/ethernet/mellanox/mlx5/core/port.c
··· 1170 1170 mlx5e_port_get_link_mode_info_arr(mdev, &table, &max_size, 1171 1171 force_legacy); 1172 1172 i = find_first_bit(&temp, max_size); 1173 - if (i < max_size) 1173 + 1174 + /* mlx5e_link_info has holes. Check speed 1175 + * is not zero as indication of one. 1176 + */ 1177 + if (i < max_size && table[i].speed) 1174 1178 return &table[i]; 1175 1179 1176 1180 return NULL;
+6 -7
drivers/net/ethernet/natsemi/ns83820.c
··· 820 820 struct ns83820 *dev = PRIV(ndev); 821 821 struct rx_info *info = &dev->rx_info; 822 822 unsigned next_rx; 823 - int rx_rc, len; 823 + int len; 824 824 u32 cmdsts; 825 825 __le32 *desc; 826 826 unsigned long flags; ··· 881 881 if (likely(CMDSTS_OK & cmdsts)) { 882 882 #endif 883 883 skb_put(skb, len); 884 - if (unlikely(!skb)) 884 + if (unlikely(!skb)) { 885 + ndev->stats.rx_dropped++; 885 886 goto netdev_mangle_me_harder_failed; 887 + } 886 888 if (cmdsts & CMDSTS_DEST_MULTI) 887 889 ndev->stats.multicast++; 888 890 ndev->stats.rx_packets++; ··· 903 901 __vlan_hwaccel_put_tag(skb, htons(ETH_P_IPV6), tag); 904 902 } 905 903 #endif 906 - rx_rc = netif_rx(skb); 907 - if (NET_RX_DROP == rx_rc) { 908 - netdev_mangle_me_harder_failed: 909 - ndev->stats.rx_dropped++; 910 - } 904 + netif_rx(skb); 911 905 } else { 912 906 dev_kfree_skb_irq(skb); 913 907 } 914 908 909 + netdev_mangle_me_harder_failed: 915 910 nr++; 916 911 next_rx = info->next_rx; 917 912 desc = info->descs + (DESC_SIZE * next_rx);
+4 -3
drivers/net/ethernet/qlogic/qed/qed_debug.c
··· 4462 4462 goto out; 4463 4463 } 4464 4464 4465 - /* Add override window info to buffer */ 4465 + /* Add override window info to buffer, preventing buffer overflow */ 4466 4466 override_window_dwords = 4467 - qed_rd(p_hwfn, p_ptt, GRC_REG_NUMBER_VALID_OVERRIDE_WINDOW) * 4468 - PROTECTION_OVERRIDE_ELEMENT_DWORDS; 4467 + min(qed_rd(p_hwfn, p_ptt, GRC_REG_NUMBER_VALID_OVERRIDE_WINDOW) * 4468 + PROTECTION_OVERRIDE_ELEMENT_DWORDS, 4469 + PROTECTION_OVERRIDE_DEPTH_DWORDS); 4469 4470 if (override_window_dwords) { 4470 4471 addr = BYTES_TO_DWORDS(GRC_REG_PROTECTION_OVERRIDE_WINDOW); 4471 4472 offset += qed_grc_dump_addr_range(p_hwfn,
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/tx.c
··· 2092 2092 break; 2093 2093 } 2094 2094 2095 - if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_9000 && 2095 + if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_7000 && 2096 2096 trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) 2097 2097 len = DIV_ROUND_UP(len, 4); 2098 2098
+4 -17
drivers/pci/controller/pci-mvebu.c
··· 1168 1168 return devm_ioremap_resource(&pdev->dev, &port->regs); 1169 1169 } 1170 1170 1171 - #define DT_FLAGS_TO_TYPE(flags) (((flags) >> 24) & 0x03) 1172 - #define DT_TYPE_IO 0x1 1173 - #define DT_TYPE_MEM32 0x2 1174 - #define DT_CPUADDR_TO_TARGET(cpuaddr) (((cpuaddr) >> 56) & 0xFF) 1175 - #define DT_CPUADDR_TO_ATTR(cpuaddr) (((cpuaddr) >> 48) & 0xFF) 1176 - 1177 1171 static int mvebu_get_tgt_attr(struct device_node *np, int devfn, 1178 1172 unsigned long type, 1179 1173 unsigned int *tgt, ··· 1183 1189 return -EINVAL; 1184 1190 1185 1191 for_each_of_range(&parser, &range) { 1186 - unsigned long rtype; 1187 1192 u32 slot = upper_32_bits(range.bus_addr); 1188 1193 1189 - if (DT_FLAGS_TO_TYPE(range.flags) == DT_TYPE_IO) 1190 - rtype = IORESOURCE_IO; 1191 - else if (DT_FLAGS_TO_TYPE(range.flags) == DT_TYPE_MEM32) 1192 - rtype = IORESOURCE_MEM; 1193 - else 1194 - continue; 1195 - 1196 - if (slot == PCI_SLOT(devfn) && type == rtype) { 1197 - *tgt = DT_CPUADDR_TO_TARGET(range.cpu_addr); 1198 - *attr = DT_CPUADDR_TO_ATTR(range.cpu_addr); 1194 + if (slot == PCI_SLOT(devfn) && 1195 + type == (range.flags & IORESOURCE_TYPE_BITS)) { 1196 + *tgt = (range.parent_bus_addr >> 56) & 0xFF; 1197 + *attr = (range.parent_bus_addr >> 48) & 0xFF; 1199 1198 return 0; 1200 1199 } 1201 1200 }
+2 -2
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
··· 127 127 rptr->cfg->init_tbl[i].value); 128 128 129 129 /* Override registers from devicetree values */ 130 - if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &val)) 130 + if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &val)) 131 131 regmap_write(regmap, base + EUSB2_TUNE_USB2_PREEM, val); 132 132 133 133 if (!of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &val)) 134 134 regmap_write(regmap, base + EUSB2_TUNE_HSDISC, val); 135 135 136 - if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &val)) 136 + if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &val)) 137 137 regmap_write(regmap, base + EUSB2_TUNE_IUSB2, val); 138 138 139 139 /* Wait for status OK */
+19 -6
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
··· 3067 3067 struct clk_fixed_rate aux_clk_fixed; 3068 3068 }; 3069 3069 3070 + static bool qphy_checkbits(const void __iomem *base, u32 offset, u32 val) 3071 + { 3072 + u32 reg; 3073 + 3074 + reg = readl(base + offset); 3075 + return (reg & val) == val; 3076 + } 3077 + 3070 3078 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) 3071 3079 { 3072 3080 u32 reg; ··· 4347 4339 struct qmp_pcie *qmp = phy_get_drvdata(phy); 4348 4340 const struct qmp_phy_cfg *cfg = qmp->cfg; 4349 4341 void __iomem *pcs = qmp->pcs; 4350 - bool phy_initialized = !!(readl(pcs + cfg->regs[QPHY_START_CTRL])); 4351 4342 int ret; 4352 4343 4353 - qmp->skip_init = qmp->nocsr_reset && phy_initialized; 4354 4344 /* 4355 - * We need to check the existence of init sequences in two cases: 4356 - * 1. The PHY doesn't support no_csr reset. 4357 - * 2. The PHY supports no_csr reset but isn't initialized by bootloader. 4358 - * As we can't skip init in these two cases. 4345 + * We can skip PHY initialization if all of the following conditions 4346 + * are met: 4347 + * 1. The PHY supports the nocsr_reset that preserves the PHY config. 4348 + * 2. The PHY was started (and not powered down again) by the 4349 + * bootloader, with all of the expected bits set correctly. 4350 + * In this case, we can continue without having the init sequence 4351 + * defined in the driver. 4359 4352 */ 4353 + qmp->skip_init = qmp->nocsr_reset && 4354 + qphy_checkbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START) && 4355 + qphy_checkbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], cfg->pwrdn_ctrl); 4356 + 4360 4357 if (!qmp->skip_init && !cfg->tbls.serdes_num) { 4361 4358 dev_err(qmp->dev, "Init sequence not available\n"); 4362 4359 return -ENODATA;
+5 -1
drivers/phy/tegra/xusb-tegra210.c
··· 3164 3164 } 3165 3165 3166 3166 pdev = of_find_device_by_node(np); 3167 + of_node_put(np); 3167 3168 if (!pdev) { 3168 3169 dev_warn(dev, "PMC device is not available\n"); 3169 3170 goto out; 3170 3171 } 3171 3172 3172 - if (!platform_get_drvdata(pdev)) 3173 + if (!platform_get_drvdata(pdev)) { 3174 + put_device(&pdev->dev); 3173 3175 return ERR_PTR(-EPROBE_DEFER); 3176 + } 3174 3177 3175 3178 padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk"); 3176 3179 if (!padctl->regmap) 3177 3180 dev_info(dev, "failed to find PMC regmap\n"); 3178 3181 3182 + put_device(&pdev->dev); 3179 3183 out: 3180 3184 return &padctl->base; 3181 3185 }
+39 -8
drivers/phy/ti/phy-gmii-sel.c
··· 34 34 PHY_GMII_SEL_PORT_MODE = 0, 35 35 PHY_GMII_SEL_RGMII_ID_MODE, 36 36 PHY_GMII_SEL_RMII_IO_CLK_EN, 37 + PHY_GMII_SEL_FIXED_TX_DELAY, 37 38 PHY_GMII_SEL_LAST, 38 39 }; 39 40 ··· 128 127 goto unsupported; 129 128 } 130 129 130 + /* With a fixed delay, some modes are not supported at all. */ 131 + if (soc_data->features & BIT(PHY_GMII_SEL_FIXED_TX_DELAY) && 132 + rgmii_id != 0) 133 + return -EINVAL; 134 + 131 135 if_phy->phy_if_mode = submode; 132 136 133 137 dev_dbg(dev, "%s id:%u mode:%u rgmii_id:%d rmii_clk_ext:%d\n", ··· 216 210 217 211 static const 218 212 struct reg_field phy_gmii_sel_fields_am654[][PHY_GMII_SEL_LAST] = { 219 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x0, 0, 2), }, 220 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x4, 0, 2), }, 221 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x8, 0, 2), }, 222 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0xC, 0, 2), }, 223 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x10, 0, 2), }, 224 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x14, 0, 2), }, 225 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x18, 0, 2), }, 226 - { [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x1C, 0, 2), }, 213 + { 214 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x0, 0, 2), 215 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x0, 4, 4), 216 + }, { 217 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x4, 0, 2), 218 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x4, 4, 4), 219 + }, { 220 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x8, 0, 2), 221 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x8, 4, 4), 222 + }, { 223 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0xC, 0, 2), 224 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0xC, 4, 4), 225 + }, { 226 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x10, 0, 2), 227 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x10, 4, 4), 228 + }, { 229 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x14, 0, 2), 230 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x14, 4, 4), 231 + }, { 232 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x18, 0, 2), 233 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x18, 4, 4), 234 + }, { 235 + [PHY_GMII_SEL_PORT_MODE] = REG_FIELD(0x1C, 0, 2), 236 + [PHY_GMII_SEL_RGMII_ID_MODE] = REG_FIELD(0x1C, 4, 4), 237 + }, 227 238 }; 228 239 229 240 static const 230 241 struct phy_gmii_sel_soc_data phy_gmii_sel_soc_am654 = { 231 242 .use_of_data = true, 243 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE) | 244 + BIT(PHY_GMII_SEL_FIXED_TX_DELAY), 232 245 .regfields = phy_gmii_sel_fields_am654, 233 246 }; 234 247 235 248 static const 236 249 struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw5g_soc_j7200 = { 237 250 .use_of_data = true, 251 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE) | 252 + BIT(PHY_GMII_SEL_FIXED_TX_DELAY), 238 253 .regfields = phy_gmii_sel_fields_am654, 239 254 .extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII) | 240 255 BIT(PHY_INTERFACE_MODE_USXGMII), ··· 266 239 static const 267 240 struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw9g_soc_j721e = { 268 241 .use_of_data = true, 242 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE) | 243 + BIT(PHY_GMII_SEL_FIXED_TX_DELAY), 269 244 .regfields = phy_gmii_sel_fields_am654, 270 245 .extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII), 271 246 .num_ports = 8, ··· 277 248 static const 278 249 struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw9g_soc_j784s4 = { 279 250 .use_of_data = true, 251 + .features = BIT(PHY_GMII_SEL_RGMII_ID_MODE) | 252 + BIT(PHY_GMII_SEL_FIXED_TX_DELAY), 280 253 .regfields = phy_gmii_sel_fields_am654, 281 254 .extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII) | BIT(PHY_INTERFACE_MODE_SGMII) | 282 255 BIT(PHY_INTERFACE_MODE_USXGMII),
+13
drivers/phy/ti/phy-omap-usb2.c
··· 363 363 phy->flags |= OMAP_USB2_DISABLE_CHRG_DET; 364 364 } 365 365 366 + static void omap_usb2_put_device(void *_dev) 367 + { 368 + struct device *dev = _dev; 369 + 370 + put_device(dev); 371 + } 372 + 366 373 static int omap_usb2_probe(struct platform_device *pdev) 367 374 { 368 375 struct omap_usb *phy; ··· 380 373 struct device_node *control_node; 381 374 struct platform_device *control_pdev; 382 375 const struct usb_phy_data *phy_data; 376 + int ret; 383 377 384 378 phy_data = device_get_match_data(&pdev->dev); 385 379 if (!phy_data) ··· 431 423 return -EINVAL; 432 424 } 433 425 phy->control_dev = &control_pdev->dev; 426 + 427 + ret = devm_add_action_or_reset(&pdev->dev, omap_usb2_put_device, 428 + phy->control_dev); 429 + if (ret) 430 + return ret; 434 431 } else { 435 432 if (of_property_read_u32_index(node, 436 433 "syscon-phy-power", 1,
+13
drivers/phy/ti/phy-ti-pipe3.c
··· 667 667 return 0; 668 668 } 669 669 670 + static void ti_pipe3_put_device(void *_dev) 671 + { 672 + struct device *dev = _dev; 673 + 674 + put_device(dev); 675 + } 676 + 670 677 static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy) 671 678 { 672 679 struct device *dev = phy->dev; 673 680 struct device_node *node = dev->of_node; 674 681 struct device_node *control_node; 675 682 struct platform_device *control_pdev; 683 + int ret; 676 684 677 685 phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node, 678 686 "syscon-phy-power"); ··· 712 704 } 713 705 714 706 phy->control_dev = &control_pdev->dev; 707 + 708 + ret = devm_add_action_or_reset(dev, ti_pipe3_put_device, 709 + phy->control_dev); 710 + if (ret) 711 + return ret; 715 712 } 716 713 717 714 if (phy->mode == PIPE3_MODE_PCIE) {
+8
drivers/platform/x86/amd/pmc/pmc-quirks.c
··· 239 239 DMI_MATCH(DMI_BOARD_NAME, "WUJIE14-GX4HRXL"), 240 240 } 241 241 }, 242 + { 243 + .ident = "MECHREVO Yilong15Pro Series GM5HG7A", 244 + .driver_data = &quirk_spurious_8042, 245 + .matches = { 246 + DMI_MATCH(DMI_SYS_VENDOR, "MECHREVO"), 247 + DMI_MATCH(DMI_PRODUCT_NAME, "Yilong15Pro Series GM5HG7A"), 248 + } 249 + }, 242 250 /* https://bugzilla.kernel.org/show_bug.cgi?id=220116 */ 243 251 { 244 252 .ident = "PCSpecialist Lafite Pro V 14M",
+1
drivers/platform/x86/amd/pmf/core.c
··· 403 403 {"AMDI0103", 0}, 404 404 {"AMDI0105", 0}, 405 405 {"AMDI0107", 0}, 406 + {"AMDI0108", 0}, 406 407 { } 407 408 }; 408 409 MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids);
+2
drivers/platform/x86/asus-nb-wmi.c
··· 673 673 if (atkbd_reports_vol_keys) 674 674 *code = ASUS_WMI_KEY_IGNORE; 675 675 break; 676 + case 0x5D: /* Wireless console Toggle */ 677 + case 0x5E: /* Wireless console Enable / Keyboard Attach, Detach */ 676 678 case 0x5F: /* Wireless console Disable / Special Key */ 677 679 if (quirks->key_wlan_event) 678 680 *code = quirks->key_wlan_event;
+14
drivers/platform/x86/oxpec.c
··· 126 126 }, 127 127 { 128 128 .matches = { 129 + DMI_MATCH(DMI_BOARD_VENDOR, "AOKZOE"), 130 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "AOKZOE A1X"), 131 + }, 132 + .driver_data = (void *)oxp_fly, 133 + }, 134 + { 135 + .matches = { 129 136 DMI_MATCH(DMI_BOARD_VENDOR, "AYANEO"), 130 137 DMI_MATCH(DMI_BOARD_NAME, "AYANEO 2"), 131 138 }, ··· 310 303 .matches = { 311 304 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), 312 305 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro"), 306 + }, 307 + .driver_data = (void *)oxp_x1, 308 + }, 309 + { 310 + .matches = { 311 + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), 312 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro EVA-02"), 313 313 }, 314 314 .driver_data = (void *)oxp_x1, 315 315 },
+2 -2
drivers/power/supply/bq27xxx_battery.c
··· 1919 1919 bool has_singe_flag = di->opts & BQ27XXX_O_ZERO; 1920 1920 1921 1921 cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag); 1922 - if ((cache.flags & 0xff) == 0xff) 1923 - cache.flags = -1; /* read error */ 1922 + if (di->chip == BQ27000 && (cache.flags & 0xff) == 0xff) 1923 + cache.flags = -ENODEV; /* bq27000 hdq read error */ 1924 1924 if (cache.flags >= 0) { 1925 1925 cache.capacity = bq27xxx_battery_read_soc(di); 1926 1926
+4 -3
drivers/regulator/sy7636a-regulator.c
··· 83 83 if (!regmap) 84 84 return -EPROBE_DEFER; 85 85 86 - gdp = devm_gpiod_get(pdev->dev.parent, "epd-pwr-good", GPIOD_IN); 86 + device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent); 87 + 88 + gdp = devm_gpiod_get(&pdev->dev, "epd-pwr-good", GPIOD_IN); 87 89 if (IS_ERR(gdp)) { 88 - dev_err(pdev->dev.parent, "Power good GPIO fault %ld\n", PTR_ERR(gdp)); 90 + dev_err(&pdev->dev, "Power good GPIO fault %ld\n", PTR_ERR(gdp)); 89 91 return PTR_ERR(gdp); 90 92 } 91 93 ··· 107 105 } 108 106 109 107 config.dev = &pdev->dev; 110 - config.dev->of_node = pdev->dev.parent->of_node; 111 108 config.regmap = regmap; 112 109 113 110 rdev = devm_regulator_register(&pdev->dev, &desc, &config);
+3 -3
drivers/tty/hvc/hvc_console.c
··· 543 543 } 544 544 545 545 /* 546 - * Racy, but harmless, kick thread if there is still pending data. 546 + * Kick thread to flush if there's still pending data 547 + * or to wakeup the write queue. 547 548 */ 548 - if (hp->n_outbuf) 549 - hvc_kick(); 549 + hvc_kick(); 550 550 551 551 return written; 552 552 }
+2 -12
drivers/tty/serial/sc16is7xx.c
··· 1177 1177 sc16is7xx_port_write(port, SC16IS7XX_FCR_REG, 1178 1178 SC16IS7XX_FCR_FIFO_BIT); 1179 1179 1180 - /* Enable EFR */ 1181 - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 1182 - SC16IS7XX_LCR_CONF_MODE_B); 1183 - 1184 - regcache_cache_bypass(one->regmap, true); 1185 - 1186 - /* Enable write access to enhanced features and internal clock div */ 1187 - sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, 1188 - SC16IS7XX_EFR_ENABLE_BIT, 1189 - SC16IS7XX_EFR_ENABLE_BIT); 1190 - 1191 1180 /* Enable TCR/TLR */ 1192 1181 sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, 1193 1182 SC16IS7XX_MCR_TCRTLR_BIT, ··· 1188 1199 SC16IS7XX_TCR_RX_RESUME(24) | 1189 1200 SC16IS7XX_TCR_RX_HALT(48)); 1190 1201 1191 - regcache_cache_bypass(one->regmap, false); 1202 + /* Disable TCR/TLR access */ 1203 + sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, SC16IS7XX_MCR_TCRTLR_BIT, 0); 1192 1204 1193 1205 /* Now, initialize the UART */ 1194 1206 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8);
+5 -5
drivers/tty/serial/xilinx_uartps.c
··· 33 33 #define CDNS_UART_MINOR 0 /* works best with devtmpfs */ 34 34 #define CDNS_UART_NR_PORTS 16 35 35 #define CDNS_UART_FIFO_SIZE 64 /* FIFO size */ 36 - #define CDNS_UART_REGISTER_SPACE 0x1000 37 36 #define TX_TIMEOUT 500000 38 37 39 38 /* Rx Trigger level */ ··· 1097 1098 */ 1098 1099 static int cdns_uart_request_port(struct uart_port *port) 1099 1100 { 1100 - if (!request_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE, 1101 + if (!request_mem_region(port->mapbase, port->mapsize, 1101 1102 CDNS_UART_NAME)) { 1102 1103 return -ENOMEM; 1103 1104 } 1104 1105 1105 - port->membase = ioremap(port->mapbase, CDNS_UART_REGISTER_SPACE); 1106 + port->membase = ioremap(port->mapbase, port->mapsize); 1106 1107 if (!port->membase) { 1107 1108 dev_err(port->dev, "Unable to map registers\n"); 1108 - release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE); 1109 + release_mem_region(port->mapbase, port->mapsize); 1109 1110 return -ENOMEM; 1110 1111 } 1111 1112 return 0; ··· 1120 1121 */ 1121 1122 static void cdns_uart_release_port(struct uart_port *port) 1122 1123 { 1123 - release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE); 1124 + release_mem_region(port->mapbase, port->mapsize); 1124 1125 iounmap(port->membase); 1125 1126 port->membase = NULL; 1126 1127 } ··· 1779 1780 * and triggers invocation of the config_port() entry point. 1780 1781 */ 1781 1782 port->mapbase = res->start; 1783 + port->mapsize = resource_size(res); 1782 1784 port->irq = irq; 1783 1785 port->dev = &pdev->dev; 1784 1786 port->uartclk = clk_get_rate(cdns_uart_data->uartclk);
+2 -2
drivers/usb/core/driver.c
··· 119 119 guard(mutex)(&usb_dynids_lock); 120 120 list_for_each_entry(dynid, &dynids->list, node) 121 121 if (dynid->id.bInterfaceClass != 0) 122 - count += sysfs_emit_at(&buf[count], count, "%04x %04x %02x\n", 122 + count += sysfs_emit_at(buf, count, "%04x %04x %02x\n", 123 123 dynid->id.idVendor, dynid->id.idProduct, 124 124 dynid->id.bInterfaceClass); 125 125 else 126 - count += sysfs_emit_at(&buf[count], count, "%04x %04x\n", 126 + count += sysfs_emit_at(buf, count, "%04x %04x\n", 127 127 dynid->id.idVendor, dynid->id.idProduct); 128 128 return count; 129 129 }
+9 -2
drivers/usb/gadget/function/f_midi2.c
··· 1599 1599 strscpy(fb->info.name, ump_fb_name(b), 1600 1600 sizeof(fb->info.name)); 1601 1601 } 1602 + snd_ump_update_group_attrs(ump); 1602 1603 } 1603 1604 1604 1605 for (i = 0; i < midi2->num_eps; i++) { ··· 1737 1736 case USB_SPEED_HIGH: 1738 1737 midi2_midi1_ep_out_desc.wMaxPacketSize = cpu_to_le16(512); 1739 1738 midi2_midi1_ep_in_desc.wMaxPacketSize = cpu_to_le16(512); 1740 - for (i = 0; i < midi2->num_eps; i++) 1739 + for (i = 0; i < midi2->num_eps; i++) { 1741 1740 midi2_midi2_ep_out_desc[i].wMaxPacketSize = 1742 1741 cpu_to_le16(512); 1742 + midi2_midi2_ep_in_desc[i].wMaxPacketSize = 1743 + cpu_to_le16(512); 1744 + } 1743 1745 fallthrough; 1744 1746 case USB_SPEED_FULL: 1745 1747 midi1_in_eps = midi2_midi1_ep_in_descs; ··· 1751 1747 case USB_SPEED_SUPER: 1752 1748 midi2_midi1_ep_out_desc.wMaxPacketSize = cpu_to_le16(1024); 1753 1749 midi2_midi1_ep_in_desc.wMaxPacketSize = cpu_to_le16(1024); 1754 - for (i = 0; i < midi2->num_eps; i++) 1750 + for (i = 0; i < midi2->num_eps; i++) { 1755 1751 midi2_midi2_ep_out_desc[i].wMaxPacketSize = 1756 1752 cpu_to_le16(1024); 1753 + midi2_midi2_ep_in_desc[i].wMaxPacketSize = 1754 + cpu_to_le16(1024); 1755 + } 1757 1756 midi1_in_eps = midi2_midi1_ep_in_ss_descs; 1758 1757 midi1_out_eps = midi2_midi1_ep_out_ss_descs; 1759 1758 break;
+4 -4
drivers/usb/gadget/udc/dummy_hcd.c
··· 765 765 if (!dum->driver) 766 766 return -ESHUTDOWN; 767 767 768 - local_irq_save(flags); 769 - spin_lock(&dum->lock); 768 + spin_lock_irqsave(&dum->lock, flags); 770 769 list_for_each_entry(iter, &ep->queue, queue) { 771 770 if (&iter->req != _req) 772 771 continue; ··· 775 776 retval = 0; 776 777 break; 777 778 } 778 - spin_unlock(&dum->lock); 779 779 780 780 if (retval == 0) { 781 781 dev_dbg(udc_dev(dum), 782 782 "dequeued req %p from %s, len %d buf %p\n", 783 783 req, _ep->name, _req->length, _req->buf); 784 + spin_unlock(&dum->lock); 784 785 usb_gadget_giveback_request(_ep, _req); 786 + spin_lock(&dum->lock); 785 787 } 786 - local_irq_restore(flags); 788 + spin_unlock_irqrestore(&dum->lock, flags); 787 789 return retval; 788 790 } 789 791
+67 -27
drivers/usb/host/xhci-dbgcap.c
··· 101 101 return string_length; 102 102 } 103 103 104 + static void xhci_dbc_init_ep_contexts(struct xhci_dbc *dbc) 105 + { 106 + struct xhci_ep_ctx *ep_ctx; 107 + unsigned int max_burst; 108 + dma_addr_t deq; 109 + 110 + max_burst = DBC_CTRL_MAXBURST(readl(&dbc->regs->control)); 111 + 112 + /* Populate bulk out endpoint context: */ 113 + ep_ctx = dbc_bulkout_ctx(dbc); 114 + deq = dbc_bulkout_enq(dbc); 115 + ep_ctx->ep_info = 0; 116 + ep_ctx->ep_info2 = dbc_epctx_info2(BULK_OUT_EP, 1024, max_burst); 117 + ep_ctx->deq = cpu_to_le64(deq | dbc->ring_out->cycle_state); 118 + 119 + /* Populate bulk in endpoint context: */ 120 + ep_ctx = dbc_bulkin_ctx(dbc); 121 + deq = dbc_bulkin_enq(dbc); 122 + ep_ctx->ep_info = 0; 123 + ep_ctx->ep_info2 = dbc_epctx_info2(BULK_IN_EP, 1024, max_burst); 124 + ep_ctx->deq = cpu_to_le64(deq | dbc->ring_in->cycle_state); 125 + } 126 + 104 127 static void xhci_dbc_init_contexts(struct xhci_dbc *dbc, u32 string_length) 105 128 { 106 129 struct dbc_info_context *info; 107 - struct xhci_ep_ctx *ep_ctx; 108 130 u32 dev_info; 109 - dma_addr_t deq, dma; 110 - unsigned int max_burst; 131 + dma_addr_t dma; 111 132 112 133 if (!dbc) 113 134 return; ··· 142 121 info->serial = cpu_to_le64(dma + DBC_MAX_STRING_LENGTH * 3); 143 122 info->length = cpu_to_le32(string_length); 144 123 145 - /* Populate bulk out endpoint context: */ 146 - ep_ctx = dbc_bulkout_ctx(dbc); 147 - max_burst = DBC_CTRL_MAXBURST(readl(&dbc->regs->control)); 148 - deq = dbc_bulkout_enq(dbc); 149 - ep_ctx->ep_info = 0; 150 - ep_ctx->ep_info2 = dbc_epctx_info2(BULK_OUT_EP, 1024, max_burst); 151 - ep_ctx->deq = cpu_to_le64(deq | dbc->ring_out->cycle_state); 152 - 153 - /* Populate bulk in endpoint context: */ 154 - ep_ctx = dbc_bulkin_ctx(dbc); 155 - deq = dbc_bulkin_enq(dbc); 156 - ep_ctx->ep_info = 0; 157 - ep_ctx->ep_info2 = dbc_epctx_info2(BULK_IN_EP, 1024, max_burst); 158 - ep_ctx->deq = cpu_to_le64(deq | dbc->ring_in->cycle_state); 124 + /* Populate bulk in and out endpoint contexts: */ 125 + xhci_dbc_init_ep_contexts(dbc); 159 126 160 127 /* Set DbC context and info registers: */ 161 128 lo_hi_writeq(dbc->ctx->dma, &dbc->regs->dccp); ··· 445 436 return ctx; 446 437 } 447 438 439 + static void xhci_dbc_ring_init(struct xhci_ring *ring) 440 + { 441 + struct xhci_segment *seg = ring->first_seg; 442 + 443 + /* clear all trbs on ring in case of old ring */ 444 + memset(seg->trbs, 0, TRB_SEGMENT_SIZE); 445 + 446 + /* Only event ring does not use link TRB */ 447 + if (ring->type != TYPE_EVENT) { 448 + union xhci_trb *trb = &seg->trbs[TRBS_PER_SEGMENT - 1]; 449 + 450 + trb->link.segment_ptr = cpu_to_le64(ring->first_seg->dma); 451 + trb->link.control = cpu_to_le32(LINK_TOGGLE | TRB_TYPE(TRB_LINK)); 452 + } 453 + xhci_initialize_ring_info(ring); 454 + } 455 + 456 + static int xhci_dbc_reinit_ep_rings(struct xhci_dbc *dbc) 457 + { 458 + struct xhci_ring *in_ring = dbc->eps[BULK_IN].ring; 459 + struct xhci_ring *out_ring = dbc->eps[BULK_OUT].ring; 460 + 461 + if (!in_ring || !out_ring || !dbc->ctx) { 462 + dev_warn(dbc->dev, "Can't re-init unallocated endpoints\n"); 463 + return -ENODEV; 464 + } 465 + 466 + xhci_dbc_ring_init(in_ring); 467 + xhci_dbc_ring_init(out_ring); 468 + 469 + /* set ep context enqueue, dequeue, and cycle to initial values */ 470 + xhci_dbc_init_ep_contexts(dbc); 471 + 472 + return 0; 473 + } 474 + 448 475 static struct xhci_ring * 449 476 xhci_dbc_ring_alloc(struct device *dev, enum xhci_ring_type type, gfp_t flags) 450 477 { ··· 509 464 510 465 seg->dma = dma; 511 466 512 - /* Only event ring does not use link TRB */ 513 - if (type != TYPE_EVENT) { 514 - union xhci_trb *trb = &seg->trbs[TRBS_PER_SEGMENT - 1]; 515 - 516 - trb->link.segment_ptr = cpu_to_le64(dma); 517 - trb->link.control = cpu_to_le32(LINK_TOGGLE | TRB_TYPE(TRB_LINK)); 518 - } 519 467 INIT_LIST_HEAD(&ring->td_list); 520 - xhci_initialize_ring_info(ring); 468 + 469 + xhci_dbc_ring_init(ring); 470 + 521 471 return ring; 522 472 dma_fail: 523 473 kfree(seg); ··· 904 864 dev_info(dbc->dev, "DbC cable unplugged\n"); 905 865 dbc->state = DS_ENABLED; 906 866 xhci_dbc_flush_requests(dbc); 907 - 867 + xhci_dbc_reinit_ep_rings(dbc); 908 868 return EVT_DISC; 909 869 } 910 870 ··· 914 874 writel(portsc, &dbc->regs->portsc); 915 875 dbc->state = DS_ENABLED; 916 876 xhci_dbc_flush_requests(dbc); 917 - 877 + xhci_dbc_reinit_ep_rings(dbc); 918 878 return EVT_DISC; 919 879 } 920 880
+1 -1
drivers/usb/host/xhci-mem.c
··· 962 962 out: 963 963 /* we are now at a leaf device */ 964 964 xhci_debugfs_remove_slot(xhci, slot_id); 965 - xhci_free_virt_device(xhci, vdev, slot_id); 965 + xhci_free_virt_device(xhci, xhci->devs[slot_id], slot_id); 966 966 } 967 967 968 968 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
+17
drivers/usb/serial/option.c
··· 1322 1322 .driver_info = NCTRL(0) | RSVD(3) }, 1323 1323 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1033, 0xff), /* Telit LE910C1-EUX (ECM) */ 1324 1324 .driver_info = NCTRL(0) }, 1325 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1034, 0xff), /* Telit LE910C4-WWX (rmnet) */ 1326 + .driver_info = RSVD(2) }, 1325 1327 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1035, 0xff) }, /* Telit LE910C4-WWX (ECM) */ 1328 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1036, 0xff) }, /* Telit LE910C4-WWX */ 1329 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1037, 0xff), /* Telit LE910C4-WWX (rmnet) */ 1330 + .driver_info = NCTRL(0) | NCTRL(1) | RSVD(4) }, 1331 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1038, 0xff), /* Telit LE910C4-WWX (rmnet) */ 1332 + .driver_info = NCTRL(0) | RSVD(3) }, 1333 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x103b, 0xff), /* Telit LE910C4-WWX */ 1334 + .driver_info = NCTRL(0) | NCTRL(1) }, 1335 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x103c, 0xff), /* Telit LE910C4-WWX */ 1336 + .driver_info = NCTRL(0) }, 1326 1337 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), 1327 1338 .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) }, 1328 1339 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG1), ··· 1380 1369 .driver_info = NCTRL(0) | RSVD(1) }, 1381 1370 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1075, 0xff), /* Telit FN990A (PCIe) */ 1382 1371 .driver_info = RSVD(0) }, 1372 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1077, 0xff), /* Telit FN990A (rmnet + audio) */ 1373 + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, 1374 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1078, 0xff), /* Telit FN990A (MBIM + audio) */ 1375 + .driver_info = NCTRL(0) | RSVD(1) }, 1376 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1079, 0xff), /* Telit FN990A (RNDIS + audio) */ 1377 + .driver_info = NCTRL(2) | RSVD(3) }, 1383 1378 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1080, 0xff), /* Telit FE990A (rmnet) */ 1384 1379 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, 1385 1380 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1081, 0xff), /* Telit FE990A (MBIM) */
+8 -4
drivers/usb/typec/tcpm/tcpm.c
··· 2426 2426 case ADEV_NONE: 2427 2427 break; 2428 2428 case ADEV_NOTIFY_USB_AND_QUEUE_VDM: 2429 - WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL)); 2430 - typec_altmode_vdm(adev, p[0], &p[1], cnt); 2429 + if (rx_sop_type == TCPC_TX_SOP_PRIME) { 2430 + typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt); 2431 + } else { 2432 + WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL)); 2433 + typec_altmode_vdm(adev, p[0], &p[1], cnt); 2434 + } 2431 2435 break; 2432 2436 case ADEV_QUEUE_VDM: 2433 - if (response_tx_sop_type == TCPC_TX_SOP_PRIME) 2437 + if (rx_sop_type == TCPC_TX_SOP_PRIME) 2434 2438 typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt); 2435 2439 else 2436 2440 typec_altmode_vdm(adev, p[0], &p[1], cnt); 2437 2441 break; 2438 2442 case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL: 2439 - if (response_tx_sop_type == TCPC_TX_SOP_PRIME) { 2443 + if (rx_sop_type == TCPC_TX_SOP_PRIME) { 2440 2444 if (typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, 2441 2445 p[0], &p[1], cnt)) { 2442 2446 int svdm_version = typec_get_cable_svdm_version(
+8 -1
fs/btrfs/block-group.c
··· 1795 1795 bg1 = list_entry(a, struct btrfs_block_group, bg_list); 1796 1796 bg2 = list_entry(b, struct btrfs_block_group, bg_list); 1797 1797 1798 - return bg1->used > bg2->used; 1798 + /* 1799 + * Some other task may be updating the ->used field concurrently, but it 1800 + * is not serious if we get a stale value or load/store tearing issues, 1801 + * as sorting the list of block groups to reclaim is not critical and an 1802 + * occasional imperfect order is ok. So silence KCSAN and avoid the 1803 + * overhead of locking or any other synchronization. 1804 + */ 1805 + return data_race(bg1->used > bg2->used); 1799 1806 } 1800 1807 1801 1808 static inline bool btrfs_should_reclaim(const struct btrfs_fs_info *fs_info)
-3
fs/btrfs/delayed-inode.c
··· 1843 1843 1844 1844 int btrfs_fill_inode(struct btrfs_inode *inode, u32 *rdev) 1845 1845 { 1846 - struct btrfs_fs_info *fs_info = inode->root->fs_info; 1847 1846 struct btrfs_delayed_node *delayed_node; 1848 1847 struct btrfs_inode_item *inode_item; 1849 1848 struct inode *vfs_inode = &inode->vfs_inode; ··· 1863 1864 i_uid_write(vfs_inode, btrfs_stack_inode_uid(inode_item)); 1864 1865 i_gid_write(vfs_inode, btrfs_stack_inode_gid(inode_item)); 1865 1866 btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item)); 1866 - btrfs_inode_set_file_extent_range(inode, 0, 1867 - round_up(i_size_read(vfs_inode), fs_info->sectorsize)); 1868 1867 vfs_inode->i_mode = btrfs_stack_inode_mode(inode_item); 1869 1868 set_nlink(vfs_inode, btrfs_stack_inode_nlink(inode_item)); 1870 1869 inode_set_bytes(vfs_inode, btrfs_stack_inode_nbytes(inode_item));
+5 -6
fs/btrfs/inode.c
··· 3885 3885 bool filled = false; 3886 3886 int first_xattr_slot; 3887 3887 3888 - ret = btrfs_init_file_extent_tree(inode); 3889 - if (ret) 3890 - goto out; 3891 - 3892 3888 ret = btrfs_fill_inode(inode, &rdev); 3893 3889 if (!ret) 3894 3890 filled = true; ··· 3916 3920 i_uid_write(vfs_inode, btrfs_inode_uid(leaf, inode_item)); 3917 3921 i_gid_write(vfs_inode, btrfs_inode_gid(leaf, inode_item)); 3918 3922 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item)); 3919 - btrfs_inode_set_file_extent_range(inode, 0, 3920 - round_up(i_size_read(vfs_inode), fs_info->sectorsize)); 3921 3923 3922 3924 inode_set_atime(vfs_inode, btrfs_timespec_sec(leaf, &inode_item->atime), 3923 3925 btrfs_timespec_nsec(leaf, &inode_item->atime)); ··· 3947 3953 btrfs_set_inode_mapping_order(inode); 3948 3954 3949 3955 cache_index: 3956 + ret = btrfs_init_file_extent_tree(inode); 3957 + if (ret) 3958 + goto out; 3959 + btrfs_inode_set_file_extent_range(inode, 0, 3960 + round_up(i_size_read(vfs_inode), fs_info->sectorsize)); 3950 3961 /* 3951 3962 * If we were modified in the current generation and evicted from memory 3952 3963 * and then re-read we need to do a full sync since we don't have any
+1 -1
fs/btrfs/tree-log.c
··· 1964 1964 1965 1965 search_key.objectid = log_key.objectid; 1966 1966 search_key.type = BTRFS_INODE_EXTREF_KEY; 1967 - search_key.offset = key->objectid; 1967 + search_key.offset = btrfs_extref_hash(key->objectid, name.name, name.len); 1968 1968 ret = backref_in_log(root->log_root, &search_key, key->objectid, &name); 1969 1969 if (ret < 0) { 1970 1970 goto out;
+1 -1
fs/btrfs/zoned.c
··· 2582 2582 spin_lock(&space_info->lock); 2583 2583 space_info->total_bytes -= bg->length; 2584 2584 space_info->disk_total -= bg->length * factor; 2585 + space_info->disk_total -= bg->zone_unusable; 2585 2586 /* There is no allocation ever happened. */ 2586 2587 ASSERT(bg->used == 0); 2587 - ASSERT(bg->zone_unusable == 0); 2588 2588 /* No super block in a block group on the zoned setup. */ 2589 2589 ASSERT(bg->bytes_super == 0); 2590 2590 spin_unlock(&space_info->lock);
+5 -4
fs/ceph/addr.c
··· 1264 1264 0, 1265 1265 gfp_flags); 1266 1266 if (IS_ERR(pages[index])) { 1267 - if (PTR_ERR(pages[index]) == -EINVAL) { 1267 + int err = PTR_ERR(pages[index]); 1268 + 1269 + if (err == -EINVAL) { 1268 1270 pr_err_client(cl, "inode->i_blkbits=%hhu\n", 1269 1271 inode->i_blkbits); 1270 1272 } ··· 1275 1273 BUG_ON(ceph_wbc->locked_pages == 0); 1276 1274 1277 1275 pages[index] = NULL; 1278 - return PTR_ERR(pages[index]); 1276 + return err; 1279 1277 } 1280 1278 } else { 1281 1279 pages[index] = &folio->page; ··· 1689 1687 1690 1688 process_folio_batch: 1691 1689 rc = ceph_process_folio_batch(mapping, wbc, &ceph_wbc); 1690 + ceph_shift_unused_folios_left(&ceph_wbc.fbatch); 1692 1691 if (rc) 1693 1692 goto release_folios; 1694 1693 ··· 1698 1695 goto release_folios; 1699 1696 1700 1697 if (ceph_wbc.processed_in_fbatch) { 1701 - ceph_shift_unused_folios_left(&ceph_wbc.fbatch); 1702 - 1703 1698 if (folio_batch_count(&ceph_wbc.fbatch) == 0 && 1704 1699 ceph_wbc.locked_pages < ceph_wbc.max_pages) { 1705 1700 doutc(cl, "reached end fbatch, trying for more\n");
+6 -8
fs/ceph/debugfs.c
··· 55 55 struct ceph_mds_client *mdsc = fsc->mdsc; 56 56 struct ceph_mds_request *req; 57 57 struct rb_node *rp; 58 - int pathlen = 0; 59 - u64 pathbase; 60 58 char *path; 61 59 62 60 mutex_lock(&mdsc->mutex); ··· 79 81 if (req->r_inode) { 80 82 seq_printf(s, " #%llx", ceph_ino(req->r_inode)); 81 83 } else if (req->r_dentry) { 82 - path = ceph_mdsc_build_path(mdsc, req->r_dentry, &pathlen, 83 - &pathbase, 0); 84 + struct ceph_path_info path_info; 85 + path = ceph_mdsc_build_path(mdsc, req->r_dentry, &path_info, 0); 84 86 if (IS_ERR(path)) 85 87 path = NULL; 86 88 spin_lock(&req->r_dentry->d_lock); ··· 89 91 req->r_dentry, 90 92 path ? path : ""); 91 93 spin_unlock(&req->r_dentry->d_lock); 92 - ceph_mdsc_free_path(path, pathlen); 94 + ceph_mdsc_free_path_info(&path_info); 93 95 } else if (req->r_path1) { 94 96 seq_printf(s, " #%llx/%s", req->r_ino1.ino, 95 97 req->r_path1); ··· 98 100 } 99 101 100 102 if (req->r_old_dentry) { 101 - path = ceph_mdsc_build_path(mdsc, req->r_old_dentry, &pathlen, 102 - &pathbase, 0); 103 + struct ceph_path_info path_info; 104 + path = ceph_mdsc_build_path(mdsc, req->r_old_dentry, &path_info, 0); 103 105 if (IS_ERR(path)) 104 106 path = NULL; 105 107 spin_lock(&req->r_old_dentry->d_lock); ··· 109 111 req->r_old_dentry, 110 112 path ? path : ""); 111 113 spin_unlock(&req->r_old_dentry->d_lock); 112 - ceph_mdsc_free_path(path, pathlen); 114 + ceph_mdsc_free_path_info(&path_info); 113 115 } else if (req->r_path2 && req->r_op != CEPH_MDS_OP_SYMLINK) { 114 116 if (req->r_ino2.ino) 115 117 seq_printf(s, " #%llx/%s", req->r_ino2.ino,
+7 -10
fs/ceph/dir.c
··· 1271 1271 1272 1272 /* If op failed, mark everyone involved for errors */ 1273 1273 if (result) { 1274 - int pathlen = 0; 1275 - u64 base = 0; 1276 - char *path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, 1277 - &base, 0); 1274 + struct ceph_path_info path_info = {0}; 1275 + char *path = ceph_mdsc_build_path(mdsc, dentry, &path_info, 0); 1278 1276 1279 1277 /* mark error on parent + clear complete */ 1280 1278 mapping_set_error(req->r_parent->i_mapping, result); ··· 1286 1288 mapping_set_error(req->r_old_inode->i_mapping, result); 1287 1289 1288 1290 pr_warn_client(cl, "failure path=(%llx)%s result=%d!\n", 1289 - base, IS_ERR(path) ? "<<bad>>" : path, result); 1290 - ceph_mdsc_free_path(path, pathlen); 1291 + path_info.vino.ino, IS_ERR(path) ? "<<bad>>" : path, result); 1292 + ceph_mdsc_free_path_info(&path_info); 1291 1293 } 1292 1294 out: 1293 1295 iput(req->r_old_inode); ··· 1345 1347 int err = -EROFS; 1346 1348 int op; 1347 1349 char *path; 1348 - int pathlen; 1349 - u64 pathbase; 1350 1350 1351 1351 if (ceph_snap(dir) == CEPH_SNAPDIR) { 1352 1352 /* rmdir .snap/foo is RMSNAP */ ··· 1363 1367 if (!dn) { 1364 1368 try_async = false; 1365 1369 } else { 1366 - path = ceph_mdsc_build_path(mdsc, dn, &pathlen, &pathbase, 0); 1370 + struct ceph_path_info path_info; 1371 + path = ceph_mdsc_build_path(mdsc, dn, &path_info, 0); 1367 1372 if (IS_ERR(path)) { 1368 1373 try_async = false; 1369 1374 err = 0; 1370 1375 } else { 1371 1376 err = ceph_mds_check_access(mdsc, path, MAY_WRITE); 1372 1377 } 1373 - ceph_mdsc_free_path(path, pathlen); 1378 + ceph_mdsc_free_path_info(&path_info); 1374 1379 dput(dn); 1375 1380 1376 1381 /* For none EACCES cases will let the MDS do the mds auth check */
+10 -14
fs/ceph/file.c
··· 368 368 int flags, fmode, wanted; 369 369 struct dentry *dentry; 370 370 char *path; 371 - int pathlen; 372 - u64 pathbase; 373 371 bool do_sync = false; 374 372 int mask = MAY_READ; 375 373 ··· 397 399 if (!dentry) { 398 400 do_sync = true; 399 401 } else { 400 - path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, &pathbase, 0); 402 + struct ceph_path_info path_info; 403 + path = ceph_mdsc_build_path(mdsc, dentry, &path_info, 0); 401 404 if (IS_ERR(path)) { 402 405 do_sync = true; 403 406 err = 0; 404 407 } else { 405 408 err = ceph_mds_check_access(mdsc, path, mask); 406 409 } 407 - ceph_mdsc_free_path(path, pathlen); 410 + ceph_mdsc_free_path_info(&path_info); 408 411 dput(dentry); 409 412 410 413 /* For none EACCES cases will let the MDS do the mds auth check */ ··· 613 614 mapping_set_error(req->r_parent->i_mapping, result); 614 615 615 616 if (result) { 616 - int pathlen = 0; 617 - u64 base = 0; 618 - char *path = ceph_mdsc_build_path(mdsc, req->r_dentry, &pathlen, 619 - &base, 0); 617 + struct ceph_path_info path_info = {0}; 618 + char *path = ceph_mdsc_build_path(mdsc, req->r_dentry, &path_info, 0); 620 619 621 620 pr_warn_client(cl, 622 621 "async create failure path=(%llx)%s result=%d!\n", 623 - base, IS_ERR(path) ? "<<bad>>" : path, result); 624 - ceph_mdsc_free_path(path, pathlen); 622 + path_info.vino.ino, IS_ERR(path) ? "<<bad>>" : path, result); 623 + ceph_mdsc_free_path_info(&path_info); 625 624 626 625 ceph_dir_clear_complete(req->r_parent); 627 626 if (!d_unhashed(dentry)) ··· 788 791 int mask; 789 792 int err; 790 793 char *path; 791 - int pathlen; 792 - u64 pathbase; 793 794 794 795 doutc(cl, "%p %llx.%llx dentry %p '%pd' %s flags %d mode 0%o\n", 795 796 dir, ceph_vinop(dir), dentry, dentry, ··· 809 814 if (!dn) { 810 815 try_async = false; 811 816 } else { 812 - path = ceph_mdsc_build_path(mdsc, dn, &pathlen, &pathbase, 0); 817 + struct ceph_path_info path_info; 818 + path = ceph_mdsc_build_path(mdsc, dn, &path_info, 0); 813 819 if (IS_ERR(path)) { 814 820 try_async = false; 815 821 err = 0; ··· 822 826 mask |= MAY_WRITE; 823 827 err = ceph_mds_check_access(mdsc, path, mask); 824 828 } 825 - ceph_mdsc_free_path(path, pathlen); 829 + ceph_mdsc_free_path_info(&path_info); 826 830 dput(dn); 827 831 828 832 /* For none EACCES cases will let the MDS do the mds auth check */
+72 -16
fs/ceph/inode.c
··· 55 55 return 0; 56 56 } 57 57 58 + /* 59 + * Check if the parent inode matches the vino from directory reply info 60 + */ 61 + static inline bool ceph_vino_matches_parent(struct inode *parent, 62 + struct ceph_vino vino) 63 + { 64 + return ceph_ino(parent) == vino.ino && ceph_snap(parent) == vino.snap; 65 + } 66 + 67 + /* 68 + * Validate that the directory inode referenced by @req->r_parent matches the 69 + * inode number and snapshot id contained in the reply's directory record. If 70 + * they do not match – which can theoretically happen if the parent dentry was 71 + * moved between the time the request was issued and the reply arrived – fall 72 + * back to looking up the correct inode in the inode cache. 73 + * 74 + * A reference is *always* returned. Callers that receive a different inode 75 + * than the original @parent are responsible for dropping the extra reference 76 + * once the reply has been processed. 77 + */ 78 + static struct inode *ceph_get_reply_dir(struct super_block *sb, 79 + struct inode *parent, 80 + struct ceph_mds_reply_info_parsed *rinfo) 81 + { 82 + struct ceph_vino vino; 83 + 84 + if (unlikely(!rinfo->diri.in)) 85 + return parent; /* nothing to compare against */ 86 + 87 + /* If we didn't have a cached parent inode to begin with, just bail out. */ 88 + if (!parent) 89 + return NULL; 90 + 91 + vino.ino = le64_to_cpu(rinfo->diri.in->ino); 92 + vino.snap = le64_to_cpu(rinfo->diri.in->snapid); 93 + 94 + if (likely(ceph_vino_matches_parent(parent, vino))) 95 + return parent; /* matches – use the original reference */ 96 + 97 + /* Mismatch – this should be rare. Emit a WARN and obtain the correct inode. */ 98 + WARN_ONCE(1, "ceph: reply dir mismatch (parent valid %llx.%llx reply %llx.%llx)\n", 99 + ceph_ino(parent), ceph_snap(parent), vino.ino, vino.snap); 100 + 101 + return ceph_get_inode(sb, vino, NULL); 102 + } 103 + 58 104 /** 59 105 * ceph_new_inode - allocate a new inode in advance of an expected create 60 106 * @dir: parent directory for new inode ··· 1569 1523 struct ceph_vino tvino, dvino; 1570 1524 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb); 1571 1525 struct ceph_client *cl = fsc->client; 1526 + struct inode *parent_dir = NULL; 1572 1527 int err = 0; 1573 1528 1574 1529 doutc(cl, "%p is_dentry %d is_target %d\n", req, ··· 1583 1536 } 1584 1537 1585 1538 if (rinfo->head->is_dentry) { 1586 - struct inode *dir = req->r_parent; 1587 - 1588 - if (dir) { 1589 - err = ceph_fill_inode(dir, NULL, &rinfo->diri, 1539 + /* 1540 + * r_parent may be stale, in cases when R_PARENT_LOCKED is not set, 1541 + * so we need to get the correct inode 1542 + */ 1543 + parent_dir = ceph_get_reply_dir(sb, req->r_parent, rinfo); 1544 + if (unlikely(IS_ERR(parent_dir))) { 1545 + err = PTR_ERR(parent_dir); 1546 + goto done; 1547 + } 1548 + if (parent_dir) { 1549 + err = ceph_fill_inode(parent_dir, NULL, &rinfo->diri, 1590 1550 rinfo->dirfrag, session, -1, 1591 1551 &req->r_caps_reservation); 1592 1552 if (err < 0) ··· 1602 1548 WARN_ON_ONCE(1); 1603 1549 } 1604 1550 1605 - if (dir && req->r_op == CEPH_MDS_OP_LOOKUPNAME && 1551 + if (parent_dir && req->r_op == CEPH_MDS_OP_LOOKUPNAME && 1606 1552 test_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags) && 1607 1553 !test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags)) { 1608 1554 bool is_nokey = false; 1609 1555 struct qstr dname; 1610 1556 struct dentry *dn, *parent; 1611 1557 struct fscrypt_str oname = FSTR_INIT(NULL, 0); 1612 - struct ceph_fname fname = { .dir = dir, 1558 + struct ceph_fname fname = { .dir = parent_dir, 1613 1559 .name = rinfo->dname, 1614 1560 .ctext = rinfo->altname, 1615 1561 .name_len = rinfo->dname_len, ··· 1618 1564 BUG_ON(!rinfo->head->is_target); 1619 1565 BUG_ON(req->r_dentry); 1620 1566 1621 - parent = d_find_any_alias(dir); 1567 + parent = d_find_any_alias(parent_dir); 1622 1568 BUG_ON(!parent); 1623 1569 1624 - err = ceph_fname_alloc_buffer(dir, &oname); 1570 + err = ceph_fname_alloc_buffer(parent_dir, &oname); 1625 1571 if (err < 0) { 1626 1572 dput(parent); 1627 1573 goto done; ··· 1630 1576 err = ceph_fname_to_usr(&fname, NULL, &oname, &is_nokey); 1631 1577 if (err < 0) { 1632 1578 dput(parent); 1633 - ceph_fname_free_buffer(dir, &oname); 1579 + ceph_fname_free_buffer(parent_dir, &oname); 1634 1580 goto done; 1635 1581 } 1636 1582 dname.name = oname.name; ··· 1649 1595 dname.len, dname.name, dn); 1650 1596 if (!dn) { 1651 1597 dput(parent); 1652 - ceph_fname_free_buffer(dir, &oname); 1598 + ceph_fname_free_buffer(parent_dir, &oname); 1653 1599 err = -ENOMEM; 1654 1600 goto done; 1655 1601 } ··· 1664 1610 ceph_snap(d_inode(dn)) != tvino.snap)) { 1665 1611 doutc(cl, " dn %p points to wrong inode %p\n", 1666 1612 dn, d_inode(dn)); 1667 - ceph_dir_clear_ordered(dir); 1613 + ceph_dir_clear_ordered(parent_dir); 1668 1614 d_delete(dn); 1669 1615 dput(dn); 1670 1616 goto retry_lookup; 1671 1617 } 1672 - ceph_fname_free_buffer(dir, &oname); 1618 + ceph_fname_free_buffer(parent_dir, &oname); 1673 1619 1674 1620 req->r_dentry = dn; 1675 1621 dput(parent); ··· 1848 1794 &dvino, ptvino); 1849 1795 } 1850 1796 done: 1797 + /* Drop extra ref from ceph_get_reply_dir() if it returned a new inode */ 1798 + if (unlikely(!IS_ERR_OR_NULL(parent_dir) && parent_dir != req->r_parent)) 1799 + iput(parent_dir); 1851 1800 doutc(cl, "done err=%d\n", err); 1852 1801 return err; 1853 1802 } ··· 2544 2487 int truncate_retry = 20; /* The RMW will take around 50ms */ 2545 2488 struct dentry *dentry; 2546 2489 char *path; 2547 - int pathlen; 2548 - u64 pathbase; 2549 2490 bool do_sync = false; 2550 2491 2551 2492 dentry = d_find_alias(inode); 2552 2493 if (!dentry) { 2553 2494 do_sync = true; 2554 2495 } else { 2555 - path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, &pathbase, 0); 2496 + struct ceph_path_info path_info; 2497 + path = ceph_mdsc_build_path(mdsc, dentry, &path_info, 0); 2556 2498 if (IS_ERR(path)) { 2557 2499 do_sync = true; 2558 2500 err = 0; 2559 2501 } else { 2560 2502 err = ceph_mds_check_access(mdsc, path, MAY_WRITE); 2561 2503 } 2562 - ceph_mdsc_free_path(path, pathlen); 2504 + ceph_mdsc_free_path_info(&path_info); 2563 2505 dput(dentry); 2564 2506 2565 2507 /* For none EACCES cases will let the MDS do the mds auth check */
+105 -67
fs/ceph/mds_client.c
··· 2681 2681 * ceph_mdsc_build_path - build a path string to a given dentry 2682 2682 * @mdsc: mds client 2683 2683 * @dentry: dentry to which path should be built 2684 - * @plen: returned length of string 2685 - * @pbase: returned base inode number 2684 + * @path_info: output path, length, base ino+snap, and freepath ownership flag 2686 2685 * @for_wire: is this path going to be sent to the MDS? 2687 2686 * 2688 2687 * Build a string that represents the path to the dentry. This is mostly called ··· 2699 2700 * foo/.snap/bar -> foo//bar 2700 2701 */ 2701 2702 char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry, 2702 - int *plen, u64 *pbase, int for_wire) 2703 + struct ceph_path_info *path_info, int for_wire) 2703 2704 { 2704 2705 struct ceph_client *cl = mdsc->fsc->client; 2705 2706 struct dentry *cur; ··· 2809 2810 return ERR_PTR(-ENAMETOOLONG); 2810 2811 } 2811 2812 2812 - *pbase = base; 2813 - *plen = PATH_MAX - 1 - pos; 2813 + /* Initialize the output structure */ 2814 + memset(path_info, 0, sizeof(*path_info)); 2815 + 2816 + path_info->vino.ino = base; 2817 + path_info->pathlen = PATH_MAX - 1 - pos; 2818 + path_info->path = path + pos; 2819 + path_info->freepath = true; 2820 + 2821 + /* Set snap from dentry if available */ 2822 + if (d_inode(dentry)) 2823 + path_info->vino.snap = ceph_snap(d_inode(dentry)); 2824 + else 2825 + path_info->vino.snap = CEPH_NOSNAP; 2826 + 2814 2827 doutc(cl, "on %p %d built %llx '%.*s'\n", dentry, d_count(dentry), 2815 - base, *plen, path + pos); 2828 + base, PATH_MAX - 1 - pos, path + pos); 2816 2829 return path + pos; 2817 2830 } 2818 2831 2819 2832 static int build_dentry_path(struct ceph_mds_client *mdsc, struct dentry *dentry, 2820 - struct inode *dir, const char **ppath, int *ppathlen, 2821 - u64 *pino, bool *pfreepath, bool parent_locked) 2833 + struct inode *dir, struct ceph_path_info *path_info, 2834 + bool parent_locked) 2822 2835 { 2823 2836 char *path; 2824 2837 ··· 2839 2828 dir = d_inode_rcu(dentry->d_parent); 2840 2829 if (dir && parent_locked && ceph_snap(dir) == CEPH_NOSNAP && 2841 2830 !IS_ENCRYPTED(dir)) { 2842 - *pino = ceph_ino(dir); 2831 + path_info->vino.ino = ceph_ino(dir); 2832 + path_info->vino.snap = ceph_snap(dir); 2843 2833 rcu_read_unlock(); 2844 - *ppath = dentry->d_name.name; 2845 - *ppathlen = dentry->d_name.len; 2834 + path_info->path = dentry->d_name.name; 2835 + path_info->pathlen = dentry->d_name.len; 2836 + path_info->freepath = false; 2846 2837 return 0; 2847 2838 } 2848 2839 rcu_read_unlock(); 2849 - path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1); 2840 + path = ceph_mdsc_build_path(mdsc, dentry, path_info, 1); 2850 2841 if (IS_ERR(path)) 2851 2842 return PTR_ERR(path); 2852 - *ppath = path; 2853 - *pfreepath = true; 2843 + /* 2844 + * ceph_mdsc_build_path already fills path_info, including snap handling. 2845 + */ 2854 2846 return 0; 2855 2847 } 2856 2848 2857 - static int build_inode_path(struct inode *inode, 2858 - const char **ppath, int *ppathlen, u64 *pino, 2859 - bool *pfreepath) 2849 + static int build_inode_path(struct inode *inode, struct ceph_path_info *path_info) 2860 2850 { 2861 2851 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); 2862 2852 struct dentry *dentry; 2863 2853 char *path; 2864 2854 2865 2855 if (ceph_snap(inode) == CEPH_NOSNAP) { 2866 - *pino = ceph_ino(inode); 2867 - *ppathlen = 0; 2856 + path_info->vino.ino = ceph_ino(inode); 2857 + path_info->vino.snap = ceph_snap(inode); 2858 + path_info->pathlen = 0; 2859 + path_info->freepath = false; 2868 2860 return 0; 2869 2861 } 2870 2862 dentry = d_find_alias(inode); 2871 - path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1); 2863 + path = ceph_mdsc_build_path(mdsc, dentry, path_info, 1); 2872 2864 dput(dentry); 2873 2865 if (IS_ERR(path)) 2874 2866 return PTR_ERR(path); 2875 - *ppath = path; 2876 - *pfreepath = true; 2867 + /* 2868 + * ceph_mdsc_build_path already fills path_info, including snap from dentry. 2869 + * Override with inode's snap since that's what this function is for. 2870 + */ 2871 + path_info->vino.snap = ceph_snap(inode); 2877 2872 return 0; 2878 2873 } 2879 2874 ··· 2889 2872 */ 2890 2873 static int set_request_path_attr(struct ceph_mds_client *mdsc, struct inode *rinode, 2891 2874 struct dentry *rdentry, struct inode *rdiri, 2892 - const char *rpath, u64 rino, const char **ppath, 2893 - int *pathlen, u64 *ino, bool *freepath, 2875 + const char *rpath, u64 rino, 2876 + struct ceph_path_info *path_info, 2894 2877 bool parent_locked) 2895 2878 { 2896 2879 struct ceph_client *cl = mdsc->fsc->client; 2897 2880 int r = 0; 2898 2881 2882 + /* Initialize the output structure */ 2883 + memset(path_info, 0, sizeof(*path_info)); 2884 + 2899 2885 if (rinode) { 2900 - r = build_inode_path(rinode, ppath, pathlen, ino, freepath); 2886 + r = build_inode_path(rinode, path_info); 2901 2887 doutc(cl, " inode %p %llx.%llx\n", rinode, ceph_ino(rinode), 2902 2888 ceph_snap(rinode)); 2903 2889 } else if (rdentry) { 2904 - r = build_dentry_path(mdsc, rdentry, rdiri, ppath, pathlen, ino, 2905 - freepath, parent_locked); 2906 - doutc(cl, " dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, *ppath); 2890 + r = build_dentry_path(mdsc, rdentry, rdiri, path_info, parent_locked); 2891 + doutc(cl, " dentry %p %llx/%.*s\n", rdentry, path_info->vino.ino, 2892 + path_info->pathlen, path_info->path); 2907 2893 } else if (rpath || rino) { 2908 - *ino = rino; 2909 - *ppath = rpath; 2910 - *pathlen = rpath ? strlen(rpath) : 0; 2911 - doutc(cl, " path %.*s\n", *pathlen, rpath); 2894 + path_info->vino.ino = rino; 2895 + path_info->vino.snap = CEPH_NOSNAP; 2896 + path_info->path = rpath; 2897 + path_info->pathlen = rpath ? strlen(rpath) : 0; 2898 + path_info->freepath = false; 2899 + 2900 + doutc(cl, " path %.*s\n", path_info->pathlen, rpath); 2912 2901 } 2913 2902 2914 2903 return r; ··· 2991 2968 struct ceph_client *cl = mdsc->fsc->client; 2992 2969 struct ceph_msg *msg; 2993 2970 struct ceph_mds_request_head_legacy *lhead; 2994 - const char *path1 = NULL; 2995 - const char *path2 = NULL; 2996 - u64 ino1 = 0, ino2 = 0; 2997 - int pathlen1 = 0, pathlen2 = 0; 2998 - bool freepath1 = false, freepath2 = false; 2971 + struct ceph_path_info path_info1 = {0}; 2972 + struct ceph_path_info path_info2 = {0}; 2999 2973 struct dentry *old_dentry = NULL; 3000 2974 int len; 3001 2975 u16 releases; ··· 3002 2982 u16 request_head_version = mds_supported_head_version(session); 3003 2983 kuid_t caller_fsuid = req->r_cred->fsuid; 3004 2984 kgid_t caller_fsgid = req->r_cred->fsgid; 2985 + bool parent_locked = test_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); 3005 2986 3006 2987 ret = set_request_path_attr(mdsc, req->r_inode, req->r_dentry, 3007 - req->r_parent, req->r_path1, req->r_ino1.ino, 3008 - &path1, &pathlen1, &ino1, &freepath1, 3009 - test_bit(CEPH_MDS_R_PARENT_LOCKED, 3010 - &req->r_req_flags)); 2988 + req->r_parent, req->r_path1, req->r_ino1.ino, 2989 + &path_info1, parent_locked); 3011 2990 if (ret < 0) { 3012 2991 msg = ERR_PTR(ret); 3013 2992 goto out; 2993 + } 2994 + 2995 + /* 2996 + * When the parent directory's i_rwsem is *not* locked, req->r_parent may 2997 + * have become stale (e.g. after a concurrent rename) between the time the 2998 + * dentry was looked up and now. If we detect that the stored r_parent 2999 + * does not match the inode number we just encoded for the request, switch 3000 + * to the correct inode so that the MDS receives a valid parent reference. 3001 + */ 3002 + if (!parent_locked && req->r_parent && path_info1.vino.ino && 3003 + ceph_ino(req->r_parent) != path_info1.vino.ino) { 3004 + struct inode *old_parent = req->r_parent; 3005 + struct inode *correct_dir = ceph_get_inode(mdsc->fsc->sb, path_info1.vino, NULL); 3006 + if (!IS_ERR(correct_dir)) { 3007 + WARN_ONCE(1, "ceph: r_parent mismatch (had %llx wanted %llx) - updating\n", 3008 + ceph_ino(old_parent), path_info1.vino.ino); 3009 + /* 3010 + * Transfer CEPH_CAP_PIN from the old parent to the new one. 3011 + * The pin was taken earlier in ceph_mdsc_submit_request(). 3012 + */ 3013 + ceph_put_cap_refs(ceph_inode(old_parent), CEPH_CAP_PIN); 3014 + iput(old_parent); 3015 + req->r_parent = correct_dir; 3016 + ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); 3017 + } 3014 3018 } 3015 3019 3016 3020 /* If r_old_dentry is set, then assume that its parent is locked */ ··· 3042 2998 !(req->r_old_dentry->d_flags & DCACHE_DISCONNECTED)) 3043 2999 old_dentry = req->r_old_dentry; 3044 3000 ret = set_request_path_attr(mdsc, NULL, old_dentry, 3045 - req->r_old_dentry_dir, 3046 - req->r_path2, req->r_ino2.ino, 3047 - &path2, &pathlen2, &ino2, &freepath2, true); 3001 + req->r_old_dentry_dir, 3002 + req->r_path2, req->r_ino2.ino, 3003 + &path_info2, true); 3048 3004 if (ret < 0) { 3049 3005 msg = ERR_PTR(ret); 3050 3006 goto out_free1; ··· 3075 3031 3076 3032 /* filepaths */ 3077 3033 len += 2 * (1 + sizeof(u32) + sizeof(u64)); 3078 - len += pathlen1 + pathlen2; 3034 + len += path_info1.pathlen + path_info2.pathlen; 3079 3035 3080 3036 /* cap releases */ 3081 3037 len += sizeof(struct ceph_mds_request_release) * ··· 3083 3039 !!req->r_old_inode_drop + !!req->r_old_dentry_drop); 3084 3040 3085 3041 if (req->r_dentry_drop) 3086 - len += pathlen1; 3042 + len += path_info1.pathlen; 3087 3043 if (req->r_old_dentry_drop) 3088 - len += pathlen2; 3044 + len += path_info2.pathlen; 3089 3045 3090 3046 /* MClientRequest tail */ 3091 3047 ··· 3198 3154 lhead->ino = cpu_to_le64(req->r_deleg_ino); 3199 3155 lhead->args = req->r_args; 3200 3156 3201 - ceph_encode_filepath(&p, end, ino1, path1); 3202 - ceph_encode_filepath(&p, end, ino2, path2); 3157 + ceph_encode_filepath(&p, end, path_info1.vino.ino, path_info1.path); 3158 + ceph_encode_filepath(&p, end, path_info2.vino.ino, path_info2.path); 3203 3159 3204 3160 /* make note of release offset, in case we need to replay */ 3205 3161 req->r_request_release_offset = p - msg->front.iov_base; ··· 3262 3218 msg->hdr.data_off = cpu_to_le16(0); 3263 3219 3264 3220 out_free2: 3265 - if (freepath2) 3266 - ceph_mdsc_free_path((char *)path2, pathlen2); 3221 + ceph_mdsc_free_path_info(&path_info2); 3267 3222 out_free1: 3268 - if (freepath1) 3269 - ceph_mdsc_free_path((char *)path1, pathlen1); 3223 + ceph_mdsc_free_path_info(&path_info1); 3270 3224 out: 3271 3225 return msg; 3272 3226 out_err: ··· 4621 4579 struct ceph_pagelist *pagelist = recon_state->pagelist; 4622 4580 struct dentry *dentry; 4623 4581 struct ceph_cap *cap; 4624 - char *path; 4625 - int pathlen = 0, err; 4626 - u64 pathbase; 4582 + struct ceph_path_info path_info = {0}; 4583 + int err; 4627 4584 u64 snap_follows; 4628 4585 4629 4586 dentry = d_find_primary(inode); 4630 4587 if (dentry) { 4631 4588 /* set pathbase to parent dir when msg_version >= 2 */ 4632 - path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, &pathbase, 4589 + char *path = ceph_mdsc_build_path(mdsc, dentry, &path_info, 4633 4590 recon_state->msg_version >= 2); 4634 4591 dput(dentry); 4635 4592 if (IS_ERR(path)) { 4636 4593 err = PTR_ERR(path); 4637 4594 goto out_err; 4638 4595 } 4639 - } else { 4640 - path = NULL; 4641 - pathbase = 0; 4642 4596 } 4643 4597 4644 4598 spin_lock(&ci->i_ceph_lock); ··· 4667 4629 rec.v2.wanted = cpu_to_le32(__ceph_caps_wanted(ci)); 4668 4630 rec.v2.issued = cpu_to_le32(cap->issued); 4669 4631 rec.v2.snaprealm = cpu_to_le64(ci->i_snap_realm->ino); 4670 - rec.v2.pathbase = cpu_to_le64(pathbase); 4632 + rec.v2.pathbase = cpu_to_le64(path_info.vino.ino); 4671 4633 rec.v2.flock_len = (__force __le32) 4672 4634 ((ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) ? 0 : 1); 4673 4635 } else { ··· 4682 4644 ts = inode_get_atime(inode); 4683 4645 ceph_encode_timespec64(&rec.v1.atime, &ts); 4684 4646 rec.v1.snaprealm = cpu_to_le64(ci->i_snap_realm->ino); 4685 - rec.v1.pathbase = cpu_to_le64(pathbase); 4647 + rec.v1.pathbase = cpu_to_le64(path_info.vino.ino); 4686 4648 } 4687 4649 4688 4650 if (list_empty(&ci->i_cap_snaps)) { ··· 4744 4706 sizeof(struct ceph_filelock); 4745 4707 rec.v2.flock_len = cpu_to_le32(struct_len); 4746 4708 4747 - struct_len += sizeof(u32) + pathlen + sizeof(rec.v2); 4709 + struct_len += sizeof(u32) + path_info.pathlen + sizeof(rec.v2); 4748 4710 4749 4711 if (struct_v >= 2) 4750 4712 struct_len += sizeof(u64); /* snap_follows */ ··· 4768 4730 ceph_pagelist_encode_8(pagelist, 1); 4769 4731 ceph_pagelist_encode_32(pagelist, struct_len); 4770 4732 } 4771 - ceph_pagelist_encode_string(pagelist, path, pathlen); 4733 + ceph_pagelist_encode_string(pagelist, (char *)path_info.path, path_info.pathlen); 4772 4734 ceph_pagelist_append(pagelist, &rec, sizeof(rec.v2)); 4773 4735 ceph_locks_to_pagelist(flocks, pagelist, 4774 4736 num_fcntl_locks, num_flock_locks); ··· 4779 4741 } else { 4780 4742 err = ceph_pagelist_reserve(pagelist, 4781 4743 sizeof(u64) + sizeof(u32) + 4782 - pathlen + sizeof(rec.v1)); 4744 + path_info.pathlen + sizeof(rec.v1)); 4783 4745 if (err) 4784 4746 goto out_err; 4785 4747 4786 4748 ceph_pagelist_encode_64(pagelist, ceph_ino(inode)); 4787 - ceph_pagelist_encode_string(pagelist, path, pathlen); 4749 + ceph_pagelist_encode_string(pagelist, (char *)path_info.path, path_info.pathlen); 4788 4750 ceph_pagelist_append(pagelist, &rec, sizeof(rec.v1)); 4789 4751 } 4790 4752 4791 4753 out_err: 4792 - ceph_mdsc_free_path(path, pathlen); 4754 + ceph_mdsc_free_path_info(&path_info); 4793 4755 if (!err) 4794 4756 recon_state->nr_caps++; 4795 4757 return err;
+14 -4
fs/ceph/mds_client.h
··· 617 617 618 618 extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); 619 619 620 - static inline void ceph_mdsc_free_path(char *path, int len) 620 + /* 621 + * Structure to group path-related output parameters for build_*_path functions 622 + */ 623 + struct ceph_path_info { 624 + const char *path; 625 + int pathlen; 626 + struct ceph_vino vino; 627 + bool freepath; 628 + }; 629 + 630 + static inline void ceph_mdsc_free_path_info(const struct ceph_path_info *path_info) 621 631 { 622 - if (!IS_ERR_OR_NULL(path)) 623 - __putname(path - (PATH_MAX - 1 - len)); 632 + if (path_info && path_info->freepath && !IS_ERR_OR_NULL(path_info->path)) 633 + __putname((char *)path_info->path - (PATH_MAX - 1 - path_info->pathlen)); 624 634 } 625 635 626 636 extern char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, 627 - struct dentry *dentry, int *plen, u64 *base, 637 + struct dentry *dentry, struct ceph_path_info *path_info, 628 638 int for_wire); 629 639 630 640 extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);
+5 -3
fs/erofs/erofs_fs.h
··· 12 12 /* to allow for x86 boot sectors and other oddities. */ 13 13 #define EROFS_SUPER_OFFSET 1024 14 14 15 - #define EROFS_FEATURE_COMPAT_SB_CHKSUM 0x00000001 16 - #define EROFS_FEATURE_COMPAT_MTIME 0x00000002 17 - #define EROFS_FEATURE_COMPAT_XATTR_FILTER 0x00000004 15 + #define EROFS_FEATURE_COMPAT_SB_CHKSUM 0x00000001 16 + #define EROFS_FEATURE_COMPAT_MTIME 0x00000002 17 + #define EROFS_FEATURE_COMPAT_XATTR_FILTER 0x00000004 18 18 #define EROFS_FEATURE_COMPAT_SHARED_EA_IN_METABOX 0x00000008 19 + #define EROFS_FEATURE_COMPAT_PLAIN_XATTR_PFX 0x00000010 20 + 19 21 20 22 /* 21 23 * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should
+1
fs/erofs/internal.h
··· 234 234 EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) 235 235 EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER) 236 236 EROFS_FEATURE_FUNCS(shared_ea_in_metabox, compat, COMPAT_SHARED_EA_IN_METABOX) 237 + EROFS_FEATURE_FUNCS(plain_xattr_pfx, compat, COMPAT_PLAIN_XATTR_PFX) 237 238 238 239 static inline u64 erofs_nid_to_ino64(struct erofs_sb_info *sbi, erofs_nid_t nid) 239 240 {
+12
fs/erofs/super.c
··· 1018 1018 return 0; 1019 1019 } 1020 1020 1021 + static void erofs_evict_inode(struct inode *inode) 1022 + { 1023 + #ifdef CONFIG_FS_DAX 1024 + if (IS_DAX(inode)) 1025 + dax_break_layout_final(inode); 1026 + #endif 1027 + 1028 + truncate_inode_pages_final(&inode->i_data); 1029 + clear_inode(inode); 1030 + } 1031 + 1021 1032 const struct super_operations erofs_sops = { 1022 1033 .put_super = erofs_put_super, 1023 1034 .alloc_inode = erofs_alloc_inode, 1024 1035 .free_inode = erofs_free_inode, 1036 + .evict_inode = erofs_evict_inode, 1025 1037 .statfs = erofs_statfs, 1026 1038 .show_options = erofs_show_options, 1027 1039 };
+10 -3
fs/erofs/xattr.c
··· 482 482 erofs_off_t pos = (erofs_off_t)sbi->xattr_prefix_start << 2; 483 483 struct erofs_xattr_prefix_item *pfs; 484 484 int ret = 0, i, len; 485 + bool plain = erofs_sb_has_plain_xattr_pfx(sbi); 485 486 486 487 if (!sbi->xattr_prefix_count) 487 488 return 0; ··· 491 490 if (!pfs) 492 491 return -ENOMEM; 493 492 494 - if (sbi->packed_inode) 495 - buf.mapping = sbi->packed_inode->i_mapping; 496 - else 493 + if (!plain) { 494 + if (erofs_sb_has_metabox(sbi)) 495 + (void)erofs_init_metabuf(&buf, sb, true); 496 + else if (sbi->packed_inode) 497 + buf.mapping = sbi->packed_inode->i_mapping; 498 + else 499 + plain = true; 500 + } 501 + if (plain) 497 502 (void)erofs_init_metabuf(&buf, sb, false); 498 503 499 504 for (i = 0; i < sbi->xattr_prefix_count; i++) {
+37 -30
fs/erofs/zmap.c
··· 394 394 .map = map, 395 395 .in_mbox = erofs_inode_in_metabox(inode), 396 396 }; 397 - int err = 0; 398 - unsigned int endoff, afmt; 397 + unsigned int endoff; 399 398 unsigned long initial_lcn; 400 399 unsigned long long ofs, end; 400 + int err; 401 401 402 402 ofs = flags & EROFS_GET_BLOCKS_FINDTAIL ? inode->i_size - 1 : map->m_la; 403 403 if (fragment && !(flags & EROFS_GET_BLOCKS_FINDTAIL) && ··· 482 482 err = -EFSCORRUPTED; 483 483 goto unmap_out; 484 484 } 485 - afmt = vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER ? 486 - Z_EROFS_COMPRESSION_INTERLACED : 487 - Z_EROFS_COMPRESSION_SHIFTED; 485 + if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER) 486 + map->m_algorithmformat = Z_EROFS_COMPRESSION_INTERLACED; 487 + else 488 + map->m_algorithmformat = Z_EROFS_COMPRESSION_SHIFTED; 489 + } else if (m.headtype == Z_EROFS_LCLUSTER_TYPE_HEAD2) { 490 + map->m_algorithmformat = vi->z_algorithmtype[1]; 488 491 } else { 489 - afmt = m.headtype == Z_EROFS_LCLUSTER_TYPE_HEAD2 ? 490 - vi->z_algorithmtype[1] : vi->z_algorithmtype[0]; 491 - if (!(EROFS_I_SB(inode)->available_compr_algs & (1 << afmt))) { 492 - erofs_err(sb, "inconsistent algorithmtype %u for nid %llu", 493 - afmt, vi->nid); 494 - err = -EFSCORRUPTED; 495 - goto unmap_out; 496 - } 492 + map->m_algorithmformat = vi->z_algorithmtype[0]; 497 493 } 498 - map->m_algorithmformat = afmt; 499 494 500 495 if ((flags & EROFS_GET_BLOCKS_FIEMAP) || 501 496 ((flags & EROFS_GET_BLOCKS_READMORE) && ··· 621 626 { 622 627 struct erofs_inode *const vi = EROFS_I(inode); 623 628 struct super_block *const sb = inode->i_sb; 624 - int err, headnr; 625 - erofs_off_t pos; 626 629 struct z_erofs_map_header *h; 630 + erofs_off_t pos; 631 + int err = 0; 627 632 628 633 if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) { 629 634 /* ··· 637 642 if (wait_on_bit_lock(&vi->flags, EROFS_I_BL_Z_BIT, TASK_KILLABLE)) 638 643 return -ERESTARTSYS; 639 644 640 - err = 0; 641 645 if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) 642 646 goto out_unlock; 643 647 ··· 672 678 vi->z_fragmentoff = le32_to_cpu(h->h_fragmentoff); 673 679 else if (vi->z_advise & Z_EROFS_ADVISE_INLINE_PCLUSTER) 674 680 vi->z_idata_size = le16_to_cpu(h->h_idata_size); 675 - 676 - headnr = 0; 677 - if (vi->z_algorithmtype[0] >= Z_EROFS_COMPRESSION_MAX || 678 - vi->z_algorithmtype[++headnr] >= Z_EROFS_COMPRESSION_MAX) { 679 - erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel", 680 - headnr + 1, vi->z_algorithmtype[headnr], vi->nid); 681 - err = -EOPNOTSUPP; 682 - goto out_unlock; 683 - } 684 681 685 682 if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) && 686 683 vi->z_advise & (Z_EROFS_ADVISE_BIG_PCLUSTER_1 | ··· 711 726 return err; 712 727 } 713 728 729 + static int z_erofs_map_sanity_check(struct inode *inode, 730 + struct erofs_map_blocks *map) 731 + { 732 + struct erofs_sb_info *sbi = EROFS_I_SB(inode); 733 + 734 + if (!(map->m_flags & EROFS_MAP_ENCODED)) 735 + return 0; 736 + if (unlikely(map->m_algorithmformat >= Z_EROFS_COMPRESSION_RUNTIME_MAX)) { 737 + erofs_err(inode->i_sb, "unknown algorithm %d @ pos %llu for nid %llu, please upgrade kernel", 738 + map->m_algorithmformat, map->m_la, EROFS_I(inode)->nid); 739 + return -EOPNOTSUPP; 740 + } 741 + if (unlikely(map->m_algorithmformat < Z_EROFS_COMPRESSION_MAX && 742 + !(sbi->available_compr_algs & (1 << map->m_algorithmformat)))) { 743 + erofs_err(inode->i_sb, "inconsistent algorithmtype %u for nid %llu", 744 + map->m_algorithmformat, EROFS_I(inode)->nid); 745 + return -EFSCORRUPTED; 746 + } 747 + if (unlikely(map->m_plen > Z_EROFS_PCLUSTER_MAX_SIZE || 748 + map->m_llen > Z_EROFS_PCLUSTER_MAX_DSIZE)) 749 + return -EOPNOTSUPP; 750 + return 0; 751 + } 752 + 714 753 int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map, 715 754 int flags) 716 755 { ··· 755 746 else 756 747 err = z_erofs_map_blocks_fo(inode, map, flags); 757 748 } 758 - if (!err && (map->m_flags & EROFS_MAP_ENCODED) && 759 - unlikely(map->m_plen > Z_EROFS_PCLUSTER_MAX_SIZE || 760 - map->m_llen > Z_EROFS_PCLUSTER_MAX_DSIZE)) 761 - err = -EOPNOTSUPP; 749 + if (!err) 750 + err = z_erofs_map_sanity_check(inode, map); 762 751 if (err) 763 752 map->m_llen = 0; 764 753 }
+38 -20
fs/kernfs/file.c
··· 70 70 !list_empty(&of->list)); 71 71 } 72 72 73 + /* Get active reference to kernfs node for an open file */ 74 + static struct kernfs_open_file *kernfs_get_active_of(struct kernfs_open_file *of) 75 + { 76 + /* Skip if file was already released */ 77 + if (unlikely(of->released)) 78 + return NULL; 79 + 80 + if (!kernfs_get_active(of->kn)) 81 + return NULL; 82 + 83 + return of; 84 + } 85 + 86 + static void kernfs_put_active_of(struct kernfs_open_file *of) 87 + { 88 + return kernfs_put_active(of->kn); 89 + } 90 + 73 91 /** 74 92 * kernfs_deref_open_node_locked - Get kernfs_open_node corresponding to @kn 75 93 * ··· 157 139 158 140 if (ops->seq_stop) 159 141 ops->seq_stop(sf, v); 160 - kernfs_put_active(of->kn); 142 + kernfs_put_active_of(of); 161 143 } 162 144 163 145 static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos) ··· 170 152 * the ops aren't called concurrently for the same open file. 171 153 */ 172 154 mutex_lock(&of->mutex); 173 - if (!kernfs_get_active(of->kn)) 155 + if (!kernfs_get_active_of(of)) 174 156 return ERR_PTR(-ENODEV); 175 157 176 158 ops = kernfs_ops(of->kn); ··· 256 238 * the ops aren't called concurrently for the same open file. 257 239 */ 258 240 mutex_lock(&of->mutex); 259 - if (!kernfs_get_active(of->kn)) { 241 + if (!kernfs_get_active_of(of)) { 260 242 len = -ENODEV; 261 243 mutex_unlock(&of->mutex); 262 244 goto out_free; ··· 270 252 else 271 253 len = -EINVAL; 272 254 273 - kernfs_put_active(of->kn); 255 + kernfs_put_active_of(of); 274 256 mutex_unlock(&of->mutex); 275 257 276 258 if (len < 0) ··· 341 323 * the ops aren't called concurrently for the same open file. 342 324 */ 343 325 mutex_lock(&of->mutex); 344 - if (!kernfs_get_active(of->kn)) { 326 + if (!kernfs_get_active_of(of)) { 345 327 mutex_unlock(&of->mutex); 346 328 len = -ENODEV; 347 329 goto out_free; ··· 353 335 else 354 336 len = -EINVAL; 355 337 356 - kernfs_put_active(of->kn); 338 + kernfs_put_active_of(of); 357 339 mutex_unlock(&of->mutex); 358 340 359 341 if (len > 0) ··· 375 357 if (!of->vm_ops) 376 358 return; 377 359 378 - if (!kernfs_get_active(of->kn)) 360 + if (!kernfs_get_active_of(of)) 379 361 return; 380 362 381 363 if (of->vm_ops->open) 382 364 of->vm_ops->open(vma); 383 365 384 - kernfs_put_active(of->kn); 366 + kernfs_put_active_of(of); 385 367 } 386 368 387 369 static vm_fault_t kernfs_vma_fault(struct vm_fault *vmf) ··· 393 375 if (!of->vm_ops) 394 376 return VM_FAULT_SIGBUS; 395 377 396 - if (!kernfs_get_active(of->kn)) 378 + if (!kernfs_get_active_of(of)) 397 379 return VM_FAULT_SIGBUS; 398 380 399 381 ret = VM_FAULT_SIGBUS; 400 382 if (of->vm_ops->fault) 401 383 ret = of->vm_ops->fault(vmf); 402 384 403 - kernfs_put_active(of->kn); 385 + kernfs_put_active_of(of); 404 386 return ret; 405 387 } 406 388 ··· 413 395 if (!of->vm_ops) 414 396 return VM_FAULT_SIGBUS; 415 397 416 - if (!kernfs_get_active(of->kn)) 398 + if (!kernfs_get_active_of(of)) 417 399 return VM_FAULT_SIGBUS; 418 400 419 401 ret = 0; ··· 422 404 else 423 405 file_update_time(file); 424 406 425 - kernfs_put_active(of->kn); 407 + kernfs_put_active_of(of); 426 408 return ret; 427 409 } 428 410 ··· 436 418 if (!of->vm_ops) 437 419 return -EINVAL; 438 420 439 - if (!kernfs_get_active(of->kn)) 421 + if (!kernfs_get_active_of(of)) 440 422 return -EINVAL; 441 423 442 424 ret = -EINVAL; 443 425 if (of->vm_ops->access) 444 426 ret = of->vm_ops->access(vma, addr, buf, len, write); 445 427 446 - kernfs_put_active(of->kn); 428 + kernfs_put_active_of(of); 447 429 return ret; 448 430 } 449 431 ··· 473 455 mutex_lock(&of->mutex); 474 456 475 457 rc = -ENODEV; 476 - if (!kernfs_get_active(of->kn)) 458 + if (!kernfs_get_active_of(of)) 477 459 goto out_unlock; 478 460 479 461 ops = kernfs_ops(of->kn); ··· 508 490 } 509 491 vma->vm_ops = &kernfs_vm_ops; 510 492 out_put: 511 - kernfs_put_active(of->kn); 493 + kernfs_put_active_of(of); 512 494 out_unlock: 513 495 mutex_unlock(&of->mutex); 514 496 ··· 870 852 struct kernfs_node *kn = kernfs_dentry_node(filp->f_path.dentry); 871 853 __poll_t ret; 872 854 873 - if (!kernfs_get_active(kn)) 855 + if (!kernfs_get_active_of(of)) 874 856 return DEFAULT_POLLMASK|EPOLLERR|EPOLLPRI; 875 857 876 858 if (kn->attr.ops->poll) ··· 878 860 else 879 861 ret = kernfs_generic_poll(of, wait); 880 862 881 - kernfs_put_active(kn); 863 + kernfs_put_active_of(of); 882 864 return ret; 883 865 } 884 866 ··· 893 875 * the ops aren't called concurrently for the same open file. 894 876 */ 895 877 mutex_lock(&of->mutex); 896 - if (!kernfs_get_active(of->kn)) { 878 + if (!kernfs_get_active_of(of)) { 897 879 mutex_unlock(&of->mutex); 898 880 return -ENODEV; 899 881 } ··· 904 886 else 905 887 ret = generic_file_llseek(file, offset, whence); 906 888 907 - kernfs_put_active(of->kn); 889 + kernfs_put_active_of(of); 908 890 mutex_unlock(&of->mutex); 909 891 return ret; 910 892 }
+2 -2
fs/nilfs2/sysfs.c
··· 1075 1075 ************************************************************************/ 1076 1076 1077 1077 static ssize_t nilfs_feature_revision_show(struct kobject *kobj, 1078 - struct attribute *attr, char *buf) 1078 + struct kobj_attribute *attr, char *buf) 1079 1079 { 1080 1080 return sysfs_emit(buf, "%d.%d\n", 1081 1081 NILFS_CURRENT_REV, NILFS_MINOR_REV); ··· 1087 1087 "(1) revision\n\tshow current revision of NILFS file system driver.\n"; 1088 1088 1089 1089 static ssize_t nilfs_feature_README_show(struct kobject *kobj, 1090 - struct attribute *attr, 1090 + struct kobj_attribute *attr, 1091 1091 char *buf) 1092 1092 { 1093 1093 return sysfs_emit(buf, features_readme_str);
+4 -4
fs/nilfs2/sysfs.h
··· 50 50 struct completion sg_segments_kobj_unregister; 51 51 }; 52 52 53 - #define NILFS_COMMON_ATTR_STRUCT(name) \ 53 + #define NILFS_KOBJ_ATTR_STRUCT(name) \ 54 54 struct nilfs_##name##_attr { \ 55 55 struct attribute attr; \ 56 - ssize_t (*show)(struct kobject *, struct attribute *, \ 56 + ssize_t (*show)(struct kobject *, struct kobj_attribute *, \ 57 57 char *); \ 58 - ssize_t (*store)(struct kobject *, struct attribute *, \ 58 + ssize_t (*store)(struct kobject *, struct kobj_attribute *, \ 59 59 const char *, size_t); \ 60 60 } 61 61 62 - NILFS_COMMON_ATTR_STRUCT(feature); 62 + NILFS_KOBJ_ATTR_STRUCT(feature); 63 63 64 64 #define NILFS_DEV_ATTR_STRUCT(name) \ 65 65 struct nilfs_##name##_attr { \
+1 -1
fs/resctrl/ctrlmondata.c
··· 625 625 */ 626 626 list_for_each_entry(d, &r->mon_domains, hdr.list) { 627 627 if (d->ci_id == domid) { 628 - rr.ci_id = d->ci_id; 629 628 cpu = cpumask_any(&d->hdr.cpu_mask); 630 629 ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); 631 630 if (!ci) 632 631 continue; 632 + rr.ci = ci; 633 633 mon_event_read(&rr, r, NULL, rdtgrp, 634 634 &ci->shared_cpu_map, evtid, false); 635 635 goto checkresult;
+2 -2
fs/resctrl/internal.h
··· 98 98 * domains in @r sharing L3 @ci.id 99 99 * @evtid: Which monitor event to read. 100 100 * @first: Initialize MBM counter when true. 101 - * @ci_id: Cacheinfo id for L3. Only set when @d is NULL. Used when summing domains. 101 + * @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains. 102 102 * @err: Error encountered when reading counter. 103 103 * @val: Returned value of event counter. If @rgrp is a parent resource group, 104 104 * @val includes the sum of event counts from its child resource groups. ··· 112 112 struct rdt_mon_domain *d; 113 113 enum resctrl_event_id evtid; 114 114 bool first; 115 - unsigned int ci_id; 115 + struct cacheinfo *ci; 116 116 int err; 117 117 u64 val; 118 118 void *arch_mon_ctx;
+2 -4
fs/resctrl/monitor.c
··· 361 361 { 362 362 int cpu = smp_processor_id(); 363 363 struct rdt_mon_domain *d; 364 - struct cacheinfo *ci; 365 364 struct mbm_state *m; 366 365 int err, ret; 367 366 u64 tval = 0; ··· 388 389 } 389 390 390 391 /* Summing domains that share a cache, must be on a CPU for that cache. */ 391 - ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); 392 - if (!ci || ci->id != rr->ci_id) 392 + if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) 393 393 return -EINVAL; 394 394 395 395 /* ··· 400 402 */ 401 403 ret = -EINVAL; 402 404 list_for_each_entry(d, &rr->r->mon_domains, hdr.list) { 403 - if (d->ci_id != rr->ci_id) 405 + if (d->ci_id != rr->ci->id) 404 406 continue; 405 407 err = resctrl_arch_rmid_read(rr->r, d, closid, rmid, 406 408 rr->evtid, &tval, rr->arch_mon_ctx);
+9 -4
fs/smb/client/cifsglob.h
··· 87 87 #define SMB_INTERFACE_POLL_INTERVAL 600 88 88 89 89 /* maximum number of PDUs in one compound */ 90 - #define MAX_COMPOUND 7 90 + #define MAX_COMPOUND 10 91 91 92 92 /* 93 93 * Default number of credits to keep available for SMB3. ··· 1882 1882 1883 1883 1884 1884 /* cifs_get_writable_file() flags */ 1885 - #define FIND_WR_ANY 0 1886 - #define FIND_WR_FSUID_ONLY 1 1887 - #define FIND_WR_WITH_DELETE 2 1885 + enum cifs_writable_file_flags { 1886 + FIND_WR_ANY = 0U, 1887 + FIND_WR_FSUID_ONLY = (1U << 0), 1888 + FIND_WR_WITH_DELETE = (1U << 1), 1889 + FIND_WR_NO_PENDING_DELETE = (1U << 2), 1890 + }; 1888 1891 1889 1892 #define MID_FREE 0 1890 1893 #define MID_REQUEST_ALLOCATED 1 ··· 2346 2343 struct kvec qi_iov; 2347 2344 struct kvec io_iov[SMB2_IOCTL_IOV_SIZE]; 2348 2345 struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE]; 2346 + struct kvec unlink_iov[SMB2_SET_INFO_IOV_SIZE]; 2347 + struct kvec rename_iov[SMB2_SET_INFO_IOV_SIZE]; 2349 2348 struct kvec close_iov; 2350 2349 struct smb2_file_rename_info_hdr rename_info; 2351 2350 struct smb2_file_link_info_hdr link_info;
+17 -1
fs/smb/client/file.c
··· 998 998 999 999 /* Get the cached handle as SMB2 close is deferred */ 1000 1000 if (OPEN_FMODE(file->f_flags) & FMODE_WRITE) { 1001 - rc = cifs_get_writable_path(tcon, full_path, FIND_WR_FSUID_ONLY, &cfile); 1001 + rc = cifs_get_writable_path(tcon, full_path, 1002 + FIND_WR_FSUID_ONLY | 1003 + FIND_WR_NO_PENDING_DELETE, 1004 + &cfile); 1002 1005 } else { 1003 1006 rc = cifs_get_readable_path(tcon, full_path, &cfile); 1004 1007 } ··· 2533 2530 continue; 2534 2531 if (with_delete && !(open_file->fid.access & DELETE)) 2535 2532 continue; 2533 + if ((flags & FIND_WR_NO_PENDING_DELETE) && 2534 + open_file->status_file_deleted) 2535 + continue; 2536 2536 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { 2537 2537 if (!open_file->invalidHandle) { 2538 2538 /* found a good writable file */ ··· 2653 2647 spin_unlock(&tcon->open_file_lock); 2654 2648 free_dentry_path(page); 2655 2649 *ret_file = find_readable_file(cinode, 0); 2650 + if (*ret_file) { 2651 + spin_lock(&cinode->open_file_lock); 2652 + if ((*ret_file)->status_file_deleted) { 2653 + spin_unlock(&cinode->open_file_lock); 2654 + cifsFileInfo_put(*ret_file); 2655 + *ret_file = NULL; 2656 + } else { 2657 + spin_unlock(&cinode->open_file_lock); 2658 + } 2659 + } 2656 2660 return *ret_file ? 0 : -ENOENT; 2657 2661 } 2658 2662
+69 -17
fs/smb/client/inode.c
··· 1931 1931 * but will return the EACCES to the caller. Note that the VFS does not call 1932 1932 * unlink on negative dentries currently. 1933 1933 */ 1934 - int cifs_unlink(struct inode *dir, struct dentry *dentry) 1934 + static int __cifs_unlink(struct inode *dir, struct dentry *dentry, bool sillyrename) 1935 1935 { 1936 1936 int rc = 0; 1937 1937 unsigned int xid; ··· 2003 2003 goto psx_del_no_retry; 2004 2004 } 2005 2005 2006 - rc = server->ops->unlink(xid, tcon, full_path, cifs_sb, dentry); 2006 + if (sillyrename || (server->vals->protocol_id > SMB10_PROT_ID && 2007 + d_is_positive(dentry) && d_count(dentry) > 2)) 2008 + rc = -EBUSY; 2009 + else 2010 + rc = server->ops->unlink(xid, tcon, full_path, cifs_sb, dentry); 2007 2011 2008 2012 psx_del_no_retry: 2009 2013 if (!rc) { ··· 2073 2069 if (rehash) 2074 2070 d_rehash(dentry); 2075 2071 return rc; 2072 + } 2073 + 2074 + int cifs_unlink(struct inode *dir, struct dentry *dentry) 2075 + { 2076 + return __cifs_unlink(dir, dentry, false); 2076 2077 } 2077 2078 2078 2079 static int ··· 2367 2358 rc = server->ops->rmdir(xid, tcon, full_path, cifs_sb); 2368 2359 cifs_put_tlink(tlink); 2369 2360 2361 + cifsInode = CIFS_I(d_inode(direntry)); 2362 + 2370 2363 if (!rc) { 2364 + set_bit(CIFS_INO_DELETE_PENDING, &cifsInode->flags); 2371 2365 spin_lock(&d_inode(direntry)->i_lock); 2372 2366 i_size_write(d_inode(direntry), 0); 2373 2367 clear_nlink(d_inode(direntry)); 2374 2368 spin_unlock(&d_inode(direntry)->i_lock); 2375 2369 } 2376 2370 2377 - cifsInode = CIFS_I(d_inode(direntry)); 2378 2371 /* force revalidate to go get info when needed */ 2379 2372 cifsInode->time = 0; 2380 2373 ··· 2469 2458 } 2470 2459 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 2471 2460 do_rename_exit: 2472 - if (rc == 0) 2461 + if (rc == 0) { 2473 2462 d_move(from_dentry, to_dentry); 2463 + /* Force a new lookup */ 2464 + d_drop(from_dentry); 2465 + } 2474 2466 cifs_put_tlink(tlink); 2475 2467 return rc; 2476 2468 } ··· 2484 2470 struct dentry *target_dentry, unsigned int flags) 2485 2471 { 2486 2472 const char *from_name, *to_name; 2473 + struct TCP_Server_Info *server; 2487 2474 void *page1, *page2; 2488 2475 struct cifs_sb_info *cifs_sb; 2489 2476 struct tcon_link *tlink; ··· 2520 2505 if (IS_ERR(tlink)) 2521 2506 return PTR_ERR(tlink); 2522 2507 tcon = tlink_tcon(tlink); 2508 + server = tcon->ses->server; 2523 2509 2524 2510 page1 = alloc_dentry_path(); 2525 2511 page2 = alloc_dentry_path(); ··· 2607 2591 2608 2592 unlink_target: 2609 2593 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 2610 - 2611 - /* Try unlinking the target dentry if it's not negative */ 2612 - if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) { 2613 - if (d_is_dir(target_dentry)) 2614 - tmprc = cifs_rmdir(target_dir, target_dentry); 2615 - else 2616 - tmprc = cifs_unlink(target_dir, target_dentry); 2617 - if (tmprc) 2618 - goto cifs_rename_exit; 2619 - rc = cifs_do_rename(xid, source_dentry, from_name, 2620 - target_dentry, to_name); 2621 - if (!rc) 2622 - rehash = false; 2594 + if (d_really_is_positive(target_dentry)) { 2595 + if (!rc) { 2596 + struct inode *inode = d_inode(target_dentry); 2597 + /* 2598 + * Samba and ksmbd servers allow renaming a target 2599 + * directory that is open, so make sure to update 2600 + * ->i_nlink and then mark it as delete pending. 2601 + */ 2602 + if (S_ISDIR(inode->i_mode)) { 2603 + drop_cached_dir_by_name(xid, tcon, to_name, cifs_sb); 2604 + spin_lock(&inode->i_lock); 2605 + i_size_write(inode, 0); 2606 + clear_nlink(inode); 2607 + spin_unlock(&inode->i_lock); 2608 + set_bit(CIFS_INO_DELETE_PENDING, &CIFS_I(inode)->flags); 2609 + CIFS_I(inode)->time = 0; /* force reval */ 2610 + inode_set_ctime_current(inode); 2611 + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); 2612 + } 2613 + } else if (rc == -EACCES || rc == -EEXIST) { 2614 + /* 2615 + * Rename failed, possibly due to a busy target. 2616 + * Retry it by unliking the target first. 2617 + */ 2618 + if (d_is_dir(target_dentry)) { 2619 + tmprc = cifs_rmdir(target_dir, target_dentry); 2620 + } else { 2621 + tmprc = __cifs_unlink(target_dir, target_dentry, 2622 + server->vals->protocol_id > SMB10_PROT_ID); 2623 + } 2624 + if (tmprc) { 2625 + /* 2626 + * Some servers will return STATUS_ACCESS_DENIED 2627 + * or STATUS_DIRECTORY_NOT_EMPTY when failing to 2628 + * rename a non-empty directory. Make sure to 2629 + * propagate the appropriate error back to 2630 + * userspace. 2631 + */ 2632 + if (tmprc == -EEXIST || tmprc == -ENOTEMPTY) 2633 + rc = tmprc; 2634 + goto cifs_rename_exit; 2635 + } 2636 + rc = cifs_do_rename(xid, source_dentry, from_name, 2637 + target_dentry, to_name); 2638 + if (!rc) 2639 + rehash = false; 2640 + } 2623 2641 } 2624 2642 2625 2643 /* force revalidate to go get info when needed */ ··· 2679 2629 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 2680 2630 struct cached_fid *cfid = NULL; 2681 2631 2632 + if (test_bit(CIFS_INO_DELETE_PENDING, &cifs_i->flags)) 2633 + return false; 2682 2634 if (cifs_i->time == 0) 2683 2635 return true; 2684 2636
+1 -2
fs/smb/client/smb2glob.h
··· 30 30 SMB2_OP_QUERY_DIR, 31 31 SMB2_OP_MKDIR, 32 32 SMB2_OP_RENAME, 33 - SMB2_OP_DELETE, 34 33 SMB2_OP_HARDLINK, 35 34 SMB2_OP_SET_EOF, 36 - SMB2_OP_RMDIR, 35 + SMB2_OP_UNLINK, 37 36 SMB2_OP_POSIX_QUERY_INFO, 38 37 SMB2_OP_SET_REPARSE, 39 38 SMB2_OP_GET_REPARSE,
+162 -42
fs/smb/client/smb2inode.c
··· 346 346 trace_smb3_posix_query_info_compound_enter(xid, tcon->tid, 347 347 ses->Suid, full_path); 348 348 break; 349 - case SMB2_OP_DELETE: 350 - trace_smb3_delete_enter(xid, tcon->tid, ses->Suid, full_path); 351 - break; 352 349 case SMB2_OP_MKDIR: 353 350 /* 354 351 * Directories are created through parameters in the ··· 353 356 */ 354 357 trace_smb3_mkdir_enter(xid, tcon->tid, ses->Suid, full_path); 355 358 break; 356 - case SMB2_OP_RMDIR: 357 - rqst[num_rqst].rq_iov = &vars->si_iov[0]; 359 + case SMB2_OP_UNLINK: 360 + rqst[num_rqst].rq_iov = vars->unlink_iov; 358 361 rqst[num_rqst].rq_nvec = 1; 359 362 360 363 size[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */ 361 364 data[0] = &delete_pending[0]; 362 365 363 - rc = SMB2_set_info_init(tcon, server, 364 - &rqst[num_rqst], COMPOUND_FID, 365 - COMPOUND_FID, current->tgid, 366 - FILE_DISPOSITION_INFORMATION, 367 - SMB2_O_INFO_FILE, 0, data, size); 368 - if (rc) 366 + if (cfile) { 367 + rc = SMB2_set_info_init(tcon, server, 368 + &rqst[num_rqst], 369 + cfile->fid.persistent_fid, 370 + cfile->fid.volatile_fid, 371 + current->tgid, 372 + FILE_DISPOSITION_INFORMATION, 373 + SMB2_O_INFO_FILE, 0, 374 + data, size); 375 + } else { 376 + rc = SMB2_set_info_init(tcon, server, 377 + &rqst[num_rqst], 378 + COMPOUND_FID, 379 + COMPOUND_FID, 380 + current->tgid, 381 + FILE_DISPOSITION_INFORMATION, 382 + SMB2_O_INFO_FILE, 0, 383 + data, size); 384 + } 385 + if (!rc && (!cfile || num_rqst > 1)) { 386 + smb2_set_next_command(tcon, &rqst[num_rqst]); 387 + smb2_set_related(&rqst[num_rqst]); 388 + } else if (rc) { 369 389 goto finished; 370 - smb2_set_next_command(tcon, &rqst[num_rqst]); 371 - smb2_set_related(&rqst[num_rqst++]); 372 - trace_smb3_rmdir_enter(xid, tcon->tid, ses->Suid, full_path); 390 + } 391 + num_rqst++; 392 + trace_smb3_unlink_enter(xid, tcon->tid, ses->Suid, full_path); 373 393 break; 374 394 case SMB2_OP_SET_EOF: 375 395 rqst[num_rqst].rq_iov = &vars->si_iov[0]; ··· 456 442 ses->Suid, full_path); 457 443 break; 458 444 case SMB2_OP_RENAME: 459 - rqst[num_rqst].rq_iov = &vars->si_iov[0]; 445 + rqst[num_rqst].rq_iov = vars->rename_iov; 460 446 rqst[num_rqst].rq_nvec = 2; 461 447 462 448 len = in_iov[i].iov_len; ··· 746 732 trace_smb3_posix_query_info_compound_done(xid, tcon->tid, 747 733 ses->Suid); 748 734 break; 749 - case SMB2_OP_DELETE: 750 - if (rc) 751 - trace_smb3_delete_err(xid, tcon->tid, ses->Suid, rc); 752 - else { 753 - /* 754 - * If dentry (hence, inode) is NULL, lease break is going to 755 - * take care of degrading leases on handles for deleted files. 756 - */ 757 - if (inode) 758 - cifs_mark_open_handles_for_deleted_file(inode, full_path); 759 - trace_smb3_delete_done(xid, tcon->tid, ses->Suid); 760 - } 761 - break; 762 735 case SMB2_OP_MKDIR: 763 736 if (rc) 764 737 trace_smb3_mkdir_err(xid, tcon->tid, ses->Suid, rc); ··· 766 765 trace_smb3_rename_done(xid, tcon->tid, ses->Suid); 767 766 SMB2_set_info_free(&rqst[num_rqst++]); 768 767 break; 769 - case SMB2_OP_RMDIR: 770 - if (rc) 771 - trace_smb3_rmdir_err(xid, tcon->tid, ses->Suid, rc); 768 + case SMB2_OP_UNLINK: 769 + if (!rc) 770 + trace_smb3_unlink_done(xid, tcon->tid, ses->Suid); 772 771 else 773 - trace_smb3_rmdir_done(xid, tcon->tid, ses->Suid); 772 + trace_smb3_unlink_err(xid, tcon->tid, ses->Suid, rc); 774 773 SMB2_set_info_free(&rqst[num_rqst++]); 775 774 break; 776 775 case SMB2_OP_SET_EOF: ··· 1167 1166 FILE_OPEN, CREATE_NOT_FILE, ACL_NO_MODE); 1168 1167 return smb2_compound_op(xid, tcon, cifs_sb, 1169 1168 name, &oparms, NULL, 1170 - &(int){SMB2_OP_RMDIR}, 1, 1169 + &(int){SMB2_OP_UNLINK}, 1, 1171 1170 NULL, NULL, NULL, NULL); 1172 1171 } 1173 1172 ··· 1176 1175 struct cifs_sb_info *cifs_sb, struct dentry *dentry) 1177 1176 { 1178 1177 struct cifs_open_parms oparms; 1178 + struct inode *inode = NULL; 1179 + int rc; 1179 1180 1180 - oparms = CIFS_OPARMS(cifs_sb, tcon, name, 1181 - DELETE, FILE_OPEN, 1182 - CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT, 1183 - ACL_NO_MODE); 1184 - int rc = smb2_compound_op(xid, tcon, cifs_sb, name, &oparms, 1185 - NULL, &(int){SMB2_OP_DELETE}, 1, 1186 - NULL, NULL, NULL, dentry); 1181 + if (dentry) 1182 + inode = d_inode(dentry); 1183 + 1184 + oparms = CIFS_OPARMS(cifs_sb, tcon, name, DELETE, 1185 + FILE_OPEN, OPEN_REPARSE_POINT, ACL_NO_MODE); 1186 + rc = smb2_compound_op(xid, tcon, cifs_sb, name, &oparms, 1187 + NULL, &(int){SMB2_OP_UNLINK}, 1188 + 1, NULL, NULL, NULL, dentry); 1187 1189 if (rc == -EINVAL) { 1188 1190 cifs_dbg(FYI, "invalid lease key, resending request without lease"); 1189 1191 rc = smb2_compound_op(xid, tcon, cifs_sb, name, &oparms, 1190 - NULL, &(int){SMB2_OP_DELETE}, 1, 1191 - NULL, NULL, NULL, NULL); 1192 + NULL, &(int){SMB2_OP_UNLINK}, 1193 + 1, NULL, NULL, NULL, NULL); 1192 1194 } 1195 + /* 1196 + * If dentry (hence, inode) is NULL, lease break is going to 1197 + * take care of degrading leases on handles for deleted files. 1198 + */ 1199 + if (!rc && inode) 1200 + cifs_mark_open_handles_for_deleted_file(inode, name); 1193 1201 return rc; 1194 1202 } 1195 1203 ··· 1449 1439 data.reparse.io.buftype = CIFS_NO_BUFFER; 1450 1440 out: 1451 1441 cifs_free_open_info(&data); 1442 + return rc; 1443 + } 1444 + 1445 + static inline __le16 *utf16_smb2_path(struct cifs_sb_info *cifs_sb, 1446 + const char *name, size_t namelen) 1447 + { 1448 + int len; 1449 + 1450 + if (*name == '\\' || 1451 + (cifs_sb_master_tlink(cifs_sb) && 1452 + cifs_sb_master_tcon(cifs_sb)->posix_extensions && *name == '/')) 1453 + name++; 1454 + return cifs_strndup_to_utf16(name, namelen, &len, 1455 + cifs_sb->local_nls, 1456 + cifs_remap(cifs_sb)); 1457 + } 1458 + 1459 + int smb2_rename_pending_delete(const char *full_path, 1460 + struct dentry *dentry, 1461 + const unsigned int xid) 1462 + { 1463 + struct cifs_sb_info *cifs_sb = CIFS_SB(d_inode(dentry)->i_sb); 1464 + struct cifsInodeInfo *cinode = CIFS_I(d_inode(dentry)); 1465 + __le16 *utf16_path __free(kfree) = NULL; 1466 + __u32 co = file_create_options(dentry); 1467 + int cmds[] = { 1468 + SMB2_OP_SET_INFO, 1469 + SMB2_OP_RENAME, 1470 + SMB2_OP_UNLINK, 1471 + }; 1472 + const int num_cmds = ARRAY_SIZE(cmds); 1473 + char *to_name __free(kfree) = NULL; 1474 + __u32 attrs = cinode->cifsAttrs; 1475 + struct cifs_open_parms oparms; 1476 + static atomic_t sillycounter; 1477 + struct cifsFileInfo *cfile; 1478 + struct tcon_link *tlink; 1479 + struct cifs_tcon *tcon; 1480 + struct kvec iov[2]; 1481 + const char *ppath; 1482 + void *page; 1483 + size_t len; 1484 + int rc; 1485 + 1486 + tlink = cifs_sb_tlink(cifs_sb); 1487 + if (IS_ERR(tlink)) 1488 + return PTR_ERR(tlink); 1489 + tcon = tlink_tcon(tlink); 1490 + 1491 + page = alloc_dentry_path(); 1492 + 1493 + ppath = build_path_from_dentry(dentry->d_parent, page); 1494 + if (IS_ERR(ppath)) { 1495 + rc = PTR_ERR(ppath); 1496 + goto out; 1497 + } 1498 + 1499 + len = strlen(ppath) + strlen("/.__smb1234") + 1; 1500 + to_name = kmalloc(len, GFP_KERNEL); 1501 + if (!to_name) { 1502 + rc = -ENOMEM; 1503 + goto out; 1504 + } 1505 + 1506 + scnprintf(to_name, len, "%s%c.__smb%04X", ppath, CIFS_DIR_SEP(cifs_sb), 1507 + atomic_inc_return(&sillycounter) & 0xffff); 1508 + 1509 + utf16_path = utf16_smb2_path(cifs_sb, to_name, len); 1510 + if (!utf16_path) { 1511 + rc = -ENOMEM; 1512 + goto out; 1513 + } 1514 + 1515 + drop_cached_dir_by_name(xid, tcon, full_path, cifs_sb); 1516 + oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, 1517 + DELETE | FILE_WRITE_ATTRIBUTES, 1518 + FILE_OPEN, co, ACL_NO_MODE); 1519 + 1520 + attrs &= ~ATTR_READONLY; 1521 + if (!attrs) 1522 + attrs = ATTR_NORMAL; 1523 + if (d_inode(dentry)->i_nlink <= 1) 1524 + attrs |= ATTR_HIDDEN; 1525 + iov[0].iov_base = &(FILE_BASIC_INFO) { 1526 + .Attributes = cpu_to_le32(attrs), 1527 + }; 1528 + iov[0].iov_len = sizeof(FILE_BASIC_INFO); 1529 + iov[1].iov_base = utf16_path; 1530 + iov[1].iov_len = sizeof(*utf16_path) * UniStrlen((wchar_t *)utf16_path); 1531 + 1532 + cifs_get_writable_path(tcon, full_path, FIND_WR_WITH_DELETE, &cfile); 1533 + rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, &oparms, iov, 1534 + cmds, num_cmds, cfile, NULL, NULL, dentry); 1535 + if (rc == -EINVAL) { 1536 + cifs_dbg(FYI, "invalid lease key, resending request without lease\n"); 1537 + cifs_get_writable_path(tcon, full_path, 1538 + FIND_WR_WITH_DELETE, &cfile); 1539 + rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, &oparms, iov, 1540 + cmds, num_cmds, cfile, NULL, NULL, NULL); 1541 + } 1542 + if (!rc) { 1543 + set_bit(CIFS_INO_DELETE_PENDING, &cinode->flags); 1544 + } else { 1545 + cifs_tcon_dbg(FYI, "%s: failed to rename '%s' to '%s': %d\n", 1546 + __func__, full_path, to_name, rc); 1547 + rc = -EIO; 1548 + } 1549 + out: 1550 + cifs_put_tlink(tlink); 1551 + free_dentry_path(page); 1452 1552 return rc; 1453 1553 }
+29 -3
fs/smb/client/smb2ops.c
··· 2640 2640 } 2641 2641 2642 2642 /* SMB headers in a compound are 8 byte aligned. */ 2643 - if (!IS_ALIGNED(len, 8)) { 2644 - num_padding = 8 - (len & 7); 2643 + if (IS_ALIGNED(len, 8)) 2644 + goto out; 2645 + 2646 + num_padding = 8 - (len & 7); 2647 + if (smb3_encryption_required(tcon)) { 2648 + int i; 2649 + 2650 + /* 2651 + * Flatten request into a single buffer with required padding as 2652 + * the encryption layer can't handle the padding iovs. 2653 + */ 2654 + for (i = 1; i < rqst->rq_nvec; i++) { 2655 + memcpy(rqst->rq_iov[0].iov_base + 2656 + rqst->rq_iov[0].iov_len, 2657 + rqst->rq_iov[i].iov_base, 2658 + rqst->rq_iov[i].iov_len); 2659 + rqst->rq_iov[0].iov_len += rqst->rq_iov[i].iov_len; 2660 + } 2661 + memset(rqst->rq_iov[0].iov_base + rqst->rq_iov[0].iov_len, 2662 + 0, num_padding); 2663 + rqst->rq_iov[0].iov_len += num_padding; 2664 + rqst->rq_nvec = 1; 2665 + } else { 2645 2666 rqst->rq_iov[rqst->rq_nvec].iov_base = smb2_padding; 2646 2667 rqst->rq_iov[rqst->rq_nvec].iov_len = num_padding; 2647 2668 rqst->rq_nvec++; 2648 - len += num_padding; 2649 2669 } 2670 + len += num_padding; 2671 + out: 2650 2672 shdr->NextCommand = cpu_to_le32(len); 2651 2673 } 2652 2674 ··· 5398 5376 .llseek = smb3_llseek, 5399 5377 .is_status_io_timeout = smb2_is_status_io_timeout, 5400 5378 .is_network_name_deleted = smb2_is_network_name_deleted, 5379 + .rename_pending_delete = smb2_rename_pending_delete, 5401 5380 }; 5402 5381 #endif /* CIFS_ALLOW_INSECURE_LEGACY */ 5403 5382 ··· 5504 5481 .llseek = smb3_llseek, 5505 5482 .is_status_io_timeout = smb2_is_status_io_timeout, 5506 5483 .is_network_name_deleted = smb2_is_network_name_deleted, 5484 + .rename_pending_delete = smb2_rename_pending_delete, 5507 5485 }; 5508 5486 5509 5487 struct smb_version_operations smb30_operations = { ··· 5621 5597 .llseek = smb3_llseek, 5622 5598 .is_status_io_timeout = smb2_is_status_io_timeout, 5623 5599 .is_network_name_deleted = smb2_is_network_name_deleted, 5600 + .rename_pending_delete = smb2_rename_pending_delete, 5624 5601 }; 5625 5602 5626 5603 struct smb_version_operations smb311_operations = { ··· 5738 5713 .llseek = smb3_llseek, 5739 5714 .is_status_io_timeout = smb2_is_status_io_timeout, 5740 5715 .is_network_name_deleted = smb2_is_network_name_deleted, 5716 + .rename_pending_delete = smb2_rename_pending_delete, 5741 5717 }; 5742 5718 5743 5719 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
+3
fs/smb/client/smb2proto.h
··· 317 317 int smb2_make_nfs_node(unsigned int xid, struct inode *inode, 318 318 struct dentry *dentry, struct cifs_tcon *tcon, 319 319 const char *full_path, umode_t mode, dev_t dev); 320 + int smb2_rename_pending_delete(const char *full_path, 321 + struct dentry *dentry, 322 + const unsigned int xid); 320 323 321 324 #endif /* _SMB2PROTO_H */
+3 -6
fs/smb/client/trace.h
··· 669 669 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(posix_query_info_compound_enter); 670 670 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(hardlink_enter); 671 671 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rename_enter); 672 - DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(rmdir_enter); 672 + DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(unlink_enter); 673 673 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter); 674 674 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter); 675 675 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_reparse_compound_enter); 676 676 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(get_reparse_compound_enter); 677 677 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(query_wsl_ea_compound_enter); 678 - DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter); 679 678 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter); 680 679 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter); 681 680 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mknod_enter); ··· 709 710 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(posix_query_info_compound_done); 710 711 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(hardlink_done); 711 712 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rename_done); 712 - DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(rmdir_done); 713 + DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(unlink_done); 713 714 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done); 714 715 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done); 715 716 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_reparse_compound_done); 716 717 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(get_reparse_compound_done); 717 718 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(query_wsl_ea_compound_done); 718 - DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done); 719 719 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done); 720 720 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done); 721 721 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mknod_done); ··· 754 756 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(posix_query_info_compound_err); 755 757 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(hardlink_err); 756 758 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rename_err); 757 - DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(rmdir_err); 759 + DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(unlink_err); 758 760 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err); 759 761 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err); 760 762 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_reparse_compound_err); 761 763 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(get_reparse_compound_err); 762 764 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(query_wsl_ea_compound_err); 763 765 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err); 764 - DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err); 765 766 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err); 766 767 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mknod_err); 767 768
+126 -59
fs/smb/server/transport_rdma.c
··· 554 554 case SMB_DIRECT_MSG_DATA_TRANSFER: { 555 555 struct smb_direct_data_transfer *data_transfer = 556 556 (struct smb_direct_data_transfer *)recvmsg->packet; 557 - unsigned int data_length; 557 + u32 remaining_data_length, data_offset, data_length; 558 558 int avail_recvmsg_count, receive_credits; 559 559 560 560 if (wc->byte_len < ··· 564 564 return; 565 565 } 566 566 567 + remaining_data_length = le32_to_cpu(data_transfer->remaining_data_length); 567 568 data_length = le32_to_cpu(data_transfer->data_length); 568 - if (data_length) { 569 - if (wc->byte_len < sizeof(struct smb_direct_data_transfer) + 570 - (u64)data_length) { 571 - put_recvmsg(t, recvmsg); 572 - smb_direct_disconnect_rdma_connection(t); 573 - return; 574 - } 569 + data_offset = le32_to_cpu(data_transfer->data_offset); 570 + if (wc->byte_len < data_offset || 571 + wc->byte_len < (u64)data_offset + data_length) { 572 + put_recvmsg(t, recvmsg); 573 + smb_direct_disconnect_rdma_connection(t); 574 + return; 575 + } 576 + if (remaining_data_length > t->max_fragmented_recv_size || 577 + data_length > t->max_fragmented_recv_size || 578 + (u64)remaining_data_length + (u64)data_length > 579 + (u64)t->max_fragmented_recv_size) { 580 + put_recvmsg(t, recvmsg); 581 + smb_direct_disconnect_rdma_connection(t); 582 + return; 583 + } 575 584 585 + if (data_length) { 576 586 if (t->full_packet_received) 577 587 recvmsg->first_segment = true; 578 588 ··· 1219 1209 bool need_invalidate, unsigned int remote_key) 1220 1210 { 1221 1211 struct smb_direct_transport *st = smb_trans_direct_transfort(t); 1222 - int remaining_data_length; 1223 - int start, i, j; 1224 - int max_iov_size = st->max_send_size - 1212 + size_t remaining_data_length; 1213 + size_t iov_idx; 1214 + size_t iov_ofs; 1215 + size_t max_iov_size = st->max_send_size - 1225 1216 sizeof(struct smb_direct_data_transfer); 1226 1217 int ret; 1227 - struct kvec vec; 1228 1218 struct smb_direct_send_ctx send_ctx; 1219 + int error = 0; 1229 1220 1230 1221 if (st->status != SMB_DIRECT_CS_CONNECTED) 1231 1222 return -ENOTCONN; 1232 1223 1233 1224 //FIXME: skip RFC1002 header.. 1225 + if (WARN_ON_ONCE(niovs <= 1 || iov[0].iov_len != 4)) 1226 + return -EINVAL; 1234 1227 buflen -= 4; 1228 + iov_idx = 1; 1229 + iov_ofs = 0; 1235 1230 1236 1231 remaining_data_length = buflen; 1237 1232 ksmbd_debug(RDMA, "Sending smb (RDMA): smb_len=%u\n", buflen); 1238 1233 1239 1234 smb_direct_send_ctx_init(st, &send_ctx, need_invalidate, remote_key); 1240 - start = i = 1; 1241 - buflen = 0; 1242 - while (true) { 1243 - buflen += iov[i].iov_len; 1244 - if (buflen > max_iov_size) { 1245 - if (i > start) { 1246 - remaining_data_length -= 1247 - (buflen - iov[i].iov_len); 1248 - ret = smb_direct_post_send_data(st, &send_ctx, 1249 - &iov[start], i - start, 1250 - remaining_data_length); 1251 - if (ret) 1252 - goto done; 1253 - } else { 1254 - /* iov[start] is too big, break it */ 1255 - int nvec = (buflen + max_iov_size - 1) / 1256 - max_iov_size; 1235 + while (remaining_data_length) { 1236 + struct kvec vecs[SMB_DIRECT_MAX_SEND_SGES - 1]; /* minus smbdirect hdr */ 1237 + size_t possible_bytes = max_iov_size; 1238 + size_t possible_vecs; 1239 + size_t bytes = 0; 1240 + size_t nvecs = 0; 1257 1241 1258 - for (j = 0; j < nvec; j++) { 1259 - vec.iov_base = 1260 - (char *)iov[start].iov_base + 1261 - j * max_iov_size; 1262 - vec.iov_len = 1263 - min_t(int, max_iov_size, 1264 - buflen - max_iov_size * j); 1265 - remaining_data_length -= vec.iov_len; 1266 - ret = smb_direct_post_send_data(st, &send_ctx, &vec, 1, 1267 - remaining_data_length); 1268 - if (ret) 1269 - goto done; 1270 - } 1271 - i++; 1272 - if (i == niovs) 1273 - break; 1274 - } 1275 - start = i; 1276 - buflen = 0; 1277 - } else { 1278 - i++; 1279 - if (i == niovs) { 1280 - /* send out all remaining vecs */ 1281 - remaining_data_length -= buflen; 1282 - ret = smb_direct_post_send_data(st, &send_ctx, 1283 - &iov[start], i - start, 1284 - remaining_data_length); 1285 - if (ret) 1242 + /* 1243 + * For the last message remaining_data_length should be 1244 + * have been 0 already! 1245 + */ 1246 + if (WARN_ON_ONCE(iov_idx >= niovs)) { 1247 + error = -EINVAL; 1248 + goto done; 1249 + } 1250 + 1251 + /* 1252 + * We have 2 factors which limit the arguments we pass 1253 + * to smb_direct_post_send_data(): 1254 + * 1255 + * 1. The number of supported sges for the send, 1256 + * while one is reserved for the smbdirect header. 1257 + * And we currently need one SGE per page. 1258 + * 2. The number of negotiated payload bytes per send. 1259 + */ 1260 + possible_vecs = min_t(size_t, ARRAY_SIZE(vecs), niovs - iov_idx); 1261 + 1262 + while (iov_idx < niovs && possible_vecs && possible_bytes) { 1263 + struct kvec *v = &vecs[nvecs]; 1264 + int page_count; 1265 + 1266 + v->iov_base = ((u8 *)iov[iov_idx].iov_base) + iov_ofs; 1267 + v->iov_len = min_t(size_t, 1268 + iov[iov_idx].iov_len - iov_ofs, 1269 + possible_bytes); 1270 + page_count = get_buf_page_count(v->iov_base, v->iov_len); 1271 + if (page_count > possible_vecs) { 1272 + /* 1273 + * If the number of pages in the buffer 1274 + * is to much (because we currently require 1275 + * one SGE per page), we need to limit the 1276 + * length. 1277 + * 1278 + * We know possible_vecs is at least 1, 1279 + * so we always keep the first page. 1280 + * 1281 + * We need to calculate the number extra 1282 + * pages (epages) we can also keep. 1283 + * 1284 + * We calculate the number of bytes in the 1285 + * first page (fplen), this should never be 1286 + * larger than v->iov_len because page_count is 1287 + * at least 2, but adding a limitation feels 1288 + * better. 1289 + * 1290 + * Then we calculate the number of bytes (elen) 1291 + * we can keep for the extra pages. 1292 + */ 1293 + size_t epages = possible_vecs - 1; 1294 + size_t fpofs = offset_in_page(v->iov_base); 1295 + size_t fplen = min_t(size_t, PAGE_SIZE - fpofs, v->iov_len); 1296 + size_t elen = min_t(size_t, v->iov_len - fplen, epages*PAGE_SIZE); 1297 + 1298 + v->iov_len = fplen + elen; 1299 + page_count = get_buf_page_count(v->iov_base, v->iov_len); 1300 + if (WARN_ON_ONCE(page_count > possible_vecs)) { 1301 + /* 1302 + * Something went wrong in the above 1303 + * logic... 1304 + */ 1305 + error = -EINVAL; 1286 1306 goto done; 1287 - break; 1307 + } 1288 1308 } 1309 + possible_vecs -= page_count; 1310 + nvecs += 1; 1311 + possible_bytes -= v->iov_len; 1312 + bytes += v->iov_len; 1313 + 1314 + iov_ofs += v->iov_len; 1315 + if (iov_ofs >= iov[iov_idx].iov_len) { 1316 + iov_idx += 1; 1317 + iov_ofs = 0; 1318 + } 1319 + } 1320 + 1321 + remaining_data_length -= bytes; 1322 + 1323 + ret = smb_direct_post_send_data(st, &send_ctx, 1324 + vecs, nvecs, 1325 + remaining_data_length); 1326 + if (unlikely(ret)) { 1327 + error = ret; 1328 + goto done; 1289 1329 } 1290 1330 } 1291 1331 1292 1332 done: 1293 1333 ret = smb_direct_flush_send_list(st, &send_ctx, true); 1334 + if (unlikely(!ret && error)) 1335 + ret = error; 1294 1336 1295 1337 /* 1296 1338 * As an optimization, we don't wait for individual I/O to finish ··· 1806 1744 return -EINVAL; 1807 1745 } 1808 1746 1747 + if (device->attrs.max_send_sge < SMB_DIRECT_MAX_SEND_SGES) { 1748 + pr_err("warning: device max_send_sge = %d too small\n", 1749 + device->attrs.max_send_sge); 1750 + return -EINVAL; 1751 + } 1809 1752 if (device->attrs.max_recv_sge < SMB_DIRECT_MAX_RECV_SGES) { 1810 1753 pr_err("warning: device max_recv_sge = %d too small\n", 1811 1754 device->attrs.max_recv_sge); ··· 1834 1767 1835 1768 cap->max_send_wr = max_send_wrs; 1836 1769 cap->max_recv_wr = t->recv_credit_max; 1837 - cap->max_send_sge = max_sge_per_wr; 1770 + cap->max_send_sge = SMB_DIRECT_MAX_SEND_SGES; 1838 1771 cap->max_recv_sge = SMB_DIRECT_MAX_RECV_SGES; 1839 1772 cap->max_inline_data = 0; 1840 1773 cap->max_rdma_ctxs = t->max_rw_credits;
+6 -3
include/kvm/arm_vgic.h
··· 8 8 #include <linux/bits.h> 9 9 #include <linux/kvm.h> 10 10 #include <linux/irqreturn.h> 11 - #include <linux/kref.h> 12 11 #include <linux/mutex.h> 12 + #include <linux/refcount.h> 13 13 #include <linux/spinlock.h> 14 14 #include <linux/static_key.h> 15 15 #include <linux/types.h> ··· 139 139 bool pending_latch; /* The pending latch state used to calculate 140 140 * the pending state for both level 141 141 * and edge triggered IRQs. */ 142 - bool active; /* not used for LPIs */ 142 + bool active; 143 + bool pending_release; /* Used for LPIs only, unreferenced IRQ 144 + * pending a release */ 145 + 143 146 bool enabled; 144 147 bool hw; /* Tied to HW IRQ */ 145 - struct kref refcount; /* Used for LPIs */ 148 + refcount_t refcount; /* Used for LPIs */ 146 149 u32 hwintid; /* HW INTID number */ 147 150 unsigned int host_irq; /* linux irq corresponding to hwintid */ 148 151 union {
+2
include/linux/damon.h
··· 636 636 * @data: Data that will be passed to @fn. 637 637 * @repeat: Repeat invocations. 638 638 * @return_code: Return code from @fn invocation. 639 + * @dealloc_on_cancel: De-allocate when canceled. 639 640 * 640 641 * Control damon_call(), which requests specific kdamond to invoke a given 641 642 * function. Refer to damon_call() for more details. ··· 646 645 void *data; 647 646 bool repeat; 648 647 int return_code; 648 + bool dealloc_on_cancel; 649 649 /* private: internal use only */ 650 650 /* informs if the kdamond finished handling of the request */ 651 651 struct completion completion;
+1
include/linux/mlx5/driver.h
··· 665 665 bool tisn_valid; 666 666 } hw_objs; 667 667 struct net_device *uplink_netdev; 668 + netdevice_tracker tracker; 668 669 struct mutex uplink_netdev_lock; 669 670 struct mlx5_crypto_dek_priv *dek_priv; 670 671 };
+10
include/linux/swap.h
··· 385 385 void mark_page_accessed(struct page *); 386 386 void folio_mark_accessed(struct folio *); 387 387 388 + static inline bool folio_may_be_lru_cached(struct folio *folio) 389 + { 390 + /* 391 + * Holding PMD-sized folios in per-CPU LRU cache unbalances accounting. 392 + * Holding small numbers of low-order mTHP folios in per-CPU LRU cache 393 + * will be sensible, but nobody has implemented and tested that yet. 394 + */ 395 + return !folio_test_large(folio); 396 + } 397 + 388 398 extern atomic_t lru_disable_count; 389 399 390 400 static inline bool lru_cache_disabled(void)
+9 -2
include/net/dst_metadata.h
··· 3 3 #define __NET_DST_METADATA_H 1 4 4 5 5 #include <linux/skbuff.h> 6 + #include <net/ip.h> 6 7 #include <net/ip_tunnels.h> 7 8 #include <net/macsec.h> 8 9 #include <net/dst.h> ··· 221 220 int md_size) 222 221 { 223 222 const struct iphdr *iph = ip_hdr(skb); 223 + struct metadata_dst *tun_dst; 224 224 225 - return __ip_tun_set_dst(iph->saddr, iph->daddr, iph->tos, iph->ttl, 226 - 0, flags, tunnel_id, md_size); 225 + tun_dst = __ip_tun_set_dst(iph->saddr, iph->daddr, iph->tos, iph->ttl, 226 + 0, flags, tunnel_id, md_size); 227 + 228 + if (tun_dst && (iph->frag_off & htons(IP_DF))) 229 + __set_bit(IP_TUNNEL_DONT_FRAGMENT_BIT, 230 + tun_dst->u.tun_info.key.tun_flags); 231 + return tun_dst; 227 232 } 228 233 229 234 static inline struct metadata_dst *__ipv6_tun_set_dst(const struct in6_addr *saddr,
+3 -2
include/net/sock.h
··· 2067 2067 if (sock) { 2068 2068 WRITE_ONCE(sk->sk_uid, SOCK_INODE(sock)->i_uid); 2069 2069 WRITE_ONCE(sk->sk_ino, SOCK_INODE(sock)->i_ino); 2070 + } else { 2071 + /* Note: sk_uid is unchanged. */ 2072 + WRITE_ONCE(sk->sk_ino, 0); 2070 2073 } 2071 2074 } 2072 2075 ··· 2091 2088 sock_set_flag(sk, SOCK_DEAD); 2092 2089 sk_set_socket(sk, NULL); 2093 2090 sk->sk_wq = NULL; 2094 - /* Note: sk_uid is unchanged. */ 2095 - WRITE_ONCE(sk->sk_ino, 0); 2096 2091 write_unlock_bh(&sk->sk_callback_lock); 2097 2092 } 2098 2093
+2
include/uapi/linux/mptcp.h
··· 31 31 #define MPTCP_INFO_FLAG_FALLBACK _BITUL(0) 32 32 #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) 33 33 34 + #define MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 _BITUL(0) 35 + 34 36 #define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) 35 37 #define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) 36 38 #define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
+2 -2
include/uapi/linux/mptcp_pm.h
··· 16 16 * good time to allocate memory and send ADD_ADDR if needed. Depending on the 17 17 * traffic-patterns it can take a long time until the MPTCP_EVENT_ESTABLISHED 18 18 * is sent. Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, 19 - * sport, dport, server-side. 19 + * sport, dport, server-side, [flags]. 20 20 * @MPTCP_EVENT_ESTABLISHED: A MPTCP connection is established (can start new 21 21 * subflows). Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, 22 - * sport, dport, server-side. 22 + * sport, dport, server-side, [flags]. 23 23 * @MPTCP_EVENT_CLOSED: A MPTCP connection has stopped. Attribute: token. 24 24 * @MPTCP_EVENT_ANNOUNCED: A new address has been announced by the peer. 25 25 * Attributes: token, rem_id, family, daddr4 | daddr6 [, dport].
+37 -7
kernel/cgroup/cgroup.c
··· 126 126 * of concurrent destructions. Use a separate workqueue so that cgroup 127 127 * destruction work items don't end up filling up max_active of system_wq 128 128 * which may lead to deadlock. 129 + * 130 + * A cgroup destruction should enqueue work sequentially to: 131 + * cgroup_offline_wq: use for css offline work 132 + * cgroup_release_wq: use for css release work 133 + * cgroup_free_wq: use for free work 134 + * 135 + * Rationale for using separate workqueues: 136 + * The cgroup root free work may depend on completion of other css offline 137 + * operations. If all tasks were enqueued to a single workqueue, this could 138 + * create a deadlock scenario where: 139 + * - Free work waits for other css offline work to complete. 140 + * - But other css offline work is queued after free work in the same queue. 141 + * 142 + * Example deadlock scenario with single workqueue (cgroup_destroy_wq): 143 + * 1. umount net_prio 144 + * 2. net_prio root destruction enqueues work to cgroup_destroy_wq (CPUx) 145 + * 3. perf_event CSS A offline enqueues work to same cgroup_destroy_wq (CPUx) 146 + * 4. net_prio cgroup_destroy_root->cgroup_lock_and_drain_offline. 147 + * 5. net_prio root destruction blocks waiting for perf_event CSS A offline, 148 + * which can never complete as it's behind in the same queue and 149 + * workqueue's max_active is 1. 129 150 */ 130 - static struct workqueue_struct *cgroup_destroy_wq; 151 + static struct workqueue_struct *cgroup_offline_wq; 152 + static struct workqueue_struct *cgroup_release_wq; 153 + static struct workqueue_struct *cgroup_free_wq; 131 154 132 155 /* generate an array of cgroup subsystem pointers */ 133 156 #define SUBSYS(_x) [_x ## _cgrp_id] = &_x ## _cgrp_subsys, ··· 4182 4159 cft->release(of); 4183 4160 put_cgroup_ns(ctx->ns); 4184 4161 kfree(ctx); 4162 + of->priv = NULL; 4185 4163 } 4186 4164 4187 4165 static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, ··· 5582 5558 cgroup_unlock(); 5583 5559 5584 5560 INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn); 5585 - queue_rcu_work(cgroup_destroy_wq, &css->destroy_rwork); 5561 + queue_rcu_work(cgroup_free_wq, &css->destroy_rwork); 5586 5562 } 5587 5563 5588 5564 static void css_release(struct percpu_ref *ref) ··· 5591 5567 container_of(ref, struct cgroup_subsys_state, refcnt); 5592 5568 5593 5569 INIT_WORK(&css->destroy_work, css_release_work_fn); 5594 - queue_work(cgroup_destroy_wq, &css->destroy_work); 5570 + queue_work(cgroup_release_wq, &css->destroy_work); 5595 5571 } 5596 5572 5597 5573 static void init_and_link_css(struct cgroup_subsys_state *css, ··· 5725 5701 list_del_rcu(&css->sibling); 5726 5702 err_free_css: 5727 5703 INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn); 5728 - queue_rcu_work(cgroup_destroy_wq, &css->destroy_rwork); 5704 + queue_rcu_work(cgroup_free_wq, &css->destroy_rwork); 5729 5705 return ERR_PTR(err); 5730 5706 } 5731 5707 ··· 5963 5939 5964 5940 if (atomic_dec_and_test(&css->online_cnt)) { 5965 5941 INIT_WORK(&css->destroy_work, css_killed_work_fn); 5966 - queue_work(cgroup_destroy_wq, &css->destroy_work); 5942 + queue_work(cgroup_offline_wq, &css->destroy_work); 5967 5943 } 5968 5944 } 5969 5945 ··· 6349 6325 * We would prefer to do this in cgroup_init() above, but that 6350 6326 * is called before init_workqueues(): so leave this until after. 6351 6327 */ 6352 - cgroup_destroy_wq = alloc_workqueue("cgroup_destroy", 0, 1); 6353 - BUG_ON(!cgroup_destroy_wq); 6328 + cgroup_offline_wq = alloc_workqueue("cgroup_offline", 0, 1); 6329 + BUG_ON(!cgroup_offline_wq); 6330 + 6331 + cgroup_release_wq = alloc_workqueue("cgroup_release", 0, 1); 6332 + BUG_ON(!cgroup_release_wq); 6333 + 6334 + cgroup_free_wq = alloc_workqueue("cgroup_free", 0, 1); 6335 + BUG_ON(!cgroup_free_wq); 6354 6336 return 0; 6355 6337 } 6356 6338 core_initcall(cgroup_wq_init);
+1 -1
kernel/sched/core.c
··· 9551 9551 #ifdef CONFIG_FAIR_GROUP_SCHED 9552 9552 return scale_load_down(tg->shares); 9553 9553 #else 9554 - return sched_weight_from_cgroup(tg->scx_weight); 9554 + return sched_weight_from_cgroup(tg->scx.weight); 9555 9555 #endif 9556 9556 } 9557 9557
+1 -5
kernel/sched/ext.c
··· 6788 6788 * CPUs disagree, they use %ENQUEUE_RESTORE which is bypassed to 6789 6789 * the current local DSQ for running tasks and thus are not 6790 6790 * visible to the BPF scheduler. 6791 - * 6792 - * Also skip re-enqueueing tasks that can only run on this 6793 - * CPU, as they would just be re-added to the same local 6794 - * DSQ without any benefit. 6795 6791 */ 6796 - if (p->migration_pending || is_migration_disabled(p) || p->nr_cpus_allowed == 1) 6792 + if (p->migration_pending) 6797 6793 continue; 6798 6794 6799 6795 dispatch_dequeue(rq, p);
+3 -8
kernel/time/hrtimer.c
··· 787 787 * of the next expiring timer is enough. The return from the SMP 788 788 * function call will take care of the reprogramming in case the 789 789 * CPU was in a NOHZ idle sleep. 790 + * 791 + * In periodic low resolution mode, the next softirq expiration 792 + * must also be updated. 790 793 */ 791 - if (!hrtimer_hres_active(base) && !tick_nohz_active) 792 - return; 793 - 794 794 raw_spin_lock(&base->lock); 795 795 hrtimer_update_base(base); 796 796 if (hrtimer_hres_active(base)) ··· 2295 2295 &new_base->clock_base[i]); 2296 2296 } 2297 2297 2298 - /* 2299 - * The migration might have changed the first expiring softirq 2300 - * timer on this CPU. Update it. 2301 - */ 2302 - __hrtimer_get_next_event(new_base, HRTIMER_ACTIVE_SOFT); 2303 2298 /* Tell the other CPU to retrigger the next event */ 2304 2299 smp_call_function_single(ncpu, retrigger_next_event, NULL, 0); 2305 2300
+2
kernel/trace/trace_kprobe.c
··· 908 908 return -EINVAL; 909 909 } 910 910 buf = kmemdup(&argv[0][1], len + 1, GFP_KERNEL); 911 + if (!buf) 912 + return -ENOMEM; 911 913 buf[len] = '\0'; 912 914 ret = kstrtouint(buf, 0, &maxactive); 913 915 if (ret || !maxactive) {
+6 -2
mm/damon/core.c
··· 2479 2479 mutex_lock(&ctx->call_controls_lock); 2480 2480 list_del(&control->list); 2481 2481 mutex_unlock(&ctx->call_controls_lock); 2482 - if (!control->repeat) 2482 + if (!control->repeat) { 2483 2483 complete(&control->completion); 2484 - else 2484 + } else if (control->canceled && control->dealloc_on_cancel) { 2485 + kfree(control); 2486 + continue; 2487 + } else { 2485 2488 list_add(&control->list, &repeat_controls); 2489 + } 2486 2490 } 2487 2491 control = list_first_entry_or_null(&repeat_controls, 2488 2492 struct damon_call_control, list);
+15 -8
mm/damon/sysfs.c
··· 1534 1534 return 0; 1535 1535 } 1536 1536 1537 - static struct damon_call_control damon_sysfs_repeat_call_control = { 1538 - .fn = damon_sysfs_repeat_call_fn, 1539 - .repeat = true, 1540 - }; 1541 - 1542 1537 static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond) 1543 1538 { 1544 1539 struct damon_ctx *ctx; 1540 + struct damon_call_control *repeat_call_control; 1545 1541 int err; 1546 1542 1547 1543 if (damon_sysfs_kdamond_running(kdamond)) ··· 1550 1554 damon_destroy_ctx(kdamond->damon_ctx); 1551 1555 kdamond->damon_ctx = NULL; 1552 1556 1557 + repeat_call_control = kmalloc(sizeof(*repeat_call_control), 1558 + GFP_KERNEL); 1559 + if (!repeat_call_control) 1560 + return -ENOMEM; 1561 + 1553 1562 ctx = damon_sysfs_build_ctx(kdamond->contexts->contexts_arr[0]); 1554 - if (IS_ERR(ctx)) 1563 + if (IS_ERR(ctx)) { 1564 + kfree(repeat_call_control); 1555 1565 return PTR_ERR(ctx); 1566 + } 1556 1567 err = damon_start(&ctx, 1, false); 1557 1568 if (err) { 1569 + kfree(repeat_call_control); 1558 1570 damon_destroy_ctx(ctx); 1559 1571 return err; 1560 1572 } 1561 1573 kdamond->damon_ctx = ctx; 1562 1574 1563 - damon_sysfs_repeat_call_control.data = kdamond; 1564 - damon_call(ctx, &damon_sysfs_repeat_call_control); 1575 + repeat_call_control->fn = damon_sysfs_repeat_call_fn; 1576 + repeat_call_control->data = kdamond; 1577 + repeat_call_control->repeat = true; 1578 + repeat_call_control->dealloc_on_cancel = true; 1579 + damon_call(ctx, repeat_call_control); 1565 1580 return err; 1566 1581 } 1567 1582
+11 -3
mm/gup.c
··· 2287 2287 struct pages_or_folios *pofs) 2288 2288 { 2289 2289 unsigned long collected = 0; 2290 - bool drain_allow = true; 2291 2290 struct folio *folio; 2291 + int drained = 0; 2292 2292 long i = 0; 2293 2293 2294 2294 for (folio = pofs_get_folio(pofs, i); folio; ··· 2307 2307 continue; 2308 2308 } 2309 2309 2310 - if (!folio_test_lru(folio) && drain_allow) { 2310 + if (drained == 0 && folio_may_be_lru_cached(folio) && 2311 + folio_ref_count(folio) != 2312 + folio_expected_ref_count(folio) + 1) { 2313 + lru_add_drain(); 2314 + drained = 1; 2315 + } 2316 + if (drained == 1 && folio_may_be_lru_cached(folio) && 2317 + folio_ref_count(folio) != 2318 + folio_expected_ref_count(folio) + 1) { 2311 2319 lru_add_drain_all(); 2312 - drain_allow = false; 2320 + drained = 2; 2313 2321 } 2314 2322 2315 2323 if (!folio_isolate_lru(folio))
+3 -3
mm/mlock.c
··· 255 255 256 256 folio_get(folio); 257 257 if (!folio_batch_add(fbatch, mlock_lru(folio)) || 258 - folio_test_large(folio) || lru_cache_disabled()) 258 + !folio_may_be_lru_cached(folio) || lru_cache_disabled()) 259 259 mlock_folio_batch(fbatch); 260 260 local_unlock(&mlock_fbatch.lock); 261 261 } ··· 278 278 279 279 folio_get(folio); 280 280 if (!folio_batch_add(fbatch, mlock_new(folio)) || 281 - folio_test_large(folio) || lru_cache_disabled()) 281 + !folio_may_be_lru_cached(folio) || lru_cache_disabled()) 282 282 mlock_folio_batch(fbatch); 283 283 local_unlock(&mlock_fbatch.lock); 284 284 } ··· 299 299 */ 300 300 folio_get(folio); 301 301 if (!folio_batch_add(fbatch, folio) || 302 - folio_test_large(folio) || lru_cache_disabled()) 302 + !folio_may_be_lru_cached(folio) || lru_cache_disabled()) 303 303 mlock_folio_batch(fbatch); 304 304 local_unlock(&mlock_fbatch.lock); 305 305 }
+26 -24
mm/swap.c
··· 164 164 for (i = 0; i < folio_batch_count(fbatch); i++) { 165 165 struct folio *folio = fbatch->folios[i]; 166 166 167 + /* block memcg migration while the folio moves between lru */ 168 + if (move_fn != lru_add && !folio_test_clear_lru(folio)) 169 + continue; 170 + 167 171 folio_lruvec_relock_irqsave(folio, &lruvec, &flags); 168 172 move_fn(lruvec, folio); 169 173 ··· 180 176 } 181 177 182 178 static void __folio_batch_add_and_move(struct folio_batch __percpu *fbatch, 183 - struct folio *folio, move_fn_t move_fn, 184 - bool on_lru, bool disable_irq) 179 + struct folio *folio, move_fn_t move_fn, bool disable_irq) 185 180 { 186 181 unsigned long flags; 187 - 188 - if (on_lru && !folio_test_clear_lru(folio)) 189 - return; 190 182 191 183 folio_get(folio); 192 184 ··· 191 191 else 192 192 local_lock(&cpu_fbatches.lock); 193 193 194 - if (!folio_batch_add(this_cpu_ptr(fbatch), folio) || folio_test_large(folio) || 195 - lru_cache_disabled()) 194 + if (!folio_batch_add(this_cpu_ptr(fbatch), folio) || 195 + !folio_may_be_lru_cached(folio) || lru_cache_disabled()) 196 196 folio_batch_move_lru(this_cpu_ptr(fbatch), move_fn); 197 197 198 198 if (disable_irq) ··· 201 201 local_unlock(&cpu_fbatches.lock); 202 202 } 203 203 204 - #define folio_batch_add_and_move(folio, op, on_lru) \ 205 - __folio_batch_add_and_move( \ 206 - &cpu_fbatches.op, \ 207 - folio, \ 208 - op, \ 209 - on_lru, \ 210 - offsetof(struct cpu_fbatches, op) >= offsetof(struct cpu_fbatches, lock_irq) \ 204 + #define folio_batch_add_and_move(folio, op) \ 205 + __folio_batch_add_and_move( \ 206 + &cpu_fbatches.op, \ 207 + folio, \ 208 + op, \ 209 + offsetof(struct cpu_fbatches, op) >= \ 210 + offsetof(struct cpu_fbatches, lock_irq) \ 211 211 ) 212 212 213 213 static void lru_move_tail(struct lruvec *lruvec, struct folio *folio) ··· 231 231 void folio_rotate_reclaimable(struct folio *folio) 232 232 { 233 233 if (folio_test_locked(folio) || folio_test_dirty(folio) || 234 - folio_test_unevictable(folio)) 234 + folio_test_unevictable(folio) || !folio_test_lru(folio)) 235 235 return; 236 236 237 - folio_batch_add_and_move(folio, lru_move_tail, true); 237 + folio_batch_add_and_move(folio, lru_move_tail); 238 238 } 239 239 240 240 void lru_note_cost_unlock_irq(struct lruvec *lruvec, bool file, ··· 328 328 329 329 void folio_activate(struct folio *folio) 330 330 { 331 - if (folio_test_active(folio) || folio_test_unevictable(folio)) 331 + if (folio_test_active(folio) || folio_test_unevictable(folio) || 332 + !folio_test_lru(folio)) 332 333 return; 333 334 334 - folio_batch_add_and_move(folio, lru_activate, true); 335 + folio_batch_add_and_move(folio, lru_activate); 335 336 } 336 337 337 338 #else ··· 508 507 lru_gen_in_fault() && !(current->flags & PF_MEMALLOC)) 509 508 folio_set_active(folio); 510 509 511 - folio_batch_add_and_move(folio, lru_add, false); 510 + folio_batch_add_and_move(folio, lru_add); 512 511 } 513 512 EXPORT_SYMBOL(folio_add_lru); 514 513 ··· 686 685 void deactivate_file_folio(struct folio *folio) 687 686 { 688 687 /* Deactivating an unevictable folio will not accelerate reclaim */ 689 - if (folio_test_unevictable(folio)) 688 + if (folio_test_unevictable(folio) || !folio_test_lru(folio)) 690 689 return; 691 690 692 691 if (lru_gen_enabled() && lru_gen_clear_refs(folio)) 693 692 return; 694 693 695 - folio_batch_add_and_move(folio, lru_deactivate_file, true); 694 + folio_batch_add_and_move(folio, lru_deactivate_file); 696 695 } 697 696 698 697 /* ··· 705 704 */ 706 705 void folio_deactivate(struct folio *folio) 707 706 { 708 - if (folio_test_unevictable(folio)) 707 + if (folio_test_unevictable(folio) || !folio_test_lru(folio)) 709 708 return; 710 709 711 710 if (lru_gen_enabled() ? lru_gen_clear_refs(folio) : !folio_test_active(folio)) 712 711 return; 713 712 714 - folio_batch_add_and_move(folio, lru_deactivate, true); 713 + folio_batch_add_and_move(folio, lru_deactivate); 715 714 } 716 715 717 716 /** ··· 724 723 void folio_mark_lazyfree(struct folio *folio) 725 724 { 726 725 if (!folio_test_anon(folio) || !folio_test_swapbacked(folio) || 726 + !folio_test_lru(folio) || 727 727 folio_test_swapcache(folio) || folio_test_unevictable(folio)) 728 728 return; 729 729 730 - folio_batch_add_and_move(folio, lru_lazyfree, true); 730 + folio_batch_add_and_move(folio, lru_lazyfree); 731 731 } 732 732 733 733 void lru_add_drain(void)
+1 -1
mm/vmscan.c
··· 4507 4507 } 4508 4508 4509 4509 /* ineligible */ 4510 - if (!folio_test_lru(folio) || zone > sc->reclaim_idx) { 4510 + if (zone > sc->reclaim_idx) { 4511 4511 gen = folio_inc_gen(lruvec, folio, false); 4512 4512 list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]); 4513 4513 return true;
+4 -3
net/ceph/messenger.c
··· 1524 1524 * in case we faulted due to authentication, invalidate our 1525 1525 * current tickets so that we can get new ones. 1526 1526 */ 1527 - if (con->v1.auth_retry) { 1527 + if (!ceph_msgr2(from_msgr(con->msgr)) && con->v1.auth_retry) { 1528 1528 dout("auth_retry %d, invalidating\n", con->v1.auth_retry); 1529 1529 if (con->ops->invalidate_authorizer) 1530 1530 con->ops->invalidate_authorizer(con); ··· 1714 1714 { 1715 1715 /* come back from STANDBY? */ 1716 1716 if (con->state == CEPH_CON_S_STANDBY) { 1717 - dout("clear_standby %p and ++connect_seq\n", con); 1717 + dout("clear_standby %p\n", con); 1718 1718 con->state = CEPH_CON_S_PREOPEN; 1719 - con->v1.connect_seq++; 1719 + if (!ceph_msgr2(from_msgr(con->msgr))) 1720 + con->v1.connect_seq++; 1720 1721 WARN_ON(ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING)); 1721 1722 WARN_ON(ceph_con_flag_test(con, CEPH_CON_F_KEEPALIVE_PENDING)); 1722 1723 }
+1 -1
net/core/dev.c
··· 7046 7046 * the kthread. 7047 7047 */ 7048 7048 while (true) { 7049 - if (!test_bit(NAPIF_STATE_SCHED_THREADED, &napi->state)) 7049 + if (!test_bit(NAPI_STATE_SCHED_THREADED, &napi->state)) 7050 7050 break; 7051 7051 7052 7052 msleep(20);
+2 -2
net/devlink/rate.c
··· 34 34 static struct devlink_rate * 35 35 devlink_rate_node_get_by_name(struct devlink *devlink, const char *node_name) 36 36 { 37 - static struct devlink_rate *devlink_rate; 37 + struct devlink_rate *devlink_rate; 38 38 39 39 list_for_each_entry(devlink_rate, &devlink->rate_list, list) { 40 40 if (devlink_rate_is_node(devlink_rate) && ··· 819 819 */ 820 820 void devl_rate_nodes_destroy(struct devlink *devlink) 821 821 { 822 - static struct devlink_rate *devlink_rate, *tmp; 823 822 const struct devlink_ops *ops = devlink->ops; 823 + struct devlink_rate *devlink_rate, *tmp; 824 824 825 825 devl_assert_locked(devlink); 826 826
+2 -2
net/ethtool/common.c
··· 925 925 int err; 926 926 927 927 if (!ops->get_ts_info) 928 - return -ENODEV; 928 + return -EOPNOTSUPP; 929 929 930 930 /* Does ptp comes from netdev */ 931 931 ethtool_init_tsinfo(info); ··· 993 993 int err; 994 994 995 995 err = ethtool_net_get_ts_info_by_phc(dev, info, hwprov_desc); 996 - if (err == -ENODEV) { 996 + if (err == -ENODEV || err == -EOPNOTSUPP) { 997 997 struct phy_device *phy; 998 998 999 999 phy = ethtool_phy_get_ts_info_by_phc(dev, info, hwprov_desc);
+5
net/ipv4/tcp.c
··· 3348 3348 struct inet_connection_sock *icsk = inet_csk(sk); 3349 3349 struct tcp_sock *tp = tcp_sk(sk); 3350 3350 int old_state = sk->sk_state; 3351 + struct request_sock *req; 3351 3352 u32 seq; 3352 3353 3353 3354 if (old_state != TCP_CLOSE) ··· 3469 3468 3470 3469 3471 3470 /* Clean up fastopen related fields */ 3471 + req = rcu_dereference_protected(tp->fastopen_rsk, 3472 + lockdep_sock_is_held(sk)); 3473 + if (req) 3474 + reqsk_fastopen_remove(sk, req, false); 3472 3475 tcp_free_fastopen_req(tp); 3473 3476 inet_clear_bit(DEFER_CONNECT, sk); 3474 3477 tp->fastopen_client_fail = 0;
+3 -1
net/ipv4/tcp_ao.c
··· 1177 1177 if (!ao) 1178 1178 return; 1179 1179 1180 - WRITE_ONCE(ao->risn, tcp_hdr(skb)->seq); 1180 + /* sk with TCP_REPAIR_ON does not have skb in tcp_finish_connect */ 1181 + if (skb) 1182 + WRITE_ONCE(ao->risn, tcp_hdr(skb)->seq); 1181 1183 ao->rcv_sne = 0; 1182 1184 1183 1185 hlist_for_each_entry_rcu(key, &ao->head, node, lockdep_sock_is_held(sk))
+3 -3
net/mptcp/options.c
··· 985 985 return false; 986 986 } 987 987 988 - if (mp_opt->deny_join_id0) 989 - WRITE_ONCE(msk->pm.remote_deny_join_id0, true); 990 - 991 988 if (unlikely(!READ_ONCE(msk->pm.server_side))) 992 989 pr_warn_once("bogus mpc option on established client sk"); 993 990 994 991 set_fully_established: 992 + if (mp_opt->deny_join_id0) 993 + WRITE_ONCE(msk->pm.remote_deny_join_id0, true); 994 + 995 995 mptcp_data_lock((struct sock *)msk); 996 996 __mptcp_subflow_fully_established(msk, subflow, mp_opt); 997 997 mptcp_data_unlock((struct sock *)msk);
+7
net/mptcp/pm_netlink.c
··· 408 408 const struct sock *ssk) 409 409 { 410 410 int err = nla_put_u32(skb, MPTCP_ATTR_TOKEN, READ_ONCE(msk->token)); 411 + u16 flags = 0; 411 412 412 413 if (err) 413 414 return err; 414 415 415 416 if (nla_put_u8(skb, MPTCP_ATTR_SERVER_SIDE, READ_ONCE(msk->pm.server_side))) 417 + return -EMSGSIZE; 418 + 419 + if (READ_ONCE(msk->pm.remote_deny_join_id0)) 420 + flags |= MPTCP_PM_EV_FLAG_DENY_JOIN_ID0; 421 + 422 + if (flags && nla_put_u16(skb, MPTCP_ATTR_FLAGS, flags)) 416 423 return -EMSGSIZE; 417 424 418 425 return mptcp_event_add_subflow(skb, ssk);
+16
net/mptcp/protocol.c
··· 372 372 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); 373 373 } 374 374 375 + static void mptcp_shutdown_subflows(struct mptcp_sock *msk) 376 + { 377 + struct mptcp_subflow_context *subflow; 378 + 379 + mptcp_for_each_subflow(msk, subflow) { 380 + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); 381 + bool slow; 382 + 383 + slow = lock_sock_fast(ssk); 384 + tcp_shutdown(ssk, SEND_SHUTDOWN); 385 + unlock_sock_fast(ssk, slow); 386 + } 387 + } 388 + 375 389 /* called under the msk socket lock */ 376 390 static bool mptcp_pending_data_fin_ack(struct sock *sk) 377 391 { ··· 410 396 break; 411 397 case TCP_CLOSING: 412 398 case TCP_LAST_ACK: 399 + mptcp_shutdown_subflows(msk); 413 400 mptcp_set_state(sk, TCP_CLOSE); 414 401 break; 415 402 } ··· 579 564 mptcp_set_state(sk, TCP_CLOSING); 580 565 break; 581 566 case TCP_FIN_WAIT2: 567 + mptcp_shutdown_subflows(msk); 582 568 mptcp_set_state(sk, TCP_CLOSE); 583 569 break; 584 570 default:
+4
net/mptcp/subflow.c
··· 883 883 884 884 ctx->subflow_id = 1; 885 885 owner = mptcp_sk(ctx->conn); 886 + 887 + if (mp_opt.deny_join_id0) 888 + WRITE_ONCE(owner->pm.remote_deny_join_id0, true); 889 + 886 890 mptcp_pm_new_connection(owner, child, 1); 887 891 888 892 /* with OoO packets we can reach here without ingress
+12 -8
net/rds/ib_frmr.c
··· 133 133 134 134 ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_dma_len, 135 135 &off, PAGE_SIZE); 136 - if (unlikely(ret != ibmr->sg_dma_len)) 137 - return ret < 0 ? ret : -EINVAL; 136 + if (unlikely(ret != ibmr->sg_dma_len)) { 137 + ret = ret < 0 ? ret : -EINVAL; 138 + goto out_inc; 139 + } 138 140 139 - if (cmpxchg(&frmr->fr_state, 140 - FRMR_IS_FREE, FRMR_IS_INUSE) != FRMR_IS_FREE) 141 - return -EBUSY; 141 + if (cmpxchg(&frmr->fr_state, FRMR_IS_FREE, FRMR_IS_INUSE) != FRMR_IS_FREE) { 142 + ret = -EBUSY; 143 + goto out_inc; 144 + } 142 145 143 146 atomic_inc(&ibmr->ic->i_fastreg_inuse_count); 144 147 ··· 169 166 /* Failure here can be because of -ENOMEM as well */ 170 167 rds_transition_frwr_state(ibmr, FRMR_IS_INUSE, FRMR_IS_STALE); 171 168 172 - atomic_inc(&ibmr->ic->i_fastreg_wrs); 173 169 if (printk_ratelimit()) 174 170 pr_warn("RDS/IB: %s returned error(%d)\n", 175 171 __func__, ret); 176 - goto out; 172 + goto out_inc; 177 173 } 178 174 179 175 /* Wait for the registration to complete in order to prevent an invalid ··· 181 179 */ 182 180 wait_event(frmr->fr_reg_done, !frmr->fr_reg); 183 181 184 - out: 182 + return ret; 185 183 184 + out_inc: 185 + atomic_inc(&ibmr->ic->i_fastreg_wrs); 186 186 return ret; 187 187 } 188 188
+2 -2
net/rfkill/rfkill-gpio.c
··· 94 94 static int rfkill_gpio_probe(struct platform_device *pdev) 95 95 { 96 96 struct rfkill_gpio_data *rfkill; 97 - struct gpio_desc *gpio; 97 + const char *type_name = NULL; 98 98 const char *name_property; 99 99 const char *type_property; 100 - const char *type_name; 100 + struct gpio_desc *gpio; 101 101 int ret; 102 102 103 103 if (dmi_check_system(rfkill_gpio_deny_table))
+10 -8
net/rxrpc/rxgk.c
··· 475 475 struct krb5_buffer metadata; 476 476 unsigned int offset = sp->offset, len = sp->len; 477 477 size_t data_offset = 0, data_len = len; 478 - u32 ac; 478 + u32 ac = 0; 479 479 int ret = -ENOMEM; 480 480 481 481 _enter(""); ··· 499 499 ret = rxgk_verify_mic_skb(gk->krb5, gk->rx_Kc, &metadata, 500 500 skb, &offset, &len, &ac); 501 501 kfree(hdr); 502 - if (ret == -EPROTO) { 503 - rxrpc_abort_eproto(call, skb, ac, 504 - rxgk_abort_1_verify_mic_eproto); 502 + if (ret < 0) { 503 + if (ret != -ENOMEM) 504 + rxrpc_abort_eproto(call, skb, ac, 505 + rxgk_abort_1_verify_mic_eproto); 505 506 } else { 506 507 sp->offset = offset; 507 508 sp->len = len; ··· 525 524 struct rxgk_header hdr; 526 525 unsigned int offset = sp->offset, len = sp->len; 527 526 int ret; 528 - u32 ac; 527 + u32 ac = 0; 529 528 530 529 _enter(""); 531 530 532 531 ret = rxgk_decrypt_skb(gk->krb5, gk->rx_enc, skb, &offset, &len, &ac); 533 - if (ret == -EPROTO) 534 - rxrpc_abort_eproto(call, skb, ac, rxgk_abort_2_decrypt_eproto); 535 - if (ret < 0) 532 + if (ret < 0) { 533 + if (ret != -ENOMEM) 534 + rxrpc_abort_eproto(call, skb, ac, rxgk_abort_2_decrypt_eproto); 536 535 goto error; 536 + } 537 537 538 538 if (len < sizeof(hdr)) { 539 539 ret = rxrpc_abort_eproto(call, skb, RXGK_PACKETSHORT,
+20 -9
net/rxrpc/rxgk_app.c
··· 54 54 55 55 _enter(""); 56 56 57 + if (ticket_len < 10 * sizeof(__be32)) 58 + return rxrpc_abort_conn(conn, skb, RXGK_INCONSISTENCY, -EPROTO, 59 + rxgk_abort_resp_short_yfs_tkt); 60 + 57 61 /* Get the session key length */ 58 62 ret = skb_copy_bits(skb, ticket_offset, tmp, sizeof(tmp)); 59 63 if (ret < 0) ··· 191 187 struct key *server_key; 192 188 unsigned int ticket_offset, ticket_len; 193 189 u32 kvno, enctype; 194 - int ret, ec; 190 + int ret, ec = 0; 195 191 196 192 struct { 197 193 __be32 kvno; ··· 199 195 __be32 token_len; 200 196 } container; 201 197 198 + if (token_len < sizeof(container)) 199 + goto short_packet; 200 + 202 201 /* Decode the RXGK_TokenContainer object. This tells us which server 203 202 * key we should be using. We can then fetch the key, get the secret 204 203 * and set up the crypto to extract the token. 205 204 */ 206 205 if (skb_copy_bits(skb, token_offset, &container, sizeof(container)) < 0) 207 - return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO, 208 - rxgk_abort_resp_tok_short); 206 + goto short_packet; 209 207 210 208 kvno = ntohl(container.kvno); 211 209 enctype = ntohl(container.enctype); 212 210 ticket_len = ntohl(container.token_len); 213 211 ticket_offset = token_offset + sizeof(container); 214 212 215 - if (xdr_round_up(ticket_len) > token_len - 3 * 4) 216 - return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO, 217 - rxgk_abort_resp_tok_short); 213 + if (xdr_round_up(ticket_len) > token_len - sizeof(container)) 214 + goto short_packet; 218 215 219 216 _debug("KVNO %u", kvno); 220 217 _debug("ENC %u", enctype); ··· 241 236 &ticket_offset, &ticket_len, &ec); 242 237 crypto_free_aead(token_enc); 243 238 token_enc = NULL; 244 - if (ret < 0) 245 - return rxrpc_abort_conn(conn, skb, ec, ret, 246 - rxgk_abort_resp_tok_dec); 239 + if (ret < 0) { 240 + if (ret != -ENOMEM) 241 + return rxrpc_abort_conn(conn, skb, ec, ret, 242 + rxgk_abort_resp_tok_dec); 243 + } 247 244 248 245 ret = conn->security->default_decode_ticket(conn, skb, ticket_offset, 249 246 ticket_len, _key); ··· 290 283 * also come out this way if the ticket decryption fails. 291 284 */ 292 285 return ret; 286 + 287 + short_packet: 288 + return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO, 289 + rxgk_abort_resp_tok_short); 293 290 }
+12 -2
net/rxrpc/rxgk_common.h
··· 88 88 *_offset += offset; 89 89 *_len = len; 90 90 break; 91 + case -EBADMSG: /* Checksum mismatch. */ 91 92 case -EPROTO: 92 - case -EBADMSG: 93 93 *_error_code = RXGK_SEALEDINCON; 94 94 break; 95 + case -EMSGSIZE: 96 + *_error_code = RXGK_PACKETSHORT; 97 + break; 98 + case -ENOPKG: /* Would prefer RXGK_BADETYPE, but not available for YFS. */ 95 99 default: 100 + *_error_code = RXGK_INCONSISTENCY; 96 101 break; 97 102 } 98 103 ··· 132 127 *_offset += offset; 133 128 *_len = len; 134 129 break; 130 + case -EBADMSG: /* Checksum mismatch */ 135 131 case -EPROTO: 136 - case -EBADMSG: 137 132 *_error_code = RXGK_SEALEDINCON; 138 133 break; 134 + case -EMSGSIZE: 135 + *_error_code = RXGK_PACKETSHORT; 136 + break; 137 + case -ENOPKG: /* Would prefer RXGK_BADETYPE, but not available for YFS. */ 139 138 default: 139 + *_error_code = RXGK_INCONSISTENCY; 140 140 break; 141 141 } 142 142
+1
net/tls/tls.h
··· 141 141 142 142 int wait_on_pending_writer(struct sock *sk, long *timeo); 143 143 void tls_err_abort(struct sock *sk, int err); 144 + void tls_strp_abort_strp(struct tls_strparser *strp, int err); 144 145 145 146 int init_prot_info(struct tls_prot_info *prot, 146 147 const struct tls_crypto_info *crypto_info,
+9 -5
net/tls/tls_strp.c
··· 13 13 14 14 static struct workqueue_struct *tls_strp_wq; 15 15 16 - static void tls_strp_abort_strp(struct tls_strparser *strp, int err) 16 + void tls_strp_abort_strp(struct tls_strparser *strp, int err) 17 17 { 18 18 if (strp->stopped) 19 19 return; ··· 211 211 struct sk_buff *in_skb, unsigned int offset, 212 212 size_t in_len) 213 213 { 214 + unsigned int nfrag = skb->len / PAGE_SIZE; 214 215 size_t len, chunk; 215 216 skb_frag_t *frag; 216 217 int sz; 217 218 218 - frag = &skb_shinfo(skb)->frags[skb->len / PAGE_SIZE]; 219 + if (unlikely(nfrag >= skb_shinfo(skb)->nr_frags)) { 220 + DEBUG_NET_WARN_ON_ONCE(1); 221 + return -EMSGSIZE; 222 + } 223 + 224 + frag = &skb_shinfo(skb)->frags[nfrag]; 219 225 220 226 len = in_len; 221 227 /* First make sure we got the header */ ··· 526 520 tls_strp_load_anchor_with_queue(strp, inq); 527 521 if (!strp->stm.full_len) { 528 522 sz = tls_rx_msg_size(strp, strp->anchor); 529 - if (sz < 0) { 530 - tls_strp_abort_strp(strp, sz); 523 + if (sz < 0) 531 524 return sz; 532 - } 533 525 534 526 strp->stm.full_len = sz; 535 527
+1 -2
net/tls/tls_sw.c
··· 2474 2474 return data_len + TLS_HEADER_SIZE; 2475 2475 2476 2476 read_failure: 2477 - tls_err_abort(strp->sk, ret); 2478 - 2477 + tls_strp_abort_strp(strp, ret); 2479 2478 return ret; 2480 2479 } 2481 2480
+3 -2
rust/kernel/device.rs
··· 138 138 /// } 139 139 /// ``` 140 140 /// 141 - /// An example for a class device implementation is [`drm::Device`]. 141 + /// An example for a class device implementation is 142 + #[cfg_attr(CONFIG_DRM = "y", doc = "[`drm::Device`](kernel::drm::Device).")] 143 + #[cfg_attr(not(CONFIG_DRM = "y"), doc = "`drm::Device`.")] 142 144 /// 143 145 /// # Invariants 144 146 /// ··· 153 151 /// dropped from any thread. 154 152 /// 155 153 /// [`AlwaysRefCounted`]: kernel::types::AlwaysRefCounted 156 - /// [`drm::Device`]: kernel::drm::Device 157 154 /// [`impl_device_context_deref`]: kernel::impl_device_context_deref 158 155 /// [`pci::Device`]: kernel::pci::Device 159 156 /// [`platform::Device`]: kernel::platform::Device
+3
samples/damon/mtier.c
··· 208 208 if (enabled == is_enabled) 209 209 return 0; 210 210 211 + if (!init_called) 212 + return 0; 213 + 211 214 if (enabled) { 212 215 err = damon_sample_mtier_start(); 213 216 if (err)
+3
samples/damon/prcl.c
··· 137 137 if (enabled == is_enabled) 138 138 return 0; 139 139 140 + if (!init_called) 141 + return 0; 142 + 140 143 if (enabled) { 141 144 err = damon_sample_prcl_start(); 142 145 if (err)
+3
samples/damon/wsse.c
··· 118 118 return 0; 119 119 120 120 if (enabled) { 121 + if (!init_called) 122 + return 0; 123 + 121 124 err = damon_sample_wsse_start(); 122 125 if (err) 123 126 enabled = false;
+3
tools/lib/subcmd/help.c
··· 75 75 size_t ci, cj, ei; 76 76 int cmp; 77 77 78 + if (!excludes->cnt) 79 + return; 80 + 78 81 ci = cj = ei = 0; 79 82 while (ci < cmds->cnt && ei < excludes->cnt) { 80 83 cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
+6 -1
tools/perf/builtin-lock.c
··· 2009 2009 .owner = show_lock_owner, 2010 2010 .cgroups = RB_ROOT, 2011 2011 }; 2012 + struct perf_env host_env; 2012 2013 2013 2014 lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table)); 2014 2015 if (!lockhash_table) ··· 2025 2024 eops.mmap = perf_event__process_mmap; 2026 2025 eops.tracing_data = perf_event__process_tracing_data; 2027 2026 2028 - session = perf_session__new(use_bpf ? NULL : &data, &eops); 2027 + perf_env__init(&host_env); 2028 + session = __perf_session__new(use_bpf ? NULL : &data, &eops, 2029 + /*trace_event_repipe=*/false, &host_env); 2030 + 2029 2031 if (IS_ERR(session)) { 2030 2032 pr_err("Initializing perf session failed\n"); 2031 2033 err = PTR_ERR(session); ··· 2146 2142 evlist__delete(con.evlist); 2147 2143 lock_contention_finish(&con); 2148 2144 perf_session__delete(session); 2145 + perf_env__exit(&host_env); 2149 2146 zfree(&lockhash_table); 2150 2147 return err; 2151 2148 }
+5 -4
tools/perf/util/maps.c
··· 477 477 } 478 478 /* Insert the value at the end. */ 479 479 maps_by_address[nr_maps] = map__get(new); 480 + map__set_kmap_maps(new, maps); 480 481 if (maps_by_name) 481 482 maps_by_name[nr_maps] = map__get(new); 482 483 ··· 502 501 } 503 502 if (map__end(new) < map__start(new)) 504 503 RC_CHK_ACCESS(maps)->ends_broken = true; 505 - 506 - map__set_kmap_maps(new, maps); 507 504 508 505 return 0; 509 506 } ··· 890 891 if (before) { 891 892 map__put(maps_by_address[i]); 892 893 maps_by_address[i] = before; 894 + map__set_kmap_maps(before, maps); 893 895 894 896 if (maps_by_name) { 895 897 map__put(maps_by_name[ni]); ··· 918 918 */ 919 919 map__put(maps_by_address[i]); 920 920 maps_by_address[i] = map__get(new); 921 + map__set_kmap_maps(new, maps); 921 922 922 923 if (maps_by_name) { 923 924 map__put(maps_by_name[ni]); ··· 943 942 */ 944 943 map__put(maps_by_address[i]); 945 944 maps_by_address[i] = map__get(new); 945 + map__set_kmap_maps(new, maps); 946 946 947 947 if (maps_by_name) { 948 948 map__put(maps_by_name[ni]); 949 949 maps_by_name[ni] = map__get(new); 950 950 } 951 - 952 - map__set_kmap_maps(new, maps); 953 951 954 952 check_invariants(maps); 955 953 return err; ··· 1019 1019 err = unwind__prepare_access(dest, new, NULL); 1020 1020 if (!err) { 1021 1021 dest_maps_by_address[i] = new; 1022 + map__set_kmap_maps(new, dest); 1022 1023 if (dest_maps_by_name) 1023 1024 dest_maps_by_name[i] = map__get(new); 1024 1025 RC_CHK_ACCESS(dest)->nr_maps = i + 1;
+195 -2
tools/testing/selftests/drivers/net/bonding/bond_options.sh
··· 7 7 prio 8 8 arp_validate 9 9 num_grat_arp 10 + fail_over_mac 11 + vlan_over_bond 10 12 " 11 13 12 14 lib_dir=$(dirname "$0") ··· 354 352 355 353 exp_num=$(echo "${param}" | cut -f6 -d ' ') 356 354 active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 357 - slowwait_for_counter $((exp_num + 5)) $exp_num \ 358 - tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}" 355 + slowwait_for_counter $((exp_num + 5)) $exp_num tc_rule_handle_stats_get \ 356 + "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}" &> /dev/null 359 357 360 358 # check result 361 359 real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}") ··· 376 374 garp_test "mode active-backup miimon 10 num_grat_arp $val peer_notify_delay 100" 377 375 log_test "num_grat_arp" "active-backup miimon num_grat_arp $val" 378 376 done 377 + } 378 + 379 + check_all_mac_same() 380 + { 381 + RET=0 382 + # all slaves should have same mac address (with the first port's mac) 383 + local bond_mac=$(ip -n "$s_ns" -j link show bond0 | jq -r '.[]["address"]') 384 + local eth0_mac=$(ip -n "$s_ns" -j link show eth0 | jq -r '.[]["address"]') 385 + local eth1_mac=$(ip -n "$s_ns" -j link show eth1 | jq -r '.[]["address"]') 386 + local eth2_mac=$(ip -n "$s_ns" -j link show eth2 | jq -r '.[]["address"]') 387 + if [ "$bond_mac" != "${mac[0]}" ] || [ "$eth0_mac" != "$bond_mac" ] || \ 388 + [ "$eth1_mac" != "$bond_mac" ] || [ "$eth2_mac" != "$bond_mac" ]; then 389 + RET=1 390 + fi 391 + } 392 + 393 + check_bond_mac_same_with_first() 394 + { 395 + RET=0 396 + # bond mac address should be same with the first added slave 397 + local bond_mac=$(ip -n "$s_ns" -j link show bond0 | jq -r '.[]["address"]') 398 + if [ "$bond_mac" != "${mac[0]}" ]; then 399 + RET=1 400 + fi 401 + } 402 + 403 + check_bond_mac_same_with_active() 404 + { 405 + RET=0 406 + # bond mac address should be same with active slave 407 + local bond_mac=$(ip -n "$s_ns" -j link show bond0 | jq -r '.[]["address"]') 408 + local active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 409 + local active_slave_mac=$(ip -n "$s_ns" -j link show "$active_slave" | jq -r '.[]["address"]') 410 + if [ "$bond_mac" != "$active_slave_mac" ]; then 411 + RET=1 412 + fi 413 + } 414 + 415 + check_backup_slave_mac_not_change() 416 + { 417 + RET=0 418 + # backup slave's mac address is not changed 419 + if ip -n "$s_ns" -d -j link show type bond_slave | jq -e '.[] 420 + | select(.linkinfo.info_slave_data.state=="BACKUP") 421 + | select(.address != .linkinfo.info_slave_data.perm_hwaddr)' &> /dev/null; then 422 + RET=1 423 + fi 424 + } 425 + 426 + check_backup_slave_mac_inherit() 427 + { 428 + local backup_mac 429 + RET=0 430 + 431 + # backup slaves should use mac[1] or mac[2] 432 + local backup_macs=$(ip -n "$s_ns" -d -j link show type bond_slave | \ 433 + jq -r '.[] | select(.linkinfo.info_slave_data.state=="BACKUP") | .address') 434 + for backup_mac in $backup_macs; do 435 + if [ "$backup_mac" != "${mac[1]}" ] && [ "$backup_mac" != "${mac[2]}" ]; then 436 + RET=1 437 + fi 438 + done 439 + } 440 + 441 + check_first_slave_random_mac() 442 + { 443 + RET=0 444 + # remove the first added slave and added it back 445 + ip -n "$s_ns" link set eth0 nomaster 446 + ip -n "$s_ns" link set eth0 master bond0 447 + 448 + # the first slave should use random mac address 449 + eth0_mac=$(ip -n "$s_ns" -j link show eth0 | jq -r '.[]["address"]') 450 + [ "$eth0_mac" = "${mac[0]}" ] && RET=1 451 + log_test "bond fail_over_mac follow" "random first slave mac" 452 + 453 + # remove the first slave, the permanent MAC address should be restored back 454 + ip -n "$s_ns" link set eth0 nomaster 455 + eth0_mac=$(ip -n "$s_ns" -j link show eth0 | jq -r '.[]["address"]') 456 + [ "$eth0_mac" != "${mac[0]}" ] && RET=1 457 + } 458 + 459 + do_active_backup_failover() 460 + { 461 + local active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 462 + ip -n ${s_ns} link set ${active_slave} down 463 + slowwait 2 active_slave_changed $active_slave 464 + ip -n ${s_ns} link set ${active_slave} up 465 + } 466 + 467 + fail_over_mac() 468 + { 469 + # Bring down the first interface on the switch to force the bond to 470 + # select another active interface instead of the first one that joined. 471 + ip -n "$g_ns" link set s0 down 472 + 473 + # fail_over_mac none 474 + bond_reset "mode active-backup miimon 100 fail_over_mac 0" 475 + check_all_mac_same 476 + log_test "fail_over_mac 0" "all slaves have same mac" 477 + do_active_backup_failover 478 + check_all_mac_same 479 + log_test "fail_over_mac 0" "failover: all slaves have same mac" 480 + 481 + # fail_over_mac active 482 + bond_reset "mode active-backup miimon 100 fail_over_mac 1" 483 + check_bond_mac_same_with_active 484 + log_test "fail_over_mac 1" "bond mac is same with active slave mac" 485 + check_backup_slave_mac_not_change 486 + log_test "fail_over_mac 1" "backup slave mac is not changed" 487 + do_active_backup_failover 488 + check_bond_mac_same_with_active 489 + log_test "fail_over_mac 1" "failover: bond mac is same with active slave mac" 490 + check_backup_slave_mac_not_change 491 + log_test "fail_over_mac 1" "failover: backup slave mac is not changed" 492 + 493 + # fail_over_mac follow 494 + bond_reset "mode active-backup miimon 100 fail_over_mac 2" 495 + check_bond_mac_same_with_first 496 + log_test "fail_over_mac 2" "bond mac is same with first slave mac" 497 + check_bond_mac_same_with_active 498 + log_test "fail_over_mac 2" "bond mac is same with active slave mac" 499 + check_backup_slave_mac_inherit 500 + log_test "fail_over_mac 2" "backup slave mac inherit" 501 + do_active_backup_failover 502 + check_bond_mac_same_with_first 503 + log_test "fail_over_mac 2" "failover: bond mac is same with first slave mac" 504 + check_bond_mac_same_with_active 505 + log_test "fail_over_mac 2" "failover: bond mac is same with active slave mac" 506 + check_backup_slave_mac_inherit 507 + log_test "fail_over_mac 2" "failover: backup slave mac inherit" 508 + check_first_slave_random_mac 509 + log_test "fail_over_mac 2" "first slave mac random" 510 + } 511 + 512 + vlan_over_bond_arp() 513 + { 514 + local mode="$1" 515 + RET=0 516 + 517 + bond_reset "mode $mode arp_interval 100 arp_ip_target 192.0.3.10" 518 + ip -n "${s_ns}" link add bond0.3 link bond0 type vlan id 3 519 + ip -n "${s_ns}" link set bond0.3 up 520 + ip -n "${s_ns}" addr add 192.0.3.1/24 dev bond0.3 521 + ip -n "${s_ns}" addr add 2001:db8::3:1/64 dev bond0.3 522 + 523 + slowwait_for_counter 5 5 tc_rule_handle_stats_get \ 524 + "dev eth0.3 ingress" 101 ".packets" "-n ${c_ns}" &> /dev/null || RET=1 525 + log_test "vlan over bond arp" "$mode" 526 + } 527 + 528 + vlan_over_bond_ns() 529 + { 530 + local mode="$1" 531 + RET=0 532 + 533 + if skip_ns; then 534 + log_test_skip "vlan_over_bond ns" "$mode" 535 + return 0 536 + fi 537 + 538 + bond_reset "mode $mode arp_interval 100 ns_ip6_target 2001:db8::3:10" 539 + ip -n "${s_ns}" link add bond0.3 link bond0 type vlan id 3 540 + ip -n "${s_ns}" link set bond0.3 up 541 + ip -n "${s_ns}" addr add 192.0.3.1/24 dev bond0.3 542 + ip -n "${s_ns}" addr add 2001:db8::3:1/64 dev bond0.3 543 + 544 + slowwait_for_counter 5 5 tc_rule_handle_stats_get \ 545 + "dev eth0.3 ingress" 102 ".packets" "-n ${c_ns}" &> /dev/null || RET=1 546 + log_test "vlan over bond ns" "$mode" 547 + } 548 + 549 + vlan_over_bond() 550 + { 551 + # add vlan 3 for client 552 + ip -n "${c_ns}" link add eth0.3 link eth0 type vlan id 3 553 + ip -n "${c_ns}" link set eth0.3 up 554 + ip -n "${c_ns}" addr add 192.0.3.10/24 dev eth0.3 555 + ip -n "${c_ns}" addr add 2001:db8::3:10/64 dev eth0.3 556 + 557 + # Add tc rule to check the vlan pkts 558 + tc -n "${c_ns}" qdisc add dev eth0.3 clsact 559 + tc -n "${c_ns}" filter add dev eth0.3 ingress protocol arp \ 560 + handle 101 flower skip_hw arp_op request \ 561 + arp_sip 192.0.3.1 arp_tip 192.0.3.10 action pass 562 + tc -n "${c_ns}" filter add dev eth0.3 ingress protocol ipv6 \ 563 + handle 102 flower skip_hw ip_proto icmpv6 \ 564 + type 135 src_ip 2001:db8::3:1 action pass 565 + 566 + vlan_over_bond_arp "active-backup" 567 + vlan_over_bond_ns "active-backup" 379 568 } 380 569 381 570 trap cleanup EXIT
+3
tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh
··· 39 39 s_ip6="2001:db8::1" 40 40 c_ip6="2001:db8::10" 41 41 g_ip6="2001:db8::254" 42 + mac[0]="00:0a:0b:0c:0d:01" 43 + mac[1]="00:0a:0b:0c:0d:02" 42 44 43 45 gateway_create() 44 46 { ··· 64 62 65 63 for i in $(seq 0 1); do 66 64 ip -n ${s_ns} link add eth${i} type veth peer name s${i} netns ${g_ns} 65 + ip -n "${s_ns}" link set "eth${i}" addr "${mac[$i]}" 67 66 68 67 ip -n ${g_ns} link set s${i} up 69 68 ip -n ${g_ns} link set s${i} master br0
+2
tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh
··· 26 26 # +-------------------------------------+ 27 27 28 28 source bond_topo_2d1c.sh 29 + mac[2]="00:0a:0b:0c:0d:03" 29 30 30 31 setup_prepare() 31 32 { ··· 37 36 # Add the extra device as we use 3 down links for bond0 38 37 local i=2 39 38 ip -n ${s_ns} link add eth${i} type veth peer name s${i} netns ${g_ns} 39 + ip -n "${s_ns}" link set "eth${i}" addr "${mac[$i]}" 40 40 ip -n ${g_ns} link set s${i} up 41 41 ip -n ${g_ns} link set s${i} master br0 42 42 ip -n ${s_ns} link set eth${i} master bond0
+1
tools/testing/selftests/drivers/net/bonding/config
··· 10 10 CONFIG_NET_SCH_INGRESS=y 11 11 CONFIG_NLMON=y 12 12 CONFIG_VETH=y 13 + CONFIG_VLAN_8021Q=m
+6 -5
tools/testing/selftests/net/mptcp/mptcp_connect.c
··· 1093 1093 struct pollfd polls; 1094 1094 socklen_t salen; 1095 1095 int remotesock; 1096 + int err = 0; 1096 1097 int fd = 0; 1097 1098 1098 1099 again: ··· 1126 1125 SOCK_TEST_TCPULP(remotesock, 0); 1127 1126 1128 1127 memset(&winfo, 0, sizeof(winfo)); 1129 - copyfd_io(fd, remotesock, 1, true, &winfo); 1128 + err = copyfd_io(fd, remotesock, 1, true, &winfo); 1130 1129 } else { 1131 1130 perror("accept"); 1132 1131 return 1; ··· 1135 1134 if (cfg_input) 1136 1135 close(fd); 1137 1136 1138 - if (--cfg_repeat > 0) 1137 + if (!err && --cfg_repeat > 0) 1139 1138 goto again; 1140 1139 1141 - return 0; 1140 + return err; 1142 1141 } 1143 1142 1144 1143 static void init_rng(void) ··· 1248 1247 else 1249 1248 xerror("bad family"); 1250 1249 1251 - strcpy(cmd, "ss -M | grep -q "); 1250 + strcpy(cmd, "ss -Mnt | grep -q "); 1252 1251 cmdlen = strlen(cmd); 1253 1252 if (!inet_ntop(addr.ss_family, raw_addr, &cmd[cmdlen], 1254 1253 sizeof(cmd) - cmdlen)) ··· 1258 1257 1259 1258 /* 1260 1259 * wait until the pending data is completely flushed and all 1261 - * the MPTCP sockets reached the closed status. 1260 + * the sockets reached the closed status. 1262 1261 * disconnect will bypass/ignore/drop any pending data. 1263 1262 */ 1264 1263 for (i = 0; ; i += msec_sleep) {
+5 -1
tools/testing/selftests/net/mptcp/mptcp_connect.sh
··· 211 211 done 212 212 fi 213 213 214 + if $capture; then 215 + rndh="${ns1:4}" 216 + mptcp_lib_pr_info "Packet capture files will have this prefix: ${rndh}-" 217 + fi 218 + 214 219 set_ethtool_flags() { 215 220 local ns="$1" 216 221 local dev="$2" ··· 366 361 367 362 if $capture; then 368 363 local capuser 369 - local rndh="${connector_ns:4}" 370 364 if [ -z $SUDO_USER ] ; then 371 365 capuser="" 372 366 else
+1 -1
tools/testing/selftests/net/mptcp/mptcp_lib.sh
··· 384 384 mptcp_lib_print_file_err() { 385 385 ls -l "${1}" 1>&2 386 386 echo "Trailing bytes are: " 387 - tail -c 27 "${1}" 387 + tail -c 32 "${1}" | od -x | head -n2 388 388 } 389 389 390 390 # $1: input file ; $2: output file ; $3: what kind of file
+10 -6
tools/testing/selftests/net/mptcp/mptcp_sockopt.c
··· 667 667 668 668 do_getsockopts(&s, fd, ret, ret2); 669 669 if (s.mptcpi_rcv_delta != (uint64_t)ret + 1) 670 - xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret); 670 + xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64 ", diff %" PRId64, 671 + s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - (ret + 1)); 671 672 672 673 /* be nice when running on top of older kernel */ 673 674 if (s.pkt_stats_avail) { 674 675 if (s.last_sample.mptcpi_bytes_sent != ret2) 675 - xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64, 676 + xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64 677 + ", diff %" PRId64, 676 678 s.last_sample.mptcpi_bytes_sent, ret2, 677 679 s.last_sample.mptcpi_bytes_sent - ret2); 678 680 if (s.last_sample.mptcpi_bytes_received != ret) 679 - xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64, 681 + xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64 682 + ", diff %" PRId64, 680 683 s.last_sample.mptcpi_bytes_received, ret, 681 684 s.last_sample.mptcpi_bytes_received - ret); 682 685 if (s.last_sample.mptcpi_bytes_acked != ret) 683 - xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64, 684 - s.last_sample.mptcpi_bytes_acked, ret2, 685 - s.last_sample.mptcpi_bytes_acked - ret2); 686 + xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64 687 + ", diff %" PRId64, 688 + s.last_sample.mptcpi_bytes_acked, ret, 689 + s.last_sample.mptcpi_bytes_acked - ret); 686 690 } 687 691 688 692 close(fd);
+7
tools/testing/selftests/net/mptcp/pm_nl_ctl.c
··· 188 188 fprintf(stderr, ",error:%u", *(__u8 *)RTA_DATA(attrs)); 189 189 else if (attrs->rta_type == MPTCP_ATTR_SERVER_SIDE) 190 190 fprintf(stderr, ",server_side:%u", *(__u8 *)RTA_DATA(attrs)); 191 + else if (attrs->rta_type == MPTCP_ATTR_FLAGS) { 192 + __u16 flags = *(__u16 *)RTA_DATA(attrs); 193 + 194 + /* only print when present, easier */ 195 + if (flags & MPTCP_PM_EV_FLAG_DENY_JOIN_ID0) 196 + fprintf(stderr, ",deny_join_id0:1"); 197 + } 191 198 192 199 attrs = RTA_NEXT(attrs, msg_len); 193 200 }
+11 -3
tools/testing/selftests/net/mptcp/userspace_pm.sh
··· 201 201 is_v6="v4" 202 202 fi 203 203 204 + # set this on the client side only: will not affect the rest 205 + ip netns exec "$ns2" sysctl -q net.mptcp.allow_join_initial_addr_port=0 206 + 204 207 :>"$client_evts" 205 208 :>"$server_evts" 206 209 ··· 226 223 local client_token 227 224 local client_port 228 225 local client_serverside 226 + local client_nojoin 229 227 local server_token 230 228 local server_serverside 229 + local server_nojoin 231 230 232 231 client_token=$(mptcp_lib_evts_get_info token "$client_evts") 233 232 client_port=$(mptcp_lib_evts_get_info sport "$client_evts") 234 233 client_serverside=$(mptcp_lib_evts_get_info server_side "$client_evts") 234 + client_nojoin=$(mptcp_lib_evts_get_info deny_join_id0 "$client_evts") 235 235 server_token=$(mptcp_lib_evts_get_info token "$server_evts") 236 236 server_serverside=$(mptcp_lib_evts_get_info server_side "$server_evts") 237 + server_nojoin=$(mptcp_lib_evts_get_info deny_join_id0 "$server_evts") 237 238 238 239 print_test "Established IP${is_v6} MPTCP Connection ns2 => ns1" 239 - if [ "$client_token" != "" ] && [ "$server_token" != "" ] && [ "$client_serverside" = 0 ] && 240 - [ "$server_serverside" = 1 ] 240 + if [ "${client_token}" != "" ] && [ "${server_token}" != "" ] && 241 + [ "${client_serverside}" = 0 ] && [ "${server_serverside}" = 1 ] && 242 + [ "${client_nojoin:-0}" = 0 ] && [ "${server_nojoin:-0}" = 1 ] 241 243 then 242 244 test_pass 243 245 print_title "Connection info: ${client_addr}:${client_port} -> ${connect_addr}:${app_port}" 244 246 else 245 - test_fail "Expected tokens (c:${client_token} - s:${server_token}) and server (c:${client_serverside} - s:${server_serverside})" 247 + test_fail "Expected tokens (c:${client_token} - s:${server_token}), server (c:${client_serverside} - s:${server_serverside}), nojoin (c:${client_nojoin} - s:${server_nojoin})" 246 248 mptcp_lib_result_print_all_tap 247 249 exit ${KSFT_FAIL} 248 250 fi
+81 -7
tools/testing/selftests/net/openvswitch/openvswitch.sh
··· 25 25 nat_related_v4 ip4-nat-related: ICMP related matches work with SNAT 26 26 netlink_checks ovsnl: validate netlink attrs and settings 27 27 upcall_interfaces ovs: test the upcall interfaces 28 + tunnel_metadata ovs: test extraction of tunnel metadata 28 29 drop_reason drop: test drop reasons are emitted 29 30 psample psample: Sampling packets with psample" 30 31 ··· 114 113 } 115 114 116 115 ovs_add_if () { 117 - info "Adding IF to DP: br:$2 if:$3" 118 - if [ "$4" != "-u" ]; then 119 - ovs_sbx "$1" python3 $ovs_base/ovs-dpctl.py add-if "$2" "$3" \ 120 - || return 1 116 + info "Adding IF to DP: br:$3 if:$4 ($2)" 117 + if [ "$5" != "-u" ]; then 118 + ovs_sbx "$1" python3 $ovs_base/ovs-dpctl.py add-if \ 119 + -t "$2" "$3" "$4" || return 1 121 120 else 122 121 python3 $ovs_base/ovs-dpctl.py add-if \ 123 - -u "$2" "$3" >$ovs_dir/$3.out 2>$ovs_dir/$3.err & 122 + -u -t "$2" "$3" "$4" >$ovs_dir/$4.out 2>$ovs_dir/$4.err & 124 123 pid=$! 125 124 on_exit "ovs_sbx $1 kill -TERM $pid 2>/dev/null" 126 125 fi ··· 167 166 fi 168 167 169 168 if [ "$7" != "-u" ]; then 170 - ovs_add_if "$1" "$2" "$4" || return 1 169 + ovs_add_if "$1" "netdev" "$2" "$4" || return 1 171 170 else 172 - ovs_add_if "$1" "$2" "$4" -u || return 1 171 + ovs_add_if "$1" "netdev" "$2" "$4" -u || return 1 173 172 fi 174 173 175 174 if [ $TRACING -eq 1 ]; then ··· 754 753 >$ovs_dir/arping.stdout 2>$ovs_dir/arping.stderr 755 754 756 755 grep -E "MISS upcall\[0/yes\]: .*arp\(sip=172.31.110.1,tip=172.31.110.20,op=1,sha=" $ovs_dir/left0.out >/dev/null 2>&1 || return 1 756 + return 0 757 + } 758 + 759 + ovs_add_kernel_tunnel() { 760 + local sbxname=$1; shift 761 + local ns=$1; shift 762 + local tnl_type=$1; shift 763 + local name=$1; shift 764 + local addr=$1; shift 765 + 766 + info "setting up kernel ${tnl_type} tunnel ${name}" 767 + ovs_sbx "${sbxname}" ip -netns ${ns} link add dev ${name} type ${tnl_type} $* || return 1 768 + on_exit "ovs_sbx ${sbxname} ip -netns ${ns} link del ${name} >/dev/null 2>&1" 769 + ovs_sbx "${sbxname}" ip -netns ${ns} addr add dev ${name} ${addr} || return 1 770 + ovs_sbx "${sbxname}" ip -netns ${ns} link set dev ${name} mtu 1450 up || return 1 771 + } 772 + 773 + test_tunnel_metadata() { 774 + which arping >/dev/null 2>&1 || return $ksft_skip 775 + 776 + sbxname="test_tunnel_metadata" 777 + sbx_add "${sbxname}" || return 1 778 + 779 + info "setting up new DP" 780 + ovs_add_dp "${sbxname}" tdp0 -V 2:1 || return 1 781 + 782 + ovs_add_netns_and_veths "${sbxname}" tdp0 tns left0 l0 \ 783 + 172.31.110.1/24 || return 1 784 + 785 + info "removing veth interface from openvswitch and setting IP" 786 + ovs_del_if "${sbxname}" tdp0 left0 || return 1 787 + ovs_sbx "${sbxname}" ip addr add 172.31.110.2/24 dev left0 || return 1 788 + ovs_sbx "${sbxname}" ip link set left0 up || return 1 789 + 790 + info "setting up tunnel port in openvswitch" 791 + ovs_add_if "${sbxname}" "vxlan" tdp0 ovs-vxlan0 -u || return 1 792 + on_exit "ovs_sbx ${sbxname} ip link del ovs-vxlan0" 793 + ovs_wait ip link show ovs-vxlan0 &>/dev/null || return 1 794 + ovs_sbx "${sbxname}" ip link set ovs-vxlan0 up || return 1 795 + 796 + configs=$(echo ' 797 + 1 172.31.221.1/24 1155332 32 set udpcsum flags\(df\|csum\) 798 + 2 172.31.222.1/24 1234567 45 set noudpcsum flags\(df\) 799 + 3 172.31.223.1/24 1020304 23 unset udpcsum flags\(csum\) 800 + 4 172.31.224.1/24 1357986 15 unset noudpcsum' | sed '/^$/d') 801 + 802 + while read -r i addr id ttl df csum flags; do 803 + ovs_add_kernel_tunnel "${sbxname}" tns vxlan vxlan${i} ${addr} \ 804 + remote 172.31.110.2 id ${id} dstport 4789 \ 805 + ttl ${ttl} df ${df} ${csum} || return 1 806 + done <<< "${configs}" 807 + 808 + ovs_wait grep -q 'listening on upcall packet handler' \ 809 + ${ovs_dir}/ovs-vxlan0.out || return 1 810 + 811 + info "sending arping" 812 + for i in 1 2 3 4; do 813 + ovs_sbx "${sbxname}" ip netns exec tns \ 814 + arping -I vxlan${i} 172.31.22${i}.2 -c 1 \ 815 + >${ovs_dir}/arping.stdout 2>${ovs_dir}/arping.stderr 816 + done 817 + 818 + info "checking that received decapsulated packets carry correct metadata" 819 + while read -r i addr id ttl df csum flags; do 820 + arp_hdr="arp\\(sip=172.31.22${i}.1,tip=172.31.22${i}.2,op=1,sha=" 821 + addrs="src=172.31.110.1,dst=172.31.110.2" 822 + ports="tp_src=[0-9]*,tp_dst=4789" 823 + tnl_md="tunnel\\(tun_id=${id},${addrs},ttl=${ttl},${ports},${flags}\\)" 824 + 825 + ovs_sbx "${sbxname}" grep -qE "MISS upcall.*${tnl_md}.*${arp_hdr}" \ 826 + ${ovs_dir}/ovs-vxlan0.out || return 1 827 + done <<< "${configs}" 828 + 757 829 return 0 758 830 } 759 831
+26
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-disconnect.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + `./defaults.sh 3 + ./set_sysctls.py /proc/sys/net/ipv4/tcp_fastopen=0x602 /proc/sys/net/ipv4/tcp_timestamps=0` 4 + 5 + 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 6 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 7 + +0 bind(3, ..., ...) = 0 8 + +0 listen(3, 1) = 0 9 + 10 + +0 < S 0:10(10) win 32792 <mss 1460,nop,nop,sackOK> 11 + +0 > S. 0:0(0) ack 11 win 65535 <mss 1460,nop,nop,sackOK> 12 + 13 + // sk->sk_state is TCP_SYN_RECV 14 + +.1 accept(3, ..., ...) = 4 15 + 16 + // tcp_disconnect() sets sk->sk_state to TCP_CLOSE 17 + +0 connect(4, AF_UNSPEC, ...) = 0 18 + +0 > R. 1:1(0) ack 11 win 65535 19 + 20 + // connect() sets sk->sk_state to TCP_SYN_SENT 21 + +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 22 + +0 connect(4, ..., ...) = -1 EINPROGRESS (Operation is now in progress) 23 + +0 > S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK,nop,wscale 8> 24 + 25 + // tp->fastopen_rsk must be NULL 26 + +1 > S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+16
tools/testing/selftests/net/tls.c
··· 2775 2775 } 2776 2776 } 2777 2777 2778 + /* Use OOB+large send to trigger copy mode due to memory pressure. 2779 + * OOB causes a short read. 2780 + */ 2781 + TEST_F(tls_err, oob_pressure) 2782 + { 2783 + char buf[1<<16]; 2784 + int i; 2785 + 2786 + memrnd(buf, sizeof(buf)); 2787 + 2788 + EXPECT_EQ(send(self->fd2, buf, 5, MSG_OOB), 5); 2789 + EXPECT_EQ(send(self->fd2, buf, sizeof(buf), 0), sizeof(buf)); 2790 + for (i = 0; i < 64; i++) 2791 + EXPECT_EQ(send(self->fd2, buf, 5, MSG_OOB), 5); 2792 + } 2793 + 2778 2794 TEST(non_established) { 2779 2795 struct tls12_crypto_info_aes_gcm_256 tls12; 2780 2796 struct sockaddr_in addr;