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.13-rc4).

No conflicts.

Adjacent changes:

drivers/net/ethernet/renesas/rswitch.h
32fd46f5b69e ("net: renesas: rswitch: remove speed from gwca structure")
922b4b955a03 ("net: renesas: rswitch: rework ts tags management")

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

+4109 -2059
+2 -5
Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
··· 113 113 maxItems: 1 114 114 115 115 - if: 116 - properties: 117 - compatible: 118 - contains: 119 - enum: 120 - - fsl,imx95-usb-phy 116 + required: 117 + - orientation-switch 121 118 then: 122 119 $ref: /schemas/usb/usb-switch.yaml# 123 120
+27
Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml
··· 18 18 compatible: 19 19 enum: 20 20 - qcom,qca6390-pmu 21 + - qcom,wcn6750-pmu 21 22 - qcom,wcn6855-pmu 22 23 - qcom,wcn7850-pmu 23 24 ··· 27 26 28 27 vddaon-supply: 29 28 description: VDD_AON supply regulator handle 29 + 30 + vddasd-supply: 31 + description: VDD_ASD supply regulator handle 30 32 31 33 vdddig-supply: 32 34 description: VDD_DIG supply regulator handle ··· 46 42 vddio1p2-supply: 47 43 description: VDD_IO_1P2 supply regulator handle 48 44 45 + vddrfa0p8-supply: 46 + description: VDD_RFA_0P8 supply regulator handle 47 + 49 48 vddrfa0p95-supply: 50 49 description: VDD_RFA_0P95 supply regulator handle 51 50 ··· 58 51 vddrfa1p3-supply: 59 52 description: VDD_RFA_1P3 supply regulator handle 60 53 54 + vddrfa1p7-supply: 55 + description: VDD_RFA_1P7 supply regulator handle 56 + 61 57 vddrfa1p8-supply: 62 58 description: VDD_RFA_1P8 supply regulator handle 63 59 64 60 vddrfa1p9-supply: 65 61 description: VDD_RFA_1P9 supply regulator handle 62 + 63 + vddrfa2p2-supply: 64 + description: VDD_RFA_2P2 supply regulator handle 66 65 67 66 vddpcie1p3-supply: 68 67 description: VDD_PCIE_1P3 supply regulator handle ··· 132 119 - vddpcie1p3-supply 133 120 - vddpcie1p9-supply 134 121 - vddio-supply 122 + - if: 123 + properties: 124 + compatible: 125 + contains: 126 + const: qcom,wcn6750-pmu 127 + then: 128 + required: 129 + - vddaon-supply 130 + - vddasd-supply 131 + - vddpmu-supply 132 + - vddrfa0p8-supply 133 + - vddrfa1p2-supply 134 + - vddrfa1p7-supply 135 + - vddrfa2p2-supply 135 136 - if: 136 137 properties: 137 138 compatible:
+3 -1
Documentation/power/runtime_pm.rst
··· 347 347 348 348 `int pm_runtime_resume_and_get(struct device *dev);` 349 349 - run pm_runtime_resume(dev) and if successful, increment the device's 350 - usage counter; return the result of pm_runtime_resume 350 + usage counter; returns 0 on success (whether or not the device's 351 + runtime PM status was already 'active') or the error code from 352 + pm_runtime_resume() on failure. 351 353 352 354 `int pm_request_idle(struct device *dev);` 353 355 - submit a request to execute the subsystem-level idle callback for the
+2 -2
MAINTAINERS
··· 3900 3900 F: drivers/net/hamradio/baycom* 3901 3901 3902 3902 BCACHE (BLOCK LAYER CACHE) 3903 - M: Coly Li <colyli@suse.de> 3903 + M: Coly Li <colyli@kernel.org> 3904 3904 M: Kent Overstreet <kent.overstreet@linux.dev> 3905 3905 L: linux-bcache@vger.kernel.org 3906 3906 S: Maintained ··· 8460 8460 EROFS FILE SYSTEM 8461 8461 M: Gao Xiang <xiang@kernel.org> 8462 8462 M: Chao Yu <chao@kernel.org> 8463 - R: Yue Hu <huyue2@coolpad.com> 8463 + R: Yue Hu <zbestahu@gmail.com> 8464 8464 R: Jeffle Xu <jefflexu@linux.alibaba.com> 8465 8465 R: Sandeep Dhavale <dhavale@google.com> 8466 8466 L: linux-erofs@lists.ozlabs.org
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 13 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc2 5 + EXTRAVERSION = -rc3 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+2 -2
arch/arc/Kconfig
··· 297 297 config ARC_PAGE_SIZE_4K 298 298 bool "4KB" 299 299 select HAVE_PAGE_SIZE_4KB 300 - depends on ARC_MMU_V3 || ARC_MMU_V4 301 300 302 301 endchoice 303 302 ··· 473 474 474 475 config ARC_HAS_PAE40 475 476 bool "Support for the 40-bit Physical Address Extension" 476 - depends on ISA_ARCV2 477 + depends on ARC_MMU_V4 478 + depends on !ARC_PAGE_SIZE_4K 477 479 select HIGHMEM 478 480 select PHYS_ADDR_T_64BIT 479 481 help
+1 -1
arch/arc/Makefile
··· 6 6 KBUILD_DEFCONFIG := haps_hs_smp_defconfig 7 7 8 8 ifeq ($(CROSS_COMPILE),) 9 - CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-) 9 + CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux- arc-linux-gnu-) 10 10 endif 11 11 12 12 cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
+1 -1
arch/arc/boot/dts/axc001.dtsi
··· 54 54 compatible = "snps,dw-apb-gpio-port"; 55 55 gpio-controller; 56 56 #gpio-cells = <2>; 57 - snps,nr-gpios = <30>; 57 + ngpios = <30>; 58 58 reg = <0>; 59 59 interrupt-controller; 60 60 #interrupt-cells = <2>;
+1 -1
arch/arc/boot/dts/axc003.dtsi
··· 62 62 compatible = "snps,dw-apb-gpio-port"; 63 63 gpio-controller; 64 64 #gpio-cells = <2>; 65 - snps,nr-gpios = <30>; 65 + ngpios = <30>; 66 66 reg = <0>; 67 67 interrupt-controller; 68 68 #interrupt-cells = <2>;
+1 -1
arch/arc/boot/dts/axc003_idu.dtsi
··· 69 69 compatible = "snps,dw-apb-gpio-port"; 70 70 gpio-controller; 71 71 #gpio-cells = <2>; 72 - snps,nr-gpios = <30>; 72 + ngpios = <30>; 73 73 reg = <0>; 74 74 interrupt-controller; 75 75 #interrupt-cells = <2>;
+6 -6
arch/arc/boot/dts/axs10x_mb.dtsi
··· 250 250 compatible = "snps,dw-apb-gpio-port"; 251 251 gpio-controller; 252 252 #gpio-cells = <2>; 253 - snps,nr-gpios = <32>; 253 + ngpios = <32>; 254 254 reg = <0>; 255 255 }; 256 256 ··· 258 258 compatible = "snps,dw-apb-gpio-port"; 259 259 gpio-controller; 260 260 #gpio-cells = <2>; 261 - snps,nr-gpios = <8>; 261 + ngpios = <8>; 262 262 reg = <1>; 263 263 }; 264 264 ··· 266 266 compatible = "snps,dw-apb-gpio-port"; 267 267 gpio-controller; 268 268 #gpio-cells = <2>; 269 - snps,nr-gpios = <8>; 269 + ngpios = <8>; 270 270 reg = <2>; 271 271 }; 272 272 }; ··· 281 281 compatible = "snps,dw-apb-gpio-port"; 282 282 gpio-controller; 283 283 #gpio-cells = <2>; 284 - snps,nr-gpios = <30>; 284 + ngpios = <30>; 285 285 reg = <0>; 286 286 }; 287 287 ··· 289 289 compatible = "snps,dw-apb-gpio-port"; 290 290 gpio-controller; 291 291 #gpio-cells = <2>; 292 - snps,nr-gpios = <10>; 292 + ngpios = <10>; 293 293 reg = <1>; 294 294 }; 295 295 ··· 297 297 compatible = "snps,dw-apb-gpio-port"; 298 298 gpio-controller; 299 299 #gpio-cells = <2>; 300 - snps,nr-gpios = <8>; 300 + ngpios = <8>; 301 301 reg = <2>; 302 302 }; 303 303 };
+1 -1
arch/arc/boot/dts/hsdk.dts
··· 308 308 compatible = "snps,dw-apb-gpio-port"; 309 309 gpio-controller; 310 310 #gpio-cells = <2>; 311 - snps,nr-gpios = <24>; 311 + ngpios = <24>; 312 312 reg = <0>; 313 313 }; 314 314 };
+1 -1
arch/arc/include/asm/arcregs.h
··· 146 146 147 147 #ifndef __ASSEMBLY__ 148 148 149 - #include <soc/arc/aux.h> 149 + #include <soc/arc/arc_aux.h> 150 150 151 151 /* Helpers */ 152 152 #define TO_KB(bytes) ((bytes) >> 10)
+1 -1
arch/arc/include/asm/cmpxchg.h
··· 48 48 \ 49 49 switch(sizeof((_p_))) { \ 50 50 case 1: \ 51 - _prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \ 51 + _prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *__force)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \ 52 52 break; \ 53 53 case 4: \ 54 54 _prev_ = __cmpxchg(_p_, _o_, _n_); \
+1 -1
arch/arc/include/asm/mmu-arcv2.h
··· 9 9 #ifndef _ASM_ARC_MMU_ARCV2_H 10 10 #define _ASM_ARC_MMU_ARCV2_H 11 11 12 - #include <soc/arc/aux.h> 12 + #include <soc/arc/arc_aux.h> 13 13 14 14 /* 15 15 * TLB Management regs
+1 -1
arch/arc/net/bpf_jit_arcv2.c
··· 2916 2916 addendum = (cond == ARC_CC_AL) ? 0 : INSN_len_normal; 2917 2917 disp = get_displacement(curr_off + addendum, targ_off); 2918 2918 2919 - if (ARC_CC_AL) 2919 + if (cond == ARC_CC_AL) 2920 2920 return is_valid_far_disp(disp); 2921 2921 else 2922 2922 return is_valid_near_disp(disp);
+1 -1
arch/arm64/boot/dts/arm/fvp-base-revc.dts
··· 233 233 #interrupt-cells = <0x1>; 234 234 compatible = "pci-host-ecam-generic"; 235 235 device_type = "pci"; 236 - bus-range = <0x0 0x1>; 236 + bus-range = <0x0 0xff>; 237 237 reg = <0x0 0x40000000 0x0 0x10000000>; 238 238 ranges = <0x2000000 0x0 0x50000000 0x0 0x50000000 0x0 0x10000000>; 239 239 interrupt-map = <0 0 0 1 &gic 0 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
+2 -2
arch/arm64/include/asm/el2_setup.h
··· 87 87 1 << PMSCR_EL2_PA_SHIFT) 88 88 msr_s SYS_PMSCR_EL2, x0 // addresses and physical counter 89 89 .Lskip_spe_el2_\@: 90 - mov x0, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT) 90 + mov x0, #MDCR_EL2_E2PB_MASK 91 91 orr x2, x2, x0 // If we don't have VHE, then 92 92 // use EL1&0 translation. 93 93 ··· 100 100 and x0, x0, TRBIDR_EL1_P 101 101 cbnz x0, .Lskip_trace_\@ // If TRBE is available at EL2 102 102 103 - mov x0, #(MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT) 103 + mov x0, #MDCR_EL2_E2TB_MASK 104 104 orr x2, x2, x0 // allow the EL1&0 translation 105 105 // to own it. 106 106
+2 -2
arch/arm64/kernel/hyp-stub.S
··· 114 114 115 115 // Use EL2 translations for SPE & TRBE and disable access from EL1 116 116 mrs x0, mdcr_el2 117 - bic x0, x0, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT) 118 - bic x0, x0, #(MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT) 117 + bic x0, x0, #MDCR_EL2_E2PB_MASK 118 + bic x0, x0, #MDCR_EL2_E2TB_MASK 119 119 msr mdcr_el2, x0 120 120 121 121 // Transfer the MM state from EL1 to EL2
+33 -15
arch/arm64/kernel/signal.c
··· 1462 1462 struct rt_sigframe_user_layout *user, int usig) 1463 1463 { 1464 1464 __sigrestore_t sigtramp; 1465 + int err; 1466 + 1467 + if (ksig->ka.sa.sa_flags & SA_RESTORER) 1468 + sigtramp = ksig->ka.sa.sa_restorer; 1469 + else 1470 + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); 1471 + 1472 + err = gcs_signal_entry(sigtramp, ksig); 1473 + if (err) 1474 + return err; 1475 + 1476 + /* 1477 + * We must not fail from this point onwards. We are going to update 1478 + * registers, including SP, in order to invoke the signal handler. If 1479 + * we failed and attempted to deliver a nested SIGSEGV to a handler 1480 + * after that point, the subsequent sigreturn would end up restoring 1481 + * the (partial) state for the original signal handler. 1482 + */ 1465 1483 1466 1484 regs->regs[0] = usig; 1485 + if (ksig->ka.sa.sa_flags & SA_SIGINFO) { 1486 + regs->regs[1] = (unsigned long)&user->sigframe->info; 1487 + regs->regs[2] = (unsigned long)&user->sigframe->uc; 1488 + } 1467 1489 regs->sp = (unsigned long)user->sigframe; 1468 1490 regs->regs[29] = (unsigned long)&user->next_frame->fp; 1491 + regs->regs[30] = (unsigned long)sigtramp; 1469 1492 regs->pc = (unsigned long)ksig->ka.sa.sa_handler; 1470 1493 1471 1494 /* ··· 1529 1506 sme_smstop(); 1530 1507 } 1531 1508 1532 - if (ksig->ka.sa.sa_flags & SA_RESTORER) 1533 - sigtramp = ksig->ka.sa.sa_restorer; 1534 - else 1535 - sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); 1536 - 1537 - regs->regs[30] = (unsigned long)sigtramp; 1538 - 1539 - return gcs_signal_entry(sigtramp, ksig); 1509 + return 0; 1540 1510 } 1541 1511 1542 1512 static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, ··· 1553 1537 1554 1538 err |= __save_altstack(&frame->uc.uc_stack, regs->sp); 1555 1539 err |= setup_sigframe(&user, regs, set, &ua_state); 1556 - if (err == 0) { 1540 + if (ksig->ka.sa.sa_flags & SA_SIGINFO) 1541 + err |= copy_siginfo_to_user(&frame->info, &ksig->info); 1542 + 1543 + if (err == 0) 1557 1544 err = setup_return(regs, ksig, &user, usig); 1558 - if (ksig->ka.sa.sa_flags & SA_SIGINFO) { 1559 - err |= copy_siginfo_to_user(&frame->info, &ksig->info); 1560 - regs->regs[1] = (unsigned long)&frame->info; 1561 - regs->regs[2] = (unsigned long)&frame->uc; 1562 - } 1563 - } 1545 + 1546 + /* 1547 + * We must not fail if setup_return() succeeded - see comment at the 1548 + * beginning of setup_return(). 1549 + */ 1564 1550 1565 1551 if (err == 0) 1566 1552 set_handler_user_access_state();
+7 -25
arch/arm64/kernel/stacktrace.c
··· 26 26 KUNWIND_SOURCE_CALLER, 27 27 KUNWIND_SOURCE_TASK, 28 28 KUNWIND_SOURCE_REGS_PC, 29 - KUNWIND_SOURCE_REGS_LR, 30 29 }; 31 30 32 31 union unwind_flags { ··· 137 138 orig_pc = ftrace_graph_ret_addr(state->task, &state->graph_idx, 138 139 state->common.pc, 139 140 (void *)state->common.fp); 140 - if (WARN_ON_ONCE(state->common.pc == orig_pc)) 141 + if (state->common.pc == orig_pc) { 142 + WARN_ON_ONCE(state->task == current); 141 143 return -EINVAL; 144 + } 142 145 state->common.pc = orig_pc; 143 146 state->flags.fgraph = 1; 144 147 } ··· 179 178 state->regs = regs; 180 179 state->common.pc = regs->pc; 181 180 state->common.fp = regs->regs[29]; 182 - state->source = KUNWIND_SOURCE_REGS_PC; 183 - return 0; 184 - } 185 - 186 - static __always_inline int 187 - kunwind_next_regs_lr(struct kunwind_state *state) 188 - { 189 - /* 190 - * The stack for the regs was consumed by kunwind_next_regs_pc(), so we 191 - * cannot consume that again here, but we know the regs are safe to 192 - * access. 193 - */ 194 - state->common.pc = state->regs->regs[30]; 195 - state->common.fp = state->regs->regs[29]; 196 181 state->regs = NULL; 197 - state->source = KUNWIND_SOURCE_REGS_LR; 198 - 182 + state->source = KUNWIND_SOURCE_REGS_PC; 199 183 return 0; 200 184 } 201 185 ··· 201 215 case FRAME_META_TYPE_FINAL: 202 216 if (meta == &task_pt_regs(tsk)->stackframe) 203 217 return -ENOENT; 204 - WARN_ON_ONCE(1); 218 + WARN_ON_ONCE(tsk == current); 205 219 return -EINVAL; 206 220 case FRAME_META_TYPE_PT_REGS: 207 221 return kunwind_next_regs_pc(state); 208 222 default: 209 - WARN_ON_ONCE(1); 223 + WARN_ON_ONCE(tsk == current); 210 224 return -EINVAL; 211 225 } 212 226 } ··· 260 274 case KUNWIND_SOURCE_FRAME: 261 275 case KUNWIND_SOURCE_CALLER: 262 276 case KUNWIND_SOURCE_TASK: 263 - case KUNWIND_SOURCE_REGS_LR: 264 - err = kunwind_next_frame_record(state); 265 - break; 266 277 case KUNWIND_SOURCE_REGS_PC: 267 - err = kunwind_next_regs_lr(state); 278 + err = kunwind_next_frame_record(state); 268 279 break; 269 280 default: 270 281 err = -EINVAL; ··· 419 436 case KUNWIND_SOURCE_CALLER: return "C"; 420 437 case KUNWIND_SOURCE_TASK: return "T"; 421 438 case KUNWIND_SOURCE_REGS_PC: return "P"; 422 - case KUNWIND_SOURCE_REGS_LR: return "L"; 423 439 default: return "U"; 424 440 } 425 441 }
+9 -2
arch/arm64/kvm/at.c
··· 739 739 final_attr = s1_parattr; 740 740 break; 741 741 default: 742 - /* MemAttr[2]=0, Device from S2 */ 743 - final_attr = s2_memattr & GENMASK(1,0) << 2; 742 + /* 743 + * MemAttr[2]=0, Device from S2. 744 + * 745 + * FWB does not influence the way that stage 1 746 + * memory types and attributes are combined 747 + * with stage 2 Device type and attributes. 748 + */ 749 + final_attr = min(s2_memattr_to_attr(s2_memattr), 750 + s1_parattr); 744 751 } 745 752 } else { 746 753 /* Combination of R_HMNDG, R_TNHFM and R_GQFSF */
+2 -2
arch/arm64/kvm/hyp/nvhe/pkvm.c
··· 126 126 /* Trap SPE */ 127 127 if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_PMSVer), feature_ids)) { 128 128 mdcr_set |= MDCR_EL2_TPMS; 129 - mdcr_clear |= MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT; 129 + mdcr_clear |= MDCR_EL2_E2PB_MASK; 130 130 } 131 131 132 132 /* Trap Trace Filter */ ··· 143 143 144 144 /* Trap External Trace */ 145 145 if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_ExtTrcBuff), feature_ids)) 146 - mdcr_clear |= MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT; 146 + mdcr_clear |= MDCR_EL2_E2TB_MASK; 147 147 148 148 vcpu->arch.mdcr_el2 |= mdcr_set; 149 149 vcpu->arch.mdcr_el2 &= ~mdcr_clear;
+2 -1
arch/arm64/kvm/sys_regs.c
··· 2618 2618 ID_WRITABLE(ID_AA64MMFR0_EL1, ~(ID_AA64MMFR0_EL1_RES0 | 2619 2619 ID_AA64MMFR0_EL1_TGRAN4_2 | 2620 2620 ID_AA64MMFR0_EL1_TGRAN64_2 | 2621 - ID_AA64MMFR0_EL1_TGRAN16_2)), 2621 + ID_AA64MMFR0_EL1_TGRAN16_2 | 2622 + ID_AA64MMFR0_EL1_ASIDBITS)), 2622 2623 ID_WRITABLE(ID_AA64MMFR1_EL1, ~(ID_AA64MMFR1_EL1_RES0 | 2623 2624 ID_AA64MMFR1_EL1_HCX | 2624 2625 ID_AA64MMFR1_EL1_TWED |
+11 -1
arch/arm64/kvm/vgic/vgic-its.c
··· 608 608 lockdep_assert_held(&its->its_lock); 609 609 vgic_get_irq_kref(irq); 610 610 611 + old = xa_store(&its->translation_cache, cache_key, irq, GFP_KERNEL_ACCOUNT); 612 + 613 + /* 614 + * Put the reference taken on @irq if the store fails. Intentionally do 615 + * not return the error as the translation cache is best effort. 616 + */ 617 + if (xa_is_err(old)) { 618 + vgic_put_irq(kvm, irq); 619 + return; 620 + } 621 + 611 622 /* 612 623 * We could have raced with another CPU caching the same 613 624 * translation behind our back, ensure we don't leak a 614 625 * reference if that is the case. 615 626 */ 616 - old = xa_store(&its->translation_cache, cache_key, irq, GFP_KERNEL_ACCOUNT); 617 627 if (old) 618 628 vgic_put_irq(kvm, old); 619 629 }
+6
arch/hexagon/Makefile
··· 32 32 TIR_NAME := r19 33 33 KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__ 34 34 KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME) 35 + 36 + # Disable HexagonConstExtenders pass for LLVM versions prior to 19.1.0 37 + # https://github.com/llvm/llvm-project/issues/99714 38 + ifneq ($(call clang-min-version, 190100),y) 39 + KBUILD_CFLAGS += -mllvm -hexagon-cext=false 40 + endif
+2
arch/openrisc/kernel/entry.S
··· 239 239 240 240 /* =====================================================[ exceptions] === */ 241 241 242 + __REF 243 + 242 244 /* ---[ 0x100: RESET exception ]----------------------------------------- */ 243 245 244 246 EXCEPTION_ENTRY(_tng_kernel_start)
+17 -15
arch/openrisc/kernel/head.S
··· 26 26 #include <asm/asm-offsets.h> 27 27 #include <linux/of_fdt.h> 28 28 29 - #define tophys(rd,rs) \ 30 - l.movhi rd,hi(-KERNELBASE) ;\ 29 + #define tophys(rd,rs) \ 30 + l.movhi rd,hi(-KERNELBASE) ;\ 31 31 l.add rd,rd,rs 32 32 33 - #define CLEAR_GPR(gpr) \ 33 + #define CLEAR_GPR(gpr) \ 34 34 l.movhi gpr,0x0 35 35 36 - #define LOAD_SYMBOL_2_GPR(gpr,symbol) \ 37 - l.movhi gpr,hi(symbol) ;\ 36 + #define LOAD_SYMBOL_2_GPR(gpr,symbol) \ 37 + l.movhi gpr,hi(symbol) ;\ 38 38 l.ori gpr,gpr,lo(symbol) 39 39 40 40 ··· 326 326 l.addi r1,r1,-(INT_FRAME_SIZE) ;\ 327 327 /* r1 is KSP, r30 is __pa(KSP) */ ;\ 328 328 tophys (r30,r1) ;\ 329 - l.sw PT_GPR12(r30),r12 ;\ 329 + l.sw PT_GPR12(r30),r12 ;\ 330 330 l.mfspr r12,r0,SPR_EPCR_BASE ;\ 331 331 l.sw PT_PC(r30),r12 ;\ 332 332 l.mfspr r12,r0,SPR_ESR_BASE ;\ 333 333 l.sw PT_SR(r30),r12 ;\ 334 334 /* save r31 */ ;\ 335 335 EXCEPTION_T_LOAD_GPR30(r12) ;\ 336 - l.sw PT_GPR30(r30),r12 ;\ 336 + l.sw PT_GPR30(r30),r12 ;\ 337 337 /* save r10 as was prior to exception */ ;\ 338 338 EXCEPTION_T_LOAD_GPR10(r12) ;\ 339 - l.sw PT_GPR10(r30),r12 ;\ 340 - /* save PT_SP as was prior to exception */ ;\ 339 + l.sw PT_GPR10(r30),r12 ;\ 340 + /* save PT_SP as was prior to exception */ ;\ 341 341 EXCEPTION_T_LOAD_SP(r12) ;\ 342 342 l.sw PT_SP(r30),r12 ;\ 343 - l.sw PT_GPR13(r30),r13 ;\ 343 + l.sw PT_GPR13(r30),r13 ;\ 344 344 /* --> */ ;\ 345 345 /* save exception r4, set r4 = EA */ ;\ 346 346 l.sw PT_GPR4(r30),r4 ;\ ··· 356 356 l.rfe 357 357 358 358 /* =====================================================[ exceptions] === */ 359 + 360 + __HEAD 359 361 360 362 /* ---[ 0x100: RESET exception ]----------------------------------------- */ 361 363 .org 0x100 ··· 396 394 .org 0x500 397 395 EXCEPTION_HANDLE(_timer_handler) 398 396 399 - /* ---[ 0x600: Alignment exception ]-------------------------------------- */ 397 + /* ---[ 0x600: Alignment exception ]------------------------------------- */ 400 398 .org 0x600 401 399 EXCEPTION_HANDLE(_alignment_handler) 402 400 ··· 426 424 .org 0xc00 427 425 EXCEPTION_HANDLE(_sys_call_handler) 428 426 429 - /* ---[ 0xd00: Floating point exception ]--------------------------------- */ 427 + /* ---[ 0xd00: Floating point exception ]-------------------------------- */ 430 428 .org 0xd00 431 429 EXCEPTION_HANDLE(_fpe_trap_handler) 432 430 ··· 508 506 509 507 /* .text*/ 510 508 511 - /* This early stuff belongs in HEAD, but some of the functions below definitely 509 + /* This early stuff belongs in the .init.text section, but some of the functions below definitely 512 510 * don't... */ 513 511 514 - __HEAD 512 + __INIT 515 513 .global _start 516 514 _start: 517 515 /* Init r0 to zero as per spec */ ··· 818 816 819 817 #endif 820 818 821 - /* ========================================[ cache ]=== */ 819 + /* ==========================================================[ cache ]=== */ 822 820 823 821 /* alignment here so we don't change memory offsets with 824 822 * memory controller defined
+1 -2
arch/openrisc/kernel/vmlinux.lds.S
··· 50 50 .text : AT(ADDR(.text) - LOAD_OFFSET) 51 51 { 52 52 _stext = .; 53 + HEAD_TEXT 53 54 TEXT_TEXT 54 55 SCHED_TEXT 55 56 LOCK_TEXT ··· 83 82 /* Init code and data */ 84 83 . = ALIGN(PAGE_SIZE); 85 84 __init_begin = .; 86 - 87 - HEAD_TEXT_SECTION 88 85 89 86 /* Page aligned */ 90 87 INIT_TEXT_SECTION(PAGE_SIZE)
+3 -1
arch/riscv/include/asm/kfence.h
··· 22 22 else 23 23 set_pte(pte, __pte(pte_val(ptep_get(pte)) | _PAGE_PRESENT)); 24 24 25 - flush_tlb_kernel_range(addr, addr + PAGE_SIZE); 25 + preempt_disable(); 26 + local_flush_tlb_kernel_range(addr, addr + PAGE_SIZE); 27 + preempt_enable(); 26 28 27 29 return true; 28 30 }
+9 -3
arch/riscv/kernel/jump_label.c
··· 36 36 insn = RISCV_INSN_NOP; 37 37 } 38 38 39 - mutex_lock(&text_mutex); 40 - patch_insn_write(addr, &insn, sizeof(insn)); 41 - mutex_unlock(&text_mutex); 39 + if (early_boot_irqs_disabled) { 40 + riscv_patch_in_stop_machine = 1; 41 + patch_insn_write(addr, &insn, sizeof(insn)); 42 + riscv_patch_in_stop_machine = 0; 43 + } else { 44 + mutex_lock(&text_mutex); 45 + patch_insn_write(addr, &insn, sizeof(insn)); 46 + mutex_unlock(&text_mutex); 47 + } 42 48 43 49 return true; 44 50 }
+1 -1
arch/riscv/kernel/setup.c
··· 227 227 static void __init parse_dtb(void) 228 228 { 229 229 /* Early scan of device tree from init memory */ 230 - if (early_init_dt_scan(dtb_early_va, __pa(dtb_early_va))) { 230 + if (early_init_dt_scan(dtb_early_va, dtb_early_pa)) { 231 231 const char *name = of_flat_dt_get_machine_name(); 232 232 233 233 if (name) {
+1 -1
arch/riscv/kvm/aia.c
··· 590 590 csr_set(CSR_HIE, BIT(IRQ_S_GEXT)); 591 591 /* Enable IRQ filtering for overflow interrupt only if sscofpmf is present */ 592 592 if (__riscv_isa_extension_available(NULL, RISCV_ISA_EXT_SSCOFPMF)) 593 - csr_write(CSR_HVIEN, BIT(IRQ_PMU_OVF)); 593 + csr_set(CSR_HVIEN, BIT(IRQ_PMU_OVF)); 594 594 } 595 595 596 596 void kvm_riscv_aia_disable(void)
+4 -3
arch/riscv/mm/init.c
··· 1566 1566 pmd_clear(pmd); 1567 1567 } 1568 1568 1569 - static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud) 1569 + static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud, bool is_vmemmap) 1570 1570 { 1571 1571 struct page *page = pud_page(*pud); 1572 1572 struct ptdesc *ptdesc = page_ptdesc(page); ··· 1579 1579 return; 1580 1580 } 1581 1581 1582 - pagetable_pmd_dtor(ptdesc); 1582 + if (!is_vmemmap) 1583 + pagetable_pmd_dtor(ptdesc); 1583 1584 if (PageReserved(page)) 1584 1585 free_reserved_page(page); 1585 1586 else ··· 1704 1703 remove_pmd_mapping(pmd_base, addr, next, is_vmemmap, altmap); 1705 1704 1706 1705 if (pgtable_l4_enabled) 1707 - free_pmd_table(pmd_base, pudp); 1706 + free_pmd_table(pmd_base, pudp, is_vmemmap); 1708 1707 } 1709 1708 } 1710 1709
+2
arch/s390/boot/startup.c
··· 234 234 vsize = round_up(SZ_2G + max_mappable, rte_size) + 235 235 round_up(vmemmap_size, rte_size) + 236 236 FIXMAP_SIZE + MODULES_LEN + KASLR_LEN; 237 + if (IS_ENABLED(CONFIG_KMSAN)) 238 + vsize += MODULES_LEN * 2; 237 239 return size_add(vsize, vmalloc_size); 238 240 } 239 241
+3 -3
arch/s390/boot/vmem.c
··· 306 306 pages++; 307 307 } 308 308 } 309 - if (mode == POPULATE_DIRECT) 309 + if (mode == POPULATE_IDENTITY) 310 310 update_page_count(PG_DIRECT_MAP_4K, pages); 311 311 } 312 312 ··· 339 339 } 340 340 pgtable_pte_populate(pmd, addr, next, mode); 341 341 } 342 - if (mode == POPULATE_DIRECT) 342 + if (mode == POPULATE_IDENTITY) 343 343 update_page_count(PG_DIRECT_MAP_1M, pages); 344 344 } 345 345 ··· 372 372 } 373 373 pgtable_pmd_populate(pud, addr, next, mode); 374 374 } 375 - if (mode == POPULATE_DIRECT) 375 + if (mode == POPULATE_IDENTITY) 376 376 update_page_count(PG_DIRECT_MAP_2G, pages); 377 377 } 378 378
+1 -1
arch/s390/kernel/ipl.c
··· 270 270 if (len >= sizeof(_value)) \ 271 271 return -E2BIG; \ 272 272 len = strscpy(_value, buf, sizeof(_value)); \ 273 - if (len < 0) \ 273 + if ((ssize_t)len < 0) \ 274 274 return len; \ 275 275 strim(_value); \ 276 276 return len; \
+2
arch/x86/include/asm/processor.h
··· 230 230 return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT); 231 231 } 232 232 233 + void init_cpu_devs(void); 234 + void get_cpu_vendor(struct cpuinfo_x86 *c); 233 235 extern void early_cpu_init(void); 234 236 extern void identify_secondary_cpu(struct cpuinfo_x86 *); 235 237 extern void print_cpu_info(struct cpuinfo_x86 *);
+15
arch/x86/include/asm/static_call.h
··· 65 65 66 66 extern bool __static_call_fixup(void *tramp, u8 op, void *dest); 67 67 68 + extern void __static_call_update_early(void *tramp, void *func); 69 + 70 + #define static_call_update_early(name, _func) \ 71 + ({ \ 72 + typeof(&STATIC_CALL_TRAMP(name)) __F = (_func); \ 73 + if (static_call_initialized) { \ 74 + __static_call_update(&STATIC_CALL_KEY(name), \ 75 + STATIC_CALL_TRAMP_ADDR(name), __F);\ 76 + } else { \ 77 + WRITE_ONCE(STATIC_CALL_KEY(name).func, _func); \ 78 + __static_call_update_early(STATIC_CALL_TRAMP_ADDR(name),\ 79 + __F); \ 80 + } \ 81 + }) 82 + 68 83 #endif /* _ASM_STATIC_CALL_H */
+3 -3
arch/x86/include/asm/sync_core.h
··· 8 8 #include <asm/special_insns.h> 9 9 10 10 #ifdef CONFIG_X86_32 11 - static inline void iret_to_self(void) 11 + static __always_inline void iret_to_self(void) 12 12 { 13 13 asm volatile ( 14 14 "pushfl\n\t" ··· 19 19 : ASM_CALL_CONSTRAINT : : "memory"); 20 20 } 21 21 #else 22 - static inline void iret_to_self(void) 22 + static __always_inline void iret_to_self(void) 23 23 { 24 24 unsigned int tmp; 25 25 ··· 55 55 * Like all of Linux's memory ordering operations, this is a 56 56 * compiler barrier as well. 57 57 */ 58 - static inline void sync_core(void) 58 + static __always_inline void sync_core(void) 59 59 { 60 60 /* 61 61 * The SERIALIZE instruction is the most straightforward way to
+22 -14
arch/x86/include/asm/xen/hypercall.h
··· 39 39 #include <linux/string.h> 40 40 #include <linux/types.h> 41 41 #include <linux/pgtable.h> 42 + #include <linux/instrumentation.h> 42 43 43 44 #include <trace/events/xen.h> 44 45 46 + #include <asm/alternative.h> 45 47 #include <asm/page.h> 46 48 #include <asm/smap.h> 47 49 #include <asm/nospec-branch.h> ··· 88 86 * there aren't more than 5 arguments...) 89 87 */ 90 88 91 - extern struct { char _entry[32]; } hypercall_page[]; 89 + void xen_hypercall_func(void); 90 + DECLARE_STATIC_CALL(xen_hypercall, xen_hypercall_func); 92 91 93 - #define __HYPERCALL "call hypercall_page+%c[offset]" 94 - #define __HYPERCALL_ENTRY(x) \ 95 - [offset] "i" (__HYPERVISOR_##x * sizeof(hypercall_page[0])) 92 + #ifdef MODULE 93 + #define __ADDRESSABLE_xen_hypercall 94 + #else 95 + #define __ADDRESSABLE_xen_hypercall __ADDRESSABLE_ASM_STR(__SCK__xen_hypercall) 96 + #endif 97 + 98 + #define __HYPERCALL \ 99 + __ADDRESSABLE_xen_hypercall \ 100 + "call __SCT__xen_hypercall" 101 + 102 + #define __HYPERCALL_ENTRY(x) "a" (x) 96 103 97 104 #ifdef CONFIG_X86_32 98 105 #define __HYPERCALL_RETREG "eax" ··· 159 148 __HYPERCALL_0ARG(); \ 160 149 asm volatile (__HYPERCALL \ 161 150 : __HYPERCALL_0PARAM \ 162 - : __HYPERCALL_ENTRY(name) \ 151 + : __HYPERCALL_ENTRY(__HYPERVISOR_ ## name) \ 163 152 : __HYPERCALL_CLOBBER0); \ 164 153 (type)__res; \ 165 154 }) ··· 170 159 __HYPERCALL_1ARG(a1); \ 171 160 asm volatile (__HYPERCALL \ 172 161 : __HYPERCALL_1PARAM \ 173 - : __HYPERCALL_ENTRY(name) \ 162 + : __HYPERCALL_ENTRY(__HYPERVISOR_ ## name) \ 174 163 : __HYPERCALL_CLOBBER1); \ 175 164 (type)__res; \ 176 165 }) ··· 181 170 __HYPERCALL_2ARG(a1, a2); \ 182 171 asm volatile (__HYPERCALL \ 183 172 : __HYPERCALL_2PARAM \ 184 - : __HYPERCALL_ENTRY(name) \ 173 + : __HYPERCALL_ENTRY(__HYPERVISOR_ ## name) \ 185 174 : __HYPERCALL_CLOBBER2); \ 186 175 (type)__res; \ 187 176 }) ··· 192 181 __HYPERCALL_3ARG(a1, a2, a3); \ 193 182 asm volatile (__HYPERCALL \ 194 183 : __HYPERCALL_3PARAM \ 195 - : __HYPERCALL_ENTRY(name) \ 184 + : __HYPERCALL_ENTRY(__HYPERVISOR_ ## name) \ 196 185 : __HYPERCALL_CLOBBER3); \ 197 186 (type)__res; \ 198 187 }) ··· 203 192 __HYPERCALL_4ARG(a1, a2, a3, a4); \ 204 193 asm volatile (__HYPERCALL \ 205 194 : __HYPERCALL_4PARAM \ 206 - : __HYPERCALL_ENTRY(name) \ 195 + : __HYPERCALL_ENTRY(__HYPERVISOR_ ## name) \ 207 196 : __HYPERCALL_CLOBBER4); \ 208 197 (type)__res; \ 209 198 }) ··· 217 206 __HYPERCALL_DECLS; 218 207 __HYPERCALL_5ARG(a1, a2, a3, a4, a5); 219 208 220 - if (call >= PAGE_SIZE / sizeof(hypercall_page[0])) 221 - return -EINVAL; 222 - 223 - asm volatile(CALL_NOSPEC 209 + asm volatile(__HYPERCALL 224 210 : __HYPERCALL_5PARAM 225 - : [thunk_target] "a" (&hypercall_page[call]) 211 + : __HYPERCALL_ENTRY(call) 226 212 : __HYPERCALL_CLOBBER5); 227 213 228 214 return (long)__res;
-5
arch/x86/kernel/callthunks.c
··· 143 143 dest < (void*)relocate_kernel + KEXEC_CONTROL_CODE_MAX_SIZE) 144 144 return true; 145 145 #endif 146 - #ifdef CONFIG_XEN 147 - if (dest >= (void *)hypercall_page && 148 - dest < (void*)hypercall_page + PAGE_SIZE) 149 - return true; 150 - #endif 151 146 return false; 152 147 } 153 148
+22 -16
arch/x86/kernel/cpu/common.c
··· 867 867 tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]); 868 868 } 869 869 870 - static void get_cpu_vendor(struct cpuinfo_x86 *c) 870 + void get_cpu_vendor(struct cpuinfo_x86 *c) 871 871 { 872 872 char *v = c->x86_vendor_id; 873 873 int i; ··· 1649 1649 detect_nopl(); 1650 1650 } 1651 1651 1652 - void __init early_cpu_init(void) 1652 + void __init init_cpu_devs(void) 1653 1653 { 1654 1654 const struct cpu_dev *const *cdev; 1655 1655 int count = 0; 1656 - 1657 - #ifdef CONFIG_PROCESSOR_SELECT 1658 - pr_info("KERNEL supported cpus:\n"); 1659 - #endif 1660 1656 1661 1657 for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { 1662 1658 const struct cpu_dev *cpudev = *cdev; ··· 1661 1665 break; 1662 1666 cpu_devs[count] = cpudev; 1663 1667 count++; 1668 + } 1669 + } 1670 + 1671 + void __init early_cpu_init(void) 1672 + { 1673 + #ifdef CONFIG_PROCESSOR_SELECT 1674 + unsigned int i, j; 1675 + 1676 + pr_info("KERNEL supported cpus:\n"); 1677 + #endif 1678 + 1679 + init_cpu_devs(); 1664 1680 1665 1681 #ifdef CONFIG_PROCESSOR_SELECT 1666 - { 1667 - unsigned int j; 1668 - 1669 - for (j = 0; j < 2; j++) { 1670 - if (!cpudev->c_ident[j]) 1671 - continue; 1672 - pr_info(" %s %s\n", cpudev->c_vendor, 1673 - cpudev->c_ident[j]); 1674 - } 1682 + for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) { 1683 + for (j = 0; j < 2; j++) { 1684 + if (!cpu_devs[i]->c_ident[j]) 1685 + continue; 1686 + pr_info(" %s %s\n", cpu_devs[i]->c_vendor, 1687 + cpu_devs[i]->c_ident[j]); 1675 1688 } 1676 - #endif 1677 1689 } 1690 + #endif 1691 + 1678 1692 early_identify_cpu(&boot_cpu_data); 1679 1693 } 1680 1694
+58
arch/x86/kernel/cpu/mshyperv.c
··· 223 223 hyperv_cleanup(); 224 224 } 225 225 #endif /* CONFIG_CRASH_DUMP */ 226 + 227 + static u64 hv_ref_counter_at_suspend; 228 + static void (*old_save_sched_clock_state)(void); 229 + static void (*old_restore_sched_clock_state)(void); 230 + 231 + /* 232 + * Hyper-V clock counter resets during hibernation. Save and restore clock 233 + * offset during suspend/resume, while also considering the time passed 234 + * before suspend. This is to make sure that sched_clock using hv tsc page 235 + * based clocksource, proceeds from where it left off during suspend and 236 + * it shows correct time for the timestamps of kernel messages after resume. 237 + */ 238 + static void save_hv_clock_tsc_state(void) 239 + { 240 + hv_ref_counter_at_suspend = hv_read_reference_counter(); 241 + } 242 + 243 + static void restore_hv_clock_tsc_state(void) 244 + { 245 + /* 246 + * Adjust the offsets used by hv tsc clocksource to 247 + * account for the time spent before hibernation. 248 + * adjusted value = reference counter (time) at suspend 249 + * - reference counter (time) now. 250 + */ 251 + hv_adj_sched_clock_offset(hv_ref_counter_at_suspend - hv_read_reference_counter()); 252 + } 253 + 254 + /* 255 + * Functions to override save_sched_clock_state and restore_sched_clock_state 256 + * functions of x86_platform. The Hyper-V clock counter is reset during 257 + * suspend-resume and the offset used to measure time needs to be 258 + * corrected, post resume. 259 + */ 260 + static void hv_save_sched_clock_state(void) 261 + { 262 + old_save_sched_clock_state(); 263 + save_hv_clock_tsc_state(); 264 + } 265 + 266 + static void hv_restore_sched_clock_state(void) 267 + { 268 + restore_hv_clock_tsc_state(); 269 + old_restore_sched_clock_state(); 270 + } 271 + 272 + static void __init x86_setup_ops_for_tsc_pg_clock(void) 273 + { 274 + if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) 275 + return; 276 + 277 + old_save_sched_clock_state = x86_platform.save_sched_clock_state; 278 + x86_platform.save_sched_clock_state = hv_save_sched_clock_state; 279 + 280 + old_restore_sched_clock_state = x86_platform.restore_sched_clock_state; 281 + x86_platform.restore_sched_clock_state = hv_restore_sched_clock_state; 282 + } 226 283 #endif /* CONFIG_HYPERV */ 227 284 228 285 static uint32_t __init ms_hyperv_platform(void) ··· 636 579 637 580 /* Register Hyper-V specific clocksource */ 638 581 hv_init_clocksource(); 582 + x86_setup_ops_for_tsc_pg_clock(); 639 583 hv_vtl_init_platform(); 640 584 #endif 641 585 /*
+9
arch/x86/kernel/static_call.c
··· 172 172 } 173 173 EXPORT_SYMBOL_GPL(arch_static_call_transform); 174 174 175 + noinstr void __static_call_update_early(void *tramp, void *func) 176 + { 177 + BUG_ON(system_state != SYSTEM_BOOTING); 178 + BUG_ON(!early_boot_irqs_disabled); 179 + BUG_ON(static_call_initialized); 180 + __text_gen_insn(tramp, JMP32_INSN_OPCODE, tramp, func, JMP32_INSN_SIZE); 181 + sync_core(); 182 + } 183 + 175 184 #ifdef CONFIG_MITIGATION_RETHUNK 176 185 /* 177 186 * This is called by apply_returns() to fix up static call trampolines,
-4
arch/x86/kernel/vmlinux.lds.S
··· 519 519 * linker will never mark as relocatable. (Using just ABSOLUTE() is not 520 520 * sufficient for that). 521 521 */ 522 - #ifdef CONFIG_XEN 523 522 #ifdef CONFIG_XEN_PV 524 523 xen_elfnote_entry_value = 525 524 ABSOLUTE(xen_elfnote_entry) + ABSOLUTE(startup_xen); 526 - #endif 527 - xen_elfnote_hypercall_page_value = 528 - ABSOLUTE(xen_elfnote_hypercall_page) + ABSOLUTE(hypercall_page); 529 525 #endif 530 526 #ifdef CONFIG_PVH 531 527 xen_elfnote_phys32_entry_value =
+26 -5
arch/x86/kvm/cpuid.c
··· 36 36 u32 kvm_cpu_caps[NR_KVM_CPU_CAPS] __read_mostly; 37 37 EXPORT_SYMBOL_GPL(kvm_cpu_caps); 38 38 39 + struct cpuid_xstate_sizes { 40 + u32 eax; 41 + u32 ebx; 42 + u32 ecx; 43 + }; 44 + 45 + static struct cpuid_xstate_sizes xstate_sizes[XFEATURE_MAX] __ro_after_init; 46 + 47 + void __init kvm_init_xstate_sizes(void) 48 + { 49 + u32 ign; 50 + int i; 51 + 52 + for (i = XFEATURE_YMM; i < ARRAY_SIZE(xstate_sizes); i++) { 53 + struct cpuid_xstate_sizes *xs = &xstate_sizes[i]; 54 + 55 + cpuid_count(0xD, i, &xs->eax, &xs->ebx, &xs->ecx, &ign); 56 + } 57 + } 58 + 39 59 u32 xstate_required_size(u64 xstate_bv, bool compacted) 40 60 { 41 61 int feature_bit = 0; ··· 64 44 xstate_bv &= XFEATURE_MASK_EXTEND; 65 45 while (xstate_bv) { 66 46 if (xstate_bv & 0x1) { 67 - u32 eax, ebx, ecx, edx, offset; 68 - cpuid_count(0xD, feature_bit, &eax, &ebx, &ecx, &edx); 47 + struct cpuid_xstate_sizes *xs = &xstate_sizes[feature_bit]; 48 + u32 offset; 49 + 69 50 /* ECX[1]: 64B alignment in compacted form */ 70 51 if (compacted) 71 - offset = (ecx & 0x2) ? ALIGN(ret, 64) : ret; 52 + offset = (xs->ecx & 0x2) ? ALIGN(ret, 64) : ret; 72 53 else 73 - offset = ebx; 74 - ret = max(ret, offset + eax); 54 + offset = xs->ebx; 55 + ret = max(ret, offset + xs->eax); 75 56 } 76 57 77 58 xstate_bv >>= 1;
+1
arch/x86/kvm/cpuid.h
··· 31 31 bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, 32 32 u32 *ecx, u32 *edx, bool exact_only); 33 33 34 + void __init kvm_init_xstate_sizes(void); 34 35 u32 xstate_required_size(u64 xstate_bv, bool compacted); 35 36 36 37 int cpuid_query_maxphyaddr(struct kvm_vcpu *vcpu);
+2
arch/x86/kvm/x86.c
··· 13997 13997 13998 13998 static int __init kvm_x86_init(void) 13999 13999 { 14000 + kvm_init_xstate_sizes(); 14001 + 14000 14002 kvm_mmu_x86_module_init(); 14001 14003 mitigate_smt_rsb &= boot_cpu_has_bug(X86_BUG_SMT_RSB) && cpu_smt_possible(); 14002 14004 return 0;
+64 -1
arch/x86/xen/enlighten.c
··· 2 2 3 3 #include <linux/console.h> 4 4 #include <linux/cpu.h> 5 + #include <linux/instrumentation.h> 5 6 #include <linux/kexec.h> 6 7 #include <linux/memblock.h> 7 8 #include <linux/slab.h> ··· 22 21 23 22 #include "xen-ops.h" 24 23 25 - EXPORT_SYMBOL_GPL(hypercall_page); 24 + DEFINE_STATIC_CALL(xen_hypercall, xen_hypercall_hvm); 25 + EXPORT_STATIC_CALL_TRAMP(xen_hypercall); 26 26 27 27 /* 28 28 * Pointer to the xen_vcpu_info structure or ··· 69 67 * page as soon as fixmap is up and running. 70 68 */ 71 69 struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info; 70 + 71 + static __ref void xen_get_vendor(void) 72 + { 73 + init_cpu_devs(); 74 + cpu_detect(&boot_cpu_data); 75 + get_cpu_vendor(&boot_cpu_data); 76 + } 77 + 78 + void xen_hypercall_setfunc(void) 79 + { 80 + if (static_call_query(xen_hypercall) != xen_hypercall_hvm) 81 + return; 82 + 83 + if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD || 84 + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)) 85 + static_call_update(xen_hypercall, xen_hypercall_amd); 86 + else 87 + static_call_update(xen_hypercall, xen_hypercall_intel); 88 + } 89 + 90 + /* 91 + * Evaluate processor vendor in order to select the correct hypercall 92 + * function for HVM/PVH guests. 93 + * Might be called very early in boot before vendor has been set by 94 + * early_cpu_init(). 95 + */ 96 + noinstr void *__xen_hypercall_setfunc(void) 97 + { 98 + void (*func)(void); 99 + 100 + /* 101 + * Xen is supported only on CPUs with CPUID, so testing for 102 + * X86_FEATURE_CPUID is a test for early_cpu_init() having been 103 + * run. 104 + * 105 + * Note that __xen_hypercall_setfunc() is noinstr only due to a nasty 106 + * dependency chain: it is being called via the xen_hypercall static 107 + * call when running as a PVH or HVM guest. Hypercalls need to be 108 + * noinstr due to PV guests using hypercalls in noinstr code. So we 109 + * can safely tag the function body as "instrumentation ok", since 110 + * the PV guest requirement is not of interest here (xen_get_vendor() 111 + * calls noinstr functions, and static_call_update_early() might do 112 + * so, too). 113 + */ 114 + instrumentation_begin(); 115 + 116 + if (!boot_cpu_has(X86_FEATURE_CPUID)) 117 + xen_get_vendor(); 118 + 119 + if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD || 120 + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)) 121 + func = xen_hypercall_amd; 122 + else 123 + func = xen_hypercall_intel; 124 + 125 + static_call_update_early(xen_hypercall, func); 126 + 127 + instrumentation_end(); 128 + 129 + return func; 130 + } 72 131 73 132 static int xen_cpu_up_online(unsigned int cpu) 74 133 {
+5 -8
arch/x86/xen/enlighten_hvm.c
··· 106 106 /* PVH set up hypercall page in xen_prepare_pvh(). */ 107 107 if (xen_pvh_domain()) 108 108 pv_info.name = "Xen PVH"; 109 - else { 110 - u64 pfn; 111 - uint32_t msr; 112 - 109 + else 113 110 pv_info.name = "Xen HVM"; 114 - msr = cpuid_ebx(base + 2); 115 - pfn = __pa(hypercall_page); 116 - wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); 117 - } 118 111 119 112 xen_setup_features(); 120 113 ··· 292 299 293 300 if (xen_pv_domain()) 294 301 return 0; 302 + 303 + /* Set correct hypercall function. */ 304 + if (xen_domain) 305 + xen_hypercall_setfunc(); 295 306 296 307 if (xen_pvh_domain() && nopv) { 297 308 /* Guest booting via the Xen-PVH boot entry goes here */
+3 -1
arch/x86/xen/enlighten_pv.c
··· 1341 1341 1342 1342 xen_domain_type = XEN_PV_DOMAIN; 1343 1343 xen_start_flags = xen_start_info->flags; 1344 + /* Interrupts are guaranteed to be off initially. */ 1345 + early_boot_irqs_disabled = true; 1346 + static_call_update_early(xen_hypercall, xen_hypercall_pv); 1344 1347 1345 1348 xen_setup_features(); 1346 1349 ··· 1434 1431 WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_pv, xen_cpu_dead_pv)); 1435 1432 1436 1433 local_irq_disable(); 1437 - early_boot_irqs_disabled = true; 1438 1434 1439 1435 xen_raw_console_write("mapping kernel into physical memory\n"); 1440 1436 xen_setup_kernel_pagetable((pgd_t *)xen_start_info->pt_base,
-7
arch/x86/xen/enlighten_pvh.c
··· 129 129 130 130 void __init xen_pvh_init(struct boot_params *boot_params) 131 131 { 132 - u32 msr; 133 - u64 pfn; 134 - 135 132 xen_pvh = 1; 136 133 xen_domain_type = XEN_HVM_DOMAIN; 137 134 xen_start_flags = pvh_start_info.flags; 138 - 139 - msr = cpuid_ebx(xen_cpuid_base() + 2); 140 - pfn = __pa(hypercall_page); 141 - wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); 142 135 143 136 x86_init.oem.arch_setup = pvh_arch_setup; 144 137 x86_init.oem.banner = xen_banner;
+41 -9
arch/x86/xen/xen-asm.S
··· 20 20 21 21 #include <linux/init.h> 22 22 #include <linux/linkage.h> 23 + #include <linux/objtool.h> 23 24 #include <../entry/calling.h> 24 25 25 26 .pushsection .noinstr.text, "ax" 27 + /* 28 + * PV hypercall interface to the hypervisor. 29 + * 30 + * Called via inline asm(), so better preserve %rcx and %r11. 31 + * 32 + * Input: 33 + * %eax: hypercall number 34 + * %rdi, %rsi, %rdx, %r10, %r8: args 1..5 for the hypercall 35 + * Output: %rax 36 + */ 37 + SYM_FUNC_START(xen_hypercall_pv) 38 + ANNOTATE_NOENDBR 39 + push %rcx 40 + push %r11 41 + UNWIND_HINT_SAVE 42 + syscall 43 + UNWIND_HINT_RESTORE 44 + pop %r11 45 + pop %rcx 46 + RET 47 + SYM_FUNC_END(xen_hypercall_pv) 48 + 26 49 /* 27 50 * Disabling events is simply a matter of making the event mask 28 51 * non-zero. ··· 199 176 SYM_CODE_END(xen_early_idt_handler_array) 200 177 __FINIT 201 178 202 - hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32 203 179 /* 204 180 * Xen64 iret frame: 205 181 * ··· 208 186 * cs 209 187 * rip <-- standard iret frame 210 188 * 211 - * flags 189 + * flags <-- xen_iret must push from here on 212 190 * 213 - * rcx } 214 - * r11 }<-- pushed by hypercall page 215 - * rsp->rax } 191 + * rcx 192 + * r11 193 + * rsp->rax 216 194 */ 195 + .macro xen_hypercall_iret 196 + pushq $0 /* Flags */ 197 + push %rcx 198 + push %r11 199 + push %rax 200 + mov $__HYPERVISOR_iret, %eax 201 + syscall /* Do the IRET. */ 202 + #ifdef CONFIG_MITIGATION_SLS 203 + int3 204 + #endif 205 + .endm 206 + 217 207 SYM_CODE_START(xen_iret) 218 208 UNWIND_HINT_UNDEFINED 219 209 ANNOTATE_NOENDBR 220 - pushq $0 221 - jmp hypercall_iret 210 + xen_hypercall_iret 222 211 SYM_CODE_END(xen_iret) 223 212 224 213 /* ··· 334 301 ENDBR 335 302 lea 16(%rsp), %rsp /* strip %rcx, %r11 */ 336 303 mov $-ENOSYS, %rax 337 - pushq $0 338 - jmp hypercall_iret 304 + xen_hypercall_iret 339 305 SYM_CODE_END(xen_entry_SYSENTER_compat) 340 306 SYM_CODE_END(xen_entry_SYSCALL_compat) 341 307
+83 -24
arch/x86/xen/xen-head.S
··· 6 6 7 7 #include <linux/elfnote.h> 8 8 #include <linux/init.h> 9 + #include <linux/instrumentation.h> 9 10 10 11 #include <asm/boot.h> 11 12 #include <asm/asm.h> 13 + #include <asm/frame.h> 12 14 #include <asm/msr.h> 13 15 #include <asm/page_types.h> 14 16 #include <asm/percpu.h> ··· 21 19 #include <xen/interface/xen.h> 22 20 #include <xen/interface/xen-mca.h> 23 21 #include <asm/xen/interface.h> 24 - 25 - .pushsection .noinstr.text, "ax" 26 - .balign PAGE_SIZE 27 - SYM_CODE_START(hypercall_page) 28 - .rept (PAGE_SIZE / 32) 29 - UNWIND_HINT_FUNC 30 - ANNOTATE_NOENDBR 31 - ANNOTATE_UNRET_SAFE 32 - ret 33 - /* 34 - * Xen will write the hypercall page, and sort out ENDBR. 35 - */ 36 - .skip 31, 0xcc 37 - .endr 38 - 39 - #define HYPERCALL(n) \ 40 - .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \ 41 - .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32 42 - #include <asm/xen-hypercalls.h> 43 - #undef HYPERCALL 44 - SYM_CODE_END(hypercall_page) 45 - .popsection 46 22 47 23 #ifdef CONFIG_XEN_PV 48 24 __INIT ··· 67 87 #endif 68 88 #endif 69 89 90 + .pushsection .noinstr.text, "ax" 91 + /* 92 + * Xen hypercall interface to the hypervisor. 93 + * 94 + * Input: 95 + * %eax: hypercall number 96 + * 32-bit: 97 + * %ebx, %ecx, %edx, %esi, %edi: args 1..5 for the hypercall 98 + * 64-bit: 99 + * %rdi, %rsi, %rdx, %r10, %r8: args 1..5 for the hypercall 100 + * Output: %[er]ax 101 + */ 102 + SYM_FUNC_START(xen_hypercall_hvm) 103 + ENDBR 104 + FRAME_BEGIN 105 + /* Save all relevant registers (caller save and arguments). */ 106 + #ifdef CONFIG_X86_32 107 + push %eax 108 + push %ebx 109 + push %ecx 110 + push %edx 111 + push %esi 112 + push %edi 113 + #else 114 + push %rax 115 + push %rcx 116 + push %rdx 117 + push %rdi 118 + push %rsi 119 + push %r11 120 + push %r10 121 + push %r9 122 + push %r8 123 + #ifdef CONFIG_FRAME_POINTER 124 + pushq $0 /* Dummy push for stack alignment. */ 125 + #endif 126 + #endif 127 + /* Set the vendor specific function. */ 128 + call __xen_hypercall_setfunc 129 + /* Set ZF = 1 if AMD, Restore saved registers. */ 130 + #ifdef CONFIG_X86_32 131 + lea xen_hypercall_amd, %ebx 132 + cmp %eax, %ebx 133 + pop %edi 134 + pop %esi 135 + pop %edx 136 + pop %ecx 137 + pop %ebx 138 + pop %eax 139 + #else 140 + lea xen_hypercall_amd(%rip), %rbx 141 + cmp %rax, %rbx 142 + #ifdef CONFIG_FRAME_POINTER 143 + pop %rax /* Dummy pop. */ 144 + #endif 145 + pop %r8 146 + pop %r9 147 + pop %r10 148 + pop %r11 149 + pop %rsi 150 + pop %rdi 151 + pop %rdx 152 + pop %rcx 153 + pop %rax 154 + #endif 155 + /* Use correct hypercall function. */ 156 + jz xen_hypercall_amd 157 + jmp xen_hypercall_intel 158 + SYM_FUNC_END(xen_hypercall_hvm) 159 + 160 + SYM_FUNC_START(xen_hypercall_amd) 161 + vmmcall 162 + RET 163 + SYM_FUNC_END(xen_hypercall_amd) 164 + 165 + SYM_FUNC_START(xen_hypercall_intel) 166 + vmcall 167 + RET 168 + SYM_FUNC_END(xen_hypercall_intel) 169 + .popsection 170 + 70 171 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") 71 172 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") 72 173 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") ··· 177 116 #else 178 117 # define FEATURES_DOM0 0 179 118 #endif 180 - ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .globl xen_elfnote_hypercall_page; 181 - xen_elfnote_hypercall_page: _ASM_PTR xen_elfnote_hypercall_page_value - .) 182 119 ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, 183 120 .long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0) 184 121 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
+9
arch/x86/xen/xen-ops.h
··· 326 326 static inline void xen_smp_count_cpus(void) { } 327 327 #endif /* CONFIG_SMP */ 328 328 329 + #ifdef CONFIG_XEN_PV 330 + void xen_hypercall_pv(void); 331 + #endif 332 + void xen_hypercall_hvm(void); 333 + void xen_hypercall_amd(void); 334 + void xen_hypercall_intel(void); 335 + void xen_hypercall_setfunc(void); 336 + void *__xen_hypercall_setfunc(void); 337 + 329 338 #endif /* XEN_OPS_H */
+1 -1
block/bio.c
··· 1171 1171 } 1172 1172 EXPORT_SYMBOL_GPL(__bio_release_pages); 1173 1173 1174 - void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) 1174 + void bio_iov_bvec_set(struct bio *bio, const struct iov_iter *iter) 1175 1175 { 1176 1176 WARN_ON_ONCE(bio->bi_max_vecs); 1177 1177
+5 -1
block/blk-cgroup.c
··· 1324 1324 struct blkcg *blkcg = css_to_blkcg(blkcg_css); 1325 1325 1326 1326 do { 1327 + struct blkcg *parent; 1328 + 1327 1329 if (!refcount_dec_and_test(&blkcg->online_pin)) 1328 1330 break; 1331 + 1332 + parent = blkcg_parent(blkcg); 1329 1333 blkcg_destroy_blkgs(blkcg); 1330 - blkcg = blkcg_parent(blkcg); 1334 + blkcg = parent; 1331 1335 } while (blkcg); 1332 1336 } 1333 1337
+8 -1
block/blk-iocost.c
··· 1098 1098 inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum, 1099 1099 iocg->child_active_sum); 1100 1100 } else { 1101 - inuse = clamp_t(u32, inuse, 1, active); 1101 + /* 1102 + * It may be tempting to turn this into a clamp expression with 1103 + * a lower limit of 1 but active may be 0, which cannot be used 1104 + * as an upper limit in that situation. This expression allows 1105 + * active to clamp inuse unless it is 0, in which case inuse 1106 + * becomes 1. 1107 + */ 1108 + inuse = min(inuse, active) ?: 1; 1102 1109 } 1103 1110 1104 1111 iocg->last_inuse = iocg->inuse;
+1 -1
block/blk-map.c
··· 574 574 bio = blk_rq_map_bio_alloc(rq, 0, GFP_KERNEL); 575 575 if (!bio) 576 576 return -ENOMEM; 577 - bio_iov_bvec_set(bio, (struct iov_iter *)iter); 577 + bio_iov_bvec_set(bio, iter); 578 578 579 579 /* check that the data layout matches the hardware restrictions */ 580 580 ret = bio_split_rw_at(bio, lim, &nsegs, max_bytes);
+6 -10
block/blk-mq-sysfs.c
··· 275 275 struct blk_mq_hw_ctx *hctx; 276 276 unsigned long i; 277 277 278 - mutex_lock(&q->sysfs_dir_lock); 278 + lockdep_assert_held(&q->sysfs_dir_lock); 279 + 279 280 if (!q->mq_sysfs_init_done) 280 - goto unlock; 281 + return; 281 282 282 283 queue_for_each_hw_ctx(q, hctx, i) 283 284 blk_mq_unregister_hctx(hctx); 284 - 285 - unlock: 286 - mutex_unlock(&q->sysfs_dir_lock); 287 285 } 288 286 289 287 int blk_mq_sysfs_register_hctxs(struct request_queue *q) ··· 290 292 unsigned long i; 291 293 int ret = 0; 292 294 293 - mutex_lock(&q->sysfs_dir_lock); 295 + lockdep_assert_held(&q->sysfs_dir_lock); 296 + 294 297 if (!q->mq_sysfs_init_done) 295 - goto unlock; 298 + return ret; 296 299 297 300 queue_for_each_hw_ctx(q, hctx, i) { 298 301 ret = blk_mq_register_hctx(hctx); 299 302 if (ret) 300 303 break; 301 304 } 302 - 303 - unlock: 304 - mutex_unlock(&q->sysfs_dir_lock); 305 305 306 306 return ret; 307 307 }
+22 -17
block/blk-mq.c
··· 1544 1544 1545 1545 while (!list_empty(&rq_list)) { 1546 1546 rq = list_entry(rq_list.next, struct request, queuelist); 1547 + list_del_init(&rq->queuelist); 1547 1548 /* 1548 - * If RQF_DONTPREP ist set, the request has been started by the 1549 + * If RQF_DONTPREP is set, the request has been started by the 1549 1550 * driver already and might have driver-specific data allocated 1550 1551 * already. Insert it into the hctx dispatch list to avoid 1551 1552 * block layer merges for the request. 1552 1553 */ 1553 - if (rq->rq_flags & RQF_DONTPREP) { 1554 - list_del_init(&rq->queuelist); 1554 + if (rq->rq_flags & RQF_DONTPREP) 1555 1555 blk_mq_request_bypass_insert(rq, 0); 1556 - } else { 1557 - list_del_init(&rq->queuelist); 1556 + else 1558 1557 blk_mq_insert_request(rq, BLK_MQ_INSERT_AT_HEAD); 1559 - } 1560 1558 } 1561 1559 1562 1560 while (!list_empty(&flush_list)) { ··· 4453 4455 unsigned long i, j; 4454 4456 4455 4457 /* protect against switching io scheduler */ 4456 - mutex_lock(&q->sysfs_lock); 4458 + lockdep_assert_held(&q->sysfs_lock); 4459 + 4457 4460 for (i = 0; i < set->nr_hw_queues; i++) { 4458 4461 int old_node; 4459 4462 int node = blk_mq_get_hctx_node(set, i); ··· 4487 4488 4488 4489 xa_for_each_start(&q->hctx_table, j, hctx, j) 4489 4490 blk_mq_exit_hctx(q, set, hctx, j); 4490 - mutex_unlock(&q->sysfs_lock); 4491 4491 4492 4492 /* unregister cpuhp callbacks for exited hctxs */ 4493 4493 blk_mq_remove_hw_queues_cpuhp(q); ··· 4518 4520 4519 4521 xa_init(&q->hctx_table); 4520 4522 4523 + mutex_lock(&q->sysfs_lock); 4524 + 4521 4525 blk_mq_realloc_hw_ctxs(set, q); 4522 4526 if (!q->nr_hw_queues) 4523 4527 goto err_hctxs; 4528 + 4529 + mutex_unlock(&q->sysfs_lock); 4524 4530 4525 4531 INIT_WORK(&q->timeout_work, blk_mq_timeout_work); 4526 4532 blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ); ··· 4544 4542 return 0; 4545 4543 4546 4544 err_hctxs: 4545 + mutex_unlock(&q->sysfs_lock); 4547 4546 blk_mq_release(q); 4548 4547 err_exit: 4549 4548 q->mq_ops = NULL; ··· 4925 4922 return false; 4926 4923 4927 4924 /* q->elevator needs protection from ->sysfs_lock */ 4928 - mutex_lock(&q->sysfs_lock); 4925 + lockdep_assert_held(&q->sysfs_lock); 4929 4926 4930 4927 /* the check has to be done with holding sysfs_lock */ 4931 4928 if (!q->elevator) { 4932 4929 kfree(qe); 4933 - goto unlock; 4930 + goto out; 4934 4931 } 4935 4932 4936 4933 INIT_LIST_HEAD(&qe->node); ··· 4940 4937 __elevator_get(qe->type); 4941 4938 list_add(&qe->node, head); 4942 4939 elevator_disable(q); 4943 - unlock: 4944 - mutex_unlock(&q->sysfs_lock); 4945 - 4940 + out: 4946 4941 return true; 4947 4942 } 4948 4943 ··· 4969 4968 list_del(&qe->node); 4970 4969 kfree(qe); 4971 4970 4972 - mutex_lock(&q->sysfs_lock); 4973 4971 elevator_switch(q, t); 4974 4972 /* drop the reference acquired in blk_mq_elv_switch_none */ 4975 4973 elevator_put(t); 4976 - mutex_unlock(&q->sysfs_lock); 4977 4974 } 4978 4975 4979 4976 static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, ··· 4991 4992 if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues) 4992 4993 return; 4993 4994 4994 - list_for_each_entry(q, &set->tag_list, tag_set_list) 4995 + list_for_each_entry(q, &set->tag_list, tag_set_list) { 4996 + mutex_lock(&q->sysfs_dir_lock); 4997 + mutex_lock(&q->sysfs_lock); 4995 4998 blk_mq_freeze_queue(q); 4999 + } 4996 5000 /* 4997 5001 * Switch IO scheduler to 'none', cleaning up the data associated 4998 5002 * with the previous scheduler. We will switch back once we are done ··· 5051 5049 list_for_each_entry(q, &set->tag_list, tag_set_list) 5052 5050 blk_mq_elv_switch_back(&head, q); 5053 5051 5054 - list_for_each_entry(q, &set->tag_list, tag_set_list) 5052 + list_for_each_entry(q, &set->tag_list, tag_set_list) { 5055 5053 blk_mq_unfreeze_queue(q); 5054 + mutex_unlock(&q->sysfs_lock); 5055 + mutex_unlock(&q->sysfs_dir_lock); 5056 + } 5056 5057 5057 5058 /* Free the excess tags when nr_hw_queues shrink. */ 5058 5059 for (i = set->nr_hw_queues; i < prev_nr_hw_queues; i++)
+3 -3
block/blk-sysfs.c
··· 263 263 264 264 static ssize_t queue_iostats_passthrough_show(struct gendisk *disk, char *page) 265 265 { 266 - return queue_var_show(blk_queue_passthrough_stat(disk->queue), page); 266 + return queue_var_show(!!blk_queue_passthrough_stat(disk->queue), page); 267 267 } 268 268 269 269 static ssize_t queue_iostats_passthrough_store(struct gendisk *disk, ··· 706 706 if (entry->load_module) 707 707 entry->load_module(disk, page, length); 708 708 709 - blk_mq_freeze_queue(q); 710 709 mutex_lock(&q->sysfs_lock); 710 + blk_mq_freeze_queue(q); 711 711 res = entry->store(disk, page, length); 712 - mutex_unlock(&q->sysfs_lock); 713 712 blk_mq_unfreeze_queue(q); 713 + mutex_unlock(&q->sysfs_lock); 714 714 return res; 715 715 } 716 716
+225 -285
block/blk-zoned.c
··· 41 41 /* 42 42 * Per-zone write plug. 43 43 * @node: hlist_node structure for managing the plug using a hash table. 44 - * @link: To list the plug in the zone write plug error list of the disk. 45 44 * @ref: Zone write plug reference counter. A zone write plug reference is 46 45 * always at least 1 when the plug is hashed in the disk plug hash table. 47 46 * The reference is incremented whenever a new BIO needing plugging is ··· 62 63 */ 63 64 struct blk_zone_wplug { 64 65 struct hlist_node node; 65 - struct list_head link; 66 66 refcount_t ref; 67 67 spinlock_t lock; 68 68 unsigned int flags; ··· 78 80 * - BLK_ZONE_WPLUG_PLUGGED: Indicates that the zone write plug is plugged, 79 81 * that is, that write BIOs are being throttled due to a write BIO already 80 82 * being executed or the zone write plug bio list is not empty. 81 - * - BLK_ZONE_WPLUG_ERROR: Indicates that a write error happened which will be 82 - * recovered with a report zone to update the zone write pointer offset. 83 + * - BLK_ZONE_WPLUG_NEED_WP_UPDATE: Indicates that we lost track of a zone 84 + * write pointer offset and need to update it. 83 85 * - BLK_ZONE_WPLUG_UNHASHED: Indicates that the zone write plug was removed 84 86 * from the disk hash table and that the initial reference to the zone 85 87 * write plug set when the plug was first added to the hash table has been ··· 89 91 * freed once all remaining references from BIOs or functions are dropped. 90 92 */ 91 93 #define BLK_ZONE_WPLUG_PLUGGED (1U << 0) 92 - #define BLK_ZONE_WPLUG_ERROR (1U << 1) 94 + #define BLK_ZONE_WPLUG_NEED_WP_UPDATE (1U << 1) 93 95 #define BLK_ZONE_WPLUG_UNHASHED (1U << 2) 94 - 95 - #define BLK_ZONE_WPLUG_BUSY (BLK_ZONE_WPLUG_PLUGGED | BLK_ZONE_WPLUG_ERROR) 96 96 97 97 /** 98 98 * blk_zone_cond_str - Return string XXX in BLK_ZONE_COND_XXX. ··· 110 114 return zone_cond_str; 111 115 } 112 116 EXPORT_SYMBOL_GPL(blk_zone_cond_str); 117 + 118 + struct disk_report_zones_cb_args { 119 + struct gendisk *disk; 120 + report_zones_cb user_cb; 121 + void *user_data; 122 + }; 123 + 124 + static void disk_zone_wplug_sync_wp_offset(struct gendisk *disk, 125 + struct blk_zone *zone); 126 + 127 + static int disk_report_zones_cb(struct blk_zone *zone, unsigned int idx, 128 + void *data) 129 + { 130 + struct disk_report_zones_cb_args *args = data; 131 + struct gendisk *disk = args->disk; 132 + 133 + if (disk->zone_wplugs_hash) 134 + disk_zone_wplug_sync_wp_offset(disk, zone); 135 + 136 + if (!args->user_cb) 137 + return 0; 138 + 139 + return args->user_cb(zone, idx, args->user_data); 140 + } 113 141 114 142 /** 115 143 * blkdev_report_zones - Get zones information ··· 159 139 { 160 140 struct gendisk *disk = bdev->bd_disk; 161 141 sector_t capacity = get_capacity(disk); 142 + struct disk_report_zones_cb_args args = { 143 + .disk = disk, 144 + .user_cb = cb, 145 + .user_data = data, 146 + }; 162 147 163 148 if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones)) 164 149 return -EOPNOTSUPP; ··· 171 146 if (!nr_zones || sector >= capacity) 172 147 return 0; 173 148 174 - return disk->fops->report_zones(disk, sector, nr_zones, cb, data); 149 + return disk->fops->report_zones(disk, sector, nr_zones, 150 + disk_report_zones_cb, &args); 175 151 } 176 152 EXPORT_SYMBOL_GPL(blkdev_report_zones); 177 153 ··· 453 427 { 454 428 if (refcount_dec_and_test(&zwplug->ref)) { 455 429 WARN_ON_ONCE(!bio_list_empty(&zwplug->bio_list)); 456 - WARN_ON_ONCE(!list_empty(&zwplug->link)); 430 + WARN_ON_ONCE(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED); 457 431 WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_UNHASHED)); 458 432 459 433 call_rcu(&zwplug->rcu_head, disk_free_zone_wplug_rcu); ··· 467 441 if (zwplug->flags & BLK_ZONE_WPLUG_UNHASHED) 468 442 return false; 469 443 470 - /* If the zone write plug is still busy, it cannot be removed. */ 471 - if (zwplug->flags & BLK_ZONE_WPLUG_BUSY) 444 + /* If the zone write plug is still plugged, it cannot be removed. */ 445 + if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED) 472 446 return false; 473 447 474 448 /* ··· 551 525 return NULL; 552 526 553 527 INIT_HLIST_NODE(&zwplug->node); 554 - INIT_LIST_HEAD(&zwplug->link); 555 528 refcount_set(&zwplug->ref, 2); 556 529 spin_lock_init(&zwplug->lock); 557 530 zwplug->flags = 0; 558 531 zwplug->zone_no = zno; 559 - zwplug->wp_offset = sector & (disk->queue->limits.chunk_sectors - 1); 532 + zwplug->wp_offset = bdev_offset_from_zone_start(disk->part0, sector); 560 533 bio_list_init(&zwplug->bio_list); 561 534 INIT_WORK(&zwplug->bio_work, blk_zone_wplug_bio_work); 562 535 zwplug->disk = disk; ··· 599 574 } 600 575 601 576 /* 602 - * Abort (fail) all plugged BIOs of a zone write plug that are not aligned 603 - * with the assumed write pointer location of the zone when the BIO will 604 - * be unplugged. 605 - */ 606 - static void disk_zone_wplug_abort_unaligned(struct gendisk *disk, 607 - struct blk_zone_wplug *zwplug) 608 - { 609 - unsigned int wp_offset = zwplug->wp_offset; 610 - struct bio_list bl = BIO_EMPTY_LIST; 611 - struct bio *bio; 612 - 613 - while ((bio = bio_list_pop(&zwplug->bio_list))) { 614 - if (disk_zone_is_full(disk, zwplug->zone_no, wp_offset) || 615 - (bio_op(bio) != REQ_OP_ZONE_APPEND && 616 - bio_offset_from_zone_start(bio) != wp_offset)) { 617 - blk_zone_wplug_bio_io_error(zwplug, bio); 618 - continue; 619 - } 620 - 621 - wp_offset += bio_sectors(bio); 622 - bio_list_add(&bl, bio); 623 - } 624 - 625 - bio_list_merge(&zwplug->bio_list, &bl); 626 - } 627 - 628 - static inline void disk_zone_wplug_set_error(struct gendisk *disk, 629 - struct blk_zone_wplug *zwplug) 630 - { 631 - unsigned long flags; 632 - 633 - if (zwplug->flags & BLK_ZONE_WPLUG_ERROR) 634 - return; 635 - 636 - /* 637 - * At this point, we already have a reference on the zone write plug. 638 - * However, since we are going to add the plug to the disk zone write 639 - * plugs work list, increase its reference count. This reference will 640 - * be dropped in disk_zone_wplugs_work() once the error state is 641 - * handled, or in disk_zone_wplug_clear_error() if the zone is reset or 642 - * finished. 643 - */ 644 - zwplug->flags |= BLK_ZONE_WPLUG_ERROR; 645 - refcount_inc(&zwplug->ref); 646 - 647 - spin_lock_irqsave(&disk->zone_wplugs_lock, flags); 648 - list_add_tail(&zwplug->link, &disk->zone_wplugs_err_list); 649 - spin_unlock_irqrestore(&disk->zone_wplugs_lock, flags); 650 - } 651 - 652 - static inline void disk_zone_wplug_clear_error(struct gendisk *disk, 653 - struct blk_zone_wplug *zwplug) 654 - { 655 - unsigned long flags; 656 - 657 - if (!(zwplug->flags & BLK_ZONE_WPLUG_ERROR)) 658 - return; 659 - 660 - /* 661 - * We are racing with the error handling work which drops the reference 662 - * on the zone write plug after handling the error state. So remove the 663 - * plug from the error list and drop its reference count only if the 664 - * error handling has not yet started, that is, if the zone write plug 665 - * is still listed. 666 - */ 667 - spin_lock_irqsave(&disk->zone_wplugs_lock, flags); 668 - if (!list_empty(&zwplug->link)) { 669 - list_del_init(&zwplug->link); 670 - zwplug->flags &= ~BLK_ZONE_WPLUG_ERROR; 671 - disk_put_zone_wplug(zwplug); 672 - } 673 - spin_unlock_irqrestore(&disk->zone_wplugs_lock, flags); 674 - } 675 - 676 - /* 677 - * Set a zone write plug write pointer offset to either 0 (zone reset case) 678 - * or to the zone size (zone finish case). This aborts all plugged BIOs, which 679 - * is fine to do as doing a zone reset or zone finish while writes are in-flight 680 - * is a mistake from the user which will most likely cause all plugged BIOs to 681 - * fail anyway. 577 + * Set a zone write plug write pointer offset to the specified value. 578 + * This aborts all plugged BIOs, which is fine as this function is called for 579 + * a zone reset operation, a zone finish operation or if the zone needs a wp 580 + * update from a report zone after a write error. 682 581 */ 683 582 static void disk_zone_wplug_set_wp_offset(struct gendisk *disk, 684 583 struct blk_zone_wplug *zwplug, 685 584 unsigned int wp_offset) 686 585 { 687 - unsigned long flags; 688 - 689 - spin_lock_irqsave(&zwplug->lock, flags); 690 - 691 - /* 692 - * Make sure that a BIO completion or another zone reset or finish 693 - * operation has not already removed the plug from the hash table. 694 - */ 695 - if (zwplug->flags & BLK_ZONE_WPLUG_UNHASHED) { 696 - spin_unlock_irqrestore(&zwplug->lock, flags); 697 - return; 698 - } 586 + lockdep_assert_held(&zwplug->lock); 699 587 700 588 /* Update the zone write pointer and abort all plugged BIOs. */ 589 + zwplug->flags &= ~BLK_ZONE_WPLUG_NEED_WP_UPDATE; 701 590 zwplug->wp_offset = wp_offset; 702 591 disk_zone_wplug_abort(zwplug); 703 - 704 - /* 705 - * Updating the write pointer offset puts back the zone 706 - * in a good state. So clear the error flag and decrement the 707 - * error count if we were in error state. 708 - */ 709 - disk_zone_wplug_clear_error(disk, zwplug); 710 592 711 593 /* 712 594 * The zone write plug now has no BIO plugged: remove it from the ··· 622 690 */ 623 691 if (disk_should_remove_zone_wplug(disk, zwplug)) 624 692 disk_remove_zone_wplug(disk, zwplug); 693 + } 625 694 695 + static unsigned int blk_zone_wp_offset(struct blk_zone *zone) 696 + { 697 + switch (zone->cond) { 698 + case BLK_ZONE_COND_IMP_OPEN: 699 + case BLK_ZONE_COND_EXP_OPEN: 700 + case BLK_ZONE_COND_CLOSED: 701 + return zone->wp - zone->start; 702 + case BLK_ZONE_COND_FULL: 703 + return zone->len; 704 + case BLK_ZONE_COND_EMPTY: 705 + return 0; 706 + case BLK_ZONE_COND_NOT_WP: 707 + case BLK_ZONE_COND_OFFLINE: 708 + case BLK_ZONE_COND_READONLY: 709 + default: 710 + /* 711 + * Conventional, offline and read-only zones do not have a valid 712 + * write pointer. 713 + */ 714 + return UINT_MAX; 715 + } 716 + } 717 + 718 + static void disk_zone_wplug_sync_wp_offset(struct gendisk *disk, 719 + struct blk_zone *zone) 720 + { 721 + struct blk_zone_wplug *zwplug; 722 + unsigned long flags; 723 + 724 + zwplug = disk_get_zone_wplug(disk, zone->start); 725 + if (!zwplug) 726 + return; 727 + 728 + spin_lock_irqsave(&zwplug->lock, flags); 729 + if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE) 730 + disk_zone_wplug_set_wp_offset(disk, zwplug, 731 + blk_zone_wp_offset(zone)); 626 732 spin_unlock_irqrestore(&zwplug->lock, flags); 733 + 734 + disk_put_zone_wplug(zwplug); 735 + } 736 + 737 + static int disk_zone_sync_wp_offset(struct gendisk *disk, sector_t sector) 738 + { 739 + struct disk_report_zones_cb_args args = { 740 + .disk = disk, 741 + }; 742 + 743 + return disk->fops->report_zones(disk, sector, 1, 744 + disk_report_zones_cb, &args); 627 745 } 628 746 629 747 static bool blk_zone_wplug_handle_reset_or_finish(struct bio *bio, ··· 682 700 struct gendisk *disk = bio->bi_bdev->bd_disk; 683 701 sector_t sector = bio->bi_iter.bi_sector; 684 702 struct blk_zone_wplug *zwplug; 703 + unsigned long flags; 685 704 686 705 /* Conventional zones cannot be reset nor finished. */ 687 706 if (!bdev_zone_is_seq(bio->bi_bdev, sector)) { 688 707 bio_io_error(bio); 689 708 return true; 690 709 } 710 + 711 + /* 712 + * No-wait reset or finish BIOs do not make much sense as the callers 713 + * issue these as blocking operations in most cases. To avoid issues 714 + * the BIO execution potentially failing with BLK_STS_AGAIN, warn about 715 + * REQ_NOWAIT being set and ignore that flag. 716 + */ 717 + if (WARN_ON_ONCE(bio->bi_opf & REQ_NOWAIT)) 718 + bio->bi_opf &= ~REQ_NOWAIT; 691 719 692 720 /* 693 721 * If we have a zone write plug, set its write pointer offset to 0 ··· 708 716 */ 709 717 zwplug = disk_get_zone_wplug(disk, sector); 710 718 if (zwplug) { 719 + spin_lock_irqsave(&zwplug->lock, flags); 711 720 disk_zone_wplug_set_wp_offset(disk, zwplug, wp_offset); 721 + spin_unlock_irqrestore(&zwplug->lock, flags); 712 722 disk_put_zone_wplug(zwplug); 713 723 } 714 724 ··· 721 727 { 722 728 struct gendisk *disk = bio->bi_bdev->bd_disk; 723 729 struct blk_zone_wplug *zwplug; 730 + unsigned long flags; 724 731 sector_t sector; 725 732 726 733 /* ··· 733 738 sector += disk->queue->limits.chunk_sectors) { 734 739 zwplug = disk_get_zone_wplug(disk, sector); 735 740 if (zwplug) { 741 + spin_lock_irqsave(&zwplug->lock, flags); 736 742 disk_zone_wplug_set_wp_offset(disk, zwplug, 0); 743 + spin_unlock_irqrestore(&zwplug->lock, flags); 737 744 disk_put_zone_wplug(zwplug); 738 745 } 739 746 } ··· 743 746 return false; 744 747 } 745 748 746 - static inline void blk_zone_wplug_add_bio(struct blk_zone_wplug *zwplug, 747 - struct bio *bio, unsigned int nr_segs) 749 + static void disk_zone_wplug_schedule_bio_work(struct gendisk *disk, 750 + struct blk_zone_wplug *zwplug) 748 751 { 752 + /* 753 + * Take a reference on the zone write plug and schedule the submission 754 + * of the next plugged BIO. blk_zone_wplug_bio_work() will release the 755 + * reference we take here. 756 + */ 757 + WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)); 758 + refcount_inc(&zwplug->ref); 759 + queue_work(disk->zone_wplugs_wq, &zwplug->bio_work); 760 + } 761 + 762 + static inline void disk_zone_wplug_add_bio(struct gendisk *disk, 763 + struct blk_zone_wplug *zwplug, 764 + struct bio *bio, unsigned int nr_segs) 765 + { 766 + bool schedule_bio_work = false; 767 + 749 768 /* 750 769 * Grab an extra reference on the BIO request queue usage counter. 751 770 * This reference will be reused to submit a request for the BIO for ··· 778 765 bio_clear_polled(bio); 779 766 780 767 /* 768 + * REQ_NOWAIT BIOs are always handled using the zone write plug BIO 769 + * work, which can block. So clear the REQ_NOWAIT flag and schedule the 770 + * work if this is the first BIO we are plugging. 771 + */ 772 + if (bio->bi_opf & REQ_NOWAIT) { 773 + schedule_bio_work = !(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED); 774 + bio->bi_opf &= ~REQ_NOWAIT; 775 + } 776 + 777 + /* 781 778 * Reuse the poll cookie field to store the number of segments when 782 779 * split to the hardware limits. 783 780 */ ··· 800 777 * at the tail of the list to preserve the sequential write order. 801 778 */ 802 779 bio_list_add(&zwplug->bio_list, bio); 780 + 781 + zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED; 782 + 783 + if (schedule_bio_work) 784 + disk_zone_wplug_schedule_bio_work(disk, zwplug); 803 785 } 804 786 805 787 /* ··· 918 890 struct gendisk *disk = bio->bi_bdev->bd_disk; 919 891 920 892 /* 893 + * If we lost track of the zone write pointer due to a write error, 894 + * the user must either execute a report zones, reset the zone or finish 895 + * the to recover a reliable write pointer position. Fail BIOs if the 896 + * user did not do that as we cannot handle emulated zone append 897 + * otherwise. 898 + */ 899 + if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE) 900 + return false; 901 + 902 + /* 921 903 * Check that the user is not attempting to write to a full zone. 922 904 * We know such BIO will fail, and that would potentially overflow our 923 905 * write pointer offset beyond the end of the zone. 924 906 */ 925 907 if (disk_zone_wplug_is_full(disk, zwplug)) 926 - goto err; 908 + return false; 927 909 928 910 if (bio_op(bio) == REQ_OP_ZONE_APPEND) { 929 911 /* ··· 952 914 bio_set_flag(bio, BIO_EMULATES_ZONE_APPEND); 953 915 } else { 954 916 /* 955 - * Check for non-sequential writes early because we avoid a 956 - * whole lot of error handling trouble if we don't send it off 957 - * to the driver. 917 + * Check for non-sequential writes early as we know that BIOs 918 + * with a start sector not unaligned to the zone write pointer 919 + * will fail. 958 920 */ 959 921 if (bio_offset_from_zone_start(bio) != zwplug->wp_offset) 960 - goto err; 922 + return false; 961 923 } 962 924 963 925 /* Advance the zone write pointer offset. */ 964 926 zwplug->wp_offset += bio_sectors(bio); 965 927 966 928 return true; 967 - 968 - err: 969 - /* We detected an invalid write BIO: schedule error recovery. */ 970 - disk_zone_wplug_set_error(disk, zwplug); 971 - kblockd_schedule_work(&disk->zone_wplugs_work); 972 - return false; 973 929 } 974 930 975 931 static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs) ··· 1002 970 1003 971 zwplug = disk_get_and_lock_zone_wplug(disk, sector, gfp_mask, &flags); 1004 972 if (!zwplug) { 1005 - bio_io_error(bio); 973 + if (bio->bi_opf & REQ_NOWAIT) 974 + bio_wouldblock_error(bio); 975 + else 976 + bio_io_error(bio); 1006 977 return true; 1007 978 } 1008 979 ··· 1013 978 bio_set_flag(bio, BIO_ZONE_WRITE_PLUGGING); 1014 979 1015 980 /* 1016 - * If the zone is already plugged or has a pending error, add the BIO 1017 - * to the plug BIO list. Otherwise, plug and let the BIO execute. 981 + * If the zone is already plugged, add the BIO to the plug BIO list. 982 + * Do the same for REQ_NOWAIT BIOs to ensure that we will not see a 983 + * BLK_STS_AGAIN failure if we let the BIO execute. 984 + * Otherwise, plug and let the BIO execute. 1018 985 */ 1019 - if (zwplug->flags & BLK_ZONE_WPLUG_BUSY) 986 + if ((zwplug->flags & BLK_ZONE_WPLUG_PLUGGED) || 987 + (bio->bi_opf & REQ_NOWAIT)) 1020 988 goto plug; 1021 989 1022 - /* 1023 - * If an error is detected when preparing the BIO, add it to the BIO 1024 - * list so that error recovery can deal with it. 1025 - */ 1026 - if (!blk_zone_wplug_prepare_bio(zwplug, bio)) 1027 - goto plug; 990 + if (!blk_zone_wplug_prepare_bio(zwplug, bio)) { 991 + spin_unlock_irqrestore(&zwplug->lock, flags); 992 + bio_io_error(bio); 993 + return true; 994 + } 1028 995 1029 996 zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED; 1030 997 ··· 1035 998 return false; 1036 999 1037 1000 plug: 1038 - zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED; 1039 - blk_zone_wplug_add_bio(zwplug, bio, nr_segs); 1001 + disk_zone_wplug_add_bio(disk, zwplug, bio, nr_segs); 1040 1002 1041 1003 spin_unlock_irqrestore(&zwplug->lock, flags); 1042 1004 ··· 1119 1083 } 1120 1084 EXPORT_SYMBOL_GPL(blk_zone_plug_bio); 1121 1085 1122 - static void disk_zone_wplug_schedule_bio_work(struct gendisk *disk, 1123 - struct blk_zone_wplug *zwplug) 1124 - { 1125 - /* 1126 - * Take a reference on the zone write plug and schedule the submission 1127 - * of the next plugged BIO. blk_zone_wplug_bio_work() will release the 1128 - * reference we take here. 1129 - */ 1130 - WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)); 1131 - refcount_inc(&zwplug->ref); 1132 - queue_work(disk->zone_wplugs_wq, &zwplug->bio_work); 1133 - } 1134 - 1135 1086 static void disk_zone_wplug_unplug_bio(struct gendisk *disk, 1136 1087 struct blk_zone_wplug *zwplug) 1137 1088 { 1138 1089 unsigned long flags; 1139 1090 1140 1091 spin_lock_irqsave(&zwplug->lock, flags); 1141 - 1142 - /* 1143 - * If we had an error, schedule error recovery. The recovery work 1144 - * will restart submission of plugged BIOs. 1145 - */ 1146 - if (zwplug->flags & BLK_ZONE_WPLUG_ERROR) { 1147 - spin_unlock_irqrestore(&zwplug->lock, flags); 1148 - kblockd_schedule_work(&disk->zone_wplugs_work); 1149 - return; 1150 - } 1151 1092 1152 1093 /* Schedule submission of the next plugged BIO if we have one. */ 1153 1094 if (!bio_list_empty(&zwplug->bio_list)) { ··· 1168 1155 } 1169 1156 1170 1157 /* 1171 - * If the BIO failed, mark the plug as having an error to trigger 1172 - * recovery. 1158 + * If the BIO failed, abort all plugged BIOs and mark the plug as 1159 + * needing a write pointer update. 1173 1160 */ 1174 1161 if (bio->bi_status != BLK_STS_OK) { 1175 1162 spin_lock_irqsave(&zwplug->lock, flags); 1176 - disk_zone_wplug_set_error(disk, zwplug); 1163 + disk_zone_wplug_abort(zwplug); 1164 + zwplug->flags |= BLK_ZONE_WPLUG_NEED_WP_UPDATE; 1177 1165 spin_unlock_irqrestore(&zwplug->lock, flags); 1178 1166 } 1179 1167 ··· 1230 1216 */ 1231 1217 spin_lock_irqsave(&zwplug->lock, flags); 1232 1218 1219 + again: 1233 1220 bio = bio_list_pop(&zwplug->bio_list); 1234 1221 if (!bio) { 1235 1222 zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED; ··· 1239 1224 } 1240 1225 1241 1226 if (!blk_zone_wplug_prepare_bio(zwplug, bio)) { 1242 - /* Error recovery will decide what to do with the BIO. */ 1243 - bio_list_add_head(&zwplug->bio_list, bio); 1244 - spin_unlock_irqrestore(&zwplug->lock, flags); 1245 - goto put_zwplug; 1227 + blk_zone_wplug_bio_io_error(zwplug, bio); 1228 + goto again; 1246 1229 } 1247 1230 1248 1231 spin_unlock_irqrestore(&zwplug->lock, flags); ··· 1262 1249 disk_put_zone_wplug(zwplug); 1263 1250 } 1264 1251 1265 - static unsigned int blk_zone_wp_offset(struct blk_zone *zone) 1266 - { 1267 - switch (zone->cond) { 1268 - case BLK_ZONE_COND_IMP_OPEN: 1269 - case BLK_ZONE_COND_EXP_OPEN: 1270 - case BLK_ZONE_COND_CLOSED: 1271 - return zone->wp - zone->start; 1272 - case BLK_ZONE_COND_FULL: 1273 - return zone->len; 1274 - case BLK_ZONE_COND_EMPTY: 1275 - return 0; 1276 - case BLK_ZONE_COND_NOT_WP: 1277 - case BLK_ZONE_COND_OFFLINE: 1278 - case BLK_ZONE_COND_READONLY: 1279 - default: 1280 - /* 1281 - * Conventional, offline and read-only zones do not have a valid 1282 - * write pointer. 1283 - */ 1284 - return UINT_MAX; 1285 - } 1286 - } 1287 - 1288 - static int blk_zone_wplug_report_zone_cb(struct blk_zone *zone, 1289 - unsigned int idx, void *data) 1290 - { 1291 - struct blk_zone *zonep = data; 1292 - 1293 - *zonep = *zone; 1294 - return 0; 1295 - } 1296 - 1297 - static void disk_zone_wplug_handle_error(struct gendisk *disk, 1298 - struct blk_zone_wplug *zwplug) 1299 - { 1300 - sector_t zone_start_sector = 1301 - bdev_zone_sectors(disk->part0) * zwplug->zone_no; 1302 - unsigned int noio_flag; 1303 - struct blk_zone zone; 1304 - unsigned long flags; 1305 - int ret; 1306 - 1307 - /* Get the current zone information from the device. */ 1308 - noio_flag = memalloc_noio_save(); 1309 - ret = disk->fops->report_zones(disk, zone_start_sector, 1, 1310 - blk_zone_wplug_report_zone_cb, &zone); 1311 - memalloc_noio_restore(noio_flag); 1312 - 1313 - spin_lock_irqsave(&zwplug->lock, flags); 1314 - 1315 - /* 1316 - * A zone reset or finish may have cleared the error already. In such 1317 - * case, do nothing as the report zones may have seen the "old" write 1318 - * pointer value before the reset/finish operation completed. 1319 - */ 1320 - if (!(zwplug->flags & BLK_ZONE_WPLUG_ERROR)) 1321 - goto unlock; 1322 - 1323 - zwplug->flags &= ~BLK_ZONE_WPLUG_ERROR; 1324 - 1325 - if (ret != 1) { 1326 - /* 1327 - * We failed to get the zone information, meaning that something 1328 - * is likely really wrong with the device. Abort all remaining 1329 - * plugged BIOs as otherwise we could endup waiting forever on 1330 - * plugged BIOs to complete if there is a queue freeze on-going. 1331 - */ 1332 - disk_zone_wplug_abort(zwplug); 1333 - goto unplug; 1334 - } 1335 - 1336 - /* Update the zone write pointer offset. */ 1337 - zwplug->wp_offset = blk_zone_wp_offset(&zone); 1338 - disk_zone_wplug_abort_unaligned(disk, zwplug); 1339 - 1340 - /* Restart BIO submission if we still have any BIO left. */ 1341 - if (!bio_list_empty(&zwplug->bio_list)) { 1342 - disk_zone_wplug_schedule_bio_work(disk, zwplug); 1343 - goto unlock; 1344 - } 1345 - 1346 - unplug: 1347 - zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED; 1348 - if (disk_should_remove_zone_wplug(disk, zwplug)) 1349 - disk_remove_zone_wplug(disk, zwplug); 1350 - 1351 - unlock: 1352 - spin_unlock_irqrestore(&zwplug->lock, flags); 1353 - } 1354 - 1355 - static void disk_zone_wplugs_work(struct work_struct *work) 1356 - { 1357 - struct gendisk *disk = 1358 - container_of(work, struct gendisk, zone_wplugs_work); 1359 - struct blk_zone_wplug *zwplug; 1360 - unsigned long flags; 1361 - 1362 - spin_lock_irqsave(&disk->zone_wplugs_lock, flags); 1363 - 1364 - while (!list_empty(&disk->zone_wplugs_err_list)) { 1365 - zwplug = list_first_entry(&disk->zone_wplugs_err_list, 1366 - struct blk_zone_wplug, link); 1367 - list_del_init(&zwplug->link); 1368 - spin_unlock_irqrestore(&disk->zone_wplugs_lock, flags); 1369 - 1370 - disk_zone_wplug_handle_error(disk, zwplug); 1371 - disk_put_zone_wplug(zwplug); 1372 - 1373 - spin_lock_irqsave(&disk->zone_wplugs_lock, flags); 1374 - } 1375 - 1376 - spin_unlock_irqrestore(&disk->zone_wplugs_lock, flags); 1377 - } 1378 - 1379 1252 static inline unsigned int disk_zone_wplugs_hash_size(struct gendisk *disk) 1380 1253 { 1381 1254 return 1U << disk->zone_wplugs_hash_bits; ··· 1270 1371 void disk_init_zone_resources(struct gendisk *disk) 1271 1372 { 1272 1373 spin_lock_init(&disk->zone_wplugs_lock); 1273 - INIT_LIST_HEAD(&disk->zone_wplugs_err_list); 1274 - INIT_WORK(&disk->zone_wplugs_work, disk_zone_wplugs_work); 1275 1374 } 1276 1375 1277 1376 /* ··· 1367 1470 { 1368 1471 if (!disk->zone_wplugs_pool) 1369 1472 return; 1370 - 1371 - cancel_work_sync(&disk->zone_wplugs_work); 1372 1473 1373 1474 if (disk->zone_wplugs_wq) { 1374 1475 destroy_workqueue(disk->zone_wplugs_wq); ··· 1564 1669 if (!disk->zone_wplugs_hash) 1565 1670 return 0; 1566 1671 1672 + disk_zone_wplug_sync_wp_offset(disk, zone); 1673 + 1567 1674 wp_offset = blk_zone_wp_offset(zone); 1568 1675 if (!wp_offset || wp_offset >= zone->capacity) 1569 1676 return 0; ··· 1696 1799 memalloc_noio_restore(noio_flag); 1697 1800 return ret; 1698 1801 } 1802 + 1699 1803 ret = disk->fops->report_zones(disk, 0, UINT_MAX, 1700 1804 blk_revalidate_zone_cb, &args); 1701 1805 if (!ret) { ··· 1732 1834 return ret; 1733 1835 } 1734 1836 EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones); 1837 + 1838 + /** 1839 + * blk_zone_issue_zeroout - zero-fill a block range in a zone 1840 + * @bdev: blockdev to write 1841 + * @sector: start sector 1842 + * @nr_sects: number of sectors to write 1843 + * @gfp_mask: memory allocation flags (for bio_alloc) 1844 + * 1845 + * Description: 1846 + * Zero-fill a block range in a zone (@sector must be equal to the zone write 1847 + * pointer), handling potential errors due to the (initially unknown) lack of 1848 + * hardware offload (See blkdev_issue_zeroout()). 1849 + */ 1850 + int blk_zone_issue_zeroout(struct block_device *bdev, sector_t sector, 1851 + sector_t nr_sects, gfp_t gfp_mask) 1852 + { 1853 + int ret; 1854 + 1855 + if (WARN_ON_ONCE(!bdev_is_zoned(bdev))) 1856 + return -EIO; 1857 + 1858 + ret = blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask, 1859 + BLKDEV_ZERO_NOFALLBACK); 1860 + if (ret != -EOPNOTSUPP) 1861 + return ret; 1862 + 1863 + /* 1864 + * The failed call to blkdev_issue_zeroout() advanced the zone write 1865 + * pointer. Undo this using a report zone to update the zone write 1866 + * pointer to the correct current value. 1867 + */ 1868 + ret = disk_zone_sync_wp_offset(bdev->bd_disk, sector); 1869 + if (ret != 1) 1870 + return ret < 0 ? ret : -EIO; 1871 + 1872 + /* 1873 + * Retry without BLKDEV_ZERO_NOFALLBACK to force the fallback to a 1874 + * regular write with zero-pages. 1875 + */ 1876 + return blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask, 0); 1877 + } 1878 + EXPORT_SYMBOL_GPL(blk_zone_issue_zeroout); 1735 1879 1736 1880 #ifdef CONFIG_BLK_DEBUG_FS 1737 1881
+1 -4
block/mq-deadline.c
··· 698 698 list_add(&rq->queuelist, &per_prio->dispatch); 699 699 rq->fifo_time = jiffies; 700 700 } else { 701 - struct list_head *insert_before; 702 - 703 701 deadline_add_rq_rb(per_prio, rq); 704 702 705 703 if (rq_mergeable(rq)) { ··· 710 712 * set expire time and add to fifo list 711 713 */ 712 714 rq->fifo_time = jiffies + dd->fifo_expire[data_dir]; 713 - insert_before = &per_prio->fifo_list[data_dir]; 714 - list_add_tail(&rq->queuelist, insert_before); 715 + list_add_tail(&rq->queuelist, &per_prio->fifo_list[data_dir]); 715 716 } 716 717 } 717 718
+14 -31
crypto/rsassa-pkcs1.c
··· 163 163 struct rsassa_pkcs1_inst_ctx *ictx = sig_instance_ctx(inst); 164 164 const struct hash_prefix *hash_prefix = ictx->hash_prefix; 165 165 struct rsassa_pkcs1_ctx *ctx = crypto_sig_ctx(tfm); 166 - unsigned int child_reqsize = crypto_akcipher_reqsize(ctx->child); 167 - struct akcipher_request *child_req __free(kfree_sensitive) = NULL; 168 - struct scatterlist in_sg[3], out_sg; 169 - struct crypto_wait cwait; 170 166 unsigned int pad_len; 171 167 unsigned int ps_end; 172 168 unsigned int len; ··· 183 187 184 188 pad_len = ctx->key_size - slen - hash_prefix->size - 1; 185 189 186 - child_req = kmalloc(sizeof(*child_req) + child_reqsize + pad_len, 187 - GFP_KERNEL); 188 - if (!child_req) 189 - return -ENOMEM; 190 - 191 190 /* RFC 8017 sec 8.2.1 step 1 - EMSA-PKCS1-v1_5 encoding generation */ 192 - in_buf = (u8 *)(child_req + 1) + child_reqsize; 191 + in_buf = dst; 192 + memmove(in_buf + pad_len + hash_prefix->size, src, slen); 193 + memcpy(in_buf + pad_len, hash_prefix->data, hash_prefix->size); 194 + 193 195 ps_end = pad_len - 1; 194 196 in_buf[0] = 0x01; 195 197 memset(in_buf + 1, 0xff, ps_end - 1); 196 198 in_buf[ps_end] = 0x00; 197 199 198 - /* RFC 8017 sec 8.2.1 step 2 - RSA signature */ 199 - crypto_init_wait(&cwait); 200 - sg_init_table(in_sg, 3); 201 - sg_set_buf(&in_sg[0], in_buf, pad_len); 202 - sg_set_buf(&in_sg[1], hash_prefix->data, hash_prefix->size); 203 - sg_set_buf(&in_sg[2], src, slen); 204 - sg_init_one(&out_sg, dst, dlen); 205 - akcipher_request_set_tfm(child_req, ctx->child); 206 - akcipher_request_set_crypt(child_req, in_sg, &out_sg, 207 - ctx->key_size - 1, dlen); 208 - akcipher_request_set_callback(child_req, CRYPTO_TFM_REQ_MAY_SLEEP, 209 - crypto_req_done, &cwait); 210 200 211 - err = crypto_akcipher_decrypt(child_req); 212 - err = crypto_wait_req(err, &cwait); 213 - if (err) 201 + /* RFC 8017 sec 8.2.1 step 2 - RSA signature */ 202 + err = crypto_akcipher_sync_decrypt(ctx->child, in_buf, 203 + ctx->key_size - 1, in_buf, 204 + ctx->key_size); 205 + if (err < 0) 214 206 return err; 215 207 216 - len = child_req->dst_len; 208 + len = err; 217 209 pad_len = ctx->key_size - len; 218 210 219 211 /* Four billion to one */ ··· 223 239 struct rsassa_pkcs1_ctx *ctx = crypto_sig_ctx(tfm); 224 240 unsigned int child_reqsize = crypto_akcipher_reqsize(ctx->child); 225 241 struct akcipher_request *child_req __free(kfree_sensitive) = NULL; 226 - struct scatterlist in_sg, out_sg; 227 242 struct crypto_wait cwait; 243 + struct scatterlist sg; 228 244 unsigned int dst_len; 229 245 unsigned int pos; 230 246 u8 *out_buf; ··· 243 259 return -ENOMEM; 244 260 245 261 out_buf = (u8 *)(child_req + 1) + child_reqsize; 262 + memcpy(out_buf, src, slen); 246 263 247 264 crypto_init_wait(&cwait); 248 - sg_init_one(&in_sg, src, slen); 249 - sg_init_one(&out_sg, out_buf, ctx->key_size); 265 + sg_init_one(&sg, out_buf, slen); 250 266 akcipher_request_set_tfm(child_req, ctx->child); 251 - akcipher_request_set_crypt(child_req, &in_sg, &out_sg, 252 - slen, ctx->key_size); 267 + akcipher_request_set_crypt(child_req, &sg, &sg, slen, slen); 253 268 akcipher_request_set_callback(child_req, CRYPTO_TFM_REQ_MAY_SLEEP, 254 269 crypto_req_done, &cwait); 255 270
-2
drivers/acpi/acpica/evxfregn.c
··· 232 232 233 233 /* Now we can delete the handler object */ 234 234 235 - acpi_os_release_mutex(handler_obj->address_space. 236 - context_mutex); 237 235 acpi_ut_remove_reference(handler_obj); 238 236 goto unlock_and_exit; 239 237 }
+6 -1
drivers/acpi/nfit/core.c
··· 454 454 if (cmd_rc) 455 455 *cmd_rc = -EINVAL; 456 456 457 - if (cmd == ND_CMD_CALL) 457 + if (cmd == ND_CMD_CALL) { 458 + if (!buf || buf_len < sizeof(*call_pkg)) 459 + return -EINVAL; 460 + 458 461 call_pkg = buf; 462 + } 463 + 459 464 func = cmd_to_func(nfit_mem, cmd, call_pkg, &family); 460 465 if (func < 0) 461 466 return func;
+3 -3
drivers/acpi/resource.c
··· 250 250 switch (addr->resource_type) { 251 251 case ACPI_MEMORY_RANGE: 252 252 acpi_dev_memresource_flags(res, len, wp); 253 + 254 + if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY) 255 + res->flags |= IORESOURCE_PREFETCH; 253 256 break; 254 257 case ACPI_IO_RANGE: 255 258 acpi_dev_ioresource_flags(res, len, iodec, ··· 267 264 268 265 if (addr->producer_consumer == ACPI_PRODUCER) 269 266 res->flags |= IORESOURCE_WINDOW; 270 - 271 - if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY) 272 - res->flags |= IORESOURCE_PREFETCH; 273 267 274 268 return !(res->flags & IORESOURCE_DISABLED); 275 269 }
+1
drivers/ata/sata_highbank.c
··· 348 348 phy_nodes[phy] = phy_data.np; 349 349 cphy_base[phy] = of_iomap(phy_nodes[phy], 0); 350 350 if (cphy_base[phy] == NULL) { 351 + of_node_put(phy_data.np); 351 352 return 0; 352 353 } 353 354 phy_count += 1;
+13 -1
drivers/clocksource/hyperv_timer.c
··· 27 27 #include <asm/mshyperv.h> 28 28 29 29 static struct clock_event_device __percpu *hv_clock_event; 30 - static u64 hv_sched_clock_offset __ro_after_init; 30 + /* Note: offset can hold negative values after hibernation. */ 31 + static u64 hv_sched_clock_offset __read_mostly; 31 32 32 33 /* 33 34 * If false, we're using the old mechanism for stimer0 interrupts ··· 469 468 tsc_msr.enable = 1; 470 469 tsc_msr.pfn = tsc_pfn; 471 470 hv_set_msr(HV_MSR_REFERENCE_TSC, tsc_msr.as_uint64); 471 + } 472 + 473 + /* 474 + * Called during resume from hibernation, from overridden 475 + * x86_platform.restore_sched_clock_state routine. This is to adjust offsets 476 + * used to calculate time for hv tsc page based sched_clock, to account for 477 + * time spent before hibernation. 478 + */ 479 + void hv_adj_sched_clock_offset(u64 offset) 480 + { 481 + hv_sched_clock_offset -= offset; 472 482 } 473 483 474 484 #ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK
+2 -2
drivers/crypto/hisilicon/debugfs.c
··· 192 192 193 193 down_read(&qm->qps_lock); 194 194 if (qm->sqc) { 195 - memcpy(&sqc, qm->sqc + qp_id * sizeof(struct qm_sqc), sizeof(struct qm_sqc)); 195 + memcpy(&sqc, qm->sqc + qp_id, sizeof(struct qm_sqc)); 196 196 sqc.base_h = cpu_to_le32(QM_XQC_ADDR_MASK); 197 197 sqc.base_l = cpu_to_le32(QM_XQC_ADDR_MASK); 198 198 dump_show(qm, &sqc, sizeof(struct qm_sqc), "SOFT SQC"); ··· 229 229 230 230 down_read(&qm->qps_lock); 231 231 if (qm->cqc) { 232 - memcpy(&cqc, qm->cqc + qp_id * sizeof(struct qm_cqc), sizeof(struct qm_cqc)); 232 + memcpy(&cqc, qm->cqc + qp_id, sizeof(struct qm_cqc)); 233 233 cqc.base_h = cpu_to_le32(QM_XQC_ADDR_MASK); 234 234 cqc.base_l = cpu_to_le32(QM_XQC_ADDR_MASK); 235 235 dump_show(qm, &cqc, sizeof(struct qm_cqc), "SOFT CQC");
+18 -7
drivers/cxl/core/region.c
··· 1295 1295 struct cxl_region_params *p = &cxlr->params; 1296 1296 struct cxl_decoder *cxld = cxl_rr->decoder; 1297 1297 struct cxl_switch_decoder *cxlsd; 1298 + struct cxl_port *iter = port; 1298 1299 u16 eig, peig; 1299 1300 u8 eiw, peiw; 1300 1301 ··· 1312 1311 1313 1312 cxlsd = to_cxl_switch_decoder(&cxld->dev); 1314 1313 if (cxl_rr->nr_targets_set) { 1315 - int i, distance; 1314 + int i, distance = 1; 1315 + struct cxl_region_ref *cxl_rr_iter; 1316 1316 1317 1317 /* 1318 - * Passthrough decoders impose no distance requirements between 1319 - * peers 1318 + * The "distance" between peer downstream ports represents which 1319 + * endpoint positions in the region interleave a given port can 1320 + * host. 1321 + * 1322 + * For example, at the root of a hierarchy the distance is 1323 + * always 1 as every index targets a different host-bridge. At 1324 + * each subsequent switch level those ports map every Nth region 1325 + * position where N is the width of the switch == distance. 1320 1326 */ 1321 - if (cxl_rr->nr_targets == 1) 1322 - distance = 0; 1323 - else 1324 - distance = p->nr_targets / cxl_rr->nr_targets; 1327 + do { 1328 + cxl_rr_iter = cxl_rr_load(iter, cxlr); 1329 + distance *= cxl_rr_iter->nr_targets; 1330 + iter = to_cxl_port(iter->dev.parent); 1331 + } while (!is_cxl_root(iter)); 1332 + distance *= cxlrd->cxlsd.cxld.interleave_ways; 1333 + 1325 1334 for (i = 0; i < cxl_rr->nr_targets_set; i++) 1326 1335 if (ep->dport == cxlsd->target[i]) { 1327 1336 rc = check_last_peer(cxled, ep, cxl_rr,
+4 -2
drivers/cxl/pci.c
··· 836 836 if (!root_dev) 837 837 return -ENXIO; 838 838 839 + if (!dport->regs.rcd_pcie_cap) 840 + return -ENXIO; 841 + 839 842 guard(device)(root_dev); 840 843 if (!root_dev->driver) 841 844 return -ENXIO; ··· 1035 1032 if (rc) 1036 1033 return rc; 1037 1034 1038 - rc = cxl_pci_ras_unmask(pdev); 1039 - if (rc) 1035 + if (cxl_pci_ras_unmask(pdev)) 1040 1036 dev_dbg(&pdev->dev, "No RAS reporting unmasked\n"); 1041 1037 1042 1038 pci_save_state(pdev);
+10 -22
drivers/edac/amd64_edac.c
··· 3362 3362 3363 3363 static bool umc_ecc_enabled(struct amd64_pvt *pvt) 3364 3364 { 3365 - u8 umc_en_mask = 0, ecc_en_mask = 0; 3366 - u16 nid = pvt->mc_node_id; 3367 3365 struct amd64_umc *umc; 3368 - u8 ecc_en = 0, i; 3366 + bool ecc_en = false; 3367 + int i; 3369 3368 3369 + /* Check whether at least one UMC is enabled: */ 3370 3370 for_each_umc(i) { 3371 3371 umc = &pvt->umc[i]; 3372 3372 3373 - /* Only check enabled UMCs. */ 3374 - if (!(umc->sdp_ctrl & UMC_SDP_INIT)) 3375 - continue; 3376 - 3377 - umc_en_mask |= BIT(i); 3378 - 3379 - if (umc->umc_cap_hi & UMC_ECC_ENABLED) 3380 - ecc_en_mask |= BIT(i); 3373 + if (umc->sdp_ctrl & UMC_SDP_INIT && 3374 + umc->umc_cap_hi & UMC_ECC_ENABLED) { 3375 + ecc_en = true; 3376 + break; 3377 + } 3381 3378 } 3382 3379 3383 - /* Check whether at least one UMC is enabled: */ 3384 - if (umc_en_mask) 3385 - ecc_en = umc_en_mask == ecc_en_mask; 3386 - else 3387 - edac_dbg(0, "Node %d: No enabled UMCs.\n", nid); 3380 + edac_dbg(3, "Node %d: DRAM ECC %s.\n", pvt->mc_node_id, (ecc_en ? "enabled" : "disabled")); 3388 3381 3389 - edac_dbg(3, "Node %d: DRAM ECC %s.\n", nid, (ecc_en ? "enabled" : "disabled")); 3390 - 3391 - if (!ecc_en) 3392 - return false; 3393 - else 3394 - return true; 3382 + return ecc_en; 3395 3383 } 3396 3384 3397 3385 static inline void
+11 -4
drivers/firmware/arm_ffa/bus.c
··· 187 187 return valid; 188 188 } 189 189 190 - struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, 191 - const struct ffa_ops *ops) 190 + struct ffa_device * 191 + ffa_device_register(const struct ffa_partition_info *part_info, 192 + const struct ffa_ops *ops) 192 193 { 193 194 int id, ret; 195 + uuid_t uuid; 194 196 struct device *dev; 195 197 struct ffa_device *ffa_dev; 198 + 199 + if (!part_info) 200 + return NULL; 196 201 197 202 id = ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL); 198 203 if (id < 0) ··· 215 210 dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id); 216 211 217 212 ffa_dev->id = id; 218 - ffa_dev->vm_id = vm_id; 213 + ffa_dev->vm_id = part_info->id; 214 + ffa_dev->properties = part_info->properties; 219 215 ffa_dev->ops = ops; 220 - uuid_copy(&ffa_dev->uuid, uuid); 216 + import_uuid(&uuid, (u8 *)part_info->uuid); 217 + uuid_copy(&ffa_dev->uuid, &uuid); 221 218 222 219 ret = device_register(&ffa_dev->dev); 223 220 if (ret) {
+1 -6
drivers/firmware/arm_ffa/driver.c
··· 1387 1387 static int ffa_setup_partitions(void) 1388 1388 { 1389 1389 int count, idx, ret; 1390 - uuid_t uuid; 1391 1390 struct ffa_device *ffa_dev; 1392 1391 struct ffa_dev_part_info *info; 1393 1392 struct ffa_partition_info *pbuf, *tpbuf; ··· 1405 1406 1406 1407 xa_init(&drv_info->partition_info); 1407 1408 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) { 1408 - import_uuid(&uuid, (u8 *)tpbuf->uuid); 1409 - 1410 1409 /* Note that if the UUID will be uuid_null, that will require 1411 1410 * ffa_bus_notifier() to find the UUID of this partition id 1412 1411 * with help of ffa_device_match_uuid(). FF-A v1.1 and above 1413 1412 * provides UUID here for each partition as part of the 1414 1413 * discovery API and the same is passed. 1415 1414 */ 1416 - ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops); 1415 + ffa_dev = ffa_device_register(tpbuf, &ffa_drv_ops); 1417 1416 if (!ffa_dev) { 1418 1417 pr_err("%s: failed to register partition ID 0x%x\n", 1419 1418 __func__, tpbuf->id); 1420 1419 continue; 1421 1420 } 1422 - 1423 - ffa_dev->properties = tpbuf->properties; 1424 1421 1425 1422 if (drv_info->version > FFA_VERSION_1_0 && 1426 1423 !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
+1
drivers/firmware/arm_scmi/vendors/imx/Kconfig
··· 15 15 config IMX_SCMI_MISC_EXT 16 16 tristate "i.MX SCMI MISC EXTENSION" 17 17 depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) 18 + depends on IMX_SCMI_MISC_DRV 18 19 default y if ARCH_MXC 19 20 help 20 21 This enables i.MX System MISC control logic such as gpio expander
-4
drivers/firmware/efi/Kconfig
··· 76 76 bool "Enable the generic EFI decompressor" 77 77 depends on EFI_GENERIC_STUB && !ARM 78 78 select HAVE_KERNEL_GZIP 79 - select HAVE_KERNEL_LZ4 80 - select HAVE_KERNEL_LZMA 81 - select HAVE_KERNEL_LZO 82 - select HAVE_KERNEL_XZ 83 79 select HAVE_KERNEL_ZSTD 84 80 help 85 81 Create the bootable image as an EFI application that carries the
-2
drivers/firmware/efi/esrt.c
··· 75 75 struct esre_attribute { 76 76 struct attribute attr; 77 77 ssize_t (*show)(struct esre_entry *entry, char *buf); 78 - ssize_t (*store)(struct esre_entry *entry, 79 - const char *buf, size_t count); 80 78 }; 81 79 82 80 static struct esre_entry *to_entry(struct kobject *kobj)
+6 -12
drivers/firmware/efi/libstub/Makefile.zboot
··· 12 12 $(obj)/vmlinux.bin: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE 13 13 $(call if_changed,copy_and_pad) 14 14 15 - comp-type-$(CONFIG_KERNEL_GZIP) := gzip 16 - comp-type-$(CONFIG_KERNEL_LZ4) := lz4 17 - comp-type-$(CONFIG_KERNEL_LZMA) := lzma 18 - comp-type-$(CONFIG_KERNEL_LZO) := lzo 19 - comp-type-$(CONFIG_KERNEL_XZ) := xzkern 20 - comp-type-$(CONFIG_KERNEL_ZSTD) := zstd22 21 - 22 15 # in GZIP, the appended le32 carrying the uncompressed size is part of the 23 16 # format, but in other cases, we just append it at the end for convenience, 24 17 # causing the original tools to complain when checking image integrity. 25 - # So disregard it when calculating the payload size in the zimage header. 26 - zboot-method-y := $(comp-type-y)_with_size 27 - zboot-size-len-y := 4 18 + comp-type-y := gzip 19 + zboot-method-y := gzip 20 + zboot-size-len-y := 0 28 21 29 - zboot-method-$(CONFIG_KERNEL_GZIP) := gzip 30 - zboot-size-len-$(CONFIG_KERNEL_GZIP) := 0 22 + comp-type-$(CONFIG_KERNEL_ZSTD) := zstd 23 + zboot-method-$(CONFIG_KERNEL_ZSTD) := zstd22_with_size 24 + zboot-size-len-$(CONFIG_KERNEL_ZSTD) := 4 31 25 32 26 $(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE 33 27 $(call if_changed,$(zboot-method-y))
-1
drivers/firmware/imx/Kconfig
··· 25 25 26 26 config IMX_SCMI_MISC_DRV 27 27 tristate "IMX SCMI MISC Protocol driver" 28 - depends on IMX_SCMI_MISC_EXT || COMPILE_TEST 29 28 default y if ARCH_MXC 30 29 help 31 30 The System Controller Management Interface firmware (SCMI FW) is
+2 -1
drivers/gpio/Kconfig
··· 482 482 Say yes here to support the Mediatek MT7621 SoC GPIO device. 483 483 484 484 config GPIO_MVEBU 485 - def_bool y 485 + bool "Marvell Orion and EBU GPIO support" if COMPILE_TEST 486 486 depends on PLAT_ORION || ARCH_MVEBU || COMPILE_TEST 487 + default PLAT_ORION || ARCH_MVEBU 487 488 select GENERIC_IRQ_CHIP 488 489 select REGMAP_MMIO 489 490
+41 -11
drivers/gpio/gpio-graniterapids.c
··· 32 32 #define GNR_PINS_PER_REG 32 33 33 #define GNR_NUM_REGS DIV_ROUND_UP(GNR_NUM_PINS, GNR_PINS_PER_REG) 34 34 35 - #define GNR_CFG_BAR 0x00 35 + #define GNR_CFG_PADBAR 0x00 36 36 #define GNR_CFG_LOCK_OFFSET 0x04 37 - #define GNR_GPI_STATUS_OFFSET 0x20 37 + #define GNR_GPI_STATUS_OFFSET 0x14 38 38 #define GNR_GPI_ENABLE_OFFSET 0x24 39 39 40 - #define GNR_CFG_DW_RX_MASK GENMASK(25, 22) 40 + #define GNR_CFG_DW_HOSTSW_MODE BIT(27) 41 + #define GNR_CFG_DW_RX_MASK GENMASK(23, 22) 42 + #define GNR_CFG_DW_INTSEL_MASK GENMASK(21, 14) 41 43 #define GNR_CFG_DW_RX_DISABLE FIELD_PREP(GNR_CFG_DW_RX_MASK, 2) 42 44 #define GNR_CFG_DW_RX_EDGE FIELD_PREP(GNR_CFG_DW_RX_MASK, 1) 43 45 #define GNR_CFG_DW_RX_LEVEL FIELD_PREP(GNR_CFG_DW_RX_MASK, 0) ··· 52 50 * struct gnr_gpio - Intel Granite Rapids-D vGPIO driver state 53 51 * @gc: GPIO controller interface 54 52 * @reg_base: base address of the GPIO registers 53 + * @pad_base: base address of the vGPIO pad configuration registers 55 54 * @ro_bitmap: bitmap of read-only pins 56 55 * @lock: guard the registers 57 56 * @pad_backup: backup of the register state for suspend ··· 60 57 struct gnr_gpio { 61 58 struct gpio_chip gc; 62 59 void __iomem *reg_base; 60 + void __iomem *pad_base; 63 61 DECLARE_BITMAP(ro_bitmap, GNR_NUM_PINS); 64 62 raw_spinlock_t lock; 65 63 u32 pad_backup[]; ··· 69 65 static void __iomem *gnr_gpio_get_padcfg_addr(const struct gnr_gpio *priv, 70 66 unsigned int gpio) 71 67 { 72 - return priv->reg_base + gpio * sizeof(u32); 68 + return priv->pad_base + gpio * sizeof(u32); 73 69 } 74 70 75 71 static int gnr_gpio_configure_line(struct gpio_chip *gc, unsigned int gpio, ··· 88 84 dw &= ~clear_mask; 89 85 dw |= set_mask; 90 86 writel(dw, addr); 87 + 88 + return 0; 89 + } 90 + 91 + static int gnr_gpio_request(struct gpio_chip *gc, unsigned int gpio) 92 + { 93 + struct gnr_gpio *priv = gpiochip_get_data(gc); 94 + u32 dw; 95 + 96 + dw = readl(gnr_gpio_get_padcfg_addr(priv, gpio)); 97 + if (!(dw & GNR_CFG_DW_HOSTSW_MODE)) { 98 + dev_warn(gc->parent, "GPIO %u is not owned by host", gpio); 99 + return -EBUSY; 100 + } 91 101 92 102 return 0; 93 103 } ··· 157 139 158 140 static const struct gpio_chip gnr_gpio_chip = { 159 141 .owner = THIS_MODULE, 142 + .request = gnr_gpio_request, 160 143 .get = gnr_gpio_get, 161 144 .set = gnr_gpio_set, 162 145 .get_direction = gnr_gpio_get_direction, ··· 185 166 guard(raw_spinlock_irqsave)(&priv->lock); 186 167 187 168 reg = readl(addr); 188 - reg &= ~BIT(bit_idx); 169 + reg |= BIT(bit_idx); 189 170 writel(reg, addr); 190 171 } 191 172 ··· 228 209 static int gnr_gpio_irq_set_type(struct irq_data *d, unsigned int type) 229 210 { 230 211 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 231 - irq_hw_number_t pin = irqd_to_hwirq(d); 232 - u32 mask = GNR_CFG_DW_RX_MASK; 212 + struct gnr_gpio *priv = gpiochip_get_data(gc); 213 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 214 + u32 reg; 233 215 u32 set; 216 + 217 + /* Allow interrupts only if Interrupt Select field is non-zero */ 218 + reg = readl(gnr_gpio_get_padcfg_addr(priv, hwirq)); 219 + if (!(reg & GNR_CFG_DW_INTSEL_MASK)) { 220 + dev_dbg(gc->parent, "GPIO %lu cannot be used as IRQ", hwirq); 221 + return -EPERM; 222 + } 234 223 235 224 /* Falling edge and level low triggers not supported by the GPIO controller */ 236 225 switch (type) { ··· 257 230 return -EINVAL; 258 231 } 259 232 260 - return gnr_gpio_configure_line(gc, pin, mask, set); 233 + return gnr_gpio_configure_line(gc, hwirq, GNR_CFG_DW_RX_MASK, set); 261 234 } 262 235 263 236 static const struct irq_chip gnr_gpio_irq_chip = { 237 + .name = "gpio-graniterapids", 264 238 .irq_ack = gnr_gpio_irq_ack, 265 239 .irq_mask = gnr_gpio_irq_mask, 266 240 .irq_unmask = gnr_gpio_irq_unmask, ··· 319 291 struct gnr_gpio *priv; 320 292 void __iomem *regs; 321 293 int irq, ret; 294 + u32 offset; 322 295 323 296 priv = devm_kzalloc(dev, struct_size(priv, pad_backup, num_backup_pins), GFP_KERNEL); 324 297 if (!priv) ··· 331 302 if (IS_ERR(regs)) 332 303 return PTR_ERR(regs); 333 304 305 + priv->reg_base = regs; 306 + offset = readl(priv->reg_base + GNR_CFG_PADBAR); 307 + priv->pad_base = priv->reg_base + offset; 308 + 334 309 irq = platform_get_irq(pdev, 0); 335 310 if (irq < 0) 336 311 return irq; ··· 343 310 dev_name(dev), priv); 344 311 if (ret) 345 312 return dev_err_probe(dev, ret, "failed to request interrupt\n"); 346 - 347 - priv->reg_base = regs + readl(regs + GNR_CFG_BAR); 348 313 349 314 gnr_gpio_init_pin_ro_bits(dev, priv->reg_base + GNR_CFG_LOCK_OFFSET, 350 315 priv->ro_bitmap); ··· 355 324 356 325 girq = &priv->gc.irq; 357 326 gpio_irq_chip_set_chip(girq, &gnr_gpio_irq_chip); 358 - girq->chip->name = dev_name(dev); 359 327 girq->parent_handler = NULL; 360 328 girq->num_parents = 0; 361 329 girq->parents = NULL;
+3 -2
drivers/gpio/gpio-idio-16.c
··· 3 3 * GPIO library for the ACCES IDIO-16 family 4 4 * Copyright (C) 2022 William Breathitt Gray 5 5 */ 6 + 7 + #define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16" 8 + 6 9 #include <linux/bits.h> 7 10 #include <linux/device.h> 8 11 #include <linux/err.h> ··· 16 13 #include <linux/types.h> 17 14 18 15 #include "gpio-idio-16.h" 19 - 20 - #define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16" 21 16 22 17 #define IDIO_16_DAT_BASE 0x0 23 18 #define IDIO_16_OUT_BASE IDIO_16_DAT_BASE
+1 -1
drivers/gpio/gpio-ljca.c
··· 82 82 int ret; 83 83 84 84 mutex_lock(&ljca_gpio->trans_lock); 85 + packet->num = 1; 85 86 packet->item[0].index = gpio_id; 86 87 packet->item[0].value = config | ljca_gpio->connect_mode[gpio_id]; 87 - packet->num = 1; 88 88 89 89 ret = ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_CONFIG, (u8 *)packet, 90 90 struct_size(packet, item, packet->num), NULL, 0);
+11 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 1801 1801 if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket) 1802 1802 return -EINVAL; 1803 1803 1804 + /* Make sure VRAM is allocated contigiously */ 1804 1805 (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; 1805 - amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains); 1806 - for (i = 0; i < (*bo)->placement.num_placement; i++) 1807 - (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS; 1808 - r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx); 1809 - if (r) 1810 - return r; 1806 + if ((*bo)->tbo.resource->mem_type == TTM_PL_VRAM && 1807 + !((*bo)->tbo.resource->placement & TTM_PL_FLAG_CONTIGUOUS)) { 1808 + 1809 + amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains); 1810 + for (i = 0; i < (*bo)->placement.num_placement; i++) 1811 + (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS; 1812 + r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx); 1813 + if (r) 1814 + return r; 1815 + } 1811 1816 1812 1817 return amdgpu_ttm_alloc_gart(&(*bo)->tbo); 1813 1818 }
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 145 145 "LAST", 146 146 }; 147 147 148 - #define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM, 0) 148 + #define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMD_IP_BLOCK_TYPE_NUM - 1, 0) 149 149 /* 150 150 * Default init level where all blocks are expected to be initialized. This is 151 151 * the level of initialization expected by default and also after a full reset
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 551 551 for (i = 0; i < abo->placement.num_placement; ++i) { 552 552 abo->placements[i].fpfn = 0 >> PAGE_SHIFT; 553 553 abo->placements[i].lpfn = (256 * 1024 * 1024) >> PAGE_SHIFT; 554 + if (abo->placements[i].mem_type == TTM_PL_VRAM) 555 + abo->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS; 554 556 } 555 557 } 556 558
+7 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 674 674 pasid_mapping_needed &= adev->gmc.gmc_funcs->emit_pasid_mapping && 675 675 ring->funcs->emit_wreg; 676 676 677 - if (adev->gfx.enable_cleaner_shader && 678 - ring->funcs->emit_cleaner_shader && 679 - job->enforce_isolation) 680 - ring->funcs->emit_cleaner_shader(ring); 681 - 682 - if (!vm_flush_needed && !gds_switch_needed && !need_pipe_sync) 677 + if (!vm_flush_needed && !gds_switch_needed && !need_pipe_sync && 678 + !(job->enforce_isolation && !job->vmid)) 683 679 return 0; 684 680 685 681 amdgpu_ring_ib_begin(ring); ··· 685 689 686 690 if (need_pipe_sync) 687 691 amdgpu_ring_emit_pipeline_sync(ring); 692 + 693 + if (adev->gfx.enable_cleaner_shader && 694 + ring->funcs->emit_cleaner_shader && 695 + job->enforce_isolation) 696 + ring->funcs->emit_cleaner_shader(ring); 688 697 689 698 if (vm_flush_needed) { 690 699 trace_amdgpu_vm_flush(ring, job->vmid, job->vm_pd_addr);
+8 -2
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
··· 45 45 MODULE_FIRMWARE("amdgpu/gc_9_4_4_mec.bin"); 46 46 MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin"); 47 47 MODULE_FIRMWARE("amdgpu/gc_9_4_4_rlc.bin"); 48 + MODULE_FIRMWARE("amdgpu/gc_9_4_3_sjt_mec.bin"); 49 + MODULE_FIRMWARE("amdgpu/gc_9_4_4_sjt_mec.bin"); 48 50 49 51 #define GFX9_MEC_HPD_SIZE 4096 50 52 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L ··· 576 574 { 577 575 int err; 578 576 579 - err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw, 580 - "amdgpu/%s_mec.bin", chip_name); 577 + if (amdgpu_sriov_vf(adev)) 578 + err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw, 579 + "amdgpu/%s_sjt_mec.bin", chip_name); 580 + else 581 + err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw, 582 + "amdgpu/%s_mec.bin", chip_name); 581 583 if (err) 582 584 goto out; 583 585 amdgpu_gfx_cp_init_microcode(adev, AMDGPU_UCODE_ID_CP_MEC1);
+1 -1
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
··· 1288 1288 struct amdgpu_job *job, 1289 1289 struct amdgpu_ib *ib) 1290 1290 { 1291 - struct amdgpu_ring *ring = to_amdgpu_ring(job->base.sched); 1291 + struct amdgpu_ring *ring = amdgpu_job_ring(job); 1292 1292 unsigned i; 1293 1293 1294 1294 /* No patching necessary for the first instance */
+21 -3
drivers/gpu/drm/amd/amdkfd/kfd_crat.c
··· 1423 1423 1424 1424 1425 1425 static int kfd_fill_gpu_cache_info_from_gfx_config(struct kfd_dev *kdev, 1426 + bool cache_line_size_missing, 1426 1427 struct kfd_gpu_cache_info *pcache_info) 1427 1428 { 1428 1429 struct amdgpu_device *adev = kdev->adev; ··· 1438 1437 CRAT_CACHE_FLAGS_SIMD_CACHE); 1439 1438 pcache_info[i].num_cu_shared = adev->gfx.config.gc_num_tcp_per_wpg / 2; 1440 1439 pcache_info[i].cache_line_size = adev->gfx.config.gc_tcp_cache_line_size; 1440 + if (cache_line_size_missing && !pcache_info[i].cache_line_size) 1441 + pcache_info[i].cache_line_size = 128; 1441 1442 i++; 1442 1443 } 1443 1444 /* Scalar L1 Instruction Cache per SQC */ ··· 1452 1449 CRAT_CACHE_FLAGS_SIMD_CACHE); 1453 1450 pcache_info[i].num_cu_shared = adev->gfx.config.gc_num_sqc_per_wgp * 2; 1454 1451 pcache_info[i].cache_line_size = adev->gfx.config.gc_instruction_cache_line_size; 1452 + if (cache_line_size_missing && !pcache_info[i].cache_line_size) 1453 + pcache_info[i].cache_line_size = 128; 1455 1454 i++; 1456 1455 } 1457 1456 /* Scalar L1 Data Cache per SQC */ ··· 1465 1460 CRAT_CACHE_FLAGS_SIMD_CACHE); 1466 1461 pcache_info[i].num_cu_shared = adev->gfx.config.gc_num_sqc_per_wgp * 2; 1467 1462 pcache_info[i].cache_line_size = adev->gfx.config.gc_scalar_data_cache_line_size; 1463 + if (cache_line_size_missing && !pcache_info[i].cache_line_size) 1464 + pcache_info[i].cache_line_size = 64; 1468 1465 i++; 1469 1466 } 1470 1467 /* GL1 Data Cache per SA */ ··· 1479 1472 CRAT_CACHE_FLAGS_DATA_CACHE | 1480 1473 CRAT_CACHE_FLAGS_SIMD_CACHE); 1481 1474 pcache_info[i].num_cu_shared = adev->gfx.config.max_cu_per_sh; 1482 - pcache_info[i].cache_line_size = 0; 1475 + if (cache_line_size_missing) 1476 + pcache_info[i].cache_line_size = 128; 1483 1477 i++; 1484 1478 } 1485 1479 /* L2 Data Cache per GPU (Total Tex Cache) */ ··· 1492 1484 CRAT_CACHE_FLAGS_SIMD_CACHE); 1493 1485 pcache_info[i].num_cu_shared = adev->gfx.config.max_cu_per_sh; 1494 1486 pcache_info[i].cache_line_size = adev->gfx.config.gc_tcc_cache_line_size; 1487 + if (cache_line_size_missing && !pcache_info[i].cache_line_size) 1488 + pcache_info[i].cache_line_size = 128; 1495 1489 i++; 1496 1490 } 1497 1491 /* L3 Data Cache per GPU */ ··· 1504 1494 CRAT_CACHE_FLAGS_DATA_CACHE | 1505 1495 CRAT_CACHE_FLAGS_SIMD_CACHE); 1506 1496 pcache_info[i].num_cu_shared = adev->gfx.config.max_cu_per_sh; 1507 - pcache_info[i].cache_line_size = 0; 1497 + pcache_info[i].cache_line_size = 64; 1508 1498 i++; 1509 1499 } 1510 1500 return i; ··· 1579 1569 int kfd_get_gpu_cache_info(struct kfd_node *kdev, struct kfd_gpu_cache_info **pcache_info) 1580 1570 { 1581 1571 int num_of_cache_types = 0; 1572 + bool cache_line_size_missing = false; 1582 1573 1583 1574 switch (kdev->adev->asic_type) { 1584 1575 case CHIP_KAVERI: ··· 1703 1692 case IP_VERSION(11, 5, 0): 1704 1693 case IP_VERSION(11, 5, 1): 1705 1694 case IP_VERSION(11, 5, 2): 1695 + /* Cacheline size not available in IP discovery for gc11. 1696 + * kfd_fill_gpu_cache_info_from_gfx_config to hard code it 1697 + */ 1698 + cache_line_size_missing = true; 1699 + fallthrough; 1706 1700 case IP_VERSION(12, 0, 0): 1707 1701 case IP_VERSION(12, 0, 1): 1708 1702 num_of_cache_types = 1709 - kfd_fill_gpu_cache_info_from_gfx_config(kdev->kfd, *pcache_info); 1703 + kfd_fill_gpu_cache_info_from_gfx_config(kdev->kfd, 1704 + cache_line_size_missing, 1705 + *pcache_info); 1710 1706 break; 1711 1707 default: 1712 1708 *pcache_info = dummy_cache_info;
+15
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 207 207 if (!down_read_trylock(&adev->reset_domain->sem)) 208 208 return -EIO; 209 209 210 + if (!pdd->proc_ctx_cpu_ptr) { 211 + r = amdgpu_amdkfd_alloc_gtt_mem(adev, 212 + AMDGPU_MES_PROC_CTX_SIZE, 213 + &pdd->proc_ctx_bo, 214 + &pdd->proc_ctx_gpu_addr, 215 + &pdd->proc_ctx_cpu_ptr, 216 + false); 217 + if (r) { 218 + dev_err(adev->dev, 219 + "failed to allocate process context bo\n"); 220 + return r; 221 + } 222 + memset(pdd->proc_ctx_cpu_ptr, 0, AMDGPU_MES_PROC_CTX_SIZE); 223 + } 224 + 210 225 memset(&queue_input, 0x0, sizeof(struct mes_add_queue_input)); 211 226 queue_input.process_id = qpd->pqm->process->pasid; 212 227 queue_input.page_table_base_addr = qpd->page_table_base;
+2 -2
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
··· 306 306 spage = migrate_pfn_to_page(migrate->src[i]); 307 307 if (spage && !is_zone_device_page(spage)) { 308 308 src[i] = dma_map_page(dev, spage, 0, PAGE_SIZE, 309 - DMA_TO_DEVICE); 309 + DMA_BIDIRECTIONAL); 310 310 r = dma_mapping_error(dev, src[i]); 311 311 if (r) { 312 312 dev_err(dev, "%s: fail %d dma_map_page\n", ··· 629 629 goto out_oom; 630 630 } 631 631 632 - dst[i] = dma_map_page(dev, dpage, 0, PAGE_SIZE, DMA_FROM_DEVICE); 632 + dst[i] = dma_map_page(dev, dpage, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); 633 633 r = dma_mapping_error(dev, dst[i]); 634 634 if (r) { 635 635 dev_err(adev->dev, "%s: fail %d dma_map_page\n", __func__, r);
+2 -21
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 1076 1076 1077 1077 kfd_free_process_doorbells(pdd->dev->kfd, pdd); 1078 1078 1079 - if (pdd->dev->kfd->shared_resources.enable_mes) 1079 + if (pdd->dev->kfd->shared_resources.enable_mes && 1080 + pdd->proc_ctx_cpu_ptr) 1080 1081 amdgpu_amdkfd_free_gtt_mem(pdd->dev->adev, 1081 1082 &pdd->proc_ctx_bo); 1082 1083 /* ··· 1609 1608 struct kfd_process *p) 1610 1609 { 1611 1610 struct kfd_process_device *pdd = NULL; 1612 - int retval = 0; 1613 1611 1614 1612 if (WARN_ON_ONCE(p->n_pdds >= MAX_GPU_INSTANCE)) 1615 1613 return NULL; ··· 1632 1632 pdd->user_gpu_id = dev->id; 1633 1633 atomic64_set(&pdd->evict_duration_counter, 0); 1634 1634 1635 - if (dev->kfd->shared_resources.enable_mes) { 1636 - retval = amdgpu_amdkfd_alloc_gtt_mem(dev->adev, 1637 - AMDGPU_MES_PROC_CTX_SIZE, 1638 - &pdd->proc_ctx_bo, 1639 - &pdd->proc_ctx_gpu_addr, 1640 - &pdd->proc_ctx_cpu_ptr, 1641 - false); 1642 - if (retval) { 1643 - dev_err(dev->adev->dev, 1644 - "failed to allocate process context bo\n"); 1645 - goto err_free_pdd; 1646 - } 1647 - memset(pdd->proc_ctx_cpu_ptr, 0, AMDGPU_MES_PROC_CTX_SIZE); 1648 - } 1649 - 1650 1635 p->pdds[p->n_pdds++] = pdd; 1651 1636 if (kfd_dbg_is_per_vmid_supported(pdd->dev)) 1652 1637 pdd->spi_dbg_override = pdd->dev->kfd2kgd->disable_debug_trap( ··· 1643 1658 idr_init(&pdd->alloc_idr); 1644 1659 1645 1660 return pdd; 1646 - 1647 - err_free_pdd: 1648 - kfree(pdd); 1649 - return NULL; 1650 1661 } 1651 1662 1652 1663 /**
+8 -4
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
··· 212 212 void pqm_uninit(struct process_queue_manager *pqm) 213 213 { 214 214 struct process_queue_node *pqn, *next; 215 - struct kfd_process_device *pdd; 216 215 217 216 list_for_each_entry_safe(pqn, next, &pqm->queues, process_queue_list) { 218 217 if (pqn->q) { 219 - pdd = kfd_get_process_device_data(pqn->q->device, pqm->process); 220 - kfd_queue_unref_bo_vas(pdd, &pqn->q->properties); 221 - kfd_queue_release_buffers(pdd, &pqn->q->properties); 218 + struct kfd_process_device *pdd = kfd_get_process_device_data(pqn->q->device, 219 + pqm->process); 220 + if (pdd) { 221 + kfd_queue_unref_bo_vas(pdd, &pqn->q->properties); 222 + kfd_queue_release_buffers(pdd, &pqn->q->properties); 223 + } else { 224 + WARN_ON(!pdd); 225 + } 222 226 pqm_clean_queue_resource(pqm, pqn); 223 227 } 224 228
+1
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 164 164 }; 165 165 166 166 enum PP_SMC_POWER_PROFILE { 167 + PP_SMC_POWER_PROFILE_UNKNOWN = -1, 167 168 PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT = 0x0, 168 169 PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x1, 169 170 PP_SMC_POWER_PROFILE_POWERSAVING = 0x2,
+17 -7
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 764 764 smu->smu_baco.platform_support = false; 765 765 smu->smu_baco.maco_support = false; 766 766 smu->user_dpm_profile.fan_mode = -1; 767 + smu->power_profile_mode = PP_SMC_POWER_PROFILE_UNKNOWN; 767 768 768 769 mutex_init(&smu->message_lock); 769 770 ··· 1249 1248 return smu->workload_map && smu->workload_map[profile].valid_mapping; 1250 1249 } 1251 1250 1251 + static void smu_init_power_profile(struct smu_context *smu) 1252 + { 1253 + if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_UNKNOWN) { 1254 + if (smu->is_apu || 1255 + !smu_is_workload_profile_available( 1256 + smu, PP_SMC_POWER_PROFILE_FULLSCREEN3D)) 1257 + smu->power_profile_mode = 1258 + PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; 1259 + else 1260 + smu->power_profile_mode = 1261 + PP_SMC_POWER_PROFILE_FULLSCREEN3D; 1262 + } 1263 + smu_power_profile_mode_get(smu, smu->power_profile_mode); 1264 + } 1265 + 1252 1266 static int smu_sw_init(struct amdgpu_ip_block *ip_block) 1253 1267 { 1254 1268 struct amdgpu_device *adev = ip_block->adev; ··· 1285 1269 atomic_set(&smu->smu_power.power_gate.vpe_gated, 1); 1286 1270 atomic_set(&smu->smu_power.power_gate.umsch_mm_gated, 1); 1287 1271 1288 - if (smu->is_apu || 1289 - !smu_is_workload_profile_available(smu, PP_SMC_POWER_PROFILE_FULLSCREEN3D)) 1290 - smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; 1291 - else 1292 - smu->power_profile_mode = PP_SMC_POWER_PROFILE_FULLSCREEN3D; 1293 - smu_power_profile_mode_get(smu, smu->power_profile_mode); 1294 - 1272 + smu_init_power_profile(smu); 1295 1273 smu->display_config = &adev->pm.pm_display_cfg; 1296 1274 1297 1275 smu->smu_dpm.dpm_level = AMD_DPM_FORCED_LEVEL_AUTO;
+1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
··· 2810 2810 smu->workload_map = smu_v13_0_7_workload_map; 2811 2811 smu->smc_driver_if_version = SMU13_0_7_DRIVER_IF_VERSION; 2812 2812 smu_v13_0_set_smu_mailbox_registers(smu); 2813 + smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; 2813 2814 }
-1
drivers/gpu/drm/drm_panic_qr.rs
··· 929 929 /// * `tmp` must be valid for reading and writing for `tmp_size` bytes. 930 930 /// 931 931 /// They must remain valid for the duration of the function call. 932 - 933 932 #[no_mangle] 934 933 pub unsafe extern "C" fn drm_panic_qr_generate( 935 934 url: *const i8,
+51 -30
drivers/gpu/drm/i915/display/intel_color.c
··· 1343 1343 intel_de_write_fw(display, reg, val); 1344 1344 } 1345 1345 1346 + static void ilk_lut_write_indexed(const struct intel_crtc_state *crtc_state, 1347 + i915_reg_t reg, u32 val) 1348 + { 1349 + struct intel_display *display = to_intel_display(crtc_state); 1350 + 1351 + if (crtc_state->dsb_color_vblank) 1352 + intel_dsb_reg_write_indexed(crtc_state->dsb_color_vblank, reg, val); 1353 + else 1354 + intel_de_write_fw(display, reg, val); 1355 + } 1356 + 1346 1357 static void ilk_load_lut_8(const struct intel_crtc_state *crtc_state, 1347 1358 const struct drm_property_blob *blob) 1348 1359 { ··· 1368 1357 lut = blob->data; 1369 1358 1370 1359 /* 1371 - * DSB fails to correctly load the legacy LUT 1372 - * unless we either write each entry twice, 1373 - * or use non-posted writes 1360 + * DSB fails to correctly load the legacy LUT unless 1361 + * we either write each entry twice when using posted 1362 + * writes, or we use non-posted writes. 1363 + * 1364 + * If palette anti-collision is active during LUT 1365 + * register writes: 1366 + * - posted writes simply get dropped and thus the LUT 1367 + * contents may not be correctly updated 1368 + * - non-posted writes are blocked and thus the LUT 1369 + * contents are always correct, but simultaneous CPU 1370 + * MMIO access will start to fail 1371 + * 1372 + * Choose the lesser of two evils and use posted writes. 1373 + * Using posted writes is also faster, even when having 1374 + * to write each register twice. 1374 1375 */ 1375 - if (crtc_state->dsb_color_vblank) 1376 - intel_dsb_nonpost_start(crtc_state->dsb_color_vblank); 1377 - 1378 - for (i = 0; i < 256; i++) 1376 + for (i = 0; i < 256; i++) { 1379 1377 ilk_lut_write(crtc_state, LGC_PALETTE(pipe, i), 1380 1378 i9xx_lut_8(&lut[i])); 1381 - 1382 - if (crtc_state->dsb_color_vblank) 1383 - intel_dsb_nonpost_end(crtc_state->dsb_color_vblank); 1379 + if (crtc_state->dsb_color_vblank) 1380 + ilk_lut_write(crtc_state, LGC_PALETTE(pipe, i), 1381 + i9xx_lut_8(&lut[i])); 1382 + } 1384 1383 } 1385 1384 1386 1385 static void ilk_load_lut_10(const struct intel_crtc_state *crtc_state, ··· 1479 1458 prec_index); 1480 1459 1481 1460 for (i = 0; i < lut_size; i++) 1482 - ilk_lut_write(crtc_state, PREC_PAL_DATA(pipe), 1483 - ilk_lut_10(&lut[i])); 1461 + ilk_lut_write_indexed(crtc_state, PREC_PAL_DATA(pipe), 1462 + ilk_lut_10(&lut[i])); 1484 1463 1485 1464 /* 1486 1465 * Reset the index, otherwise it prevents the legacy palette to be ··· 1633 1612 * ToDo: Extend to max 7.0. Enable 32 bit input value 1634 1613 * as compared to just 16 to achieve this. 1635 1614 */ 1636 - ilk_lut_write(crtc_state, PRE_CSC_GAMC_DATA(pipe), 1637 - DISPLAY_VER(display) >= 14 ? 1638 - mtl_degamma_lut(&lut[i]) : glk_degamma_lut(&lut[i])); 1615 + ilk_lut_write_indexed(crtc_state, PRE_CSC_GAMC_DATA(pipe), 1616 + DISPLAY_VER(display) >= 14 ? 1617 + mtl_degamma_lut(&lut[i]) : glk_degamma_lut(&lut[i])); 1639 1618 } 1640 1619 1641 1620 /* Clamp values > 1.0. */ 1642 1621 while (i++ < glk_degamma_lut_size(display)) 1643 - ilk_lut_write(crtc_state, PRE_CSC_GAMC_DATA(pipe), 1644 - DISPLAY_VER(display) >= 14 ? 1645 - 1 << 24 : 1 << 16); 1622 + ilk_lut_write_indexed(crtc_state, PRE_CSC_GAMC_DATA(pipe), 1623 + DISPLAY_VER(display) >= 14 ? 1624 + 1 << 24 : 1 << 16); 1646 1625 1647 1626 ilk_lut_write(crtc_state, PRE_CSC_GAMC_INDEX(pipe), 0); 1648 1627 } ··· 1708 1687 for (i = 0; i < 9; i++) { 1709 1688 const struct drm_color_lut *entry = &lut[i]; 1710 1689 1711 - ilk_lut_write(crtc_state, PREC_PAL_MULTI_SEG_DATA(pipe), 1712 - ilk_lut_12p4_ldw(entry)); 1713 - ilk_lut_write(crtc_state, PREC_PAL_MULTI_SEG_DATA(pipe), 1714 - ilk_lut_12p4_udw(entry)); 1690 + ilk_lut_write_indexed(crtc_state, PREC_PAL_MULTI_SEG_DATA(pipe), 1691 + ilk_lut_12p4_ldw(entry)); 1692 + ilk_lut_write_indexed(crtc_state, PREC_PAL_MULTI_SEG_DATA(pipe), 1693 + ilk_lut_12p4_udw(entry)); 1715 1694 } 1716 1695 1717 1696 ilk_lut_write(crtc_state, PREC_PAL_MULTI_SEG_INDEX(pipe), ··· 1747 1726 for (i = 1; i < 257; i++) { 1748 1727 entry = &lut[i * 8]; 1749 1728 1750 - ilk_lut_write(crtc_state, PREC_PAL_DATA(pipe), 1751 - ilk_lut_12p4_ldw(entry)); 1752 - ilk_lut_write(crtc_state, PREC_PAL_DATA(pipe), 1753 - ilk_lut_12p4_udw(entry)); 1729 + ilk_lut_write_indexed(crtc_state, PREC_PAL_DATA(pipe), 1730 + ilk_lut_12p4_ldw(entry)); 1731 + ilk_lut_write_indexed(crtc_state, PREC_PAL_DATA(pipe), 1732 + ilk_lut_12p4_udw(entry)); 1754 1733 } 1755 1734 1756 1735 /* ··· 1768 1747 for (i = 0; i < 256; i++) { 1769 1748 entry = &lut[i * 8 * 128]; 1770 1749 1771 - ilk_lut_write(crtc_state, PREC_PAL_DATA(pipe), 1772 - ilk_lut_12p4_ldw(entry)); 1773 - ilk_lut_write(crtc_state, PREC_PAL_DATA(pipe), 1774 - ilk_lut_12p4_udw(entry)); 1750 + ilk_lut_write_indexed(crtc_state, PREC_PAL_DATA(pipe), 1751 + ilk_lut_12p4_ldw(entry)); 1752 + ilk_lut_write_indexed(crtc_state, PREC_PAL_DATA(pipe), 1753 + ilk_lut_12p4_udw(entry)); 1775 1754 } 1776 1755 1777 1756 ilk_lut_write(crtc_state, PREC_PAL_INDEX(pipe),
+16 -3
drivers/gpu/drm/i915/display/intel_dsb.c
··· 273 273 } 274 274 275 275 /** 276 - * intel_dsb_reg_write() - Emit register wriite to the DSB context 276 + * intel_dsb_reg_write_indexed() - Emit register wriite to the DSB context 277 277 * @dsb: DSB context 278 278 * @reg: register address. 279 279 * @val: value. 280 280 * 281 281 * This function is used for writing register-value pair in command 282 282 * buffer of DSB. 283 + * 284 + * Note that indexed writes are slower than normal MMIO writes 285 + * for a small number (less than 5 or so) of writes to the same 286 + * register. 283 287 */ 284 - void intel_dsb_reg_write(struct intel_dsb *dsb, 285 - i915_reg_t reg, u32 val) 288 + void intel_dsb_reg_write_indexed(struct intel_dsb *dsb, 289 + i915_reg_t reg, u32 val) 286 290 { 287 291 /* 288 292 * For example the buffer will look like below for 3 dwords for auto ··· 342 338 if (dsb->free_pos & 0x1) 343 339 intel_dsb_buffer_write(&dsb->dsb_buf, dsb->free_pos, 0); 344 340 } 341 + } 342 + 343 + void intel_dsb_reg_write(struct intel_dsb *dsb, 344 + i915_reg_t reg, u32 val) 345 + { 346 + intel_dsb_emit(dsb, val, 347 + (DSB_OPCODE_MMIO_WRITE << DSB_OPCODE_SHIFT) | 348 + (DSB_BYTE_EN << DSB_BYTE_EN_SHIFT) | 349 + i915_mmio_reg_offset(reg)); 345 350 } 346 351 347 352 static u32 intel_dsb_mask_to_byte_en(u32 mask)
+2
drivers/gpu/drm/i915/display/intel_dsb.h
··· 34 34 void intel_dsb_cleanup(struct intel_dsb *dsb); 35 35 void intel_dsb_reg_write(struct intel_dsb *dsb, 36 36 i915_reg_t reg, u32 val); 37 + void intel_dsb_reg_write_indexed(struct intel_dsb *dsb, 38 + i915_reg_t reg, u32 val); 37 39 void intel_dsb_reg_write_masked(struct intel_dsb *dsb, 38 40 i915_reg_t reg, u32 mask, u32 val); 39 41 void intel_dsb_noop(struct intel_dsb *dsb, int count);
+15 -3
drivers/gpu/drm/i915/i915_gpu_error.c
··· 1643 1643 return NULL; 1644 1644 1645 1645 intel_engine_get_hung_entity(engine, &ce, &rq); 1646 - if (rq && !i915_request_started(rq)) 1647 - drm_info(&engine->gt->i915->drm, "Got hung context on %s with active request %lld:%lld [0x%04X] not yet started\n", 1648 - engine->name, rq->fence.context, rq->fence.seqno, ce->guc_id.id); 1646 + if (rq && !i915_request_started(rq)) { 1647 + /* 1648 + * We want to know also what is the guc_id of the context, 1649 + * but if we don't have the context reference, then skip 1650 + * printing it. 1651 + */ 1652 + if (ce) 1653 + drm_info(&engine->gt->i915->drm, 1654 + "Got hung context on %s with active request %lld:%lld [0x%04X] not yet started\n", 1655 + engine->name, rq->fence.context, rq->fence.seqno, ce->guc_id.id); 1656 + else 1657 + drm_info(&engine->gt->i915->drm, 1658 + "Got hung context on %s with active request %lld:%lld not yet started\n", 1659 + engine->name, rq->fence.context, rq->fence.seqno); 1660 + } 1649 1661 1650 1662 if (rq) { 1651 1663 capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
+1 -1
drivers/gpu/drm/i915/i915_scheduler.c
··· 506 506 return 0; 507 507 508 508 err_priorities: 509 - kmem_cache_destroy(slab_priorities); 509 + kmem_cache_destroy(slab_dependencies); 510 510 return -ENOMEM; 511 511 }
+2 -2
drivers/gpu/drm/xe/tests/xe_migrate.c
··· 224 224 XE_BO_FLAG_VRAM_IF_DGFX(tile) | 225 225 XE_BO_FLAG_PINNED); 226 226 if (IS_ERR(tiny)) { 227 - KUNIT_FAIL(test, "Failed to allocate fake pt: %li\n", 228 - PTR_ERR(pt)); 227 + KUNIT_FAIL(test, "Failed to allocate tiny fake pt: %li\n", 228 + PTR_ERR(tiny)); 229 229 goto free_pt; 230 230 } 231 231
+8
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
··· 65 65 __invalidation_fence_signal(xe, fence); 66 66 } 67 67 68 + void xe_gt_tlb_invalidation_fence_signal(struct xe_gt_tlb_invalidation_fence *fence) 69 + { 70 + if (WARN_ON_ONCE(!fence->gt)) 71 + return; 72 + 73 + __invalidation_fence_signal(gt_to_xe(fence->gt), fence); 74 + } 75 + 68 76 static void xe_gt_tlb_fence_timeout(struct work_struct *work) 69 77 { 70 78 struct xe_gt *gt = container_of(work, struct xe_gt,
+1
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.h
··· 28 28 void xe_gt_tlb_invalidation_fence_init(struct xe_gt *gt, 29 29 struct xe_gt_tlb_invalidation_fence *fence, 30 30 bool stack); 31 + void xe_gt_tlb_invalidation_fence_signal(struct xe_gt_tlb_invalidation_fence *fence); 31 32 32 33 static inline void 33 34 xe_gt_tlb_invalidation_fence_wait(struct xe_gt_tlb_invalidation_fence *fence)
+1 -2
drivers/gpu/drm/xe/xe_pt.c
··· 1333 1333 queue_work(system_wq, &ifence->work); 1334 1334 } else { 1335 1335 ifence->base.base.error = ifence->fence->error; 1336 - dma_fence_signal(&ifence->base.base); 1337 - dma_fence_put(&ifence->base.base); 1336 + xe_gt_tlb_invalidation_fence_signal(&ifence->base); 1338 1337 } 1339 1338 dma_fence_put(ifence->fence); 1340 1339 }
+6 -25
drivers/gpu/drm/xe/xe_reg_sr.c
··· 27 27 #include "xe_reg_whitelist.h" 28 28 #include "xe_rtp_types.h" 29 29 30 - #define XE_REG_SR_GROW_STEP_DEFAULT 16 31 - 32 30 static void reg_sr_fini(struct drm_device *drm, void *arg) 33 31 { 34 32 struct xe_reg_sr *sr = arg; 33 + struct xe_reg_sr_entry *entry; 34 + unsigned long reg; 35 + 36 + xa_for_each(&sr->xa, reg, entry) 37 + kfree(entry); 35 38 36 39 xa_destroy(&sr->xa); 37 - kfree(sr->pool.arr); 38 - memset(&sr->pool, 0, sizeof(sr->pool)); 39 40 } 40 41 41 42 int xe_reg_sr_init(struct xe_reg_sr *sr, const char *name, struct xe_device *xe) 42 43 { 43 44 xa_init(&sr->xa); 44 - memset(&sr->pool, 0, sizeof(sr->pool)); 45 - sr->pool.grow_step = XE_REG_SR_GROW_STEP_DEFAULT; 46 45 sr->name = name; 47 46 48 47 return drmm_add_action_or_reset(&xe->drm, reg_sr_fini, sr); 49 48 } 50 49 EXPORT_SYMBOL_IF_KUNIT(xe_reg_sr_init); 51 - 52 - static struct xe_reg_sr_entry *alloc_entry(struct xe_reg_sr *sr) 53 - { 54 - if (sr->pool.used == sr->pool.allocated) { 55 - struct xe_reg_sr_entry *arr; 56 - 57 - arr = krealloc_array(sr->pool.arr, 58 - ALIGN(sr->pool.allocated + 1, sr->pool.grow_step), 59 - sizeof(*arr), GFP_KERNEL); 60 - if (!arr) 61 - return NULL; 62 - 63 - sr->pool.arr = arr; 64 - sr->pool.allocated += sr->pool.grow_step; 65 - } 66 - 67 - return &sr->pool.arr[sr->pool.used++]; 68 - } 69 50 70 51 static bool compatible_entries(const struct xe_reg_sr_entry *e1, 71 52 const struct xe_reg_sr_entry *e2) ··· 93 112 return 0; 94 113 } 95 114 96 - pentry = alloc_entry(sr); 115 + pentry = kmalloc(sizeof(*pentry), GFP_KERNEL); 97 116 if (!pentry) { 98 117 ret = -ENOMEM; 99 118 goto fail;
-6
drivers/gpu/drm/xe/xe_reg_sr_types.h
··· 20 20 }; 21 21 22 22 struct xe_reg_sr { 23 - struct { 24 - struct xe_reg_sr_entry *arr; 25 - unsigned int used; 26 - unsigned int allocated; 27 - unsigned int grow_step; 28 - } pool; 29 23 struct xarray xa; 30 24 const char *name; 31 25
+5 -4
drivers/hv/hv_balloon.c
··· 756 756 * adding succeeded, it is ok to proceed even if the memory was 757 757 * not onlined in time. 758 758 */ 759 - wait_for_completion_timeout(&dm_device.ol_waitevent, 5 * HZ); 759 + wait_for_completion_timeout(&dm_device.ol_waitevent, secs_to_jiffies(5)); 760 760 post_status(&dm_device); 761 761 } 762 762 } ··· 1373 1373 struct hv_dynmem_device *dm = dm_dev; 1374 1374 1375 1375 while (!kthread_should_stop()) { 1376 - wait_for_completion_interruptible_timeout(&dm_device.config_event, 1 * HZ); 1376 + wait_for_completion_interruptible_timeout(&dm_device.config_event, 1377 + secs_to_jiffies(1)); 1377 1378 /* 1378 1379 * The host expects us to post information on the memory 1379 1380 * pressure every second. ··· 1749 1748 if (ret) 1750 1749 goto out; 1751 1750 1752 - t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ); 1751 + t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5)); 1753 1752 if (t == 0) { 1754 1753 ret = -ETIMEDOUT; 1755 1754 goto out; ··· 1807 1806 if (ret) 1808 1807 goto out; 1809 1808 1810 - t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ); 1809 + t = wait_for_completion_timeout(&dm_device.host_event, secs_to_jiffies(5)); 1811 1810 if (t == 0) { 1812 1811 ret = -ETIMEDOUT; 1813 1812 goto out;
+8 -2
drivers/hv/hv_kvp.c
··· 655 655 if (host_negotiatied == NEGO_NOT_STARTED) { 656 656 host_negotiatied = NEGO_IN_PROGRESS; 657 657 schedule_delayed_work(&kvp_host_handshake_work, 658 - HV_UTIL_NEGO_TIMEOUT * HZ); 658 + secs_to_jiffies(HV_UTIL_NEGO_TIMEOUT)); 659 659 } 660 660 return; 661 661 } ··· 724 724 */ 725 725 schedule_work(&kvp_sendkey_work); 726 726 schedule_delayed_work(&kvp_timeout_work, 727 - HV_UTIL_TIMEOUT * HZ); 727 + secs_to_jiffies(HV_UTIL_TIMEOUT)); 728 728 729 729 return; 730 730 ··· 767 767 */ 768 768 kvp_transaction.state = HVUTIL_DEVICE_INIT; 769 769 770 + return 0; 771 + } 772 + 773 + int 774 + hv_kvp_init_transport(void) 775 + { 770 776 hvt = hvutil_transport_init(kvp_devname, CN_KVP_IDX, CN_KVP_VAL, 771 777 kvp_on_msg, kvp_on_reset); 772 778 if (!hvt)
+8 -1
drivers/hv/hv_snapshot.c
··· 193 193 vss_transaction.state = HVUTIL_USERSPACE_REQ; 194 194 195 195 schedule_delayed_work(&vss_timeout_work, op == VSS_OP_FREEZE ? 196 - VSS_FREEZE_TIMEOUT * HZ : HV_UTIL_TIMEOUT * HZ); 196 + secs_to_jiffies(VSS_FREEZE_TIMEOUT) : 197 + secs_to_jiffies(HV_UTIL_TIMEOUT)); 197 198 198 199 rc = hvutil_transport_send(hvt, vss_msg, sizeof(*vss_msg), NULL); 199 200 if (rc) { ··· 389 388 */ 390 389 vss_transaction.state = HVUTIL_DEVICE_INIT; 391 390 391 + return 0; 392 + } 393 + 394 + int 395 + hv_vss_init_transport(void) 396 + { 392 397 hvt = hvutil_transport_init(vss_devname, CN_VSS_IDX, CN_VSS_VAL, 393 398 vss_on_msg, vss_on_reset); 394 399 if (!hvt) {
+10 -3
drivers/hv/hv_util.c
··· 141 141 static struct hv_util_service util_kvp = { 142 142 .util_cb = hv_kvp_onchannelcallback, 143 143 .util_init = hv_kvp_init, 144 + .util_init_transport = hv_kvp_init_transport, 144 145 .util_pre_suspend = hv_kvp_pre_suspend, 145 146 .util_pre_resume = hv_kvp_pre_resume, 146 147 .util_deinit = hv_kvp_deinit, ··· 150 149 static struct hv_util_service util_vss = { 151 150 .util_cb = hv_vss_onchannelcallback, 152 151 .util_init = hv_vss_init, 152 + .util_init_transport = hv_vss_init_transport, 153 153 .util_pre_suspend = hv_vss_pre_suspend, 154 154 .util_pre_resume = hv_vss_pre_resume, 155 155 .util_deinit = hv_vss_deinit, ··· 592 590 srv->channel = dev->channel; 593 591 if (srv->util_init) { 594 592 ret = srv->util_init(srv); 595 - if (ret) { 596 - ret = -ENODEV; 593 + if (ret) 597 594 goto error1; 598 - } 599 595 } 600 596 601 597 /* ··· 613 613 if (ret) 614 614 goto error; 615 615 616 + if (srv->util_init_transport) { 617 + ret = srv->util_init_transport(); 618 + if (ret) { 619 + vmbus_close(dev->channel); 620 + goto error; 621 + } 622 + } 616 623 return 0; 617 624 618 625 error:
+2
drivers/hv/hyperv_vmbus.h
··· 370 370 void vmbus_on_msg_dpc(unsigned long data); 371 371 372 372 int hv_kvp_init(struct hv_util_service *srv); 373 + int hv_kvp_init_transport(void); 373 374 void hv_kvp_deinit(void); 374 375 int hv_kvp_pre_suspend(void); 375 376 int hv_kvp_pre_resume(void); 376 377 void hv_kvp_onchannelcallback(void *context); 377 378 378 379 int hv_vss_init(struct hv_util_service *srv); 380 + int hv_vss_init_transport(void); 379 381 void hv_vss_deinit(void); 380 382 int hv_vss_pre_suspend(void); 381 383 int hv_vss_pre_resume(void);
+1 -1
drivers/hv/vmbus_drv.c
··· 2507 2507 vmbus_request_offers(); 2508 2508 2509 2509 if (wait_for_completion_timeout( 2510 - &vmbus_connection.ready_for_resume_event, 10 * HZ) == 0) 2510 + &vmbus_connection.ready_for_resume_event, secs_to_jiffies(10)) == 0) 2511 2511 pr_err("Some vmbus device is missing after suspending?\n"); 2512 2512 2513 2513 /* Reset the event for the next suspend. */
+1
drivers/i2c/busses/i2c-nomadik.c
··· 1075 1075 .compatible = "mobileye,eyeq6h-i2c", 1076 1076 .data = (void *)NMK_I2C_EYEQ_FLAG_32B_BUS, 1077 1077 }, 1078 + { /* sentinel */ } 1078 1079 }; 1079 1080 1080 1081 static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
+2 -2
drivers/i2c/busses/i2c-pnx.c
··· 95 95 96 96 static inline int wait_timeout(struct i2c_pnx_algo_data *data) 97 97 { 98 - long timeout = data->timeout; 98 + long timeout = jiffies_to_msecs(data->timeout); 99 99 while (timeout > 0 && 100 100 (ioread32(I2C_REG_STS(data)) & mstatus_active)) { 101 101 mdelay(1); ··· 106 106 107 107 static inline int wait_reset(struct i2c_pnx_algo_data *data) 108 108 { 109 - long timeout = data->timeout; 109 + long timeout = jiffies_to_msecs(data->timeout); 110 110 while (timeout > 0 && 111 111 (ioread32(I2C_REG_CTL(data)) & mcntrl_reset)) { 112 112 mdelay(1);
+1 -1
drivers/i2c/busses/i2c-riic.c
··· 352 352 if (brl <= (0x1F + 3)) 353 353 break; 354 354 355 - total_ticks /= 2; 355 + total_ticks = DIV_ROUND_UP(total_ticks, 2); 356 356 rate /= 2; 357 357 } 358 358
+9 -1
drivers/iommu/amd/iommu.c
··· 1415 1415 struct iommu_cmd cmd; 1416 1416 int ret = 0; 1417 1417 1418 + lockdep_assert_held(&pdom->lock); 1418 1419 list_for_each_entry(dev_data, &pdom->dev_list, list) { 1419 1420 struct amd_iommu *iommu = get_amd_iommu_from_dev(dev_data->dev); 1420 1421 u16 domid = dev_data->gcr3_info.domid; ··· 1464 1463 int ret = 0; 1465 1464 ioasid_t pasid = IOMMU_NO_PASID; 1466 1465 bool gn = false; 1466 + 1467 + lockdep_assert_held(&domain->lock); 1467 1468 1468 1469 if (pdom_is_v2_pgtbl_mode(domain)) { 1469 1470 gn = true; ··· 1587 1584 void amd_iommu_update_and_flush_device_table(struct protection_domain *domain) 1588 1585 { 1589 1586 struct iommu_dev_data *dev_data; 1587 + 1588 + lockdep_assert_held(&domain->lock); 1590 1589 1591 1590 list_for_each_entry(dev_data, &domain->dev_list, list) { 1592 1591 struct amd_iommu *iommu = rlookup_amd_iommu(dev_data->dev); ··· 2078 2073 struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev); 2079 2074 struct amd_iommu *iommu = get_amd_iommu_from_dev_data(dev_data); 2080 2075 struct pci_dev *pdev; 2076 + unsigned long flags; 2081 2077 int ret = 0; 2082 2078 2083 2079 mutex_lock(&dev_data->mutex); ··· 2119 2113 2120 2114 /* Update data structures */ 2121 2115 dev_data->domain = domain; 2116 + spin_lock_irqsave(&domain->lock, flags); 2122 2117 list_add(&dev_data->list, &domain->dev_list); 2118 + spin_unlock_irqrestore(&domain->lock, flags); 2123 2119 2124 2120 /* Update device table */ 2125 2121 dev_update_dte(dev_data, true); ··· 2168 2160 /* Flush IOTLB and wait for the flushes to finish */ 2169 2161 spin_lock_irqsave(&domain->lock, flags); 2170 2162 amd_iommu_domain_flush_all(domain); 2163 + list_del(&dev_data->list); 2171 2164 spin_unlock_irqrestore(&domain->lock, flags); 2172 2165 2173 2166 /* Clear GCR3 table */ ··· 2177 2168 2178 2169 /* Update data structures */ 2179 2170 dev_data->domain = NULL; 2180 - list_del(&dev_data->list); 2181 2171 2182 2172 /* decrease reference counters - needs to happen after the flushes */ 2183 2173 pdom_detach_iommu(iommu, domain);
+1 -1
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
··· 339 339 * one CPU at a time can enter the process, while the others 340 340 * will be spinning at the same lock. 341 341 */ 342 - lidx = smp_processor_id() % cmdqv->num_lvcmdqs_per_vintf; 342 + lidx = raw_smp_processor_id() % cmdqv->num_lvcmdqs_per_vintf; 343 343 vcmdq = vintf->lvcmdqs[lidx]; 344 344 if (!vcmdq || !READ_ONCE(vcmdq->enabled)) 345 345 return NULL;
+27 -7
drivers/iommu/intel/cache.c
··· 105 105 spin_unlock_irqrestore(&domain->cache_lock, flags); 106 106 } 107 107 108 + /* domain->qi_batch will be freed in iommu_free_domain() path. */ 109 + static int domain_qi_batch_alloc(struct dmar_domain *domain) 110 + { 111 + unsigned long flags; 112 + int ret = 0; 113 + 114 + spin_lock_irqsave(&domain->cache_lock, flags); 115 + if (domain->qi_batch) 116 + goto out_unlock; 117 + 118 + domain->qi_batch = kzalloc(sizeof(*domain->qi_batch), GFP_ATOMIC); 119 + if (!domain->qi_batch) 120 + ret = -ENOMEM; 121 + out_unlock: 122 + spin_unlock_irqrestore(&domain->cache_lock, flags); 123 + 124 + return ret; 125 + } 126 + 108 127 static int __cache_tag_assign_domain(struct dmar_domain *domain, u16 did, 109 128 struct device *dev, ioasid_t pasid) 110 129 { 111 130 struct device_domain_info *info = dev_iommu_priv_get(dev); 112 131 int ret; 132 + 133 + ret = domain_qi_batch_alloc(domain); 134 + if (ret) 135 + return ret; 113 136 114 137 ret = cache_tag_assign(domain, did, dev, pasid, CACHE_TAG_IOTLB); 115 138 if (ret || !info->ats_enabled) ··· 161 138 { 162 139 struct device_domain_info *info = dev_iommu_priv_get(dev); 163 140 int ret; 141 + 142 + ret = domain_qi_batch_alloc(domain); 143 + if (ret) 144 + return ret; 164 145 165 146 ret = cache_tag_assign(domain, did, dev, pasid, CACHE_TAG_NESTING_IOTLB); 166 147 if (ret || !info->ats_enabled) ··· 216 189 { 217 190 u16 did = domain_get_id_for_dev(domain, dev); 218 191 int ret; 219 - 220 - /* domain->qi_bach will be freed in iommu_free_domain() path. */ 221 - if (!domain->qi_batch) { 222 - domain->qi_batch = kzalloc(sizeof(*domain->qi_batch), GFP_KERNEL); 223 - if (!domain->qi_batch) 224 - return -ENOMEM; 225 - } 226 192 227 193 ret = __cache_tag_assign_domain(domain, did, dev, pasid); 228 194 if (ret || domain->domain.type != IOMMU_DOMAIN_NESTED)
+3 -1
drivers/iommu/intel/iommu.c
··· 3220 3220 struct intel_iommu *iommu = info->iommu; 3221 3221 unsigned long flags; 3222 3222 3223 + if (info->domain) 3224 + cache_tag_unassign_domain(info->domain, dev, IOMMU_NO_PASID); 3225 + 3223 3226 iommu_disable_pci_caps(info); 3224 3227 if (!dev_is_real_dma_subdevice(dev)) { 3225 3228 if (sm_supported(iommu)) ··· 3239 3236 list_del(&info->link); 3240 3237 spin_unlock_irqrestore(&info->domain->lock, flags); 3241 3238 3242 - cache_tag_unassign_domain(info->domain, dev, IOMMU_NO_PASID); 3243 3239 domain_detach_iommu(info->domain, iommu); 3244 3240 info->domain = NULL; 3245 3241 }
+2 -1
drivers/iommu/intel/pasid.c
··· 265 265 iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH); 266 266 267 267 devtlb_invalidation_with_pasid(iommu, dev, pasid); 268 - intel_iommu_drain_pasid_prq(dev, pasid); 268 + if (!fault_ignore) 269 + intel_iommu_drain_pasid_prq(dev, pasid); 269 270 } 270 271 271 272 /*
+16 -1
drivers/irqchip/irq-gic-v3.c
··· 161 161 162 162 static void __init gic_prio_init(void) 163 163 { 164 - cpus_have_security_disabled = gic_dist_security_disabled(); 164 + bool ds; 165 + 166 + ds = gic_dist_security_disabled(); 167 + if (!ds) { 168 + u32 val; 169 + 170 + val = readl_relaxed(gic_data.dist_base + GICD_CTLR); 171 + val |= GICD_CTLR_DS; 172 + writel_relaxed(val, gic_data.dist_base + GICD_CTLR); 173 + 174 + ds = gic_dist_security_disabled(); 175 + if (ds) 176 + pr_warn("Broken GIC integration, security disabled"); 177 + } 178 + 179 + cpus_have_security_disabled = ds; 165 180 cpus_have_group0 = gic_has_group0(); 166 181 167 182 /*
+1 -1
drivers/irqchip/irq-gic.c
··· 64 64 65 65 union gic_base { 66 66 void __iomem *common_base; 67 - void __percpu * __iomem *percpu_base; 67 + void __iomem * __percpu *percpu_base; 68 68 }; 69 69 70 70 struct gic_chip_data {
+3 -3
drivers/md/dm-zoned-reclaim.c
··· 76 76 * pointer and the requested position. 77 77 */ 78 78 nr_blocks = block - wp_block; 79 - ret = blkdev_issue_zeroout(dev->bdev, 80 - dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block), 81 - dmz_blk2sect(nr_blocks), GFP_NOIO, 0); 79 + ret = blk_zone_issue_zeroout(dev->bdev, 80 + dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block), 81 + dmz_blk2sect(nr_blocks), GFP_NOIO); 82 82 if (ret) { 83 83 dmz_dev_err(dev, 84 84 "Align zone %u wp %llu to %llu (wp+%u) blocks failed %d",
+2
drivers/mmc/host/mtk-sd.c
··· 3070 3070 msdc_gate_clock(host); 3071 3071 platform_set_drvdata(pdev, NULL); 3072 3072 release_mem: 3073 + device_init_wakeup(&pdev->dev, false); 3073 3074 if (host->dma.gpd) 3074 3075 dma_free_coherent(&pdev->dev, 3075 3076 2 * sizeof(struct mt_gpdma_desc), ··· 3104 3103 host->dma.gpd, host->dma.gpd_addr); 3105 3104 dma_free_coherent(&pdev->dev, MAX_BD_NUM * sizeof(struct mt_bdma_desc), 3106 3105 host->dma.bd, host->dma.bd_addr); 3106 + device_init_wakeup(&pdev->dev, false); 3107 3107 } 3108 3108 3109 3109 static void msdc_save_reg(struct msdc_host *host)
-1
drivers/mmc/host/sdhci-tegra.c
··· 1525 1525 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | 1526 1526 SDHCI_QUIRK_SINGLE_POWER_WRITE | 1527 1527 SDHCI_QUIRK_NO_HISPD_BIT | 1528 - SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 1529 1528 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 1530 1529 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 1531 1530 SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER,
+26 -10
drivers/net/can/m_can/m_can.c
··· 1220 1220 static int m_can_interrupt_handler(struct m_can_classdev *cdev) 1221 1221 { 1222 1222 struct net_device *dev = cdev->net; 1223 - u32 ir; 1223 + u32 ir = 0, ir_read; 1224 1224 int ret; 1225 1225 1226 1226 if (pm_runtime_suspended(cdev->dev)) 1227 1227 return IRQ_NONE; 1228 1228 1229 - ir = m_can_read(cdev, M_CAN_IR); 1229 + /* The m_can controller signals its interrupt status as a level, but 1230 + * depending in the integration the CPU may interpret the signal as 1231 + * edge-triggered (for example with m_can_pci). For these 1232 + * edge-triggered integrations, we must observe that IR is 0 at least 1233 + * once to be sure that the next interrupt will generate an edge. 1234 + */ 1235 + while ((ir_read = m_can_read(cdev, M_CAN_IR)) != 0) { 1236 + ir |= ir_read; 1237 + 1238 + /* ACK all irqs */ 1239 + m_can_write(cdev, M_CAN_IR, ir); 1240 + 1241 + if (!cdev->irq_edge_triggered) 1242 + break; 1243 + } 1244 + 1230 1245 m_can_coalescing_update(cdev, ir); 1231 1246 if (!ir) 1232 1247 return IRQ_NONE; 1233 - 1234 - /* ACK all irqs */ 1235 - m_can_write(cdev, M_CAN_IR, ir); 1236 1248 1237 1249 if (cdev->ops->clear_interrupts) 1238 1250 cdev->ops->clear_interrupts(cdev); ··· 1707 1695 return -EINVAL; 1708 1696 } 1709 1697 1698 + /* Write the INIT bit, in case no hardware reset has happened before 1699 + * the probe (for example, it was observed that the Intel Elkhart Lake 1700 + * SoCs do not properly reset the CAN controllers on reboot) 1701 + */ 1702 + err = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT); 1703 + if (err) 1704 + return err; 1705 + 1710 1706 if (!cdev->is_peripheral) 1711 1707 netif_napi_add(dev, &cdev->napi, m_can_poll); 1712 1708 ··· 1766 1746 return -EINVAL; 1767 1747 } 1768 1748 1769 - /* Forcing standby mode should be redundant, as the chip should be in 1770 - * standby after a reset. Write the INIT bit anyways, should the chip 1771 - * be configured by previous stage. 1772 - */ 1773 - return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT); 1749 + return 0; 1774 1750 } 1775 1751 1776 1752 static void m_can_stop(struct net_device *dev)
+1
drivers/net/can/m_can/m_can.h
··· 99 99 int pm_clock_support; 100 100 int pm_wake_source; 101 101 int is_peripheral; 102 + bool irq_edge_triggered; 102 103 103 104 // Cached M_CAN_IE register content 104 105 u32 active_interrupts;
+1
drivers/net/can/m_can/m_can_pci.c
··· 127 127 mcan_class->pm_clock_support = 1; 128 128 mcan_class->pm_wake_source = 0; 129 129 mcan_class->can.clock.freq = id->driver_data; 130 + mcan_class->irq_edge_triggered = true; 130 131 mcan_class->ops = &m_can_pci_ops; 131 132 132 133 pci_set_drvdata(pci, mcan_class);
+4 -1
drivers/net/ethernet/broadcom/bgmac-platform.c
··· 171 171 static int bgmac_probe(struct platform_device *pdev) 172 172 { 173 173 struct device_node *np = pdev->dev.of_node; 174 + struct device_node *phy_node; 174 175 struct bgmac *bgmac; 175 176 struct resource *regs; 176 177 int ret; ··· 237 236 bgmac->cco_ctl_maskset = platform_bgmac_cco_ctl_maskset; 238 237 bgmac->get_bus_clock = platform_bgmac_get_bus_clock; 239 238 bgmac->cmn_maskset32 = platform_bgmac_cmn_maskset32; 240 - if (of_parse_phandle(np, "phy-handle", 0)) { 239 + phy_node = of_parse_phandle(np, "phy-handle", 0); 240 + if (phy_node) { 241 + of_node_put(phy_node); 241 242 bgmac->phy_connect = platform_phy_connect; 242 243 } else { 243 244 bgmac->phy_connect = bgmac_phy_connect_direct;
+3 -2
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c
··· 346 346 * driver. Once driver synthesizes cpl_pass_accept_req the skb will go 347 347 * through the regular cpl_pass_accept_req processing in TOM. 348 348 */ 349 - skb = alloc_skb(gl->tot_len + sizeof(struct cpl_pass_accept_req) 350 - - pktshift, GFP_ATOMIC); 349 + skb = alloc_skb(size_add(gl->tot_len, 350 + sizeof(struct cpl_pass_accept_req)) - 351 + pktshift, GFP_ATOMIC); 351 352 if (unlikely(!skb)) 352 353 return NULL; 353 354 __skb_put(skb, gl->tot_len + sizeof(struct cpl_pass_accept_req)
+2
drivers/net/ethernet/huawei/hinic/hinic_main.c
··· 172 172 hinic_sq_dbgfs_uninit(nic_dev); 173 173 174 174 devm_kfree(&netdev->dev, nic_dev->txqs); 175 + nic_dev->txqs = NULL; 175 176 return err; 176 177 } 177 178 ··· 269 268 hinic_rq_dbgfs_uninit(nic_dev); 270 269 271 270 devm_kfree(&netdev->dev, nic_dev->rxqs); 271 + nic_dev->rxqs = NULL; 272 272 return err; 273 273 } 274 274
+3
drivers/net/ethernet/intel/idpf/idpf_dev.c
··· 101 101 intr->dyn_ctl_itridx_s = PF_GLINT_DYN_CTL_ITR_INDX_S; 102 102 intr->dyn_ctl_intrvl_s = PF_GLINT_DYN_CTL_INTERVAL_S; 103 103 intr->dyn_ctl_wb_on_itr_m = PF_GLINT_DYN_CTL_WB_ON_ITR_M; 104 + intr->dyn_ctl_swint_trig_m = PF_GLINT_DYN_CTL_SWINT_TRIG_M; 105 + intr->dyn_ctl_sw_itridx_ena_m = 106 + PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_M; 104 107 105 108 spacing = IDPF_ITR_IDX_SPACING(reg_vals[vec_id].itrn_index_spacing, 106 109 IDPF_PF_ITR_IDX_SPACING);
+19 -10
drivers/net/ethernet/intel/idpf/idpf_txrx.c
··· 3604 3604 /** 3605 3605 * idpf_vport_intr_buildreg_itr - Enable default interrupt generation settings 3606 3606 * @q_vector: pointer to q_vector 3607 - * @type: itr index 3608 - * @itr: itr value 3609 3607 */ 3610 - static u32 idpf_vport_intr_buildreg_itr(struct idpf_q_vector *q_vector, 3611 - const int type, u16 itr) 3608 + static u32 idpf_vport_intr_buildreg_itr(struct idpf_q_vector *q_vector) 3612 3609 { 3613 - u32 itr_val; 3610 + u32 itr_val = q_vector->intr_reg.dyn_ctl_intena_m; 3611 + int type = IDPF_NO_ITR_UPDATE_IDX; 3612 + u16 itr = 0; 3613 + 3614 + if (q_vector->wb_on_itr) { 3615 + /* 3616 + * Trigger a software interrupt when exiting wb_on_itr, to make 3617 + * sure we catch any pending write backs that might have been 3618 + * missed due to interrupt state transition. 3619 + */ 3620 + itr_val |= q_vector->intr_reg.dyn_ctl_swint_trig_m | 3621 + q_vector->intr_reg.dyn_ctl_sw_itridx_ena_m; 3622 + type = IDPF_SW_ITR_UPDATE_IDX; 3623 + itr = IDPF_ITR_20K; 3624 + } 3614 3625 3615 3626 itr &= IDPF_ITR_MASK; 3616 3627 /* Don't clear PBA because that can cause lost interrupts that 3617 3628 * came in while we were cleaning/polling 3618 3629 */ 3619 - itr_val = q_vector->intr_reg.dyn_ctl_intena_m | 3620 - (type << q_vector->intr_reg.dyn_ctl_itridx_s) | 3621 - (itr << (q_vector->intr_reg.dyn_ctl_intrvl_s - 1)); 3630 + itr_val |= (type << q_vector->intr_reg.dyn_ctl_itridx_s) | 3631 + (itr << (q_vector->intr_reg.dyn_ctl_intrvl_s - 1)); 3622 3632 3623 3633 return itr_val; 3624 3634 } ··· 3726 3716 /* net_dim() updates ITR out-of-band using a work item */ 3727 3717 idpf_net_dim(q_vector); 3728 3718 3719 + intval = idpf_vport_intr_buildreg_itr(q_vector); 3729 3720 q_vector->wb_on_itr = false; 3730 - intval = idpf_vport_intr_buildreg_itr(q_vector, 3731 - IDPF_NO_ITR_UPDATE_IDX, 0); 3732 3721 3733 3722 writel(intval, q_vector->intr_reg.dyn_ctl); 3734 3723 }
+7 -1
drivers/net/ethernet/intel/idpf/idpf_txrx.h
··· 354 354 * @dyn_ctl_itridx_m: Mask for ITR index 355 355 * @dyn_ctl_intrvl_s: Register bit offset for ITR interval 356 356 * @dyn_ctl_wb_on_itr_m: Mask for WB on ITR feature 357 + * @dyn_ctl_sw_itridx_ena_m: Mask for SW ITR index 358 + * @dyn_ctl_swint_trig_m: Mask for dyn_ctl SW triggered interrupt enable 357 359 * @rx_itr: RX ITR register 358 360 * @tx_itr: TX ITR register 359 361 * @icr_ena: Interrupt cause register offset ··· 369 367 u32 dyn_ctl_itridx_m; 370 368 u32 dyn_ctl_intrvl_s; 371 369 u32 dyn_ctl_wb_on_itr_m; 370 + u32 dyn_ctl_sw_itridx_ena_m; 371 + u32 dyn_ctl_swint_trig_m; 372 372 void __iomem *rx_itr; 373 373 void __iomem *tx_itr; 374 374 void __iomem *icr_ena; ··· 441 437 cpumask_var_t affinity_mask; 442 438 __cacheline_group_end_aligned(cold); 443 439 }; 444 - libeth_cacheline_set_assert(struct idpf_q_vector, 112, 440 + libeth_cacheline_set_assert(struct idpf_q_vector, 120, 445 441 24 + sizeof(struct napi_struct) + 446 442 2 * sizeof(struct dim), 447 443 8 + sizeof(cpumask_var_t)); ··· 475 471 #define IDPF_ITR_IS_DYNAMIC(itr_mode) (itr_mode) 476 472 #define IDPF_ITR_TX_DEF IDPF_ITR_20K 477 473 #define IDPF_ITR_RX_DEF IDPF_ITR_20K 474 + /* Index used for 'SW ITR' update in DYN_CTL register */ 475 + #define IDPF_SW_ITR_UPDATE_IDX 2 478 476 /* Index used for 'No ITR' update in DYN_CTL register */ 479 477 #define IDPF_NO_ITR_UPDATE_IDX 3 480 478 #define IDPF_ITR_IDX_SPACING(spacing, dflt) (spacing ? spacing : dflt)
+3
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c
··· 101 101 intr->dyn_ctl_itridx_s = VF_INT_DYN_CTLN_ITR_INDX_S; 102 102 intr->dyn_ctl_intrvl_s = VF_INT_DYN_CTLN_INTERVAL_S; 103 103 intr->dyn_ctl_wb_on_itr_m = VF_INT_DYN_CTLN_WB_ON_ITR_M; 104 + intr->dyn_ctl_swint_trig_m = VF_INT_DYN_CTLN_SWINT_TRIG_M; 105 + intr->dyn_ctl_sw_itridx_ena_m = 106 + VF_INT_DYN_CTLN_SW_ITR_INDX_ENA_M; 104 107 105 108 spacing = IDPF_ITR_IDX_SPACING(reg_vals[vec_id].itrn_index_spacing, 106 109 IDPF_VF_ITR_IDX_SPACING);
+4 -1
drivers/net/ethernet/marvell/octeontx2/nic/rep.c
··· 680 680 ndev->features |= ndev->hw_features; 681 681 eth_hw_addr_random(ndev); 682 682 err = rvu_rep_devlink_port_register(rep); 683 - if (err) 683 + if (err) { 684 + free_netdev(ndev); 684 685 goto exit; 686 + } 685 687 686 688 SET_NETDEV_DEVLINK_PORT(ndev, &rep->dl_port); 687 689 err = register_netdev(ndev); 688 690 if (err) { 689 691 NL_SET_ERR_MSG_MOD(extack, 690 692 "PFVF representor registration failed"); 693 + rvu_rep_devlink_port_unregister(rep); 691 694 free_netdev(ndev); 692 695 goto exit; 693 696 }
+1 -1
drivers/net/ethernet/mscc/ocelot.c
··· 1432 1432 1433 1433 memset(ifh, 0, OCELOT_TAG_LEN); 1434 1434 ocelot_ifh_set_bypass(ifh, 1); 1435 - ocelot_ifh_set_src(ifh, BIT_ULL(ocelot->num_phys_ports)); 1435 + ocelot_ifh_set_src(ifh, ocelot->num_phys_ports); 1436 1436 ocelot_ifh_set_dest(ifh, BIT_ULL(port)); 1437 1437 ocelot_ifh_set_qos_class(ifh, qos_class); 1438 1438 ocelot_ifh_set_tag_type(ifh, tag_type);
+9 -2
drivers/net/ethernet/oa_tc6.c
··· 113 113 struct mii_bus *mdiobus; 114 114 struct spi_device *spi; 115 115 struct mutex spi_ctrl_lock; /* Protects spi control transfer */ 116 + spinlock_t tx_skb_lock; /* Protects tx skb handling */ 116 117 void *spi_ctrl_tx_buf; 117 118 void *spi_ctrl_rx_buf; 118 119 void *spi_data_tx_buf; ··· 1005 1004 for (used_tx_credits = 0; used_tx_credits < tc6->tx_credits; 1006 1005 used_tx_credits++) { 1007 1006 if (!tc6->ongoing_tx_skb) { 1007 + spin_lock_bh(&tc6->tx_skb_lock); 1008 1008 tc6->ongoing_tx_skb = tc6->waiting_tx_skb; 1009 1009 tc6->waiting_tx_skb = NULL; 1010 + spin_unlock_bh(&tc6->tx_skb_lock); 1010 1011 } 1011 1012 if (!tc6->ongoing_tx_skb) 1012 1013 break; ··· 1114 1111 /* This kthread will be waken up if there is a tx skb or mac-phy 1115 1112 * interrupt to perform spi transfer with tx chunks. 1116 1113 */ 1117 - wait_event_interruptible(tc6->spi_wq, tc6->waiting_tx_skb || 1118 - tc6->int_flag || 1114 + wait_event_interruptible(tc6->spi_wq, tc6->int_flag || 1115 + (tc6->waiting_tx_skb && 1116 + tc6->tx_credits) || 1119 1117 kthread_should_stop()); 1120 1118 1121 1119 if (kthread_should_stop()) ··· 1213 1209 return NETDEV_TX_OK; 1214 1210 } 1215 1211 1212 + spin_lock_bh(&tc6->tx_skb_lock); 1216 1213 tc6->waiting_tx_skb = skb; 1214 + spin_unlock_bh(&tc6->tx_skb_lock); 1217 1215 1218 1216 /* Wake spi kthread to perform spi transfer */ 1219 1217 wake_up_interruptible(&tc6->spi_wq); ··· 1245 1239 tc6->netdev = netdev; 1246 1240 SET_NETDEV_DEV(netdev, &spi->dev); 1247 1241 mutex_init(&tc6->spi_ctrl_lock); 1242 + spin_lock_init(&tc6->tx_skb_lock); 1248 1243 1249 1244 /* Set the SPI controller to pump at realtime priority */ 1250 1245 tc6->spi->rt = true;
+4 -1
drivers/net/ethernet/pensando/ionic/ionic_dev.c
··· 277 277 idev->phy_cmb_pages = 0; 278 278 idev->cmb_npages = 0; 279 279 280 - destroy_workqueue(ionic->wq); 280 + if (ionic->wq) { 281 + destroy_workqueue(ionic->wq); 282 + ionic->wq = NULL; 283 + } 281 284 mutex_destroy(&idev->cmb_inuse_lock); 282 285 } 283 286
+2 -2
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
··· 1001 1001 len = min_t(u32, sizeof(xcvr->sprom), ee->len); 1002 1002 1003 1003 do { 1004 - memcpy(data, xcvr->sprom, len); 1005 - memcpy(tbuf, xcvr->sprom, len); 1004 + memcpy(data, &xcvr->sprom[ee->offset], len); 1005 + memcpy(tbuf, &xcvr->sprom[ee->offset], len); 1006 1006 1007 1007 /* Let's make sure we got a consistent copy */ 1008 1008 if (!memcmp(data, tbuf, len))
+2 -2
drivers/net/ethernet/pensando/ionic/ionic_lif.c
··· 3863 3863 /* only register LIF0 for now */ 3864 3864 err = register_netdev(lif->netdev); 3865 3865 if (err) { 3866 - dev_err(lif->ionic->dev, "Cannot register net device, aborting\n"); 3867 - ionic_lif_unregister_phc(lif); 3866 + dev_err(lif->ionic->dev, "Cannot register net device: %d, aborting\n", err); 3867 + ionic_lif_unregister(lif); 3868 3868 return err; 3869 3869 } 3870 3870
+1
drivers/net/ethernet/qlogic/qed/qed_mcp.c
··· 3358 3358 p_ptt, &nvm_info.num_images); 3359 3359 if (rc == -EOPNOTSUPP) { 3360 3360 DP_INFO(p_hwfn, "DRV_MSG_CODE_BIST_TEST is not supported\n"); 3361 + nvm_info.num_images = 0; 3361 3362 goto out; 3362 3363 } else if (rc || !nvm_info.num_images) { 3363 3364 DP_ERR(p_hwfn, "Failed getting number of images\n");
+36 -32
drivers/net/ethernet/renesas/rswitch.c
··· 557 557 desc = &gq->ts_ring[gq->ring_size]; 558 558 desc->desc.die_dt = DT_LINKFIX; 559 559 rswitch_desc_set_dptr(&desc->desc, gq->ring_dma); 560 - INIT_LIST_HEAD(&priv->gwca.ts_info_list); 561 560 562 561 return 0; 563 562 } ··· 1012 1013 static void rswitch_ts(struct rswitch_private *priv) 1013 1014 { 1014 1015 struct rswitch_gwca_queue *gq = &priv->gwca.ts_queue; 1015 - struct rswitch_gwca_ts_info *ts_info, *ts_info2; 1016 1016 struct skb_shared_hwtstamps shhwtstamps; 1017 1017 struct rswitch_ts_desc *desc; 1018 + struct rswitch_device *rdev; 1019 + struct sk_buff *ts_skb; 1018 1020 struct timespec64 ts; 1019 1021 unsigned int num; 1020 1022 u32 tag, port; ··· 1025 1025 dma_rmb(); 1026 1026 1027 1027 port = TS_DESC_DPN(__le32_to_cpu(desc->desc.dptrl)); 1028 + if (unlikely(port >= RSWITCH_NUM_PORTS)) 1029 + goto next; 1030 + rdev = priv->rdev[port]; 1031 + 1028 1032 tag = TS_DESC_TSUN(__le32_to_cpu(desc->desc.dptrl)); 1033 + if (unlikely(tag >= TS_TAGS_PER_PORT)) 1034 + goto next; 1035 + ts_skb = xchg(&rdev->ts_skb[tag], NULL); 1036 + smp_mb(); /* order rdev->ts_skb[] read before bitmap update */ 1037 + clear_bit(tag, rdev->ts_skb_used); 1029 1038 1030 - list_for_each_entry_safe(ts_info, ts_info2, &priv->gwca.ts_info_list, list) { 1031 - if (!(ts_info->port == port && ts_info->tag == tag)) 1032 - continue; 1039 + if (unlikely(!ts_skb)) 1040 + goto next; 1033 1041 1034 - memset(&shhwtstamps, 0, sizeof(shhwtstamps)); 1035 - ts.tv_sec = __le32_to_cpu(desc->ts_sec); 1036 - ts.tv_nsec = __le32_to_cpu(desc->ts_nsec & cpu_to_le32(0x3fffffff)); 1037 - shhwtstamps.hwtstamp = timespec64_to_ktime(ts); 1038 - skb_tstamp_tx(ts_info->skb, &shhwtstamps); 1039 - dev_consume_skb_irq(ts_info->skb); 1040 - list_del(&ts_info->list); 1041 - kfree(ts_info); 1042 - break; 1043 - } 1042 + memset(&shhwtstamps, 0, sizeof(shhwtstamps)); 1043 + ts.tv_sec = __le32_to_cpu(desc->ts_sec); 1044 + ts.tv_nsec = __le32_to_cpu(desc->ts_nsec & cpu_to_le32(0x3fffffff)); 1045 + shhwtstamps.hwtstamp = timespec64_to_ktime(ts); 1046 + skb_tstamp_tx(ts_skb, &shhwtstamps); 1047 + dev_consume_skb_irq(ts_skb); 1044 1048 1049 + next: 1045 1050 gq->cur = rswitch_next_queue_index(gq, true, 1); 1046 1051 desc = &gq->ts_ring[gq->cur]; 1047 1052 } ··· 1611 1606 static int rswitch_stop(struct net_device *ndev) 1612 1607 { 1613 1608 struct rswitch_device *rdev = netdev_priv(ndev); 1614 - struct rswitch_gwca_ts_info *ts_info, *ts_info2; 1609 + struct sk_buff *ts_skb; 1615 1610 unsigned long flags; 1611 + unsigned int tag; 1616 1612 1617 1613 netif_tx_stop_all_queues(ndev); 1618 1614 ··· 1630 1624 if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS)) 1631 1625 iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDID); 1632 1626 1633 - list_for_each_entry_safe(ts_info, ts_info2, &rdev->priv->gwca.ts_info_list, list) { 1634 - if (ts_info->port != rdev->port) 1635 - continue; 1636 - dev_kfree_skb_irq(ts_info->skb); 1637 - list_del(&ts_info->list); 1638 - kfree(ts_info); 1627 + for (tag = find_first_bit(rdev->ts_skb_used, TS_TAGS_PER_PORT); 1628 + tag < TS_TAGS_PER_PORT; 1629 + tag = find_next_bit(rdev->ts_skb_used, TS_TAGS_PER_PORT, tag + 1)) { 1630 + ts_skb = xchg(&rdev->ts_skb[tag], NULL); 1631 + clear_bit(tag, rdev->ts_skb_used); 1632 + if (ts_skb) 1633 + dev_kfree_skb(ts_skb); 1639 1634 } 1640 1635 1641 1636 return 0; ··· 1649 1642 desc->info1 = cpu_to_le64(INFO1_DV(BIT(rdev->etha->index)) | 1650 1643 INFO1_IPV(GWCA_IPV_NUM) | INFO1_FMT); 1651 1644 if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { 1652 - struct rswitch_gwca_ts_info *ts_info; 1645 + unsigned int tag; 1653 1646 1654 - ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC); 1655 - if (!ts_info) 1647 + tag = find_first_zero_bit(rdev->ts_skb_used, TS_TAGS_PER_PORT); 1648 + if (tag == TS_TAGS_PER_PORT) 1656 1649 return false; 1650 + smp_mb(); /* order bitmap read before rdev->ts_skb[] write */ 1651 + rdev->ts_skb[tag] = skb_get(skb); 1652 + set_bit(tag, rdev->ts_skb_used); 1657 1653 1658 1654 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; 1659 - rdev->ts_tag++; 1660 - desc->info1 |= cpu_to_le64(INFO1_TSUN(rdev->ts_tag) | INFO1_TXC); 1661 - 1662 - ts_info->skb = skb_get(skb); 1663 - ts_info->port = rdev->port; 1664 - ts_info->tag = rdev->ts_tag; 1665 - list_add_tail(&ts_info->list, &rdev->priv->gwca.ts_info_list); 1655 + desc->info1 |= cpu_to_le64(INFO1_TSUN(tag) | INFO1_TXC); 1666 1656 1667 1657 skb_tx_timestamp(skb); 1668 1658 }
+3 -10
drivers/net/ethernet/renesas/rswitch.h
··· 967 967 }; 968 968 }; 969 969 970 - struct rswitch_gwca_ts_info { 971 - struct sk_buff *skb; 972 - struct list_head list; 973 - 974 - int port; 975 - u8 tag; 976 - }; 977 - 978 970 #define RSWITCH_NUM_IRQ_REGS (RSWITCH_MAX_NUM_QUEUES / BITS_PER_TYPE(u32)) 979 971 struct rswitch_gwca { 980 972 unsigned int index; ··· 976 984 struct rswitch_gwca_queue *queues; 977 985 int num_queues; 978 986 struct rswitch_gwca_queue ts_queue; 979 - struct list_head ts_info_list; 980 987 DECLARE_BITMAP(used, RSWITCH_MAX_NUM_QUEUES); 981 988 u32 tx_irq_bits[RSWITCH_NUM_IRQ_REGS]; 982 989 u32 rx_irq_bits[RSWITCH_NUM_IRQ_REGS]; 983 990 }; 984 991 985 992 #define NUM_QUEUES_PER_NDEV 2 993 + #define TS_TAGS_PER_PORT 256 986 994 struct rswitch_device { 987 995 struct rswitch_private *priv; 988 996 struct net_device *ndev; ··· 990 998 void __iomem *addr; 991 999 struct rswitch_gwca_queue *tx_queue; 992 1000 struct rswitch_gwca_queue *rx_queue; 993 - u8 ts_tag; 1001 + struct sk_buff *ts_skb[TS_TAGS_PER_PORT]; 1002 + DECLARE_BITMAP(ts_skb_used, TS_TAGS_PER_PORT); 994 1003 bool disabled; 995 1004 996 1005 int port;
+10 -3
drivers/net/mdio/fwnode_mdio.c
··· 40 40 static struct mii_timestamper * 41 41 fwnode_find_mii_timestamper(struct fwnode_handle *fwnode) 42 42 { 43 + struct mii_timestamper *mii_ts; 43 44 struct of_phandle_args arg; 44 45 int err; 45 46 ··· 54 53 else if (err) 55 54 return ERR_PTR(err); 56 55 57 - if (arg.args_count != 1) 58 - return ERR_PTR(-EINVAL); 56 + if (arg.args_count != 1) { 57 + mii_ts = ERR_PTR(-EINVAL); 58 + goto put_node; 59 + } 59 60 60 - return register_mii_timestamper(arg.np, arg.args[0]); 61 + mii_ts = register_mii_timestamper(arg.np, arg.args[0]); 62 + 63 + put_node: 64 + of_node_put(arg.np); 65 + return mii_ts; 61 66 } 62 67 63 68 int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
+2
drivers/net/netdevsim/health.c
··· 149 149 char *break_msg; 150 150 int err; 151 151 152 + if (count == 0 || count > PAGE_SIZE) 153 + return -EINVAL; 152 154 break_msg = memdup_user_nul(data, count); 153 155 if (IS_ERR(break_msg)) 154 156 return PTR_ERR(break_msg);
+2 -2
drivers/net/netdevsim/netdev.c
··· 635 635 page_pool_put_full_page(ns->page->pp, ns->page, false); 636 636 ns->page = NULL; 637 637 } 638 - rtnl_unlock(); 639 638 640 639 exit: 641 - return count; 640 + rtnl_unlock(); 641 + return ret; 642 642 } 643 643 644 644 static const struct file_operations nsim_pp_hold_fops = {
+1 -1
drivers/net/phy/aquantia/aquantia_leds.c
··· 156 156 if (force_active_high || force_active_low) 157 157 return aqr_phy_led_active_low_set(phydev, index, force_active_low); 158 158 159 - unreachable(); 159 + return -EINVAL; 160 160 }
+1 -1
drivers/net/phy/intel-xway.c
··· 529 529 if (force_active_high) 530 530 return phy_clear_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index)); 531 531 532 - unreachable(); 532 + return -EINVAL; 533 533 } 534 534 535 535 static struct phy_driver xway_gphy[] = {
+1 -1
drivers/net/phy/mxl-gpy.c
··· 1014 1014 if (force_active_high) 1015 1015 return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); 1016 1016 1017 - unreachable(); 1017 + return -EINVAL; 1018 1018 } 1019 1019 1020 1020 static struct phy_driver gpy_drivers[] = {
+7 -3
drivers/net/team/team_core.c
··· 998 998 unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE | 999 999 IFF_XMIT_DST_RELEASE_PERM; 1000 1000 1001 - vlan_features = netdev_base_features(vlan_features); 1002 - 1003 1001 rcu_read_lock(); 1002 + if (list_empty(&team->port_list)) 1003 + goto done; 1004 + 1005 + vlan_features = netdev_base_features(vlan_features); 1006 + enc_features = netdev_base_features(enc_features); 1007 + 1004 1008 list_for_each_entry_rcu(port, &team->port_list, list) { 1005 1009 vlan_features = netdev_increment_features(vlan_features, 1006 1010 port->dev->vlan_features, ··· 1014 1010 port->dev->hw_enc_features, 1015 1011 TEAM_ENC_FEATURES); 1016 1012 1017 - 1018 1013 dst_release_flag &= port->dev->priv_flags; 1019 1014 if (port->dev->hard_header_len > max_hard_header_len) 1020 1015 max_hard_header_len = port->dev->hard_header_len; 1021 1016 } 1017 + done: 1022 1018 rcu_read_unlock(); 1023 1019 1024 1020 team->dev->vlan_features = vlan_features;
+1 -1
drivers/net/tun.c
··· 1485 1485 skb->truesize += skb->data_len; 1486 1486 1487 1487 for (i = 1; i < it->nr_segs; i++) { 1488 - const struct iovec *iov = iter_iov(it); 1488 + const struct iovec *iov = iter_iov(it) + i; 1489 1489 size_t fragsz = iov->iov_len; 1490 1490 struct page *page; 1491 1491 void *frag;
+1
drivers/net/usb/qmi_wwan.c
··· 1429 1429 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0195, 4)}, /* Quectel EG95 */ 1430 1430 {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ 1431 1431 {QMI_QUIRK_SET_DTR(0x2c7c, 0x030e, 4)}, /* Quectel EM05GV2 */ 1432 + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0316, 3)}, /* Quectel RG255C */ 1432 1433 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */ 1433 1434 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0112, 0)}, /* Fibocom FG132 */ 1434 1435 {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */
+4 -1
drivers/net/xen-netfront.c
··· 867 867 static int xennet_close(struct net_device *dev) 868 868 { 869 869 struct netfront_info *np = netdev_priv(dev); 870 - unsigned int num_queues = dev->real_num_tx_queues; 870 + unsigned int num_queues = np->queues ? dev->real_num_tx_queues : 0; 871 871 unsigned int i; 872 872 struct netfront_queue *queue; 873 873 netif_tx_stop_all_queues(np->netdev); ··· 881 881 static void xennet_destroy_queues(struct netfront_info *info) 882 882 { 883 883 unsigned int i; 884 + 885 + if (!info->queues) 886 + return; 884 887 885 888 for (i = 0; i < info->netdev->real_num_tx_queues; i++) { 886 889 struct netfront_queue *queue = &info->queues[i];
+19 -5
drivers/platform/x86/dell/alienware-wmi.c
··· 190 190 }; 191 191 192 192 static struct quirk_entry quirk_g_series = { 193 - .num_zones = 2, 193 + .num_zones = 0, 194 194 .hdmi_mux = 0, 195 195 .amplifier = 0, 196 196 .deepslp = 0, ··· 199 199 }; 200 200 201 201 static struct quirk_entry quirk_x_series = { 202 - .num_zones = 2, 202 + .num_zones = 0, 203 203 .hdmi_mux = 0, 204 204 .amplifier = 0, 205 205 .deepslp = 0, ··· 240 240 DMI_MATCH(DMI_PRODUCT_NAME, "ASM201"), 241 241 }, 242 242 .driver_data = &quirk_asm201, 243 + }, 244 + { 245 + .callback = dmi_matched, 246 + .ident = "Alienware m16 R1 AMD", 247 + .matches = { 248 + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), 249 + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m16 R1 AMD"), 250 + }, 251 + .driver_data = &quirk_x_series, 243 252 }, 244 253 { 245 254 .callback = dmi_matched, ··· 695 686 static void alienware_zone_exit(struct platform_device *dev) 696 687 { 697 688 u8 zone; 689 + 690 + if (!quirks->num_zones) 691 + return; 698 692 699 693 sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group); 700 694 led_classdev_unregister(&global_led); ··· 1241 1229 goto fail_prep_thermal_profile; 1242 1230 } 1243 1231 1244 - ret = alienware_zone_init(platform_device); 1245 - if (ret) 1246 - goto fail_prep_zones; 1232 + if (quirks->num_zones > 0) { 1233 + ret = alienware_zone_init(platform_device); 1234 + if (ret) 1235 + goto fail_prep_zones; 1236 + } 1247 1237 1248 1238 return 0; 1249 1239
+1
drivers/platform/x86/intel/ifs/core.c
··· 20 20 X86_MATCH(INTEL_GRANITERAPIDS_X, ARRAY_GEN0), 21 21 X86_MATCH(INTEL_GRANITERAPIDS_D, ARRAY_GEN0), 22 22 X86_MATCH(INTEL_ATOM_CRESTMONT_X, ARRAY_GEN1), 23 + X86_MATCH(INTEL_ATOM_DARKMONT_X, ARRAY_GEN1), 23 24 {} 24 25 }; 25 26 MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
+2
drivers/platform/x86/intel/vsec.c
··· 423 423 #define PCI_DEVICE_ID_INTEL_VSEC_RPL 0xa77d 424 424 #define PCI_DEVICE_ID_INTEL_VSEC_TGL 0x9a0d 425 425 #define PCI_DEVICE_ID_INTEL_VSEC_LNL_M 0x647d 426 + #define PCI_DEVICE_ID_INTEL_VSEC_PTL 0xb07d 426 427 static const struct pci_device_id intel_vsec_pci_ids[] = { 427 428 { PCI_DEVICE_DATA(INTEL, VSEC_ADL, &tgl_info) }, 428 429 { PCI_DEVICE_DATA(INTEL, VSEC_DG1, &dg1_info) }, ··· 433 432 { PCI_DEVICE_DATA(INTEL, VSEC_RPL, &tgl_info) }, 434 433 { PCI_DEVICE_DATA(INTEL, VSEC_TGL, &tgl_info) }, 435 434 { PCI_DEVICE_DATA(INTEL, VSEC_LNL_M, &lnl_info) }, 435 + { PCI_DEVICE_DATA(INTEL, VSEC_PTL, &mtl_info) }, 436 436 { } 437 437 }; 438 438 MODULE_DEVICE_TABLE(pci, intel_vsec_pci_ids);
+56 -23
drivers/platform/x86/p2sb.c
··· 43 43 }; 44 44 45 45 static struct p2sb_res_cache p2sb_resources[NR_P2SB_RES_CACHE]; 46 + static bool p2sb_hidden_by_bios; 46 47 47 48 static void p2sb_get_devfn(unsigned int *devfn) 48 49 { ··· 98 97 99 98 static int p2sb_scan_and_cache(struct pci_bus *bus, unsigned int devfn) 100 99 { 100 + /* 101 + * The BIOS prevents the P2SB device from being enumerated by the PCI 102 + * subsystem, so we need to unhide and hide it back to lookup the BAR. 103 + */ 104 + pci_bus_write_config_dword(bus, devfn, P2SBC, 0); 105 + 101 106 /* Scan the P2SB device and cache its BAR0 */ 102 107 p2sb_scan_and_cache_devfn(bus, devfn); 103 108 104 109 /* On Goldmont p2sb_bar() also gets called for the SPI controller */ 105 110 if (devfn == P2SB_DEVFN_GOLDMONT) 106 111 p2sb_scan_and_cache_devfn(bus, SPI_DEVFN_GOLDMONT); 112 + 113 + pci_bus_write_config_dword(bus, devfn, P2SBC, P2SBC_HIDE); 107 114 108 115 if (!p2sb_valid_resource(&p2sb_resources[PCI_FUNC(devfn)].res)) 109 116 return -ENOENT; ··· 138 129 u32 value = P2SBC_HIDE; 139 130 struct pci_bus *bus; 140 131 u16 class; 141 - int ret; 132 + int ret = 0; 142 133 143 134 /* Get devfn for P2SB device itself */ 144 135 p2sb_get_devfn(&devfn_p2sb); ··· 161 152 */ 162 153 pci_lock_rescan_remove(); 163 154 164 - /* 165 - * The BIOS prevents the P2SB device from being enumerated by the PCI 166 - * subsystem, so we need to unhide and hide it back to lookup the BAR. 167 - * Unhide the P2SB device here, if needed. 168 - */ 169 155 pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value); 170 - if (value & P2SBC_HIDE) 171 - pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0); 156 + p2sb_hidden_by_bios = value & P2SBC_HIDE; 172 157 173 - ret = p2sb_scan_and_cache(bus, devfn_p2sb); 174 - 175 - /* Hide the P2SB device, if it was hidden */ 176 - if (value & P2SBC_HIDE) 177 - pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, P2SBC_HIDE); 158 + /* 159 + * If the BIOS does not hide the P2SB device then its resources 160 + * are accesilble. Cache them only if the P2SB device is hidden. 161 + */ 162 + if (p2sb_hidden_by_bios) 163 + ret = p2sb_scan_and_cache(bus, devfn_p2sb); 178 164 179 165 pci_unlock_rescan_remove(); 166 + 167 + return ret; 168 + } 169 + 170 + static int p2sb_read_from_cache(struct pci_bus *bus, unsigned int devfn, 171 + struct resource *mem) 172 + { 173 + struct p2sb_res_cache *cache = &p2sb_resources[PCI_FUNC(devfn)]; 174 + 175 + if (cache->bus_dev_id != bus->dev.id) 176 + return -ENODEV; 177 + 178 + if (!p2sb_valid_resource(&cache->res)) 179 + return -ENOENT; 180 + 181 + memcpy(mem, &cache->res, sizeof(*mem)); 182 + 183 + return 0; 184 + } 185 + 186 + static int p2sb_read_from_dev(struct pci_bus *bus, unsigned int devfn, 187 + struct resource *mem) 188 + { 189 + struct pci_dev *pdev; 190 + int ret = 0; 191 + 192 + pdev = pci_get_slot(bus, devfn); 193 + if (!pdev) 194 + return -ENODEV; 195 + 196 + if (p2sb_valid_resource(pci_resource_n(pdev, 0))) 197 + p2sb_read_bar0(pdev, mem); 198 + else 199 + ret = -ENOENT; 200 + 201 + pci_dev_put(pdev); 180 202 181 203 return ret; 182 204 } ··· 228 188 */ 229 189 int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem) 230 190 { 231 - struct p2sb_res_cache *cache; 232 - 233 191 bus = p2sb_get_bus(bus); 234 192 if (!bus) 235 193 return -ENODEV; ··· 235 197 if (!devfn) 236 198 p2sb_get_devfn(&devfn); 237 199 238 - cache = &p2sb_resources[PCI_FUNC(devfn)]; 239 - if (cache->bus_dev_id != bus->dev.id) 240 - return -ENODEV; 200 + if (p2sb_hidden_by_bios) 201 + return p2sb_read_from_cache(bus, devfn, mem); 241 202 242 - if (!p2sb_valid_resource(&cache->res)) 243 - return -ENOENT; 244 - 245 - memcpy(mem, &cache->res, sizeof(*mem)); 246 - return 0; 203 + return p2sb_read_from_dev(bus, devfn, mem); 247 204 } 248 205 EXPORT_SYMBOL_GPL(p2sb_bar); 249 206
+26
drivers/platform/x86/touchscreen_dmi.c
··· 855 855 .properties = rwc_nanote_next_props, 856 856 }; 857 857 858 + static const struct property_entry sary_tab_3_props[] = { 859 + PROPERTY_ENTRY_U32("touchscreen-size-x", 1730), 860 + PROPERTY_ENTRY_U32("touchscreen-size-y", 1151), 861 + PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"), 862 + PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), 863 + PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), 864 + PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-sary-tab-3.fw"), 865 + PROPERTY_ENTRY_U32("silead,max-fingers", 10), 866 + PROPERTY_ENTRY_BOOL("silead,home-button"), 867 + { } 868 + }; 869 + 870 + static const struct ts_dmi_data sary_tab_3_data = { 871 + .acpi_name = "MSSL1680:00", 872 + .properties = sary_tab_3_props, 873 + }; 874 + 858 875 static const struct property_entry schneider_sct101ctm_props[] = { 859 876 PROPERTY_ENTRY_U32("touchscreen-size-x", 1715), 860 877 PROPERTY_ENTRY_U32("touchscreen-size-y", 1140), ··· 1630 1613 DMI_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."), 1631 1614 /* Above matches are too generic, add bios-version match */ 1632 1615 DMI_MATCH(DMI_BIOS_VERSION, "S8A70R100-V005"), 1616 + }, 1617 + }, 1618 + { 1619 + /* SARY Tab 3 */ 1620 + .driver_data = (void *)&sary_tab_3_data, 1621 + .matches = { 1622 + DMI_MATCH(DMI_SYS_VENDOR, "SARY"), 1623 + DMI_MATCH(DMI_PRODUCT_NAME, "C210C"), 1624 + DMI_MATCH(DMI_PRODUCT_SKU, "TAB3"), 1633 1625 }, 1634 1626 }, 1635 1627 {
+1 -1
drivers/pwm/pwm-stm32.c
··· 84 84 85 85 wfhw->ccer = TIM_CCER_CCxE(ch + 1); 86 86 if (priv->have_complementary_output) 87 - wfhw->ccer = TIM_CCER_CCxNE(ch + 1); 87 + wfhw->ccer |= TIM_CCER_CCxNE(ch + 1); 88 88 89 89 rate = clk_get_rate(priv->clk); 90 90
+24 -12
drivers/regulator/axp20x-regulator.c
··· 371 371 .ops = &axp20x_ops, \ 372 372 } 373 373 374 - #define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 375 - _vmask, _ereg, _emask) \ 374 + #define AXP_DESC_DELAY(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 375 + _vmask, _ereg, _emask, _ramp_delay) \ 376 376 [_family##_##_id] = { \ 377 377 .name = (_match), \ 378 378 .supply_name = (_supply), \ ··· 388 388 .vsel_mask = (_vmask), \ 389 389 .enable_reg = (_ereg), \ 390 390 .enable_mask = (_emask), \ 391 + .ramp_delay = (_ramp_delay), \ 391 392 .ops = &axp20x_ops, \ 392 393 } 394 + 395 + #define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 396 + _vmask, _ereg, _emask) \ 397 + AXP_DESC_DELAY(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 398 + _vmask, _ereg, _emask, 0) 393 399 394 400 #define AXP_DESC_SW(_family, _id, _match, _supply, _ereg, _emask) \ 395 401 [_family##_##_id] = { \ ··· 425 419 .ops = &axp20x_ops_fixed \ 426 420 } 427 421 428 - #define AXP_DESC_RANGES(_family, _id, _match, _supply, _ranges, _n_voltages, \ 429 - _vreg, _vmask, _ereg, _emask) \ 422 + #define AXP_DESC_RANGES_DELAY(_family, _id, _match, _supply, _ranges, _n_voltages, \ 423 + _vreg, _vmask, _ereg, _emask, _ramp_delay) \ 430 424 [_family##_##_id] = { \ 431 425 .name = (_match), \ 432 426 .supply_name = (_supply), \ ··· 442 436 .enable_mask = (_emask), \ 443 437 .linear_ranges = (_ranges), \ 444 438 .n_linear_ranges = ARRAY_SIZE(_ranges), \ 439 + .ramp_delay = (_ramp_delay), \ 445 440 .ops = &axp20x_ops_range, \ 446 441 } 442 + 443 + #define AXP_DESC_RANGES(_family, _id, _match, _supply, _ranges, _n_voltages, \ 444 + _vreg, _vmask, _ereg, _emask) \ 445 + AXP_DESC_RANGES_DELAY(_family, _id, _match, _supply, _ranges, \ 446 + _n_voltages, _vreg, _vmask, _ereg, _emask, 0) 447 447 448 448 static const int axp209_dcdc2_ldo3_slew_rates[] = { 449 449 1600, ··· 793 781 }; 794 782 795 783 static const struct regulator_desc axp717_regulators[] = { 796 - AXP_DESC_RANGES(AXP717, DCDC1, "dcdc1", "vin1", 784 + AXP_DESC_RANGES_DELAY(AXP717, DCDC1, "dcdc1", "vin1", 797 785 axp717_dcdc1_ranges, AXP717_DCDC1_NUM_VOLTAGES, 798 786 AXP717_DCDC1_CONTROL, AXP717_DCDC_V_OUT_MASK, 799 - AXP717_DCDC_OUTPUT_CONTROL, BIT(0)), 800 - AXP_DESC_RANGES(AXP717, DCDC2, "dcdc2", "vin2", 787 + AXP717_DCDC_OUTPUT_CONTROL, BIT(0), 640), 788 + AXP_DESC_RANGES_DELAY(AXP717, DCDC2, "dcdc2", "vin2", 801 789 axp717_dcdc2_ranges, AXP717_DCDC2_NUM_VOLTAGES, 802 790 AXP717_DCDC2_CONTROL, AXP717_DCDC_V_OUT_MASK, 803 - AXP717_DCDC_OUTPUT_CONTROL, BIT(1)), 804 - AXP_DESC_RANGES(AXP717, DCDC3, "dcdc3", "vin3", 791 + AXP717_DCDC_OUTPUT_CONTROL, BIT(1), 640), 792 + AXP_DESC_RANGES_DELAY(AXP717, DCDC3, "dcdc3", "vin3", 805 793 axp717_dcdc3_ranges, AXP717_DCDC3_NUM_VOLTAGES, 806 794 AXP717_DCDC3_CONTROL, AXP717_DCDC_V_OUT_MASK, 807 - AXP717_DCDC_OUTPUT_CONTROL, BIT(2)), 808 - AXP_DESC(AXP717, DCDC4, "dcdc4", "vin4", 1000, 3700, 100, 795 + AXP717_DCDC_OUTPUT_CONTROL, BIT(2), 640), 796 + AXP_DESC_DELAY(AXP717, DCDC4, "dcdc4", "vin4", 1000, 3700, 100, 809 797 AXP717_DCDC4_CONTROL, AXP717_DCDC_V_OUT_MASK, 810 - AXP717_DCDC_OUTPUT_CONTROL, BIT(3)), 798 + AXP717_DCDC_OUTPUT_CONTROL, BIT(3), 6400), 811 799 AXP_DESC(AXP717, ALDO1, "aldo1", "aldoin", 500, 3500, 100, 812 800 AXP717_ALDO1_CONTROL, AXP717_LDO_V_OUT_MASK, 813 801 AXP717_LDO0_OUTPUT_CONTROL, BIT(0)),
+6 -4
drivers/spi/spi-aspeed-smc.c
··· 239 239 240 240 ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, offset, op->cmd.opcode); 241 241 if (ret < 0) 242 - return ret; 242 + goto stop_user; 243 243 244 244 if (op->dummy.buswidth && op->dummy.nbytes) { 245 245 for (i = 0; i < op->dummy.nbytes / op->dummy.buswidth; i++) ··· 249 249 aspeed_spi_set_io_mode(chip, io_mode); 250 250 251 251 aspeed_spi_read_from_ahb(buf, chip->ahb_base, len); 252 + stop_user: 252 253 aspeed_spi_stop_user(chip); 253 - return 0; 254 + return ret; 254 255 } 255 256 256 257 static ssize_t aspeed_spi_write_user(struct aspeed_spi_chip *chip, ··· 262 261 aspeed_spi_start_user(chip); 263 262 ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, op->addr.val, op->cmd.opcode); 264 263 if (ret < 0) 265 - return ret; 264 + goto stop_user; 266 265 aspeed_spi_write_to_ahb(chip->ahb_base, op->data.buf.out, op->data.nbytes); 266 + stop_user: 267 267 aspeed_spi_stop_user(chip); 268 - return 0; 268 + return ret; 269 269 } 270 270 271 271 /* support for 1-1-1, 1-1-2 or 1-1-4 */
+8 -2
drivers/spi/spi-cadence-quadspi.c
··· 43 43 #define CQSPI_SLOW_SRAM BIT(4) 44 44 #define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5) 45 45 #define CQSPI_RD_NO_IRQ BIT(6) 46 + #define CQSPI_DISABLE_STIG_MODE BIT(7) 46 47 47 48 /* Capabilities */ 48 49 #define CQSPI_SUPPORTS_OCTAL BIT(0) ··· 104 103 bool apb_ahb_hazard; 105 104 106 105 bool is_jh7110; /* Flag for StarFive JH7110 SoC */ 106 + bool disable_stig_mode; 107 107 108 108 const struct cqspi_driver_platdata *ddata; 109 109 }; ··· 1418 1416 * reads, prefer STIG mode for such small reads. 1419 1417 */ 1420 1418 if (!op->addr.nbytes || 1421 - op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX) 1419 + (op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX && 1420 + !cqspi->disable_stig_mode)) 1422 1421 return cqspi_command_read(f_pdata, op); 1423 1422 1424 1423 return cqspi_read(f_pdata, op); ··· 1883 1880 if (ret) 1884 1881 goto probe_reset_failed; 1885 1882 } 1883 + if (ddata->quirks & CQSPI_DISABLE_STIG_MODE) 1884 + cqspi->disable_stig_mode = true; 1886 1885 1887 1886 if (of_device_is_compatible(pdev->dev.of_node, 1888 1887 "xlnx,versal-ospi-1.0")) { ··· 2048 2043 static const struct cqspi_driver_platdata socfpga_qspi = { 2049 2044 .quirks = CQSPI_DISABLE_DAC_MODE 2050 2045 | CQSPI_NO_SUPPORT_WR_COMPLETION 2051 - | CQSPI_SLOW_SRAM, 2046 + | CQSPI_SLOW_SRAM 2047 + | CQSPI_DISABLE_STIG_MODE, 2052 2048 }; 2053 2049 2054 2050 static const struct cqspi_driver_platdata versal_ospi = {
+14
drivers/spi/spi-rockchip.c
··· 241 241 struct spi_controller *ctlr = spi->controller; 242 242 struct rockchip_spi *rs = spi_controller_get_devdata(ctlr); 243 243 bool cs_asserted = spi->mode & SPI_CS_HIGH ? enable : !enable; 244 + bool cs_actual; 245 + 246 + /* 247 + * SPI subsystem tries to avoid no-op calls that would break the PM 248 + * refcount below. It can't however for the first time it is used. 249 + * To detect this case we read it here and bail out early for no-ops. 250 + */ 251 + if (spi_get_csgpiod(spi, 0)) 252 + cs_actual = !!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SER) & 1); 253 + else 254 + cs_actual = !!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SER) & 255 + BIT(spi_get_chipselect(spi, 0))); 256 + if (unlikely(cs_actual == cs_asserted)) 257 + return; 244 258 245 259 if (cs_asserted) { 246 260 /* Keep things powered as long as CS is asserted */
+6 -1
drivers/staging/gpib/Kconfig
··· 50 50 tristate "CEC PCI board" 51 51 depends on PCI 52 52 depends on HAS_IOPORT 53 + depends on !X86_PAE 53 54 select GPIB_COMMON 54 55 select GPIB_NEC7210 55 56 help ··· 63 62 config GPIB_NI_PCI_ISA 64 63 tristate "NI PCI/ISA compatible boards" 65 64 depends on ISA_BUS || PCI || PCMCIA 65 + depends on HAS_IOPORT 66 + depends on !X86_PAE 66 67 select GPIB_COMMON 67 68 select GPIB_NEC7210 68 69 help ··· 88 85 tristate "Measurement Computing compatible boards" 89 86 depends on HAS_IOPORT 90 87 depends on ISA_BUS || PCI || PCMCIA 88 + depends on !X86_PAE 91 89 select GPIB_COMMON 92 90 select GPIB_NEC7210 93 91 help ··· 132 128 tristate "FMH FPGA based devices" 133 129 select GPIB_COMMON 134 130 select GPIB_NEC7210 135 - depends on BROKEN 131 + depends on !PPC 136 132 depends on OF && PCI 137 133 help 138 134 GPIB driver for fmhess FPGA based devices ··· 178 174 tristate "INES" 179 175 depends on PCI || ISA_BUS || PCMCIA 180 176 depends on HAS_IOPORT 177 + depends on !X86_PAE 181 178 select GPIB_COMMON 182 179 select GPIB_NEC7210 183 180 help
+1 -1
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
··· 901 901 902 902 } else { 903 903 /* we are in the closing <DLE><ETX> sequence */ 904 - 904 + c = nc; 905 905 if (c == ETX) { 906 906 c = one_char(board, &b); 907 907 if (c == ACK) {
+2 -1
drivers/tty/serial/8250/8250_port.c
··· 467 467 break; 468 468 #endif 469 469 default: 470 - WARN(1, "Unsupported UART type %x\n", p->iotype); 470 + WARN(p->iotype != UPIO_PORT || p->iobase, 471 + "Unsupported UART type %x\n", p->iotype); 471 472 p->serial_in = no_serial_in; 472 473 p->serial_out = no_serial_out; 473 474 }
+29
drivers/tty/serial/sh-sci.c
··· 157 157 158 158 bool has_rtscts; 159 159 bool autorts; 160 + bool tx_occurred; 160 161 }; 161 162 162 163 #define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS ··· 851 850 { 852 851 struct tty_port *tport = &port->state->port; 853 852 unsigned int stopped = uart_tx_stopped(port); 853 + struct sci_port *s = to_sci_port(port); 854 854 unsigned short status; 855 855 unsigned short ctrl; 856 856 int count; ··· 887 885 } 888 886 889 887 sci_serial_out(port, SCxTDR, c); 888 + s->tx_occurred = true; 890 889 891 890 port->icount.tx++; 892 891 } while (--count > 0); ··· 1243 1240 1244 1241 if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS) 1245 1242 uart_write_wakeup(port); 1243 + 1244 + s->tx_occurred = true; 1246 1245 1247 1246 if (!kfifo_is_empty(&tport->xmit_fifo)) { 1248 1247 s->cookie_tx = 0; ··· 1736 1731 s->cookie_tx = -EINVAL; 1737 1732 } 1738 1733 } 1734 + 1735 + static void sci_dma_check_tx_occurred(struct sci_port *s) 1736 + { 1737 + struct dma_tx_state state; 1738 + enum dma_status status; 1739 + 1740 + if (!s->chan_tx) 1741 + return; 1742 + 1743 + status = dmaengine_tx_status(s->chan_tx, s->cookie_tx, &state); 1744 + if (status == DMA_COMPLETE || status == DMA_IN_PROGRESS) 1745 + s->tx_occurred = true; 1746 + } 1739 1747 #else /* !CONFIG_SERIAL_SH_SCI_DMA */ 1740 1748 static inline void sci_request_dma(struct uart_port *port) 1741 1749 { 1742 1750 } 1743 1751 1744 1752 static inline void sci_free_dma(struct uart_port *port) 1753 + { 1754 + } 1755 + 1756 + static void sci_dma_check_tx_occurred(struct sci_port *s) 1745 1757 { 1746 1758 } 1747 1759 ··· 2098 2076 { 2099 2077 unsigned short status = sci_serial_in(port, SCxSR); 2100 2078 unsigned short in_tx_fifo = sci_txfill(port); 2079 + struct sci_port *s = to_sci_port(port); 2080 + 2081 + sci_dma_check_tx_occurred(s); 2082 + 2083 + if (!s->tx_occurred) 2084 + return TIOCSER_TEMT; 2101 2085 2102 2086 return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0; 2103 2087 } ··· 2275 2247 2276 2248 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); 2277 2249 2250 + s->tx_occurred = false; 2278 2251 sci_request_dma(port); 2279 2252 2280 2253 ret = sci_request_irq(s);
+1
drivers/ufs/core/ufshcd.c
··· 5556 5556 5557 5557 lrbp = &hba->lrb[task_tag]; 5558 5558 lrbp->compl_time_stamp = ktime_get(); 5559 + lrbp->compl_time_stamp_local_clock = local_clock(); 5559 5560 cmd = lrbp->cmd; 5560 5561 if (cmd) { 5561 5562 if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
+7 -1
drivers/usb/core/hcd.c
··· 2794 2794 int retval; 2795 2795 struct usb_device *rhdev; 2796 2796 struct usb_hcd *shared_hcd; 2797 + int skip_phy_initialization; 2797 2798 2798 - if (!hcd->skip_phy_initialization) { 2799 + if (usb_hcd_is_primary_hcd(hcd)) 2800 + skip_phy_initialization = hcd->skip_phy_initialization; 2801 + else 2802 + skip_phy_initialization = hcd->primary_hcd->skip_phy_initialization; 2803 + 2804 + if (!skip_phy_initialization) { 2799 2805 if (usb_hcd_is_primary_hcd(hcd)) { 2800 2806 hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); 2801 2807 if (IS_ERR(hcd->phy_roothub))
+8 -11
drivers/usb/dwc2/hcd.c
··· 3546 3546 port_status |= USB_PORT_STAT_C_OVERCURRENT << 16; 3547 3547 } 3548 3548 3549 - if (!hsotg->flags.b.port_connect_status) { 3549 + if (dwc2_is_device_mode(hsotg)) { 3550 3550 /* 3551 - * The port is disconnected, which means the core is 3552 - * either in device mode or it soon will be. Just 3553 - * return 0's for the remainder of the port status 3551 + * Just return 0's for the remainder of the port status 3554 3552 * since the port register can't be read if the core 3555 3553 * is in device mode. 3556 3554 */ ··· 3618 3620 if (wvalue != USB_PORT_FEAT_TEST && (!windex || windex > 1)) 3619 3621 goto error; 3620 3622 3621 - if (!hsotg->flags.b.port_connect_status) { 3623 + if (dwc2_is_device_mode(hsotg)) { 3622 3624 /* 3623 - * The port is disconnected, which means the core is 3624 - * either in device mode or it soon will be. Just 3625 - * return without doing anything since the port 3626 - * register can't be written if the core is in device 3627 - * mode. 3625 + * Just return 0's for the remainder of the port status 3626 + * since the port register can't be read if the core 3627 + * is in device mode. 3628 3628 */ 3629 3629 break; 3630 3630 } ··· 4345 4349 if (hsotg->bus_suspended) 4346 4350 goto skip_power_saving; 4347 4351 4348 - if (hsotg->flags.b.port_connect_status == 0) 4352 + if (!(dwc2_read_hprt0(hsotg) & HPRT0_CONNSTS)) 4349 4353 goto skip_power_saving; 4350 4354 4351 4355 switch (hsotg->params.power_down) { ··· 4427 4431 * Power Down mode. 4428 4432 */ 4429 4433 if (hprt0 & HPRT0_CONNSTS) { 4434 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 4430 4435 hsotg->lx_state = DWC2_L0; 4431 4436 goto unlock; 4432 4437 }
+16 -14
drivers/usb/dwc3/dwc3-imx8mp.c
··· 129 129 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); 130 130 } 131 131 132 + static const struct property_entry dwc3_imx8mp_properties[] = { 133 + PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk"), 134 + PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk"), 135 + {}, 136 + }; 137 + 138 + static const struct software_node dwc3_imx8mp_swnode = { 139 + .properties = dwc3_imx8mp_properties, 140 + }; 141 + 132 142 static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx) 133 143 { 134 144 struct dwc3_imx8mp *dwc3_imx = _dwc3_imx; ··· 156 146 pm_runtime_get(dwc->dev); 157 147 158 148 return IRQ_HANDLED; 159 - } 160 - 161 - static int dwc3_imx8mp_set_software_node(struct device *dev) 162 - { 163 - struct property_entry props[3] = { 0 }; 164 - int prop_idx = 0; 165 - 166 - props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk"); 167 - props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk"); 168 - 169 - return device_create_managed_software_node(dev, props, NULL); 170 149 } 171 150 172 151 static int dwc3_imx8mp_probe(struct platform_device *pdev) ··· 220 221 if (err < 0) 221 222 goto disable_rpm; 222 223 223 - err = dwc3_imx8mp_set_software_node(dev); 224 + err = device_add_software_node(dev, &dwc3_imx8mp_swnode); 224 225 if (err) { 225 226 err = -ENODEV; 226 - dev_err(dev, "failed to create software node\n"); 227 + dev_err(dev, "failed to add software node\n"); 227 228 goto disable_rpm; 228 229 } 229 230 230 231 err = of_platform_populate(node, NULL, NULL, dev); 231 232 if (err) { 232 233 dev_err(&pdev->dev, "failed to create dwc3 core\n"); 233 - goto disable_rpm; 234 + goto remove_swnode; 234 235 } 235 236 236 237 dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np); ··· 254 255 255 256 depopulate: 256 257 of_platform_depopulate(dev); 258 + remove_swnode: 259 + device_remove_software_node(dev); 257 260 disable_rpm: 258 261 pm_runtime_disable(dev); 259 262 pm_runtime_put_noidle(dev); ··· 269 268 270 269 pm_runtime_get_sync(dev); 271 270 of_platform_depopulate(dev); 271 + device_remove_software_node(dev); 272 272 273 273 pm_runtime_disable(dev); 274 274 pm_runtime_put_noidle(dev);
+4 -1
drivers/usb/dwc3/dwc3-xilinx.c
··· 121 121 * in use but the usb3-phy entry is missing from the device tree. 122 122 * Therefore, skip these operations in this case. 123 123 */ 124 - if (!priv_data->usb3_phy) 124 + if (!priv_data->usb3_phy) { 125 + /* Deselect the PIPE Clock Select bit in FPD PIPE Clock register */ 126 + writel(PIPE_CLK_DESELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK); 125 127 goto skip_usb3_phy; 128 + } 126 129 127 130 crst = devm_reset_control_get_exclusive(dev, "usb_crst"); 128 131 if (IS_ERR(crst)) {
+5 -1
drivers/usb/gadget/function/f_midi2.c
··· 1591 1591 fb->info.midi_ci_version = b->midi_ci_version; 1592 1592 fb->info.ui_hint = reverse_dir(b->ui_hint); 1593 1593 fb->info.sysex8_streams = b->sysex8_streams; 1594 - fb->info.flags |= b->is_midi1; 1594 + if (b->is_midi1 < 2) 1595 + fb->info.flags |= b->is_midi1; 1596 + else 1597 + fb->info.flags |= SNDRV_UMP_BLOCK_IS_MIDI1 | 1598 + SNDRV_UMP_BLOCK_IS_LOWSPEED; 1595 1599 strscpy(fb->info.name, ump_fb_name(b), 1596 1600 sizeof(fb->info.name)); 1597 1601 }
+6 -3
drivers/usb/gadget/function/u_serial.c
··· 579 579 * we didn't in gs_start_tx() */ 580 580 tty_wakeup(port->port.tty); 581 581 } else { 582 - gs_free_requests(ep, head, &port->read_allocated); 583 - gs_free_requests(port->port_usb->in, &port->write_pool, 584 - &port->write_allocated); 582 + /* Free reqs only if we are still connected */ 583 + if (port->port_usb) { 584 + gs_free_requests(ep, head, &port->read_allocated); 585 + gs_free_requests(port->port_usb->in, &port->write_pool, 586 + &port->write_allocated); 587 + } 585 588 status = -EIO; 586 589 } 587 590
+7 -2
drivers/usb/host/ehci-sh.c
··· 119 119 if (IS_ERR(priv->iclk)) 120 120 priv->iclk = NULL; 121 121 122 - clk_enable(priv->fclk); 123 - clk_enable(priv->iclk); 122 + ret = clk_enable(priv->fclk); 123 + if (ret) 124 + goto fail_request_resource; 125 + ret = clk_enable(priv->iclk); 126 + if (ret) 127 + goto fail_iclk; 124 128 125 129 ret = usb_add_hcd(hcd, irq, IRQF_SHARED); 126 130 if (ret != 0) { ··· 140 136 141 137 fail_add_hcd: 142 138 clk_disable(priv->iclk); 139 + fail_iclk: 143 140 clk_disable(priv->fclk); 144 141 145 142 fail_request_resource:
+11 -5
drivers/usb/host/max3421-hcd.c
··· 779 779 retval = 1; 780 780 dev_dbg(&spi->dev, "%s: URB %p unlinked=%d", 781 781 __func__, urb, urb->unlinked); 782 - usb_hcd_unlink_urb_from_ep(hcd, urb); 783 - spin_unlock_irqrestore(&max3421_hcd->lock, 784 - flags); 785 - usb_hcd_giveback_urb(hcd, urb, 0); 786 - spin_lock_irqsave(&max3421_hcd->lock, flags); 782 + if (urb == max3421_hcd->curr_urb) { 783 + max3421_hcd->urb_done = 1; 784 + max3421_hcd->hien &= ~(BIT(MAX3421_HI_HXFRDN_BIT) | 785 + BIT(MAX3421_HI_RCVDAV_BIT)); 786 + } else { 787 + usb_hcd_unlink_urb_from_ep(hcd, urb); 788 + spin_unlock_irqrestore(&max3421_hcd->lock, 789 + flags); 790 + usb_hcd_giveback_urb(hcd, urb, 0); 791 + spin_lock_irqsave(&max3421_hcd->lock, flags); 792 + } 787 793 } 788 794 } 789 795 }
+3 -1
drivers/usb/misc/onboard_usb_dev.c
··· 407 407 } 408 408 409 409 if (of_device_is_compatible(pdev->dev.of_node, "usb424,2744") || 410 - of_device_is_compatible(pdev->dev.of_node, "usb424,5744")) 410 + of_device_is_compatible(pdev->dev.of_node, "usb424,5744")) { 411 411 err = onboard_dev_5744_i2c_init(client); 412 + onboard_dev->always_powered_in_suspend = true; 413 + } 412 414 413 415 put_device(&client->dev); 414 416 if (err < 0)
+41 -25
drivers/usb/typec/anx7411.c
··· 290 290 struct power_supply *psy; 291 291 struct power_supply_desc psy_desc; 292 292 struct device *dev; 293 + struct fwnode_handle *switch_node; 294 + struct fwnode_handle *mux_node; 293 295 }; 294 296 295 297 static u8 snk_identity[] = { ··· 1023 1021 } 1024 1022 } 1025 1023 1024 + static void anx7411_port_unregister(struct typec_params *typecp) 1025 + { 1026 + fwnode_handle_put(typecp->caps.fwnode); 1027 + anx7411_port_unregister_altmodes(typecp->port_amode); 1028 + if (typecp->port) 1029 + typec_unregister_port(typecp->port); 1030 + if (typecp->role_sw) 1031 + usb_role_switch_put(typecp->role_sw); 1032 + } 1033 + 1026 1034 static int anx7411_usb_mux_set(struct typec_mux_dev *mux, 1027 1035 struct typec_mux_state *state) 1028 1036 { ··· 1101 1089 if (ctx->typec.typec_mux) { 1102 1090 typec_mux_unregister(ctx->typec.typec_mux); 1103 1091 ctx->typec.typec_mux = NULL; 1092 + fwnode_handle_put(ctx->mux_node); 1104 1093 } 1105 1094 } 1106 1095 ··· 1110 1097 if (ctx->typec.typec_switch) { 1111 1098 typec_switch_unregister(ctx->typec.typec_switch); 1112 1099 ctx->typec.typec_switch = NULL; 1100 + fwnode_handle_put(ctx->switch_node); 1113 1101 } 1114 1102 } 1115 1103 ··· 1118 1104 struct device *dev) 1119 1105 { 1120 1106 int ret; 1121 - struct device_node *node; 1122 1107 1123 - node = of_get_child_by_name(dev->of_node, "orientation_switch"); 1124 - if (!node) 1108 + ctx->switch_node = device_get_named_child_node(dev, "orientation_switch"); 1109 + if (!ctx->switch_node) 1125 1110 return 0; 1126 1111 1127 - ret = anx7411_register_switch(ctx, dev, &node->fwnode); 1112 + ret = anx7411_register_switch(ctx, dev, ctx->switch_node); 1128 1113 if (ret) { 1129 1114 dev_err(dev, "failed register switch"); 1115 + fwnode_handle_put(ctx->switch_node); 1130 1116 return ret; 1131 1117 } 1132 1118 1133 - node = of_get_child_by_name(dev->of_node, "mode_switch"); 1134 - if (!node) { 1119 + ctx->mux_node = device_get_named_child_node(dev, "mode_switch"); 1120 + if (!ctx->mux_node) { 1135 1121 dev_err(dev, "no typec mux exist"); 1136 1122 ret = -ENODEV; 1137 1123 goto unregister_switch; 1138 1124 } 1139 1125 1140 - ret = anx7411_register_mux(ctx, dev, &node->fwnode); 1126 + ret = anx7411_register_mux(ctx, dev, ctx->mux_node); 1141 1127 if (ret) { 1142 1128 dev_err(dev, "failed register mode switch"); 1129 + fwnode_handle_put(ctx->mux_node); 1143 1130 ret = -ENODEV; 1144 1131 goto unregister_switch; 1145 1132 } ··· 1169 1154 ret = fwnode_property_read_string(fwnode, "power-role", &buf); 1170 1155 if (ret) { 1171 1156 dev_err(dev, "power-role not found: %d\n", ret); 1172 - return ret; 1157 + goto put_fwnode; 1173 1158 } 1174 1159 1175 1160 ret = typec_find_port_power_role(buf); 1176 1161 if (ret < 0) 1177 - return ret; 1162 + goto put_fwnode; 1178 1163 cap->type = ret; 1179 1164 1180 1165 ret = fwnode_property_read_string(fwnode, "data-role", &buf); 1181 1166 if (ret) { 1182 1167 dev_err(dev, "data-role not found: %d\n", ret); 1183 - return ret; 1168 + goto put_fwnode; 1184 1169 } 1185 1170 1186 1171 ret = typec_find_port_data_role(buf); 1187 1172 if (ret < 0) 1188 - return ret; 1173 + goto put_fwnode; 1189 1174 cap->data = ret; 1190 1175 1191 1176 ret = fwnode_property_read_string(fwnode, "try-power-role", &buf); 1192 1177 if (ret) { 1193 1178 dev_err(dev, "try-power-role not found: %d\n", ret); 1194 - return ret; 1179 + goto put_fwnode; 1195 1180 } 1196 1181 1197 1182 ret = typec_find_power_role(buf); 1198 1183 if (ret < 0) 1199 - return ret; 1184 + goto put_fwnode; 1200 1185 cap->prefer_role = ret; 1201 1186 1202 1187 /* Get source pdos */ ··· 1208 1193 typecp->src_pdo_nr); 1209 1194 if (ret < 0) { 1210 1195 dev_err(dev, "source cap validate failed: %d\n", ret); 1211 - return -EINVAL; 1196 + goto put_fwnode; 1212 1197 } 1213 1198 1214 1199 typecp->caps_flags |= HAS_SOURCE_CAP; ··· 1222 1207 typecp->sink_pdo_nr); 1223 1208 if (ret < 0) { 1224 1209 dev_err(dev, "sink cap validate failed: %d\n", ret); 1225 - return -EINVAL; 1210 + goto put_fwnode; 1226 1211 } 1227 1212 1228 1213 for (i = 0; i < typecp->sink_pdo_nr; i++) { ··· 1266 1251 ret = PTR_ERR(ctx->typec.port); 1267 1252 ctx->typec.port = NULL; 1268 1253 dev_err(dev, "Failed to register type c port %d\n", ret); 1269 - return ret; 1254 + goto put_usb_role_switch; 1270 1255 } 1271 1256 1272 1257 typec_port_register_altmodes(ctx->typec.port, NULL, ctx, 1273 1258 ctx->typec.port_amode, 1274 1259 MAX_ALTMODE); 1275 1260 return 0; 1261 + 1262 + put_usb_role_switch: 1263 + if (ctx->typec.role_sw) 1264 + usb_role_switch_put(ctx->typec.role_sw); 1265 + put_fwnode: 1266 + fwnode_handle_put(fwnode); 1267 + 1268 + return ret; 1276 1269 } 1277 1270 1278 1271 static int anx7411_typec_check_connection(struct anx7411_data *ctx) ··· 1546 1523 destroy_workqueue(plat->workqueue); 1547 1524 1548 1525 free_typec_port: 1549 - typec_unregister_port(plat->typec.port); 1550 - anx7411_port_unregister_altmodes(plat->typec.port_amode); 1526 + anx7411_port_unregister(&plat->typec); 1551 1527 1552 1528 free_typec_switch: 1553 1529 anx7411_unregister_switch(plat); ··· 1570 1548 1571 1549 i2c_unregister_device(plat->spi_client); 1572 1550 1573 - if (plat->typec.role_sw) 1574 - usb_role_switch_put(plat->typec.role_sw); 1575 - 1576 1551 anx7411_unregister_mux(plat); 1577 1552 1578 1553 anx7411_unregister_switch(plat); 1579 1554 1580 - if (plat->typec.port) 1581 - typec_unregister_port(plat->typec.port); 1582 - 1583 - anx7411_port_unregister_altmodes(plat->typec.port_amode); 1555 + anx7411_port_unregister(&plat->typec); 1584 1556 } 1585 1557 1586 1558 static const struct i2c_device_id anx7411_id[] = {
+6 -3
drivers/usb/typec/ucsi/ucsi.c
··· 46 46 ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci)); 47 47 48 48 if (cci & UCSI_CCI_ACK_COMPLETE && 49 - test_bit(ACK_PENDING, &ucsi->flags)) 49 + test_and_clear_bit(ACK_PENDING, &ucsi->flags)) 50 50 complete(&ucsi->complete); 51 51 52 52 if (cci & UCSI_CCI_COMMAND_COMPLETE && 53 - test_bit(COMMAND_PENDING, &ucsi->flags)) 53 + test_and_clear_bit(COMMAND_PENDING, &ucsi->flags)) 54 54 complete(&ucsi->complete); 55 55 } 56 56 EXPORT_SYMBOL_GPL(ucsi_notify_common); ··· 64 64 set_bit(ACK_PENDING, &ucsi->flags); 65 65 else 66 66 set_bit(COMMAND_PENDING, &ucsi->flags); 67 + 68 + reinit_completion(&ucsi->complete); 67 69 68 70 ret = ucsi->ops->async_control(ucsi, command); 69 71 if (ret) ··· 653 651 static int ucsi_get_connector_status(struct ucsi_connector *con, bool conn_ack) 654 652 { 655 653 u64 command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num); 656 - size_t size = min(UCSI_GET_CONNECTOR_STATUS_SIZE, UCSI_MAX_DATA_LENGTH(con->ucsi)); 654 + size_t size = min(sizeof(con->status), 655 + UCSI_MAX_DATA_LENGTH(con->ucsi)); 657 656 int ret; 658 657 659 658 ret = ucsi_send_command_common(con->ucsi, command, &con->status, size, conn_ack);
+11 -5
fs/btrfs/bio.c
··· 358 358 INIT_WORK(&bbio->end_io_work, btrfs_end_bio_work); 359 359 queue_work(btrfs_end_io_wq(fs_info, bio), &bbio->end_io_work); 360 360 } else { 361 - if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status) 361 + if (bio_is_zone_append(bio) && !bio->bi_status) 362 362 btrfs_record_physical_zoned(bbio); 363 363 btrfs_bio_end_io(bbio, bbio->bio.bi_status); 364 364 } ··· 401 401 else 402 402 bio->bi_status = BLK_STS_OK; 403 403 404 - if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status) 404 + if (bio_is_zone_append(bio) && !bio->bi_status) 405 405 stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT; 406 406 407 407 btrfs_bio_end_io(bbio, bbio->bio.bi_status); ··· 415 415 if (bio->bi_status) { 416 416 atomic_inc(&stripe->bioc->error); 417 417 btrfs_log_dev_io_error(bio, stripe->dev); 418 - } else if (bio_op(bio) == REQ_OP_ZONE_APPEND) { 418 + } else if (bio_is_zone_append(bio)) { 419 419 stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT; 420 420 } 421 421 ··· 652 652 map_length = min(map_length, bbio->fs_info->max_zone_append_size); 653 653 sector_offset = bio_split_rw_at(&bbio->bio, &bbio->fs_info->limits, 654 654 &nr_segs, map_length); 655 - if (sector_offset) 656 - return sector_offset << SECTOR_SHIFT; 655 + if (sector_offset) { 656 + /* 657 + * bio_split_rw_at() could split at a size smaller than our 658 + * sectorsize and thus cause unaligned I/Os. Fix that by 659 + * always rounding down to the nearest boundary. 660 + */ 661 + return ALIGN_DOWN(sector_offset << SECTOR_SHIFT, bbio->fs_info->sectorsize); 662 + } 657 663 return map_length; 658 664 } 659 665
+19
fs/btrfs/ctree.h
··· 371 371 } 372 372 373 373 /* 374 + * Return the generation this root started with. 375 + * 376 + * Every normal root that is created with root->root_key.offset set to it's 377 + * originating generation. If it is a snapshot it is the generation when the 378 + * snapshot was created. 379 + * 380 + * However for TREE_RELOC roots root_key.offset is the objectid of the owning 381 + * tree root. Thankfully we copy the root item of the owning tree root, which 382 + * has it's last_snapshot set to what we would have root_key.offset set to, so 383 + * return that if this is a TREE_RELOC root. 384 + */ 385 + static inline u64 btrfs_root_origin_generation(const struct btrfs_root *root) 386 + { 387 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 388 + return btrfs_root_last_snapshot(&root->root_item); 389 + return root->root_key.offset; 390 + } 391 + 392 + /* 374 393 * Structure that conveys information about an extent that is going to replace 375 394 * all the extents in a file range. 376 395 */
+3 -3
fs/btrfs/extent-tree.c
··· 5285 5285 * reference to it. 5286 5286 */ 5287 5287 generation = btrfs_node_ptr_generation(eb, slot); 5288 - if (!wc->update_ref || generation <= root->root_key.offset) 5288 + if (!wc->update_ref || generation <= btrfs_root_origin_generation(root)) 5289 5289 return false; 5290 5290 5291 5291 /* ··· 5340 5340 goto reada; 5341 5341 5342 5342 if (wc->stage == UPDATE_BACKREF && 5343 - generation <= root->root_key.offset) 5343 + generation <= btrfs_root_origin_generation(root)) 5344 5344 continue; 5345 5345 5346 5346 /* We don't lock the tree block, it's OK to be racy here */ ··· 5683 5683 * for the subtree 5684 5684 */ 5685 5685 if (wc->stage == UPDATE_BACKREF && 5686 - generation <= root->root_key.offset) { 5686 + generation <= btrfs_root_origin_generation(root)) { 5687 5687 wc->lookup_info = 1; 5688 5688 return 1; 5689 5689 }
+26 -1
fs/btrfs/tree-checker.c
··· 1527 1527 dref_offset, fs_info->sectorsize); 1528 1528 return -EUCLEAN; 1529 1529 } 1530 + if (unlikely(btrfs_extent_data_ref_count(leaf, dref) == 0)) { 1531 + extent_err(leaf, slot, 1532 + "invalid data ref count, should have non-zero value"); 1533 + return -EUCLEAN; 1534 + } 1530 1535 inline_refs += btrfs_extent_data_ref_count(leaf, dref); 1531 1536 break; 1532 1537 /* Contains parent bytenr and ref count */ ··· 1542 1537 extent_err(leaf, slot, 1543 1538 "invalid data parent bytenr, have %llu expect aligned to %u", 1544 1539 inline_offset, fs_info->sectorsize); 1540 + return -EUCLEAN; 1541 + } 1542 + if (unlikely(btrfs_shared_data_ref_count(leaf, sref) == 0)) { 1543 + extent_err(leaf, slot, 1544 + "invalid shared data ref count, should have non-zero value"); 1545 1545 return -EUCLEAN; 1546 1546 } 1547 1547 inline_refs += btrfs_shared_data_ref_count(leaf, sref); ··· 1621 1611 { 1622 1612 u32 expect_item_size = 0; 1623 1613 1624 - if (key->type == BTRFS_SHARED_DATA_REF_KEY) 1614 + if (key->type == BTRFS_SHARED_DATA_REF_KEY) { 1615 + struct btrfs_shared_data_ref *sref; 1616 + 1617 + sref = btrfs_item_ptr(leaf, slot, struct btrfs_shared_data_ref); 1618 + if (unlikely(btrfs_shared_data_ref_count(leaf, sref) == 0)) { 1619 + extent_err(leaf, slot, 1620 + "invalid shared data backref count, should have non-zero value"); 1621 + return -EUCLEAN; 1622 + } 1623 + 1625 1624 expect_item_size = sizeof(struct btrfs_shared_data_ref); 1625 + } 1626 1626 1627 1627 if (unlikely(btrfs_item_size(leaf, slot) != expect_item_size)) { 1628 1628 generic_err(leaf, slot, ··· 1707 1687 extent_err(leaf, slot, 1708 1688 "invalid extent data backref offset, have %llu expect aligned to %u", 1709 1689 offset, leaf->fs_info->sectorsize); 1690 + return -EUCLEAN; 1691 + } 1692 + if (unlikely(btrfs_extent_data_ref_count(leaf, dref) == 0)) { 1693 + extent_err(leaf, slot, 1694 + "invalid extent data backref count, should have non-zero value"); 1710 1695 return -EUCLEAN; 1711 1696 } 1712 1697 }
+1 -1
fs/efivarfs/inode.c
··· 51 51 * 52 52 * VariableName-12345678-1234-1234-1234-1234567891bc 53 53 */ 54 - bool efivarfs_valid_name(const char *str, int len) 54 + static bool efivarfs_valid_name(const char *str, int len) 55 55 { 56 56 const char *s = str + len - EFI_VARIABLE_GUID_LEN; 57 57
-1
fs/efivarfs/internal.h
··· 60 60 61 61 extern const struct file_operations efivarfs_file_operations; 62 62 extern const struct inode_operations efivarfs_dir_inode_operations; 63 - extern bool efivarfs_valid_name(const char *str, int len); 64 63 extern struct inode *efivarfs_get_inode(struct super_block *sb, 65 64 const struct inode *dir, int mode, dev_t dev, 66 65 bool is_removable);
-3
fs/efivarfs/super.c
··· 144 144 const unsigned char *s = qstr->name; 145 145 unsigned int len = qstr->len; 146 146 147 - if (!efivarfs_valid_name(s, len)) 148 - return -EINVAL; 149 - 150 147 while (len-- > EFI_VARIABLE_GUID_LEN) 151 148 hash = partial_name_hash(*s++, hash); 152 149
+13 -23
fs/erofs/data.c
··· 56 56 57 57 buf->file = NULL; 58 58 if (erofs_is_fileio_mode(sbi)) { 59 - buf->file = sbi->fdev; /* some fs like FUSE needs it */ 59 + buf->file = sbi->dif0.file; /* some fs like FUSE needs it */ 60 60 buf->mapping = buf->file->f_mapping; 61 61 } else if (erofs_is_fscache_mode(sb)) 62 - buf->mapping = sbi->s_fscache->inode->i_mapping; 62 + buf->mapping = sbi->dif0.fscache->inode->i_mapping; 63 63 else 64 64 buf->mapping = sb->s_bdev->bd_mapping; 65 65 } ··· 179 179 } 180 180 181 181 static void erofs_fill_from_devinfo(struct erofs_map_dev *map, 182 - struct erofs_device_info *dif) 182 + struct super_block *sb, struct erofs_device_info *dif) 183 183 { 184 + map->m_sb = sb; 185 + map->m_dif = dif; 184 186 map->m_bdev = NULL; 185 - map->m_fp = NULL; 186 - if (dif->file) { 187 - if (S_ISBLK(file_inode(dif->file)->i_mode)) 188 - map->m_bdev = file_bdev(dif->file); 189 - else 190 - map->m_fp = dif->file; 191 - } 192 - map->m_daxdev = dif->dax_dev; 193 - map->m_dax_part_off = dif->dax_part_off; 194 - map->m_fscache = dif->fscache; 187 + if (dif->file && S_ISBLK(file_inode(dif->file)->i_mode)) 188 + map->m_bdev = file_bdev(dif->file); 195 189 } 196 190 197 191 int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) ··· 195 201 erofs_off_t startoff, length; 196 202 int id; 197 203 198 - map->m_bdev = sb->s_bdev; 199 - map->m_daxdev = EROFS_SB(sb)->dax_dev; 200 - map->m_dax_part_off = EROFS_SB(sb)->dax_part_off; 201 - map->m_fscache = EROFS_SB(sb)->s_fscache; 202 - map->m_fp = EROFS_SB(sb)->fdev; 203 - 204 + erofs_fill_from_devinfo(map, sb, &EROFS_SB(sb)->dif0); 205 + map->m_bdev = sb->s_bdev; /* use s_bdev for the primary device */ 204 206 if (map->m_deviceid) { 205 207 down_read(&devs->rwsem); 206 208 dif = idr_find(&devs->tree, map->m_deviceid - 1); ··· 209 219 up_read(&devs->rwsem); 210 220 return 0; 211 221 } 212 - erofs_fill_from_devinfo(map, dif); 222 + erofs_fill_from_devinfo(map, sb, dif); 213 223 up_read(&devs->rwsem); 214 224 } else if (devs->extra_devices && !devs->flatdev) { 215 225 down_read(&devs->rwsem); ··· 222 232 if (map->m_pa >= startoff && 223 233 map->m_pa < startoff + length) { 224 234 map->m_pa -= startoff; 225 - erofs_fill_from_devinfo(map, dif); 235 + erofs_fill_from_devinfo(map, sb, dif); 226 236 break; 227 237 } 228 238 } ··· 292 302 293 303 iomap->offset = map.m_la; 294 304 if (flags & IOMAP_DAX) 295 - iomap->dax_dev = mdev.m_daxdev; 305 + iomap->dax_dev = mdev.m_dif->dax_dev; 296 306 else 297 307 iomap->bdev = mdev.m_bdev; 298 308 iomap->length = map.m_llen; ··· 321 331 iomap->type = IOMAP_MAPPED; 322 332 iomap->addr = mdev.m_pa; 323 333 if (flags & IOMAP_DAX) 324 - iomap->addr += mdev.m_dax_part_off; 334 + iomap->addr += mdev.m_dif->dax_part_off; 325 335 } 326 336 return 0; 327 337 }
+6 -3
fs/erofs/fileio.c
··· 9 9 struct bio_vec bvecs[BIO_MAX_VECS]; 10 10 struct bio bio; 11 11 struct kiocb iocb; 12 + struct super_block *sb; 12 13 }; 13 14 14 15 struct erofs_fileio { ··· 53 52 rq->iocb.ki_pos = rq->bio.bi_iter.bi_sector << SECTOR_SHIFT; 54 53 rq->iocb.ki_ioprio = get_current_ioprio(); 55 54 rq->iocb.ki_complete = erofs_fileio_ki_complete; 56 - rq->iocb.ki_flags = (rq->iocb.ki_filp->f_mode & FMODE_CAN_ODIRECT) ? 57 - IOCB_DIRECT : 0; 55 + if (test_opt(&EROFS_SB(rq->sb)->opt, DIRECT_IO) && 56 + rq->iocb.ki_filp->f_mode & FMODE_CAN_ODIRECT) 57 + rq->iocb.ki_flags = IOCB_DIRECT; 58 58 iov_iter_bvec(&iter, ITER_DEST, rq->bvecs, rq->bio.bi_vcnt, 59 59 rq->bio.bi_iter.bi_size); 60 60 ret = vfs_iocb_iter_read(rq->iocb.ki_filp, &rq->iocb, &iter); ··· 69 67 GFP_KERNEL | __GFP_NOFAIL); 70 68 71 69 bio_init(&rq->bio, NULL, rq->bvecs, BIO_MAX_VECS, REQ_OP_READ); 72 - rq->iocb.ki_filp = mdev->m_fp; 70 + rq->iocb.ki_filp = mdev->m_dif->file; 71 + rq->sb = mdev->m_sb; 73 72 return rq; 74 73 } 75 74
+5 -5
fs/erofs/fscache.c
··· 198 198 199 199 io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL); 200 200 bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ); 201 - io->io.private = mdev->m_fscache->cookie; 201 + io->io.private = mdev->m_dif->fscache->cookie; 202 202 io->io.end_io = erofs_fscache_bio_endio; 203 203 refcount_set(&io->io.ref, 1); 204 204 return &io->bio; ··· 316 316 if (!io) 317 317 return -ENOMEM; 318 318 iov_iter_xarray(&io->iter, ITER_DEST, &mapping->i_pages, pos, count); 319 - ret = erofs_fscache_read_io_async(mdev.m_fscache->cookie, 319 + ret = erofs_fscache_read_io_async(mdev.m_dif->fscache->cookie, 320 320 mdev.m_pa + (pos - map.m_la), io); 321 321 erofs_fscache_req_io_put(io); 322 322 ··· 657 657 if (IS_ERR(fscache)) 658 658 return PTR_ERR(fscache); 659 659 660 - sbi->s_fscache = fscache; 660 + sbi->dif0.fscache = fscache; 661 661 return 0; 662 662 } 663 663 ··· 665 665 { 666 666 struct erofs_sb_info *sbi = EROFS_SB(sb); 667 667 668 - erofs_fscache_unregister_cookie(sbi->s_fscache); 668 + erofs_fscache_unregister_cookie(sbi->dif0.fscache); 669 669 670 670 if (sbi->domain) 671 671 erofs_fscache_domain_put(sbi->domain); 672 672 else 673 673 fscache_relinquish_volume(sbi->volume, NULL, false); 674 674 675 - sbi->s_fscache = NULL; 675 + sbi->dif0.fscache = NULL; 676 676 sbi->volume = NULL; 677 677 sbi->domain = NULL; 678 678 }
+5 -10
fs/erofs/internal.h
··· 107 107 }; 108 108 109 109 struct erofs_sb_info { 110 + struct erofs_device_info dif0; 110 111 struct erofs_mount_opts opt; /* options */ 111 112 #ifdef CONFIG_EROFS_FS_ZIP 112 113 /* list for all registered superblocks, mainly for shrinker */ ··· 125 124 126 125 struct erofs_sb_lz4_info lz4; 127 126 #endif /* CONFIG_EROFS_FS_ZIP */ 128 - struct file *fdev; 129 127 struct inode *packed_inode; 130 128 struct erofs_dev_context *devs; 131 - struct dax_device *dax_dev; 132 - u64 dax_part_off; 133 129 u64 total_blocks; 134 - u32 primarydevice_blocks; 135 130 136 131 u32 meta_blkaddr; 137 132 #ifdef CONFIG_EROFS_FS_XATTR ··· 163 166 164 167 /* fscache support */ 165 168 struct fscache_volume *volume; 166 - struct erofs_fscache *s_fscache; 167 169 struct erofs_domain *domain; 168 170 char *fsid; 169 171 char *domain_id; ··· 176 180 #define EROFS_MOUNT_POSIX_ACL 0x00000020 177 181 #define EROFS_MOUNT_DAX_ALWAYS 0x00000040 178 182 #define EROFS_MOUNT_DAX_NEVER 0x00000080 183 + #define EROFS_MOUNT_DIRECT_IO 0x00000100 179 184 180 185 #define clear_opt(opt, option) ((opt)->mount_opt &= ~EROFS_MOUNT_##option) 181 186 #define set_opt(opt, option) ((opt)->mount_opt |= EROFS_MOUNT_##option) ··· 184 187 185 188 static inline bool erofs_is_fileio_mode(struct erofs_sb_info *sbi) 186 189 { 187 - return IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && sbi->fdev; 190 + return IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && sbi->dif0.file; 188 191 } 189 192 190 193 static inline bool erofs_is_fscache_mode(struct super_block *sb) ··· 354 357 }; 355 358 356 359 struct erofs_map_dev { 357 - struct erofs_fscache *m_fscache; 360 + struct super_block *m_sb; 361 + struct erofs_device_info *m_dif; 358 362 struct block_device *m_bdev; 359 - struct dax_device *m_daxdev; 360 - struct file *m_fp; 361 - u64 m_dax_part_off; 362 363 363 364 erofs_off_t m_pa; 364 365 unsigned int m_deviceid;
+44 -36
fs/erofs/super.c
··· 203 203 struct erofs_device_info *dif; 204 204 int id, err = 0; 205 205 206 - sbi->total_blocks = sbi->primarydevice_blocks; 206 + sbi->total_blocks = sbi->dif0.blocks; 207 207 if (!erofs_sb_has_device_table(sbi)) 208 208 ondisk_extradevs = 0; 209 209 else ··· 307 307 sbi->sb_size); 308 308 goto out; 309 309 } 310 - sbi->primarydevice_blocks = le32_to_cpu(dsb->blocks); 310 + sbi->dif0.blocks = le32_to_cpu(dsb->blocks); 311 311 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr); 312 312 #ifdef CONFIG_EROFS_FS_XATTR 313 313 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr); ··· 364 364 } 365 365 366 366 enum { 367 - Opt_user_xattr, 368 - Opt_acl, 369 - Opt_cache_strategy, 370 - Opt_dax, 371 - Opt_dax_enum, 372 - Opt_device, 373 - Opt_fsid, 374 - Opt_domain_id, 367 + Opt_user_xattr, Opt_acl, Opt_cache_strategy, Opt_dax, Opt_dax_enum, 368 + Opt_device, Opt_fsid, Opt_domain_id, Opt_directio, 375 369 Opt_err 376 370 }; 377 371 ··· 392 398 fsparam_string("device", Opt_device), 393 399 fsparam_string("fsid", Opt_fsid), 394 400 fsparam_string("domain_id", Opt_domain_id), 401 + fsparam_flag_no("directio", Opt_directio), 395 402 {} 396 403 }; 397 404 ··· 506 511 errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 507 512 break; 508 513 #endif 514 + case Opt_directio: 515 + #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 516 + if (result.boolean) 517 + set_opt(&sbi->opt, DIRECT_IO); 518 + else 519 + clear_opt(&sbi->opt, DIRECT_IO); 520 + #else 521 + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); 522 + #endif 523 + break; 509 524 default: 510 525 return -ENOPARAM; 511 526 } ··· 607 602 return -EINVAL; 608 603 } 609 604 610 - sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev, 611 - &sbi->dax_part_off, 612 - NULL, NULL); 605 + sbi->dif0.dax_dev = fs_dax_get_by_bdev(sb->s_bdev, 606 + &sbi->dif0.dax_part_off, NULL, NULL); 613 607 } 614 608 615 609 err = erofs_read_superblock(sb); ··· 631 627 } 632 628 633 629 if (test_opt(&sbi->opt, DAX_ALWAYS)) { 634 - if (!sbi->dax_dev) { 630 + if (!sbi->dif0.dax_dev) { 635 631 errorfc(fc, "DAX unsupported by block device. Turning off DAX."); 636 632 clear_opt(&sbi->opt, DAX_ALWAYS); 637 633 } else if (sbi->blkszbits != PAGE_SHIFT) { ··· 707 703 GET_TREE_BDEV_QUIET_LOOKUP : 0); 708 704 #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE 709 705 if (ret == -ENOTBLK) { 706 + struct file *file; 707 + 710 708 if (!fc->source) 711 709 return invalf(fc, "No source specified"); 712 - sbi->fdev = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0); 713 - if (IS_ERR(sbi->fdev)) 714 - return PTR_ERR(sbi->fdev); 710 + file = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0); 711 + if (IS_ERR(file)) 712 + return PTR_ERR(file); 713 + sbi->dif0.file = file; 715 714 716 - if (S_ISREG(file_inode(sbi->fdev)->i_mode) && 717 - sbi->fdev->f_mapping->a_ops->read_folio) 715 + if (S_ISREG(file_inode(sbi->dif0.file)->i_mode) && 716 + sbi->dif0.file->f_mapping->a_ops->read_folio) 718 717 return get_tree_nodev(fc, erofs_fc_fill_super); 719 - fput(sbi->fdev); 720 718 } 721 719 #endif 722 720 return ret; ··· 769 763 kfree(devs); 770 764 } 771 765 766 + static void erofs_sb_free(struct erofs_sb_info *sbi) 767 + { 768 + erofs_free_dev_context(sbi->devs); 769 + kfree(sbi->fsid); 770 + kfree(sbi->domain_id); 771 + if (sbi->dif0.file) 772 + fput(sbi->dif0.file); 773 + kfree(sbi); 774 + } 775 + 772 776 static void erofs_fc_free(struct fs_context *fc) 773 777 { 774 778 struct erofs_sb_info *sbi = fc->s_fs_info; 775 779 776 - if (!sbi) 777 - return; 778 - 779 - erofs_free_dev_context(sbi->devs); 780 - kfree(sbi->fsid); 781 - kfree(sbi->domain_id); 782 - kfree(sbi); 780 + if (sbi) /* free here if an error occurs before transferring to sb */ 781 + erofs_sb_free(sbi); 783 782 } 784 783 785 784 static const struct fs_context_operations erofs_context_ops = { ··· 820 809 { 821 810 struct erofs_sb_info *sbi = EROFS_SB(sb); 822 811 823 - if ((IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) || sbi->fdev) 812 + if ((IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) || 813 + sbi->dif0.file) 824 814 kill_anon_super(sb); 825 815 else 826 816 kill_block_super(sb); 827 - 828 - erofs_free_dev_context(sbi->devs); 829 - fs_put_dax(sbi->dax_dev, NULL); 817 + fs_put_dax(sbi->dif0.dax_dev, NULL); 830 818 erofs_fscache_unregister_fs(sb); 831 - kfree(sbi->fsid); 832 - kfree(sbi->domain_id); 833 - if (sbi->fdev) 834 - fput(sbi->fdev); 835 - kfree(sbi); 819 + erofs_sb_free(sbi); 836 820 sb->s_fs_info = NULL; 837 821 } 838 822 ··· 953 947 seq_puts(seq, ",dax=always"); 954 948 if (test_opt(opt, DAX_NEVER)) 955 949 seq_puts(seq, ",dax=never"); 950 + if (erofs_is_fileio_mode(sbi) && test_opt(opt, DIRECT_IO)) 951 + seq_puts(seq, ",directio"); 956 952 #ifdef CONFIG_EROFS_FS_ONDEMAND 957 953 if (sbi->fsid) 958 954 seq_printf(seq, ",fsid=%s", sbi->fsid);
+2 -2
fs/erofs/zdata.c
··· 1792 1792 erofs_fscache_submit_bio(bio); 1793 1793 else 1794 1794 submit_bio(bio); 1795 - if (memstall) 1796 - psi_memstall_leave(&pflags); 1797 1795 } 1796 + if (memstall) 1797 + psi_memstall_leave(&pflags); 1798 1798 1799 1799 /* 1800 1800 * although background is preferred, no one is pending for submission.
+4 -3
fs/erofs/zutil.c
··· 230 230 struct erofs_sb_info *const sbi = EROFS_SB(sb); 231 231 232 232 mutex_lock(&sbi->umount_mutex); 233 - /* clean up all remaining pclusters in memory */ 234 - z_erofs_shrink_scan(sbi, ~0UL); 235 - 233 + while (!xa_empty(&sbi->managed_pslots)) { 234 + z_erofs_shrink_scan(sbi, ~0UL); 235 + cond_resched(); 236 + } 236 237 spin_lock(&erofs_sb_list_lock); 237 238 list_del(&sbi->list); 238 239 spin_unlock(&erofs_sb_list_lock);
+1
fs/smb/client/cifsfs.c
··· 2043 2043 destroy_workqueue(decrypt_wq); 2044 2044 destroy_workqueue(fileinfo_put_wq); 2045 2045 destroy_workqueue(serverclose_wq); 2046 + destroy_workqueue(cfid_put_wq); 2046 2047 destroy_workqueue(cifsiod_wq); 2047 2048 cifs_proc_clean(); 2048 2049 }
+4 -1
fs/smb/client/inode.c
··· 1947 1947 goto unlink_out; 1948 1948 } 1949 1949 1950 + netfs_wait_for_outstanding_io(inode); 1950 1951 cifs_close_deferred_file_under_dentry(tcon, full_path); 1951 1952 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 1952 1953 if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP & ··· 2465 2464 } 2466 2465 2467 2466 cifs_close_deferred_file_under_dentry(tcon, from_name); 2468 - if (d_inode(target_dentry) != NULL) 2467 + if (d_inode(target_dentry) != NULL) { 2468 + netfs_wait_for_outstanding_io(d_inode(target_dentry)); 2469 2469 cifs_close_deferred_file_under_dentry(tcon, to_name); 2470 + } 2470 2471 2471 2472 rc = cifs_do_rename(xid, source_dentry, from_name, target_dentry, 2472 2473 to_name);
+1 -1
fs/smb/client/reparse.c
··· 676 676 return -ENOMEM; 677 677 symname_utf16_len = utf8s_to_utf16s(buf->PathBuffer, symname_utf8_len, 678 678 UTF16_LITTLE_ENDIAN, 679 - symname_utf16, symname_utf8_len * 2); 679 + (wchar_t *) symname_utf16, symname_utf8_len * 2); 680 680 if (symname_utf16_len < 0) { 681 681 kfree(symname_utf16); 682 682 return symname_utf16_len;
+2 -2
fs/smb/client/sess.c
··· 488 488 489 489 if (iface->sockaddr.ss_family == AF_INET) 490 490 cifs_dbg(FYI, "adding channel to ses %p (speed:%zu bps rdma:%s ip:%pI4)\n", 491 - ses, iface->speed, iface->rdma_capable ? "yes" : "no", 491 + ses, iface->speed, str_yes_no(iface->rdma_capable), 492 492 &ipv4->sin_addr); 493 493 else 494 494 cifs_dbg(FYI, "adding channel to ses %p (speed:%zu bps rdma:%s ip:%pI6)\n", 495 - ses, iface->speed, iface->rdma_capable ? "yes" : "no", 495 + ses, iface->speed, str_yes_no(iface->rdma_capable), 496 496 &ipv6->sin6_addr); 497 497 498 498 /*
+2
fs/smb/server/auth.c
··· 1016 1016 1017 1017 ses_enc_key = enc ? sess->smb3encryptionkey : 1018 1018 sess->smb3decryptionkey; 1019 + if (enc) 1020 + ksmbd_user_session_get(sess); 1019 1021 memcpy(key, ses_enc_key, SMB3_ENC_DEC_KEY_SIZE); 1020 1022 1021 1023 return 0;
+14 -4
fs/smb/server/connection.c
··· 70 70 atomic_set(&conn->req_running, 0); 71 71 atomic_set(&conn->r_count, 0); 72 72 atomic_set(&conn->refcnt, 1); 73 - atomic_set(&conn->mux_smb_requests, 0); 74 73 conn->total_credits = 1; 75 74 conn->outstanding_credits = 0; 76 75 ··· 119 120 if (conn->ops->get_cmd_val(work) != SMB2_CANCEL_HE) 120 121 requests_queue = &conn->requests; 121 122 123 + atomic_inc(&conn->req_running); 122 124 if (requests_queue) { 123 - atomic_inc(&conn->req_running); 124 125 spin_lock(&conn->request_lock); 125 126 list_add_tail(&work->request_entry, requests_queue); 126 127 spin_unlock(&conn->request_lock); ··· 131 132 { 132 133 struct ksmbd_conn *conn = work->conn; 133 134 135 + atomic_dec(&conn->req_running); 136 + if (waitqueue_active(&conn->req_running_q)) 137 + wake_up(&conn->req_running_q); 138 + 134 139 if (list_empty(&work->request_entry) && 135 140 list_empty(&work->async_request_entry)) 136 141 return; 137 142 138 - atomic_dec(&conn->req_running); 139 143 spin_lock(&conn->request_lock); 140 144 list_del_init(&work->request_entry); 141 145 spin_unlock(&conn->request_lock); ··· 310 308 { 311 309 struct ksmbd_conn *conn = (struct ksmbd_conn *)p; 312 310 struct ksmbd_transport *t = conn->transport; 313 - unsigned int pdu_size, max_allowed_pdu_size; 311 + unsigned int pdu_size, max_allowed_pdu_size, max_req; 314 312 char hdr_buf[4] = {0,}; 315 313 int size; 316 314 ··· 320 318 if (t->ops->prepare && t->ops->prepare(t)) 321 319 goto out; 322 320 321 + max_req = server_conf.max_inflight_req; 323 322 conn->last_active = jiffies; 324 323 set_freezable(); 325 324 while (ksmbd_conn_alive(conn)) { ··· 329 326 330 327 kvfree(conn->request_buf); 331 328 conn->request_buf = NULL; 329 + 330 + recheck: 331 + if (atomic_read(&conn->req_running) + 1 > max_req) { 332 + wait_event_interruptible(conn->req_running_q, 333 + atomic_read(&conn->req_running) < max_req); 334 + goto recheck; 335 + } 332 336 333 337 size = t->ops->read(t, hdr_buf, sizeof(hdr_buf), -1); 334 338 if (size != sizeof(hdr_buf))
-1
fs/smb/server/connection.h
··· 107 107 __le16 signing_algorithm; 108 108 bool binding; 109 109 atomic_t refcnt; 110 - atomic_t mux_smb_requests; 111 110 }; 112 111 113 112 struct ksmbd_conn_ops {
+5 -1
fs/smb/server/mgmt/user_session.c
··· 263 263 264 264 down_read(&conn->session_lock); 265 265 sess = xa_load(&conn->sessions, id); 266 - if (sess) 266 + if (sess) { 267 267 sess->last_active = jiffies; 268 + ksmbd_user_session_get(sess); 269 + } 268 270 up_read(&conn->session_lock); 269 271 return sess; 270 272 } ··· 277 275 278 276 down_read(&sessions_table_lock); 279 277 sess = __session_lookup(id); 278 + if (sess) 279 + ksmbd_user_session_get(sess); 280 280 up_read(&sessions_table_lock); 281 281 282 282 return sess;
+3 -8
fs/smb/server/server.c
··· 241 241 if (work->tcon) 242 242 ksmbd_tree_connect_put(work->tcon); 243 243 smb3_preauth_hash_rsp(work); 244 - if (work->sess) 245 - ksmbd_user_session_put(work->sess); 246 244 if (work->sess && work->sess->enc && work->encrypted && 247 245 conn->ops->encrypt_resp) { 248 246 rc = conn->ops->encrypt_resp(work); 249 247 if (rc < 0) 250 248 conn->ops->set_rsp_status(work, STATUS_DATA_ERROR); 251 249 } 250 + if (work->sess) 251 + ksmbd_user_session_put(work->sess); 252 252 253 253 ksmbd_conn_write(work); 254 254 } ··· 270 270 271 271 ksmbd_conn_try_dequeue_request(work); 272 272 ksmbd_free_work_struct(work); 273 - atomic_dec(&conn->mux_smb_requests); 274 273 /* 275 274 * Checking waitqueue to dropping pending requests on 276 275 * disconnection. waitqueue_active is safe because it ··· 298 299 err = ksmbd_init_smb_server(conn); 299 300 if (err) 300 301 return 0; 301 - 302 - if (atomic_inc_return(&conn->mux_smb_requests) >= conn->vals->max_credits) { 303 - atomic_dec_return(&conn->mux_smb_requests); 304 - return -ENOSPC; 305 - } 306 302 307 303 work = ksmbd_alloc_work_struct(); 308 304 if (!work) { ··· 361 367 server_conf.auth_mechs |= KSMBD_AUTH_KRB5 | 362 368 KSMBD_AUTH_MSKRB5; 363 369 #endif 370 + server_conf.max_inflight_req = SMB2_MAX_CREDITS; 364 371 return 0; 365 372 } 366 373
+1
fs/smb/server/server.h
··· 42 42 struct smb_sid domain_sid; 43 43 unsigned int auth_mechs; 44 44 unsigned int max_connections; 45 + unsigned int max_inflight_req; 45 46 46 47 char *conf[SERVER_CONF_WORK_GROUP + 1]; 47 48 struct task_struct *dh_task;
+30 -21
fs/smb/server/smb2pdu.c
··· 67 67 return false; 68 68 69 69 sess = ksmbd_session_lookup_all(conn, id); 70 - if (sess) 70 + if (sess) { 71 + ksmbd_user_session_put(sess); 71 72 return true; 73 + } 72 74 pr_err("Invalid user session id: %llu\n", id); 73 75 return false; 74 76 } ··· 607 605 608 606 /* Check for validity of user session */ 609 607 work->sess = ksmbd_session_lookup_all(conn, sess_id); 610 - if (work->sess) { 611 - ksmbd_user_session_get(work->sess); 608 + if (work->sess) 612 609 return 1; 613 - } 614 610 ksmbd_debug(SMB, "Invalid user session, Uid %llu\n", sess_id); 615 611 return -ENOENT; 616 612 } ··· 1097 1097 return rc; 1098 1098 } 1099 1099 1100 + ksmbd_conn_lock(conn); 1100 1101 smb2_buf_len = get_rfc1002_len(work->request_buf); 1101 1102 smb2_neg_size = offsetof(struct smb2_negotiate_req, Dialects); 1102 1103 if (smb2_neg_size > smb2_buf_len) { ··· 1248 1247 ksmbd_conn_set_need_negotiate(conn); 1249 1248 1250 1249 err_out: 1250 + ksmbd_conn_unlock(conn); 1251 1251 if (rc) 1252 1252 rsp->hdr.Status = STATUS_INSUFFICIENT_RESOURCES; 1253 1253 ··· 1703 1701 1704 1702 if (conn->dialect != sess->dialect) { 1705 1703 rc = -EINVAL; 1704 + ksmbd_user_session_put(sess); 1706 1705 goto out_err; 1707 1706 } 1708 1707 1709 1708 if (!(req->hdr.Flags & SMB2_FLAGS_SIGNED)) { 1710 1709 rc = -EINVAL; 1710 + ksmbd_user_session_put(sess); 1711 1711 goto out_err; 1712 1712 } 1713 1713 1714 1714 if (strncmp(conn->ClientGUID, sess->ClientGUID, 1715 1715 SMB2_CLIENT_GUID_SIZE)) { 1716 1716 rc = -ENOENT; 1717 + ksmbd_user_session_put(sess); 1717 1718 goto out_err; 1718 1719 } 1719 1720 1720 1721 if (sess->state == SMB2_SESSION_IN_PROGRESS) { 1721 1722 rc = -EACCES; 1723 + ksmbd_user_session_put(sess); 1722 1724 goto out_err; 1723 1725 } 1724 1726 1725 1727 if (sess->state == SMB2_SESSION_EXPIRED) { 1726 1728 rc = -EFAULT; 1729 + ksmbd_user_session_put(sess); 1727 1730 goto out_err; 1728 1731 } 1732 + ksmbd_user_session_put(sess); 1729 1733 1730 1734 if (ksmbd_conn_need_reconnect(conn)) { 1731 1735 rc = -EFAULT; ··· 1739 1731 goto out_err; 1740 1732 } 1741 1733 1742 - if (ksmbd_session_lookup(conn, sess_id)) { 1734 + sess = ksmbd_session_lookup(conn, sess_id); 1735 + if (!sess) { 1743 1736 rc = -EACCES; 1744 1737 goto out_err; 1745 1738 } ··· 1751 1742 } 1752 1743 1753 1744 conn->binding = true; 1754 - ksmbd_user_session_get(sess); 1755 1745 } else if ((conn->dialect < SMB30_PROT_ID || 1756 1746 server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) && 1757 1747 (req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) { ··· 1777 1769 } 1778 1770 1779 1771 conn->binding = false; 1780 - ksmbd_user_session_get(sess); 1781 1772 } 1782 1773 work->sess = sess; 1783 1774 ··· 2204 2197 int smb2_session_logoff(struct ksmbd_work *work) 2205 2198 { 2206 2199 struct ksmbd_conn *conn = work->conn; 2200 + struct ksmbd_session *sess = work->sess; 2207 2201 struct smb2_logoff_req *req; 2208 2202 struct smb2_logoff_rsp *rsp; 2209 - struct ksmbd_session *sess; 2210 2203 u64 sess_id; 2211 2204 int err; 2212 2205 ··· 2228 2221 ksmbd_close_session_fds(work); 2229 2222 ksmbd_conn_wait_idle(conn); 2230 2223 2231 - /* 2232 - * Re-lookup session to validate if session is deleted 2233 - * while waiting request complete 2234 - */ 2235 - sess = ksmbd_session_lookup_all(conn, sess_id); 2236 2224 if (ksmbd_tree_conn_session_logoff(sess)) { 2237 2225 ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId); 2238 2226 rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED; ··· 4230 4228 /* dot and dotdot entries are already reserved */ 4231 4229 if (!strcmp(".", name) || !strcmp("..", name)) 4232 4230 return true; 4231 + d_info->num_scan++; 4233 4232 if (ksmbd_share_veto_filename(priv->work->tcon->share_conf, name)) 4234 4233 return true; 4235 4234 if (!match_pattern(name, namlen, priv->search_pattern)) ··· 4393 4390 query_dir_private.info_level = req->FileInformationClass; 4394 4391 dir_fp->readdir_data.private = &query_dir_private; 4395 4392 set_ctx_actor(&dir_fp->readdir_data.ctx, __query_dir); 4396 - 4393 + again: 4394 + d_info.num_scan = 0; 4397 4395 rc = iterate_dir(dir_fp->filp, &dir_fp->readdir_data.ctx); 4396 + /* 4397 + * num_entry can be 0 if the directory iteration stops before reaching 4398 + * the end of the directory and no file is matched with the search 4399 + * pattern. 4400 + */ 4401 + if (rc >= 0 && !d_info.num_entry && d_info.num_scan && 4402 + d_info.out_buf_len > 0) 4403 + goto again; 4398 4404 /* 4399 4405 * req->OutputBufferLength is too small to contain even one entry. 4400 4406 * In this case, it immediately returns OutputBufferLength 0 to client. ··· 6028 6016 attrs.ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); 6029 6017 } 6030 6018 6031 - attrs.ia_valid |= ATTR_CTIME; 6032 6019 if (file_info->ChangeTime) 6033 - attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime); 6034 - else 6035 - attrs.ia_ctime = inode_get_ctime(inode); 6020 + inode_set_ctime_to_ts(inode, 6021 + ksmbd_NTtimeToUnix(file_info->ChangeTime)); 6036 6022 6037 6023 if (file_info->LastWriteTime) { 6038 6024 attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime); 6039 - attrs.ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); 6025 + attrs.ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME); 6040 6026 } 6041 6027 6042 6028 if (file_info->Attributes) { ··· 6076 6066 return -EACCES; 6077 6067 6078 6068 inode_lock(inode); 6079 - inode_set_ctime_to_ts(inode, attrs.ia_ctime); 6080 - attrs.ia_valid &= ~ATTR_CTIME; 6081 6069 rc = notify_change(idmap, dentry, &attrs, NULL); 6082 6070 inode_unlock(inode); 6083 6071 } ··· 8990 8982 le64_to_cpu(tr_hdr->SessionId)); 8991 8983 return -ECONNABORTED; 8992 8984 } 8985 + ksmbd_user_session_put(sess); 8993 8986 8994 8987 iov[0].iov_base = buf; 8995 8988 iov[0].iov_len = sizeof(struct smb2_transform_hdr) + 4;
+4 -1
fs/smb/server/transport_ipc.c
··· 319 319 init_smb2_max_write_size(req->smb2_max_write); 320 320 if (req->smb2_max_trans) 321 321 init_smb2_max_trans_size(req->smb2_max_trans); 322 - if (req->smb2_max_credits) 322 + if (req->smb2_max_credits) { 323 323 init_smb2_max_credits(req->smb2_max_credits); 324 + server_conf.max_inflight_req = 325 + req->smb2_max_credits; 326 + } 324 327 if (req->smbd_max_io_size) 325 328 init_smbd_max_io_size(req->smbd_max_io_size); 326 329
+1
fs/smb/server/vfs.h
··· 43 43 char *rptr; 44 44 int name_len; 45 45 int out_buf_len; 46 + int num_scan; 46 47 int num_entry; 47 48 int data_count; 48 49 int last_entry_offset;
+25 -8
fs/xfs/libxfs/xfs_btree.c
··· 3557 3557 xfs_btree_log_block(cur, bp, XFS_BB_NUMRECS); 3558 3558 3559 3559 /* 3560 - * If we just inserted into a new tree block, we have to 3561 - * recalculate nkey here because nkey is out of date. 3560 + * Update btree keys to reflect the newly added record or keyptr. 3561 + * There are three cases here to be aware of. Normally, all we have to 3562 + * do is walk towards the root, updating keys as necessary. 3562 3563 * 3563 - * Otherwise we're just updating an existing block (having shoved 3564 - * some records into the new tree block), so use the regular key 3565 - * update mechanism. 3564 + * If the caller had us target a full block for the insertion, we dealt 3565 + * with that by calling the _make_block_unfull function. If the 3566 + * "make unfull" function splits the block, it'll hand us back the key 3567 + * and pointer of the new block. We haven't yet added the new block to 3568 + * the next level up, so if we decide to add the new record to the new 3569 + * block (bp->b_bn != old_bn), we have to update the caller's pointer 3570 + * so that the caller adds the new block with the correct key. 3571 + * 3572 + * However, there is a third possibility-- if the selected block is the 3573 + * root block of an inode-rooted btree and cannot be expanded further, 3574 + * the "make unfull" function moves the root block contents to a new 3575 + * block and updates the root block to point to the new block. In this 3576 + * case, no block pointer is passed back because the block has already 3577 + * been added to the btree. In this case, we need to use the regular 3578 + * key update function, just like the first case. This is critical for 3579 + * overlapping btrees, because the high key must be updated to reflect 3580 + * the entire tree, not just the subtree accessible through the first 3581 + * child of the root (which is now two levels down from the root). 3566 3582 */ 3567 - if (bp && xfs_buf_daddr(bp) != old_bn) { 3583 + if (!xfs_btree_ptr_is_null(cur, &nptr) && 3584 + bp && xfs_buf_daddr(bp) != old_bn) { 3568 3585 xfs_btree_get_keys(cur, block, lkey); 3569 3586 } else if (xfs_btree_needs_key_update(cur, optr)) { 3570 3587 error = xfs_btree_update_keys(cur, level); ··· 5161 5144 int level, 5162 5145 void *data) 5163 5146 { 5164 - xfs_extlen_t *blocks = data; 5147 + xfs_filblks_t *blocks = data; 5165 5148 (*blocks)++; 5166 5149 5167 5150 return 0; ··· 5171 5154 int 5172 5155 xfs_btree_count_blocks( 5173 5156 struct xfs_btree_cur *cur, 5174 - xfs_extlen_t *blocks) 5157 + xfs_filblks_t *blocks) 5175 5158 { 5176 5159 *blocks = 0; 5177 5160 return xfs_btree_visit_blocks(cur, xfs_btree_count_blocks_helper,
+1 -1
fs/xfs/libxfs/xfs_btree.h
··· 484 484 int xfs_btree_visit_blocks(struct xfs_btree_cur *cur, 485 485 xfs_btree_visit_blocks_fn fn, unsigned int flags, void *data); 486 486 487 - int xfs_btree_count_blocks(struct xfs_btree_cur *cur, xfs_extlen_t *blocks); 487 + int xfs_btree_count_blocks(struct xfs_btree_cur *cur, xfs_filblks_t *blocks); 488 488 489 489 union xfs_btree_rec *xfs_btree_rec_addr(struct xfs_btree_cur *cur, int n, 490 490 struct xfs_btree_block *block);
+3 -1
fs/xfs/libxfs/xfs_ialloc_btree.c
··· 744 744 { 745 745 struct xfs_buf *agbp = NULL; 746 746 struct xfs_btree_cur *cur; 747 + xfs_filblks_t blocks; 747 748 int error; 748 749 749 750 error = xfs_ialloc_read_agi(pag, tp, 0, &agbp); ··· 752 751 return error; 753 752 754 753 cur = xfs_finobt_init_cursor(pag, tp, agbp); 755 - error = xfs_btree_count_blocks(cur, tree_blocks); 754 + error = xfs_btree_count_blocks(cur, &blocks); 756 755 xfs_btree_del_cursor(cur, error); 757 756 xfs_trans_brelse(tp, agbp); 757 + *tree_blocks = blocks; 758 758 759 759 return error; 760 760 }
+1 -1
fs/xfs/libxfs/xfs_rtgroup.c
··· 496 496 497 497 error = xfs_metadir_create(&upd, S_IFREG); 498 498 if (error) 499 - return error; 499 + goto out_cancel; 500 500 501 501 xfs_rtginode_lockdep_setup(upd.ip, rtg_rgno(rtg), type); 502 502
+6 -5
fs/xfs/libxfs/xfs_sb.c
··· 494 494 return -EINVAL; 495 495 } 496 496 497 - if (!sbp->sb_spino_align || 498 - sbp->sb_spino_align > sbp->sb_inoalignmt || 499 - (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0) { 497 + if (sbp->sb_spino_align && 498 + (sbp->sb_spino_align > sbp->sb_inoalignmt || 499 + (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0)) { 500 500 xfs_warn(mp, 501 - "Sparse inode alignment (%u) is invalid.", 502 - sbp->sb_spino_align); 501 + "Sparse inode alignment (%u) is invalid, must be integer factor of (%u).", 502 + sbp->sb_spino_align, 503 + sbp->sb_inoalignmt); 503 504 return -EINVAL; 504 505 } 505 506 } else if (sbp->sb_spino_align) {
+59 -18
fs/xfs/scrub/agheader.c
··· 60 60 } 61 61 62 62 /* 63 + * Calculate the ondisk superblock size in bytes given the feature set of the 64 + * mounted filesystem (aka the primary sb). This is subtlely different from 65 + * the logic in xfs_repair, which computes the size of a secondary sb given the 66 + * featureset listed in the secondary sb. 67 + */ 68 + STATIC size_t 69 + xchk_superblock_ondisk_size( 70 + struct xfs_mount *mp) 71 + { 72 + if (xfs_has_metadir(mp)) 73 + return offsetofend(struct xfs_dsb, sb_pad); 74 + if (xfs_has_metauuid(mp)) 75 + return offsetofend(struct xfs_dsb, sb_meta_uuid); 76 + if (xfs_has_crc(mp)) 77 + return offsetofend(struct xfs_dsb, sb_lsn); 78 + if (xfs_sb_version_hasmorebits(&mp->m_sb)) 79 + return offsetofend(struct xfs_dsb, sb_bad_features2); 80 + if (xfs_has_logv2(mp)) 81 + return offsetofend(struct xfs_dsb, sb_logsunit); 82 + if (xfs_has_sector(mp)) 83 + return offsetofend(struct xfs_dsb, sb_logsectsize); 84 + /* only support dirv2 or more recent */ 85 + return offsetofend(struct xfs_dsb, sb_dirblklog); 86 + } 87 + 88 + /* 63 89 * Scrub the filesystem superblock. 64 90 * 65 91 * Note: We do /not/ attempt to check AG 0's superblock. Mount is ··· 101 75 struct xfs_buf *bp; 102 76 struct xfs_dsb *sb; 103 77 struct xfs_perag *pag; 78 + size_t sblen; 104 79 xfs_agnumber_t agno; 105 80 uint32_t v2_ok; 106 81 __be32 features_mask; ··· 172 145 xchk_block_set_preen(sc, bp); 173 146 174 147 if (xfs_has_metadir(sc->mp)) { 175 - if (sb->sb_metadirino != cpu_to_be64(mp->m_sb.sb_metadirino)) 176 - xchk_block_set_preen(sc, bp); 148 + if (sb->sb_rbmino != cpu_to_be64(0)) 149 + xchk_block_set_corrupt(sc, bp); 150 + 151 + if (sb->sb_rsumino != cpu_to_be64(0)) 152 + xchk_block_set_corrupt(sc, bp); 177 153 } else { 178 154 if (sb->sb_rbmino != cpu_to_be64(mp->m_sb.sb_rbmino)) 179 155 xchk_block_set_preen(sc, bp); ··· 259 229 * sb_icount, sb_ifree, sb_fdblocks, sb_frexents 260 230 */ 261 231 262 - if (!xfs_has_metadir(mp)) { 232 + if (xfs_has_metadir(mp)) { 233 + if (sb->sb_uquotino != cpu_to_be64(0)) 234 + xchk_block_set_corrupt(sc, bp); 235 + 236 + if (sb->sb_gquotino != cpu_to_be64(0)) 237 + xchk_block_set_preen(sc, bp); 238 + } else { 263 239 if (sb->sb_uquotino != cpu_to_be64(mp->m_sb.sb_uquotino)) 264 240 xchk_block_set_preen(sc, bp); 265 241 ··· 317 281 if (!!(sb->sb_features2 & cpu_to_be32(~v2_ok))) 318 282 xchk_block_set_corrupt(sc, bp); 319 283 320 - if (xfs_has_metadir(mp)) { 321 - if (sb->sb_rgblklog != mp->m_sb.sb_rgblklog) 322 - xchk_block_set_corrupt(sc, bp); 323 - if (memchr_inv(sb->sb_pad, 0, sizeof(sb->sb_pad))) 324 - xchk_block_set_preen(sc, bp); 325 - } else { 326 - if (sb->sb_features2 != sb->sb_bad_features2) 327 - xchk_block_set_preen(sc, bp); 328 - } 284 + if (sb->sb_features2 != sb->sb_bad_features2) 285 + xchk_block_set_preen(sc, bp); 329 286 } 330 287 331 288 /* Check sb_features2 flags that are set at mkfs time. */ ··· 380 351 if (sb->sb_spino_align != cpu_to_be32(mp->m_sb.sb_spino_align)) 381 352 xchk_block_set_corrupt(sc, bp); 382 353 383 - if (!xfs_has_metadir(mp)) { 354 + if (xfs_has_metadir(mp)) { 355 + if (sb->sb_pquotino != cpu_to_be64(0)) 356 + xchk_block_set_corrupt(sc, bp); 357 + } else { 384 358 if (sb->sb_pquotino != cpu_to_be64(mp->m_sb.sb_pquotino)) 385 359 xchk_block_set_preen(sc, bp); 386 360 } ··· 398 366 } 399 367 400 368 if (xfs_has_metadir(mp)) { 369 + if (sb->sb_metadirino != cpu_to_be64(mp->m_sb.sb_metadirino)) 370 + xchk_block_set_preen(sc, bp); 371 + 401 372 if (sb->sb_rgcount != cpu_to_be32(mp->m_sb.sb_rgcount)) 402 373 xchk_block_set_corrupt(sc, bp); 403 374 404 375 if (sb->sb_rgextents != cpu_to_be32(mp->m_sb.sb_rgextents)) 405 376 xchk_block_set_corrupt(sc, bp); 377 + 378 + if (sb->sb_rgblklog != mp->m_sb.sb_rgblklog) 379 + xchk_block_set_corrupt(sc, bp); 380 + 381 + if (memchr_inv(sb->sb_pad, 0, sizeof(sb->sb_pad))) 382 + xchk_block_set_corrupt(sc, bp); 406 383 } 407 384 408 385 /* Everything else must be zero. */ 409 - if (memchr_inv(sb + 1, 0, 410 - BBTOB(bp->b_length) - sizeof(struct xfs_dsb))) 386 + sblen = xchk_superblock_ondisk_size(mp); 387 + if (memchr_inv((char *)sb + sblen, 0, BBTOB(bp->b_length) - sblen)) 411 388 xchk_block_set_corrupt(sc, bp); 412 389 413 390 xchk_superblock_xref(sc, bp); ··· 499 458 { 500 459 struct xfs_agf *agf = sc->sa.agf_bp->b_addr; 501 460 struct xfs_mount *mp = sc->mp; 502 - xfs_agblock_t blocks; 461 + xfs_filblks_t blocks; 503 462 xfs_agblock_t btreeblks; 504 463 int error; 505 464 ··· 548 507 struct xfs_scrub *sc) 549 508 { 550 509 struct xfs_agf *agf = sc->sa.agf_bp->b_addr; 551 - xfs_agblock_t blocks; 510 + xfs_filblks_t blocks; 552 511 int error; 553 512 554 513 if (!sc->sa.refc_cur) ··· 881 840 struct xfs_scrub *sc) 882 841 { 883 842 struct xfs_agi *agi = sc->sa.agi_bp->b_addr; 884 - xfs_agblock_t blocks; 843 + xfs_filblks_t blocks; 885 844 int error = 0; 886 845 887 846 if (!xfs_has_inobtcounts(sc->mp))
+3 -3
fs/xfs/scrub/agheader_repair.c
··· 256 256 struct xfs_agf *agf = agf_bp->b_addr; 257 257 struct xfs_mount *mp = sc->mp; 258 258 xfs_agblock_t btreeblks; 259 - xfs_agblock_t blocks; 259 + xfs_filblks_t blocks; 260 260 int error; 261 261 262 262 /* Update the AGF counters from the bnobt. */ ··· 946 946 if (error) 947 947 goto err; 948 948 if (xfs_has_inobtcounts(mp)) { 949 - xfs_agblock_t blocks; 949 + xfs_filblks_t blocks; 950 950 951 951 error = xfs_btree_count_blocks(cur, &blocks); 952 952 if (error) ··· 959 959 agi->agi_freecount = cpu_to_be32(freecount); 960 960 961 961 if (xfs_has_finobt(mp) && xfs_has_inobtcounts(mp)) { 962 - xfs_agblock_t blocks; 962 + xfs_filblks_t blocks; 963 963 964 964 cur = xfs_finobt_init_cursor(sc->sa.pag, sc->tp, agi_bp); 965 965 error = xfs_btree_count_blocks(cur, &blocks);
+1 -1
fs/xfs/scrub/fscounters.c
··· 261 261 struct xchk_fscounters *fsc, 262 262 xfs_agnumber_t agno) 263 263 { 264 - xfs_extlen_t blocks; 264 + xfs_filblks_t blocks; 265 265 int error; 266 266 267 267 error = xchk_ag_init_existing(sc, agno, &sc->sa);
+33 -24
fs/xfs/scrub/health.c
··· 71 71 /* Map our scrub type to a sick mask and a set of health update functions. */ 72 72 73 73 enum xchk_health_group { 74 - XHG_FS = 1, 74 + XHG_NONE = 1, 75 + XHG_FS, 75 76 XHG_AG, 76 77 XHG_INO, 77 78 XHG_RTGROUP, ··· 84 83 }; 85 84 86 85 static const struct xchk_health_map type_to_health_flag[XFS_SCRUB_TYPE_NR] = { 86 + [XFS_SCRUB_TYPE_PROBE] = { XHG_NONE, 0 }, 87 87 [XFS_SCRUB_TYPE_SB] = { XHG_AG, XFS_SICK_AG_SB }, 88 88 [XFS_SCRUB_TYPE_AGF] = { XHG_AG, XFS_SICK_AG_AGF }, 89 89 [XFS_SCRUB_TYPE_AGFL] = { XHG_AG, XFS_SICK_AG_AGFL }, ··· 135 133 { 136 134 if (!(sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 137 135 XFS_SCRUB_OFLAG_XCORRUPT))) 138 - sc->sick_mask |= mask; 136 + sc->healthy_mask |= mask; 139 137 } 140 138 141 139 /* ··· 191 189 { 192 190 struct xfs_perag *pag; 193 191 struct xfs_rtgroup *rtg; 192 + unsigned int mask = sc->sick_mask; 194 193 bool bad; 195 194 196 195 /* ··· 206 203 return; 207 204 } 208 205 209 - if (!sc->sick_mask) 210 - return; 211 - 212 206 bad = (sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 213 207 XFS_SCRUB_OFLAG_XCORRUPT)); 208 + if (!bad) 209 + mask |= sc->healthy_mask; 214 210 switch (type_to_health_flag[sc->sm->sm_type].group) { 211 + case XHG_NONE: 212 + break; 215 213 case XHG_AG: 214 + if (!mask) 215 + return; 216 216 pag = xfs_perag_get(sc->mp, sc->sm->sm_agno); 217 217 if (bad) 218 - xfs_group_mark_corrupt(pag_group(pag), sc->sick_mask); 218 + xfs_group_mark_corrupt(pag_group(pag), mask); 219 219 else 220 - xfs_group_mark_healthy(pag_group(pag), sc->sick_mask); 220 + xfs_group_mark_healthy(pag_group(pag), mask); 221 221 xfs_perag_put(pag); 222 222 break; 223 223 case XHG_INO: 224 224 if (!sc->ip) 225 225 return; 226 - if (bad) { 227 - unsigned int mask = sc->sick_mask; 228 - 229 - /* 230 - * If we're coming in for repairs then we don't want 231 - * sickness flags to propagate to the incore health 232 - * status if the inode gets inactivated before we can 233 - * fix it. 234 - */ 235 - if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) 236 - mask |= XFS_SICK_INO_FORGET; 226 + /* 227 + * If we're coming in for repairs then we don't want sickness 228 + * flags to propagate to the incore health status if the inode 229 + * gets inactivated before we can fix it. 230 + */ 231 + if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) 232 + mask |= XFS_SICK_INO_FORGET; 233 + if (!mask) 234 + return; 235 + if (bad) 237 236 xfs_inode_mark_corrupt(sc->ip, mask); 238 - } else 239 - xfs_inode_mark_healthy(sc->ip, sc->sick_mask); 237 + else 238 + xfs_inode_mark_healthy(sc->ip, mask); 240 239 break; 241 240 case XHG_FS: 241 + if (!mask) 242 + return; 242 243 if (bad) 243 - xfs_fs_mark_corrupt(sc->mp, sc->sick_mask); 244 + xfs_fs_mark_corrupt(sc->mp, mask); 244 245 else 245 - xfs_fs_mark_healthy(sc->mp, sc->sick_mask); 246 + xfs_fs_mark_healthy(sc->mp, mask); 246 247 break; 247 248 case XHG_RTGROUP: 249 + if (!mask) 250 + return; 248 251 rtg = xfs_rtgroup_get(sc->mp, sc->sm->sm_agno); 249 252 if (bad) 250 - xfs_group_mark_corrupt(rtg_group(rtg), sc->sick_mask); 253 + xfs_group_mark_corrupt(rtg_group(rtg), mask); 251 254 else 252 - xfs_group_mark_healthy(rtg_group(rtg), sc->sick_mask); 255 + xfs_group_mark_healthy(rtg_group(rtg), mask); 253 256 xfs_rtgroup_put(rtg); 254 257 break; 255 258 default:
+2 -2
fs/xfs/scrub/ialloc.c
··· 650 650 struct xfs_scrub *sc) 651 651 { 652 652 xfs_filblks_t blocks; 653 - xfs_extlen_t inobt_blocks = 0; 654 - xfs_extlen_t finobt_blocks = 0; 653 + xfs_filblks_t inobt_blocks = 0; 654 + xfs_filblks_t finobt_blocks = 0; 655 655 int error; 656 656 657 657 if (!sc->sa.ino_cur || !sc->sa.rmap_cur ||
+26 -42
fs/xfs/scrub/metapath.c
··· 171 171 xchk_setup_metapath_quotadir( 172 172 struct xfs_scrub *sc) 173 173 { 174 - struct xfs_trans *tp; 175 - struct xfs_inode *dp = NULL; 176 - int error; 174 + struct xfs_quotainfo *qi = sc->mp->m_quotainfo; 177 175 178 - error = xfs_trans_alloc_empty(sc->mp, &tp); 179 - if (error) 180 - return error; 176 + if (!qi || !qi->qi_dirip) 177 + return -ENOENT; 181 178 182 - error = xfs_dqinode_load_parent(tp, &dp); 183 - xfs_trans_cancel(tp); 184 - if (error) 185 - return error; 186 - 187 - error = xchk_setup_metapath_scan(sc, sc->mp->m_metadirip, 188 - kasprintf(GFP_KERNEL, "quota"), dp); 189 - xfs_irele(dp); 190 - return error; 179 + return xchk_setup_metapath_scan(sc, sc->mp->m_metadirip, 180 + kstrdup("quota", GFP_KERNEL), qi->qi_dirip); 191 181 } 192 182 193 183 /* Scan a quota inode under the /quota directory. */ ··· 186 196 struct xfs_scrub *sc, 187 197 xfs_dqtype_t type) 188 198 { 189 - struct xfs_trans *tp = NULL; 190 - struct xfs_inode *dp = NULL; 199 + struct xfs_quotainfo *qi = sc->mp->m_quotainfo; 191 200 struct xfs_inode *ip = NULL; 192 - const char *path; 193 - int error; 194 201 195 - error = xfs_trans_alloc_empty(sc->mp, &tp); 196 - if (error) 197 - return error; 202 + if (!qi) 203 + return -ENOENT; 198 204 199 - error = xfs_dqinode_load_parent(tp, &dp); 200 - if (error) 201 - goto out_cancel; 205 + switch (type) { 206 + case XFS_DQTYPE_USER: 207 + ip = qi->qi_uquotaip; 208 + break; 209 + case XFS_DQTYPE_GROUP: 210 + ip = qi->qi_gquotaip; 211 + break; 212 + case XFS_DQTYPE_PROJ: 213 + ip = qi->qi_pquotaip; 214 + break; 215 + default: 216 + ASSERT(0); 217 + return -EINVAL; 218 + } 219 + if (!ip) 220 + return -ENOENT; 202 221 203 - error = xfs_dqinode_load(tp, dp, type, &ip); 204 - if (error) 205 - goto out_dp; 206 - 207 - xfs_trans_cancel(tp); 208 - tp = NULL; 209 - 210 - path = kasprintf(GFP_KERNEL, "%s", xfs_dqinode_path(type)); 211 - error = xchk_setup_metapath_scan(sc, dp, path, ip); 212 - 213 - xfs_irele(ip); 214 - out_dp: 215 - xfs_irele(dp); 216 - out_cancel: 217 - if (tp) 218 - xfs_trans_cancel(tp); 219 - return error; 222 + return xchk_setup_metapath_scan(sc, qi->qi_dirip, 223 + kstrdup(xfs_dqinode_path(type), GFP_KERNEL), ip); 220 224 } 221 225 #else 222 226 # define xchk_setup_metapath_quotadir(...) (-ENOENT)
+1 -1
fs/xfs/scrub/refcount.c
··· 491 491 struct xfs_scrub *sc, 492 492 xfs_filblks_t cow_blocks) 493 493 { 494 - xfs_extlen_t refcbt_blocks = 0; 494 + xfs_filblks_t refcbt_blocks = 0; 495 495 xfs_filblks_t blocks; 496 496 int error; 497 497
+6
fs/xfs/scrub/scrub.h
··· 184 184 */ 185 185 unsigned int sick_mask; 186 186 187 + /* 188 + * Clear these XFS_SICK_* flags but only if the scan is ok. Useful for 189 + * removing ZAPPED flags after a repair. 190 + */ 191 + unsigned int healthy_mask; 192 + 187 193 /* next time we want to cond_resched() */ 188 194 struct xchk_relax relax; 189 195
+19 -3
fs/xfs/scrub/tempfile.c
··· 184 184 } 185 185 186 186 /* 187 + * Move sc->tempip from the regular directory tree to the metadata directory 188 + * tree if sc->ip is part of the metadata directory tree and tempip has an 189 + * eligible file mode. 190 + * 187 191 * Temporary files have to be created before we even know which inode we're 188 192 * going to scrub, so we assume that they will be part of the regular directory 189 193 * tree. If it turns out that we're actually scrubbing a file from the 190 194 * metadata directory tree, we have to subtract the temp file from the root 191 - * dquots and detach the dquots. 195 + * dquots and detach the dquots prior to setting the METADATA iflag. However, 196 + * the scrub setup functions grab sc->ip and create sc->tempip before we 197 + * actually get around to checking if the file mode is the right type for the 198 + * scrubber. 192 199 */ 193 200 int 194 201 xrep_tempfile_adjust_directory_tree( ··· 210 203 ASSERT(!xfs_is_metadir_inode(sc->tempip)); 211 204 212 205 if (!sc->ip || !xfs_is_metadir_inode(sc->ip)) 206 + return 0; 207 + if (!S_ISDIR(VFS_I(sc->tempip)->i_mode) && 208 + !S_ISREG(VFS_I(sc->tempip)->i_mode)) 213 209 return 0; 214 210 215 211 xfs_ilock(sc->tempip, XFS_IOLOCK_EXCL); ··· 233 223 if (error) 234 224 goto out_ilock; 235 225 226 + xfs_iflags_set(sc->tempip, XFS_IRECOVERY); 236 227 xfs_qm_dqdetach(sc->tempip); 237 228 out_ilock: 238 229 xrep_tempfile_iunlock(sc); ··· 256 245 return 0; 257 246 258 247 ASSERT(sc->tp == NULL); 248 + 249 + xfs_iflags_clear(sc->tempip, XFS_IRECOVERY); 259 250 260 251 xfs_ilock(sc->tempip, XFS_IOLOCK_EXCL); 261 252 sc->temp_ilock_flags |= XFS_IOLOCK_EXCL; ··· 958 945 959 946 /* 960 947 * Files in the metadata directory tree also have S_PRIVATE set and 961 - * IOP_XATTR unset, so we must distinguish them separately. 948 + * IOP_XATTR unset, so we must distinguish them separately. We (ab)use 949 + * the IRECOVERY flag to mark temporary metadir inodes knowing that the 950 + * end of log recovery clears IRECOVERY, so the only ones that can 951 + * exist during online repair are the ones we create. 962 952 */ 963 953 if (xfs_has_metadir(mp) && (ip->i_diflags2 & XFS_DIFLAG2_METADATA)) 964 - return false; 954 + return __xfs_iflags_test(ip, XFS_IRECOVERY); 965 955 966 956 if (IS_PRIVATE(inode) && !(inode->i_opflags & IOP_XATTR)) 967 957 return true;
+1 -1
fs/xfs/scrub/trace.h
··· 605 605 TP_fast_assign( 606 606 xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level); 607 607 __entry->dev = sc->mp->m_super->s_dev; 608 - __entry->ino = sc->ip->i_ino; 608 + __entry->ino = cur->bc_ino.ip->i_ino; 609 609 __entry->whichfork = cur->bc_ino.whichfork; 610 610 __entry->type = sc->sm->sm_type; 611 611 __assign_str(name);
+1 -1
fs/xfs/xfs_bmap_util.c
··· 103 103 struct xfs_mount *mp = ip->i_mount; 104 104 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); 105 105 struct xfs_btree_cur *cur; 106 - xfs_extlen_t btblocks = 0; 106 + xfs_filblks_t btblocks = 0; 107 107 int error; 108 108 109 109 *nextents = 0;
+165 -30
fs/xfs/xfs_dquot.c
··· 69 69 } 70 70 71 71 /* 72 + * Detach the dquot buffer if it's still attached, because we can get called 73 + * through dqpurge after a log shutdown. Caller must hold the dqflock or have 74 + * otherwise isolated the dquot. 75 + */ 76 + void 77 + xfs_dquot_detach_buf( 78 + struct xfs_dquot *dqp) 79 + { 80 + struct xfs_dq_logitem *qlip = &dqp->q_logitem; 81 + struct xfs_buf *bp = NULL; 82 + 83 + spin_lock(&qlip->qli_lock); 84 + if (qlip->qli_item.li_buf) { 85 + bp = qlip->qli_item.li_buf; 86 + qlip->qli_item.li_buf = NULL; 87 + } 88 + spin_unlock(&qlip->qli_lock); 89 + if (bp) { 90 + list_del_init(&qlip->qli_item.li_bio_list); 91 + xfs_buf_rele(bp); 92 + } 93 + } 94 + 95 + /* 72 96 * This is called to free all the memory associated with a dquot 73 97 */ 74 98 void ··· 100 76 struct xfs_dquot *dqp) 101 77 { 102 78 ASSERT(list_empty(&dqp->q_lru)); 79 + ASSERT(dqp->q_logitem.qli_item.li_buf == NULL); 103 80 104 81 kvfree(dqp->q_logitem.qli_item.li_lv_shadow); 105 82 mutex_destroy(&dqp->q_qlock); ··· 1167 1142 xfs_qm_dqflush_done( 1168 1143 struct xfs_log_item *lip) 1169 1144 { 1170 - struct xfs_dq_logitem *qip = (struct xfs_dq_logitem *)lip; 1171 - struct xfs_dquot *dqp = qip->qli_dquot; 1145 + struct xfs_dq_logitem *qlip = 1146 + container_of(lip, struct xfs_dq_logitem, qli_item); 1147 + struct xfs_dquot *dqp = qlip->qli_dquot; 1172 1148 struct xfs_ail *ailp = lip->li_ailp; 1149 + struct xfs_buf *bp = NULL; 1173 1150 xfs_lsn_t tail_lsn; 1174 1151 1175 1152 /* ··· 1183 1156 * holding the lock before removing the dquot from the AIL. 1184 1157 */ 1185 1158 if (test_bit(XFS_LI_IN_AIL, &lip->li_flags) && 1186 - ((lip->li_lsn == qip->qli_flush_lsn) || 1159 + (lip->li_lsn == qlip->qli_flush_lsn || 1187 1160 test_bit(XFS_LI_FAILED, &lip->li_flags))) { 1188 1161 1189 1162 spin_lock(&ailp->ail_lock); 1190 1163 xfs_clear_li_failed(lip); 1191 - if (lip->li_lsn == qip->qli_flush_lsn) { 1164 + if (lip->li_lsn == qlip->qli_flush_lsn) { 1192 1165 /* xfs_ail_update_finish() drops the AIL lock */ 1193 1166 tail_lsn = xfs_ail_delete_one(ailp, lip); 1194 1167 xfs_ail_update_finish(ailp, tail_lsn); ··· 1196 1169 spin_unlock(&ailp->ail_lock); 1197 1170 } 1198 1171 } 1172 + 1173 + /* 1174 + * If this dquot hasn't been dirtied since initiating the last dqflush, 1175 + * release the buffer reference. We already unlinked this dquot item 1176 + * from the buffer. 1177 + */ 1178 + spin_lock(&qlip->qli_lock); 1179 + if (!qlip->qli_dirty) { 1180 + bp = lip->li_buf; 1181 + lip->li_buf = NULL; 1182 + } 1183 + spin_unlock(&qlip->qli_lock); 1184 + if (bp) 1185 + xfs_buf_rele(bp); 1199 1186 1200 1187 /* 1201 1188 * Release the dq's flush lock since we're done with it. ··· 1237 1196 1238 1197 spin_lock(&bp->b_mount->m_ail->ail_lock); 1239 1198 list_for_each_entry(lip, &bp->b_li_list, li_bio_list) 1240 - xfs_set_li_failed(lip, bp); 1199 + set_bit(XFS_LI_FAILED, &lip->li_flags); 1241 1200 spin_unlock(&bp->b_mount->m_ail->ail_lock); 1242 1201 } 1243 1202 ··· 1280 1239 } 1281 1240 1282 1241 /* 1242 + * Get the buffer containing the on-disk dquot. 1243 + * 1244 + * Requires dquot flush lock, will clear the dirty flag, delete the quota log 1245 + * item from the AIL, and shut down the system if something goes wrong. 1246 + */ 1247 + static int 1248 + xfs_dquot_read_buf( 1249 + struct xfs_trans *tp, 1250 + struct xfs_dquot *dqp, 1251 + struct xfs_buf **bpp) 1252 + { 1253 + struct xfs_mount *mp = dqp->q_mount; 1254 + struct xfs_buf *bp = NULL; 1255 + int error; 1256 + 1257 + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno, 1258 + mp->m_quotainfo->qi_dqchunklen, 0, 1259 + &bp, &xfs_dquot_buf_ops); 1260 + if (xfs_metadata_is_sick(error)) 1261 + xfs_dquot_mark_sick(dqp); 1262 + if (error) 1263 + goto out_abort; 1264 + 1265 + *bpp = bp; 1266 + return 0; 1267 + 1268 + out_abort: 1269 + dqp->q_flags &= ~XFS_DQFLAG_DIRTY; 1270 + xfs_trans_ail_delete(&dqp->q_logitem.qli_item, 0); 1271 + xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 1272 + return error; 1273 + } 1274 + 1275 + /* 1276 + * Attach a dquot buffer to this dquot to avoid allocating a buffer during a 1277 + * dqflush, since dqflush can be called from reclaim context. 1278 + */ 1279 + int 1280 + xfs_dquot_attach_buf( 1281 + struct xfs_trans *tp, 1282 + struct xfs_dquot *dqp) 1283 + { 1284 + struct xfs_dq_logitem *qlip = &dqp->q_logitem; 1285 + struct xfs_log_item *lip = &qlip->qli_item; 1286 + int error; 1287 + 1288 + spin_lock(&qlip->qli_lock); 1289 + if (!lip->li_buf) { 1290 + struct xfs_buf *bp = NULL; 1291 + 1292 + spin_unlock(&qlip->qli_lock); 1293 + error = xfs_dquot_read_buf(tp, dqp, &bp); 1294 + if (error) 1295 + return error; 1296 + 1297 + /* 1298 + * Attach the dquot to the buffer so that the AIL does not have 1299 + * to read the dquot buffer to push this item. 1300 + */ 1301 + xfs_buf_hold(bp); 1302 + spin_lock(&qlip->qli_lock); 1303 + lip->li_buf = bp; 1304 + xfs_trans_brelse(tp, bp); 1305 + } 1306 + qlip->qli_dirty = true; 1307 + spin_unlock(&qlip->qli_lock); 1308 + 1309 + return 0; 1310 + } 1311 + 1312 + /* 1313 + * Get a new reference the dquot buffer attached to this dquot for a dqflush 1314 + * operation. 1315 + * 1316 + * Returns 0 and a NULL bp if none was attached to the dquot; 0 and a locked 1317 + * bp; or -EAGAIN if the buffer could not be locked. 1318 + */ 1319 + int 1320 + xfs_dquot_use_attached_buf( 1321 + struct xfs_dquot *dqp, 1322 + struct xfs_buf **bpp) 1323 + { 1324 + struct xfs_buf *bp = dqp->q_logitem.qli_item.li_buf; 1325 + 1326 + /* 1327 + * A NULL buffer can happen if the dquot dirty flag was set but the 1328 + * filesystem shut down before transaction commit happened. In that 1329 + * case we're not going to flush anyway. 1330 + */ 1331 + if (!bp) { 1332 + ASSERT(xfs_is_shutdown(dqp->q_mount)); 1333 + 1334 + *bpp = NULL; 1335 + return 0; 1336 + } 1337 + 1338 + if (!xfs_buf_trylock(bp)) 1339 + return -EAGAIN; 1340 + 1341 + xfs_buf_hold(bp); 1342 + *bpp = bp; 1343 + return 0; 1344 + } 1345 + 1346 + /* 1283 1347 * Write a modified dquot to disk. 1284 1348 * The dquot must be locked and the flush lock too taken by caller. 1285 1349 * The flush lock will not be unlocked until the dquot reaches the disk, ··· 1395 1249 int 1396 1250 xfs_qm_dqflush( 1397 1251 struct xfs_dquot *dqp, 1398 - struct xfs_buf **bpp) 1252 + struct xfs_buf *bp) 1399 1253 { 1400 1254 struct xfs_mount *mp = dqp->q_mount; 1401 - struct xfs_log_item *lip = &dqp->q_logitem.qli_item; 1402 - struct xfs_buf *bp; 1255 + struct xfs_dq_logitem *qlip = &dqp->q_logitem; 1256 + struct xfs_log_item *lip = &qlip->qli_item; 1403 1257 struct xfs_dqblk *dqblk; 1404 1258 xfs_failaddr_t fa; 1405 1259 int error; ··· 1409 1263 1410 1264 trace_xfs_dqflush(dqp); 1411 1265 1412 - *bpp = NULL; 1413 - 1414 1266 xfs_qm_dqunpin_wait(dqp); 1415 - 1416 - /* 1417 - * Get the buffer containing the on-disk dquot 1418 - */ 1419 - error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, 1420 - mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK, 1421 - &bp, &xfs_dquot_buf_ops); 1422 - if (error == -EAGAIN) 1423 - goto out_unlock; 1424 - if (xfs_metadata_is_sick(error)) 1425 - xfs_dquot_mark_sick(dqp); 1426 - if (error) 1427 - goto out_abort; 1428 1267 1429 1268 fa = xfs_qm_dqflush_check(dqp); 1430 1269 if (fa) { 1431 1270 xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS", 1432 1271 dqp->q_id, fa); 1433 - xfs_buf_relse(bp); 1434 1272 xfs_dquot_mark_sick(dqp); 1435 1273 error = -EFSCORRUPTED; 1436 1274 goto out_abort; ··· 1429 1299 */ 1430 1300 dqp->q_flags &= ~XFS_DQFLAG_DIRTY; 1431 1301 1432 - xfs_trans_ail_copy_lsn(mp->m_ail, &dqp->q_logitem.qli_flush_lsn, 1433 - &dqp->q_logitem.qli_item.li_lsn); 1302 + /* 1303 + * We hold the dquot lock, so nobody can dirty it while we're 1304 + * scheduling the write out. Clear the dirty-since-flush flag. 1305 + */ 1306 + spin_lock(&qlip->qli_lock); 1307 + qlip->qli_dirty = false; 1308 + spin_unlock(&qlip->qli_lock); 1309 + 1310 + xfs_trans_ail_copy_lsn(mp->m_ail, &qlip->qli_flush_lsn, &lip->li_lsn); 1434 1311 1435 1312 /* 1436 1313 * copy the lsn into the on-disk dquot now while we have the in memory ··· 1449 1312 * of a dquot without an up-to-date CRC getting to disk. 1450 1313 */ 1451 1314 if (xfs_has_crc(mp)) { 1452 - dqblk->dd_lsn = cpu_to_be64(dqp->q_logitem.qli_item.li_lsn); 1315 + dqblk->dd_lsn = cpu_to_be64(lip->li_lsn); 1453 1316 xfs_update_cksum((char *)dqblk, sizeof(struct xfs_dqblk), 1454 1317 XFS_DQUOT_CRC_OFF); 1455 1318 } ··· 1459 1322 * the AIL and release the flush lock once the dquot is synced to disk. 1460 1323 */ 1461 1324 bp->b_flags |= _XBF_DQUOTS; 1462 - list_add_tail(&dqp->q_logitem.qli_item.li_bio_list, &bp->b_li_list); 1325 + list_add_tail(&lip->li_bio_list, &bp->b_li_list); 1463 1326 1464 1327 /* 1465 1328 * If the buffer is pinned then push on the log so we won't ··· 1471 1334 } 1472 1335 1473 1336 trace_xfs_dqflush_done(dqp); 1474 - *bpp = bp; 1475 1337 return 0; 1476 1338 1477 1339 out_abort: 1478 1340 dqp->q_flags &= ~XFS_DQFLAG_DIRTY; 1479 1341 xfs_trans_ail_delete(lip, 0); 1480 1342 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 1481 - out_unlock: 1482 1343 xfs_dqfunlock(dqp); 1483 1344 return error; 1484 1345 }
+5 -1
fs/xfs/xfs_dquot.h
··· 214 214 #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->q_flags & XFS_DQFLAG_DIRTY) 215 215 216 216 void xfs_qm_dqdestroy(struct xfs_dquot *dqp); 217 - int xfs_qm_dqflush(struct xfs_dquot *dqp, struct xfs_buf **bpp); 217 + int xfs_qm_dqflush(struct xfs_dquot *dqp, struct xfs_buf *bp); 218 218 void xfs_qm_dqunpin_wait(struct xfs_dquot *dqp); 219 219 void xfs_qm_adjust_dqtimers(struct xfs_dquot *d); 220 220 void xfs_qm_adjust_dqlimits(struct xfs_dquot *d); ··· 236 236 void xfs_dqlockn(struct xfs_dqtrx *q); 237 237 238 238 void xfs_dquot_set_prealloc_limits(struct xfs_dquot *); 239 + 240 + int xfs_dquot_attach_buf(struct xfs_trans *tp, struct xfs_dquot *dqp); 241 + int xfs_dquot_use_attached_buf(struct xfs_dquot *dqp, struct xfs_buf **bpp); 242 + void xfs_dquot_detach_buf(struct xfs_dquot *dqp); 239 243 240 244 static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp) 241 245 {
+37 -14
fs/xfs/xfs_dquot_item.c
··· 123 123 __releases(&lip->li_ailp->ail_lock) 124 124 __acquires(&lip->li_ailp->ail_lock) 125 125 { 126 - struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot; 127 - struct xfs_buf *bp = lip->li_buf; 126 + struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); 127 + struct xfs_dquot *dqp = qlip->qli_dquot; 128 + struct xfs_buf *bp; 128 129 uint rval = XFS_ITEM_SUCCESS; 129 130 int error; 130 131 ··· 156 155 157 156 spin_unlock(&lip->li_ailp->ail_lock); 158 157 159 - error = xfs_qm_dqflush(dqp, &bp); 158 + error = xfs_dquot_use_attached_buf(dqp, &bp); 159 + if (error == -EAGAIN) { 160 + xfs_dqfunlock(dqp); 161 + rval = XFS_ITEM_LOCKED; 162 + goto out_relock_ail; 163 + } 164 + 165 + /* 166 + * dqflush completes dqflock on error, and the delwri ioend does it on 167 + * success. 168 + */ 169 + error = xfs_qm_dqflush(dqp, bp); 160 170 if (!error) { 161 171 if (!xfs_buf_delwri_queue(bp, buffer_list)) 162 172 rval = XFS_ITEM_FLUSHING; 163 - xfs_buf_relse(bp); 164 - } else if (error == -EAGAIN) 165 - rval = XFS_ITEM_LOCKED; 173 + } 174 + xfs_buf_relse(bp); 166 175 176 + out_relock_ail: 167 177 spin_lock(&lip->li_ailp->ail_lock); 168 178 out_unlock: 169 179 xfs_dqunlock(dqp); ··· 207 195 } 208 196 209 197 #ifdef DEBUG_EXPENSIVE 210 - static int 211 - xfs_qm_dquot_logitem_precommit( 212 - struct xfs_trans *tp, 213 - struct xfs_log_item *lip) 198 + static void 199 + xfs_qm_dquot_logitem_precommit_check( 200 + struct xfs_dquot *dqp) 214 201 { 215 - struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot; 216 202 struct xfs_mount *mp = dqp->q_mount; 217 203 struct xfs_disk_dquot ddq = { }; 218 204 xfs_failaddr_t fa; ··· 226 216 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 227 217 ASSERT(fa == NULL); 228 218 } 229 - 230 - return 0; 231 219 } 232 220 #else 233 - # define xfs_qm_dquot_logitem_precommit NULL 221 + # define xfs_qm_dquot_logitem_precommit_check(...) ((void)0) 234 222 #endif 223 + 224 + static int 225 + xfs_qm_dquot_logitem_precommit( 226 + struct xfs_trans *tp, 227 + struct xfs_log_item *lip) 228 + { 229 + struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); 230 + struct xfs_dquot *dqp = qlip->qli_dquot; 231 + 232 + xfs_qm_dquot_logitem_precommit_check(dqp); 233 + 234 + return xfs_dquot_attach_buf(tp, dqp); 235 + } 235 236 236 237 static const struct xfs_item_ops xfs_dquot_item_ops = { 237 238 .iop_size = xfs_qm_dquot_logitem_size, ··· 268 247 269 248 xfs_log_item_init(dqp->q_mount, &lp->qli_item, XFS_LI_DQUOT, 270 249 &xfs_dquot_item_ops); 250 + spin_lock_init(&lp->qli_lock); 271 251 lp->qli_dquot = dqp; 252 + lp->qli_dirty = false; 272 253 }
+7
fs/xfs/xfs_dquot_item.h
··· 14 14 struct xfs_log_item qli_item; /* common portion */ 15 15 struct xfs_dquot *qli_dquot; /* dquot ptr */ 16 16 xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ 17 + 18 + /* 19 + * We use this spinlock to coordinate access to the li_buf pointer in 20 + * the log item and the qli_dirty flag. 21 + */ 22 + spinlock_t qli_lock; 23 + bool qli_dirty; /* dirtied since last flush? */ 17 24 }; 18 25 19 26 void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp);
+7 -7
fs/xfs/xfs_exchrange.c
··· 854 854 struct xfs_commit_range __user *argp) 855 855 { 856 856 struct xfs_commit_range args = { }; 857 - struct timespec64 ts; 857 + struct kstat kstat = { }; 858 858 struct xfs_commit_range_fresh *kern_f; 859 859 struct xfs_commit_range_fresh __user *user_f; 860 860 struct inode *inode2 = file_inode(file); ··· 871 871 memcpy(&kern_f->fsid, ip2->i_mount->m_fixedfsid, sizeof(xfs_fsid_t)); 872 872 873 873 xfs_ilock(ip2, lockflags); 874 - ts = inode_get_ctime(inode2); 875 - kern_f->file2_ctime = ts.tv_sec; 876 - kern_f->file2_ctime_nsec = ts.tv_nsec; 877 - ts = inode_get_mtime(inode2); 878 - kern_f->file2_mtime = ts.tv_sec; 879 - kern_f->file2_mtime_nsec = ts.tv_nsec; 874 + /* Force writing of a distinct ctime if any writes happen. */ 875 + fill_mg_cmtime(&kstat, STATX_CTIME | STATX_MTIME, inode2); 876 + kern_f->file2_ctime = kstat.ctime.tv_sec; 877 + kern_f->file2_ctime_nsec = kstat.ctime.tv_nsec; 878 + kern_f->file2_mtime = kstat.mtime.tv_sec; 879 + kern_f->file2_mtime_nsec = kstat.mtime.tv_nsec; 880 880 kern_f->file2_ino = ip2->i_ino; 881 881 kern_f->file2_gen = inode2->i_generation; 882 882 kern_f->magic = XCR_FRESH_MAGIC;
+8
fs/xfs/xfs_file.c
··· 1242 1242 xfs_iunlock2_remapping(src, dest); 1243 1243 if (ret) 1244 1244 trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); 1245 + /* 1246 + * If the caller did not set CAN_SHORTEN, then it is not prepared to 1247 + * handle partial results -- either the whole remap succeeds, or we 1248 + * must say why it did not. In this case, any error should be returned 1249 + * to the caller. 1250 + */ 1251 + if (ret && remapped < len && !(remap_flags & REMAP_FILE_CAN_SHORTEN)) 1252 + return ret; 1245 1253 return remapped > 0 ? remapped : ret; 1246 1254 } 1247 1255
+22 -16
fs/xfs/xfs_fsmap.c
··· 163 163 xfs_daddr_t next_daddr; /* next daddr we expect */ 164 164 /* daddr of low fsmap key when we're using the rtbitmap */ 165 165 xfs_daddr_t low_daddr; 166 - xfs_daddr_t end_daddr; /* daddr of high fsmap key */ 166 + /* daddr of high fsmap key, or the last daddr on the device */ 167 + xfs_daddr_t end_daddr; 167 168 u64 missing_owner; /* owner of holes */ 168 169 u32 dev; /* device id */ 169 170 /* ··· 388 387 * we calculated from userspace's high key to synthesize the record. 389 388 * Note that if the btree query found a mapping, there won't be a gap. 390 389 */ 391 - if (info->last && info->end_daddr != XFS_BUF_DADDR_NULL) 392 - frec->start_daddr = info->end_daddr; 390 + if (info->last) 391 + frec->start_daddr = info->end_daddr + 1; 393 392 else 394 393 frec->start_daddr = xfs_gbno_to_daddr(xg, startblock); 395 394 ··· 737 736 * we calculated from userspace's high key to synthesize the record. 738 737 * Note that if the btree query found a mapping, there won't be a gap. 739 738 */ 740 - if (info->last && info->end_daddr != XFS_BUF_DADDR_NULL) { 741 - frec.start_daddr = info->end_daddr; 742 - } else { 739 + if (info->last) 740 + frec.start_daddr = info->end_daddr + 1; 741 + else 743 742 frec.start_daddr = xfs_rtb_to_daddr(mp, start_rtb); 744 - } 745 743 746 744 frec.len_daddr = XFS_FSB_TO_BB(mp, rtbcount); 747 745 return xfs_getfsmap_helper(tp, info, &frec); ··· 933 933 struct xfs_trans *tp = NULL; 934 934 struct xfs_fsmap dkeys[2]; /* per-dev keys */ 935 935 struct xfs_getfsmap_dev handlers[XFS_GETFSMAP_DEVS]; 936 - struct xfs_getfsmap_info info = { NULL }; 936 + struct xfs_getfsmap_info info = { 937 + .fsmap_recs = fsmap_recs, 938 + .head = head, 939 + }; 937 940 bool use_rmap; 938 941 int i; 939 942 int error = 0; ··· 1001 998 1002 999 info.next_daddr = head->fmh_keys[0].fmr_physical + 1003 1000 head->fmh_keys[0].fmr_length; 1004 - info.end_daddr = XFS_BUF_DADDR_NULL; 1005 - info.fsmap_recs = fsmap_recs; 1006 - info.head = head; 1007 1001 1008 1002 /* For each device we support... */ 1009 1003 for (i = 0; i < XFS_GETFSMAP_DEVS; i++) { ··· 1013 1013 break; 1014 1014 1015 1015 /* 1016 - * If this device number matches the high key, we have 1017 - * to pass the high key to the handler to limit the 1018 - * query results. If the device number exceeds the 1019 - * low key, zero out the low key so that we get 1020 - * everything from the beginning. 1016 + * If this device number matches the high key, we have to pass 1017 + * the high key to the handler to limit the query results, and 1018 + * set the end_daddr so that we can synthesize records at the 1019 + * end of the query range or device. 1021 1020 */ 1022 1021 if (handlers[i].dev == head->fmh_keys[1].fmr_device) { 1023 1022 dkeys[1] = head->fmh_keys[1]; 1024 1023 info.end_daddr = min(handlers[i].nr_sectors - 1, 1025 1024 dkeys[1].fmr_physical); 1025 + } else { 1026 + info.end_daddr = handlers[i].nr_sectors - 1; 1026 1027 } 1028 + 1029 + /* 1030 + * If the device number exceeds the low key, zero out the low 1031 + * key so that we get everything from the beginning. 1032 + */ 1027 1033 if (handlers[i].dev > head->fmh_keys[0].fmr_device) 1028 1034 memset(&dkeys[0], 0, sizeof(struct xfs_fsmap)); 1029 1035
+1 -1
fs/xfs/xfs_inode.h
··· 231 231 } 232 232 233 233 static inline int 234 - __xfs_iflags_test(xfs_inode_t *ip, unsigned long flags) 234 + __xfs_iflags_test(const struct xfs_inode *ip, unsigned long flags) 235 235 { 236 236 return (ip->i_flags & flags); 237 237 }
+74 -30
fs/xfs/xfs_qm.c
··· 148 148 * We don't care about getting disk errors here. We need 149 149 * to purge this dquot anyway, so we go ahead regardless. 150 150 */ 151 - error = xfs_qm_dqflush(dqp, &bp); 152 - if (!error) { 153 - error = xfs_bwrite(bp); 154 - xfs_buf_relse(bp); 155 - } else if (error == -EAGAIN) { 151 + error = xfs_dquot_use_attached_buf(dqp, &bp); 152 + if (error == -EAGAIN) { 153 + xfs_dqfunlock(dqp); 156 154 dqp->q_flags &= ~XFS_DQFLAG_FREEING; 157 155 goto out_unlock; 158 156 } 157 + if (!bp) 158 + goto out_funlock; 159 + 160 + /* 161 + * dqflush completes dqflock on error, and the bwrite ioend 162 + * does it on success. 163 + */ 164 + error = xfs_qm_dqflush(dqp, bp); 165 + if (!error) { 166 + error = xfs_bwrite(bp); 167 + xfs_buf_relse(bp); 168 + } 159 169 xfs_dqflock(dqp); 160 170 } 171 + xfs_dquot_detach_buf(dqp); 161 172 173 + out_funlock: 162 174 ASSERT(atomic_read(&dqp->q_pincount) == 0); 163 175 ASSERT(xlog_is_shutdown(dqp->q_logitem.qli_item.li_log) || 164 176 !test_bit(XFS_LI_IN_AIL, &dqp->q_logitem.qli_item.li_flags)); ··· 252 240 if (qi->qi_pquotaip) { 253 241 xfs_irele(qi->qi_pquotaip); 254 242 qi->qi_pquotaip = NULL; 243 + } 244 + if (qi->qi_dirip) { 245 + xfs_irele(qi->qi_dirip); 246 + qi->qi_dirip = NULL; 255 247 } 256 248 } 257 249 ··· 506 490 /* we have to drop the LRU lock to flush the dquot */ 507 491 spin_unlock(&lru->lock); 508 492 509 - error = xfs_qm_dqflush(dqp, &bp); 493 + error = xfs_dquot_use_attached_buf(dqp, &bp); 494 + if (!bp || error == -EAGAIN) { 495 + xfs_dqfunlock(dqp); 496 + goto out_unlock_dirty; 497 + } 498 + 499 + /* 500 + * dqflush completes dqflock on error, and the delwri ioend 501 + * does it on success. 502 + */ 503 + error = xfs_qm_dqflush(dqp, bp); 510 504 if (error) 511 505 goto out_unlock_dirty; 512 506 ··· 524 498 xfs_buf_relse(bp); 525 499 goto out_unlock_dirty; 526 500 } 501 + 502 + xfs_dquot_detach_buf(dqp); 527 503 xfs_dqfunlock(dqp); 528 504 529 505 /* ··· 674 646 static int 675 647 xfs_qm_load_metadir_qinos( 676 648 struct xfs_mount *mp, 677 - struct xfs_quotainfo *qi, 678 - struct xfs_inode **dpp) 649 + struct xfs_quotainfo *qi) 679 650 { 680 651 struct xfs_trans *tp; 681 652 int error; ··· 683 656 if (error) 684 657 return error; 685 658 686 - error = xfs_dqinode_load_parent(tp, dpp); 659 + error = xfs_dqinode_load_parent(tp, &qi->qi_dirip); 687 660 if (error == -ENOENT) { 688 661 /* no quota dir directory, but we'll create one later */ 689 662 error = 0; ··· 693 666 goto out_trans; 694 667 695 668 if (XFS_IS_UQUOTA_ON(mp)) { 696 - error = xfs_dqinode_load(tp, *dpp, XFS_DQTYPE_USER, 669 + error = xfs_dqinode_load(tp, qi->qi_dirip, XFS_DQTYPE_USER, 697 670 &qi->qi_uquotaip); 698 671 if (error && error != -ENOENT) 699 672 goto out_trans; 700 673 } 701 674 702 675 if (XFS_IS_GQUOTA_ON(mp)) { 703 - error = xfs_dqinode_load(tp, *dpp, XFS_DQTYPE_GROUP, 676 + error = xfs_dqinode_load(tp, qi->qi_dirip, XFS_DQTYPE_GROUP, 704 677 &qi->qi_gquotaip); 705 678 if (error && error != -ENOENT) 706 679 goto out_trans; 707 680 } 708 681 709 682 if (XFS_IS_PQUOTA_ON(mp)) { 710 - error = xfs_dqinode_load(tp, *dpp, XFS_DQTYPE_PROJ, 683 + error = xfs_dqinode_load(tp, qi->qi_dirip, XFS_DQTYPE_PROJ, 711 684 &qi->qi_pquotaip); 712 685 if (error && error != -ENOENT) 713 686 goto out_trans; ··· 723 696 STATIC int 724 697 xfs_qm_create_metadir_qinos( 725 698 struct xfs_mount *mp, 726 - struct xfs_quotainfo *qi, 727 - struct xfs_inode **dpp) 699 + struct xfs_quotainfo *qi) 728 700 { 729 701 int error; 730 702 731 - if (!*dpp) { 732 - error = xfs_dqinode_mkdir_parent(mp, dpp); 703 + if (!qi->qi_dirip) { 704 + error = xfs_dqinode_mkdir_parent(mp, &qi->qi_dirip); 733 705 if (error && error != -EEXIST) 734 706 return error; 707 + /* 708 + * If the /quotas dirent points to an inode that isn't 709 + * loadable, qi_dirip will be NULL but mkdir_parent will return 710 + * -EEXIST. In this case the metadir is corrupt, so bail out. 711 + */ 712 + if (XFS_IS_CORRUPT(mp, qi->qi_dirip == NULL)) 713 + return -EFSCORRUPTED; 735 714 } 736 715 737 716 if (XFS_IS_UQUOTA_ON(mp) && !qi->qi_uquotaip) { 738 - error = xfs_dqinode_metadir_create(*dpp, XFS_DQTYPE_USER, 739 - &qi->qi_uquotaip); 717 + error = xfs_dqinode_metadir_create(qi->qi_dirip, 718 + XFS_DQTYPE_USER, &qi->qi_uquotaip); 740 719 if (error) 741 720 return error; 742 721 } 743 722 744 723 if (XFS_IS_GQUOTA_ON(mp) && !qi->qi_gquotaip) { 745 - error = xfs_dqinode_metadir_create(*dpp, XFS_DQTYPE_GROUP, 746 - &qi->qi_gquotaip); 724 + error = xfs_dqinode_metadir_create(qi->qi_dirip, 725 + XFS_DQTYPE_GROUP, &qi->qi_gquotaip); 747 726 if (error) 748 727 return error; 749 728 } 750 729 751 730 if (XFS_IS_PQUOTA_ON(mp) && !qi->qi_pquotaip) { 752 - error = xfs_dqinode_metadir_create(*dpp, XFS_DQTYPE_PROJ, 753 - &qi->qi_pquotaip); 731 + error = xfs_dqinode_metadir_create(qi->qi_dirip, 732 + XFS_DQTYPE_PROJ, &qi->qi_pquotaip); 754 733 if (error) 755 734 return error; 756 735 } ··· 801 768 struct xfs_mount *mp) 802 769 { 803 770 struct xfs_quotainfo *qi = mp->m_quotainfo; 804 - struct xfs_inode *dp = NULL; 805 771 int error; 806 772 807 773 if (!xfs_has_quota(mp)) { ··· 809 777 return error; 810 778 } 811 779 812 - error = xfs_qm_load_metadir_qinos(mp, qi, &dp); 780 + error = xfs_qm_load_metadir_qinos(mp, qi); 813 781 if (error) 814 782 goto out_err; 815 783 816 - error = xfs_qm_create_metadir_qinos(mp, qi, &dp); 784 + error = xfs_qm_create_metadir_qinos(mp, qi); 817 785 if (error) 818 786 goto out_err; 819 787 820 - xfs_irele(dp); 788 + /* The only user of the quota dir inode is online fsck */ 789 + #if !IS_ENABLED(CONFIG_XFS_ONLINE_SCRUB) 790 + xfs_irele(qi->qi_dirip); 791 + qi->qi_dirip = NULL; 792 + #endif 821 793 return 0; 822 794 out_err: 823 795 xfs_qm_destroy_quotainos(mp->m_quotainfo); 824 - if (dp) 825 - xfs_irele(dp); 826 796 return error; 827 797 } 828 798 ··· 1338 1304 return error; 1339 1305 } 1340 1306 1307 + error = xfs_dquot_attach_buf(NULL, dqp); 1308 + if (error) 1309 + return error; 1310 + 1341 1311 trace_xfs_dqadjust(dqp); 1342 1312 1343 1313 /* ··· 1524 1486 goto out_unlock; 1525 1487 } 1526 1488 1527 - error = xfs_qm_dqflush(dqp, &bp); 1489 + error = xfs_dquot_use_attached_buf(dqp, &bp); 1528 1490 if (error) 1529 1491 goto out_unlock; 1492 + if (!bp) { 1493 + error = -EFSCORRUPTED; 1494 + goto out_unlock; 1495 + } 1530 1496 1531 - xfs_buf_delwri_queue(bp, buffer_list); 1497 + error = xfs_qm_dqflush(dqp, bp); 1498 + if (!error) 1499 + xfs_buf_delwri_queue(bp, buffer_list); 1532 1500 xfs_buf_relse(bp); 1533 1501 out_unlock: 1534 1502 xfs_dqunlock(dqp);
+1
fs/xfs/xfs_qm.h
··· 55 55 struct xfs_inode *qi_uquotaip; /* user quota inode */ 56 56 struct xfs_inode *qi_gquotaip; /* group quota inode */ 57 57 struct xfs_inode *qi_pquotaip; /* project quota inode */ 58 + struct xfs_inode *qi_dirip; /* quota metadir */ 58 59 struct list_lru qi_lru; 59 60 int qi_dquots; 60 61 struct mutex qi_quotaofflock;/* to serialize quotaoff */
+3 -2
fs/xfs/xfs_quota.h
··· 101 101 extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *, 102 102 uint, int64_t); 103 103 extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); 104 - extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); 104 + void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *tp, 105 + bool already_locked); 105 106 int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip, 106 107 int64_t dblocks, int64_t rblocks, bool force); 107 108 extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, ··· 174 173 { 175 174 } 176 175 #define xfs_trans_apply_dquot_deltas(tp) 177 - #define xfs_trans_unreserve_and_mod_dquots(tp) 176 + #define xfs_trans_unreserve_and_mod_dquots(tp, a) 178 177 static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, 179 178 struct xfs_inode *ip, int64_t dblocks, int64_t rblocks, 180 179 bool force)
+1 -1
fs/xfs/xfs_rtalloc.c
··· 1827 1827 * For an allocation to an empty file at offset 0, pick an extent that 1828 1828 * will space things out in the rt area. 1829 1829 */ 1830 - if (bno_hint) 1830 + if (bno_hint != NULLFSBLOCK) 1831 1831 start = xfs_rtb_to_rtx(args.mp, bno_hint); 1832 1832 else if (!xfs_has_rtgroups(args.mp) && initial_user_data) 1833 1833 start = xfs_rtpick_extent(args.rtg, tp, maxlen);
+27 -29
fs/xfs/xfs_trans.c
··· 860 860 861 861 trace_xfs_trans_commit(tp, _RET_IP_); 862 862 863 - error = xfs_trans_run_precommits(tp); 864 - if (error) { 865 - if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) 866 - xfs_defer_cancel(tp); 867 - goto out_unreserve; 868 - } 869 - 870 863 /* 871 - * Finish deferred items on final commit. Only permanent transactions 872 - * should ever have deferred ops. 864 + * Commit per-transaction changes that are not already tracked through 865 + * log items. This can add dirty log items to the transaction. 873 866 */ 874 - WARN_ON_ONCE(!list_empty(&tp->t_dfops) && 875 - !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); 876 - if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { 877 - error = xfs_defer_finish_noroll(&tp); 878 - if (error) 879 - goto out_unreserve; 867 + if (tp->t_flags & XFS_TRANS_SB_DIRTY) 868 + xfs_trans_apply_sb_deltas(tp); 869 + xfs_trans_apply_dquot_deltas(tp); 880 870 881 - /* Run precommits from final tx in defer chain. */ 882 - error = xfs_trans_run_precommits(tp); 883 - if (error) 884 - goto out_unreserve; 885 - } 871 + error = xfs_trans_run_precommits(tp); 872 + if (error) 873 + goto out_unreserve; 886 874 887 875 /* 888 876 * If there is nothing to be logged by the transaction, ··· 894 906 } 895 907 896 908 ASSERT(tp->t_ticket != NULL); 897 - 898 - /* 899 - * If we need to update the superblock, then do it now. 900 - */ 901 - if (tp->t_flags & XFS_TRANS_SB_DIRTY) 902 - xfs_trans_apply_sb_deltas(tp); 903 - xfs_trans_apply_dquot_deltas(tp); 904 909 905 910 xlog_cil_commit(log, tp, &commit_seq, regrant); 906 911 ··· 920 939 * the dqinfo portion to be. All that means is that we have some 921 940 * (non-persistent) quota reservations that need to be unreserved. 922 941 */ 923 - xfs_trans_unreserve_and_mod_dquots(tp); 942 + xfs_trans_unreserve_and_mod_dquots(tp, true); 924 943 if (tp->t_ticket) { 925 944 if (regrant && !xlog_is_shutdown(log)) 926 945 xfs_log_ticket_regrant(log, tp->t_ticket); ··· 939 958 xfs_trans_commit( 940 959 struct xfs_trans *tp) 941 960 { 961 + /* 962 + * Finish deferred items on final commit. Only permanent transactions 963 + * should ever have deferred ops. 964 + */ 965 + WARN_ON_ONCE(!list_empty(&tp->t_dfops) && 966 + !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); 967 + if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) { 968 + int error = xfs_defer_finish_noroll(&tp); 969 + if (error) { 970 + xfs_trans_cancel(tp); 971 + return error; 972 + } 973 + } 974 + 942 975 return __xfs_trans_commit(tp, false); 943 976 } 944 977 ··· 1014 1019 } 1015 1020 #endif 1016 1021 xfs_trans_unreserve_and_mod_sb(tp); 1017 - xfs_trans_unreserve_and_mod_dquots(tp); 1022 + xfs_trans_unreserve_and_mod_dquots(tp, false); 1018 1023 1019 1024 if (tp->t_ticket) { 1020 1025 xfs_log_ticket_ungrant(log, tp->t_ticket); ··· 1430 1435 1431 1436 out_cancel: 1432 1437 xfs_trans_cancel(tp); 1438 + xfs_iunlock(dp, XFS_ILOCK_EXCL); 1439 + if (dp != ip) 1440 + xfs_iunlock(ip, XFS_ILOCK_EXCL); 1433 1441 return error; 1434 1442 }
+1 -1
fs/xfs/xfs_trans_ail.c
··· 360 360 361 361 /* protected by ail_lock */ 362 362 list_for_each_entry(lip, &bp->b_li_list, li_bio_list) { 363 - if (bp->b_flags & _XBF_INODES) 363 + if (bp->b_flags & (_XBF_INODES | _XBF_DQUOTS)) 364 364 clear_bit(XFS_LI_FAILED, &lip->li_flags); 365 365 else 366 366 xfs_clear_li_failed(lip);
+26 -5
fs/xfs/xfs_trans_dquot.c
··· 606 606 ASSERT(dqp->q_blk.reserved >= dqp->q_blk.count); 607 607 ASSERT(dqp->q_ino.reserved >= dqp->q_ino.count); 608 608 ASSERT(dqp->q_rtb.reserved >= dqp->q_rtb.count); 609 + 610 + /* 611 + * We've applied the count changes and given back 612 + * whatever reservation we didn't use. Zero out the 613 + * dqtrx fields. 614 + */ 615 + qtrx->qt_blk_res = 0; 616 + qtrx->qt_bcount_delta = 0; 617 + qtrx->qt_delbcnt_delta = 0; 618 + 619 + qtrx->qt_rtblk_res = 0; 620 + qtrx->qt_rtblk_res_used = 0; 621 + qtrx->qt_rtbcount_delta = 0; 622 + qtrx->qt_delrtb_delta = 0; 623 + 624 + qtrx->qt_ino_res = 0; 625 + qtrx->qt_ino_res_used = 0; 626 + qtrx->qt_icount_delta = 0; 609 627 } 610 628 } 611 629 } ··· 660 642 */ 661 643 void 662 644 xfs_trans_unreserve_and_mod_dquots( 663 - struct xfs_trans *tp) 645 + struct xfs_trans *tp, 646 + bool already_locked) 664 647 { 665 648 int i, j; 666 649 struct xfs_dquot *dqp; ··· 690 671 * about the number of blocks used field, or deltas. 691 672 * Also we don't bother to zero the fields. 692 673 */ 693 - locked = false; 674 + locked = already_locked; 694 675 if (qtrx->qt_blk_res) { 695 - xfs_dqlock(dqp); 696 - locked = true; 676 + if (!locked) { 677 + xfs_dqlock(dqp); 678 + locked = true; 679 + } 697 680 dqp->q_blk.reserved -= 698 681 (xfs_qcnt_t)qtrx->qt_blk_res; 699 682 } ··· 716 695 dqp->q_rtb.reserved -= 717 696 (xfs_qcnt_t)qtrx->qt_rtblk_res; 718 697 } 719 - if (locked) 698 + if (locked && !already_locked) 720 699 xfs_dqunlock(dqp); 721 700 722 701 }
+2
include/clocksource/hyperv_timer.h
··· 38 38 extern unsigned long hv_get_tsc_pfn(void); 39 39 extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void); 40 40 41 + extern void hv_adj_sched_clock_offset(u64 offset); 42 + 41 43 static __always_inline bool 42 44 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, 43 45 u64 *cur_tsc, u64 *time)
+8 -5
include/linux/arm_ffa.h
··· 166 166 return dev_get_drvdata(&fdev->dev); 167 167 } 168 168 169 + struct ffa_partition_info; 170 + 169 171 #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT) 170 - struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, 171 - const struct ffa_ops *ops); 172 + struct ffa_device * 173 + ffa_device_register(const struct ffa_partition_info *part_info, 174 + const struct ffa_ops *ops); 172 175 void ffa_device_unregister(struct ffa_device *ffa_dev); 173 176 int ffa_driver_register(struct ffa_driver *driver, struct module *owner, 174 177 const char *mod_name); ··· 179 176 bool ffa_device_is_valid(struct ffa_device *ffa_dev); 180 177 181 178 #else 182 - static inline 183 - struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, 184 - const struct ffa_ops *ops) 179 + static inline struct ffa_device * 180 + ffa_device_register(const struct ffa_partition_info *part_info, 181 + const struct ffa_ops *ops) 185 182 { 186 183 return NULL; 187 184 }
+1 -1
include/linux/bio.h
··· 423 423 void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len, 424 424 size_t off); 425 425 int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); 426 - void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter); 426 + void bio_iov_bvec_set(struct bio *bio, const struct iov_iter *iter); 427 427 void __bio_release_pages(struct bio *bio, bool mark_dirty); 428 428 extern void bio_set_pages_dirty(struct bio *bio); 429 429 extern void bio_check_pages_dirty(struct bio *bio);
+3 -2
include/linux/blkdev.h
··· 200 200 spinlock_t zone_wplugs_lock; 201 201 struct mempool_s *zone_wplugs_pool; 202 202 struct hlist_head *zone_wplugs_hash; 203 - struct list_head zone_wplugs_err_list; 204 - struct work_struct zone_wplugs_work; 205 203 struct workqueue_struct *zone_wplugs_wq; 206 204 #endif /* CONFIG_BLK_DEV_ZONED */ 207 205 ··· 1418 1420 1419 1421 return is_seq; 1420 1422 } 1423 + 1424 + int blk_zone_issue_zeroout(struct block_device *bdev, sector_t sector, 1425 + sector_t nr_sects, gfp_t gfp_mask); 1421 1426 1422 1427 static inline unsigned int queue_dma_alignment(const struct request_queue *q) 1423 1428 {
+6 -14
include/linux/bpf.h
··· 1527 1527 bool is_extended; /* true if extended by freplace program */ 1528 1528 bool jits_use_priv_stack; 1529 1529 bool priv_stack_requested; 1530 + bool changes_pkt_data; 1530 1531 u64 prog_array_member_cnt; /* counts how many times as member of prog_array */ 1531 1532 struct mutex ext_mutex; /* mutex for is_extended and prog_array_member_cnt */ 1532 1533 struct bpf_arena *arena; ··· 2194 2193 * rcu-protected dynamically sized maps. 2195 2194 */ 2196 2195 static __always_inline u32 2197 - bpf_prog_run_array_uprobe(const struct bpf_prog_array __rcu *array_rcu, 2196 + bpf_prog_run_array_uprobe(const struct bpf_prog_array *array, 2198 2197 const void *ctx, bpf_prog_run_fn run_prog) 2199 2198 { 2200 2199 const struct bpf_prog_array_item *item; 2201 2200 const struct bpf_prog *prog; 2202 - const struct bpf_prog_array *array; 2203 2201 struct bpf_run_ctx *old_run_ctx; 2204 2202 struct bpf_trace_run_ctx run_ctx; 2205 2203 u32 ret = 1; 2206 2204 2207 2205 might_fault(); 2206 + RCU_LOCKDEP_WARN(!rcu_read_lock_trace_held(), "no rcu lock held"); 2208 2207 2209 - rcu_read_lock_trace(); 2208 + if (unlikely(!array)) 2209 + return ret; 2210 + 2210 2211 migrate_disable(); 2211 2212 2212 2213 run_ctx.is_uprobe = true; 2213 2214 2214 - array = rcu_dereference_check(array_rcu, rcu_read_lock_trace_held()); 2215 - if (unlikely(!array)) 2216 - goto out; 2217 2215 old_run_ctx = bpf_set_run_ctx(&run_ctx.run_ctx); 2218 2216 item = &array->items[0]; 2219 2217 while ((prog = READ_ONCE(item->prog))) { ··· 2227 2227 rcu_read_unlock(); 2228 2228 } 2229 2229 bpf_reset_run_ctx(old_run_ctx); 2230 - out: 2231 2230 migrate_enable(); 2232 - rcu_read_unlock_trace(); 2233 2231 return ret; 2234 2232 } 2235 2233 ··· 3512 3514 static inline bool bpf_is_subprog(const struct bpf_prog *prog) 3513 3515 { 3514 3516 return prog->aux->func_idx != 0; 3515 - } 3516 - 3517 - static inline bool bpf_prog_is_raw_tp(const struct bpf_prog *prog) 3518 - { 3519 - return prog->type == BPF_PROG_TYPE_TRACING && 3520 - prog->expected_attach_type == BPF_TRACE_RAW_TP; 3521 3517 } 3522 3518 3523 3519 #endif /* _LINUX_BPF_H */
+1
include/linux/bpf_verifier.h
··· 659 659 bool args_cached: 1; 660 660 /* true if bpf_fastcall stack region is used by functions that can't be inlined */ 661 661 bool keep_fastcall_stack: 1; 662 + bool changes_pkt_data: 1; 662 663 663 664 enum priv_stack_mode priv_stack_mode; 664 665 u8 arg_cnt;
+27 -12
include/linux/compiler.h
··· 216 216 217 217 #endif /* __KERNEL__ */ 218 218 219 - /* 220 - * Force the compiler to emit 'sym' as a symbol, so that we can reference 221 - * it from inline assembler. Necessary in case 'sym' could be inlined 222 - * otherwise, or eliminated entirely due to lack of references that are 223 - * visible to the compiler. 224 - */ 225 - #define ___ADDRESSABLE(sym, __attrs) \ 226 - static void * __used __attrs \ 227 - __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym; 228 - #define __ADDRESSABLE(sym) \ 229 - ___ADDRESSABLE(sym, __section(".discard.addressable")) 230 - 231 219 /** 232 220 * offset_to_ptr - convert a relative memory offset to an absolute pointer 233 221 * @off: the address of the 32-bit offset value ··· 226 238 } 227 239 228 240 #endif /* __ASSEMBLY__ */ 241 + 242 + #ifdef CONFIG_64BIT 243 + #define ARCH_SEL(a,b) a 244 + #else 245 + #define ARCH_SEL(a,b) b 246 + #endif 247 + 248 + /* 249 + * Force the compiler to emit 'sym' as a symbol, so that we can reference 250 + * it from inline assembler. Necessary in case 'sym' could be inlined 251 + * otherwise, or eliminated entirely due to lack of references that are 252 + * visible to the compiler. 253 + */ 254 + #define ___ADDRESSABLE(sym, __attrs) \ 255 + static void * __used __attrs \ 256 + __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym; 257 + 258 + #define __ADDRESSABLE(sym) \ 259 + ___ADDRESSABLE(sym, __section(".discard.addressable")) 260 + 261 + #define __ADDRESSABLE_ASM(sym) \ 262 + .pushsection .discard.addressable,"aw"; \ 263 + .align ARCH_SEL(8,4); \ 264 + ARCH_SEL(.quad, .long) __stringify(sym); \ 265 + .popsection; 266 + 267 + #define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym)) 229 268 230 269 #ifdef __CHECKER__ 231 270 #define __BUILD_BUG_ON_ZERO_MSG(e, msg) (0)
+1 -1
include/linux/filter.h
··· 1122 1122 bool bpf_jit_supports_private_stack(void); 1123 1123 u64 bpf_arch_uaddress_limit(void); 1124 1124 void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie); 1125 - bool bpf_helper_changes_pkt_data(void *func); 1125 + bool bpf_helper_changes_pkt_data(enum bpf_func_id func_id); 1126 1126 1127 1127 static inline bool bpf_dump_raw_ok(const struct cred *cred) 1128 1128 {
+13 -1
include/linux/fortify-string.h
··· 616 616 return false; 617 617 } 618 618 619 + /* 620 + * To work around what seems to be an optimizer bug, the macro arguments 621 + * need to have const copies or the values end up changed by the time they 622 + * reach fortify_warn_once(). See commit 6f7630b1b5bc ("fortify: Capture 623 + * __bos() results in const temp vars") for more details. 624 + */ 619 625 #define __fortify_memcpy_chk(p, q, size, p_size, q_size, \ 620 626 p_size_field, q_size_field, op) ({ \ 621 627 const size_t __fortify_size = (size_t)(size); \ ··· 629 623 const size_t __q_size = (q_size); \ 630 624 const size_t __p_size_field = (p_size_field); \ 631 625 const size_t __q_size_field = (q_size_field); \ 626 + /* Keep a mutable version of the size for the final copy. */ \ 627 + size_t __copy_size = __fortify_size; \ 632 628 fortify_warn_once(fortify_memcpy_chk(__fortify_size, __p_size, \ 633 629 __q_size, __p_size_field, \ 634 630 __q_size_field, FORTIFY_FUNC_ ##op), \ ··· 638 630 __fortify_size, \ 639 631 "field \"" #p "\" at " FILE_LINE, \ 640 632 __p_size_field); \ 641 - __underlying_##op(p, q, __fortify_size); \ 633 + /* Hide only the run-time size from value range tracking to */ \ 634 + /* silence compile-time false positive bounds warnings. */ \ 635 + if (!__builtin_constant_p(__copy_size)) \ 636 + OPTIMIZER_HIDE_VAR(__copy_size); \ 637 + __underlying_##op(p, q, __copy_size); \ 642 638 }) 643 639 644 640 /*
+1
include/linux/hyperv.h
··· 1559 1559 void *channel; 1560 1560 void (*util_cb)(void *); 1561 1561 int (*util_init)(struct hv_util_service *); 1562 + int (*util_init_transport)(void); 1562 1563 void (*util_deinit)(void); 1563 1564 int (*util_pre_suspend)(void); 1564 1565 int (*util_pre_resume)(void);
+7
include/linux/sched.h
··· 656 656 * @dl_defer_armed tells if the deferrable server is waiting 657 657 * for the replenishment timer to activate it. 658 658 * 659 + * @dl_server_active tells if the dlserver is active(started). 660 + * dlserver is started on first cfs enqueue on an idle runqueue 661 + * and is stopped when a dequeue results in 0 cfs tasks on the 662 + * runqueue. In other words, dlserver is active only when cpu's 663 + * runqueue has atleast one cfs task. 664 + * 659 665 * @dl_defer_running tells if the deferrable server is actually 660 666 * running, skipping the defer phase. 661 667 */ ··· 670 664 unsigned int dl_non_contending : 1; 671 665 unsigned int dl_overrun : 1; 672 666 unsigned int dl_server : 1; 667 + unsigned int dl_server_active : 1; 673 668 unsigned int dl_defer : 1; 674 669 unsigned int dl_defer_armed : 1; 675 670 unsigned int dl_defer_running : 1;
+6
include/linux/static_call.h
··· 160 160 161 161 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE 162 162 163 + extern int static_call_initialized; 164 + 163 165 extern int __init static_call_init(void); 164 166 165 167 extern void static_call_force_reinit(void); ··· 227 225 228 226 #elif defined(CONFIG_HAVE_STATIC_CALL) 229 227 228 + #define static_call_initialized 0 229 + 230 230 static inline int static_call_init(void) { return 0; } 231 231 232 232 #define DEFINE_STATIC_CALL(name, _func) \ ··· 284 280 EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name)) 285 281 286 282 #else /* Generic implementation */ 283 + 284 + #define static_call_initialized 0 287 285 288 286 static inline int static_call_init(void) { return 0; } 289 287
+5 -1
include/linux/trace_events.h
··· 273 273 const char *name; 274 274 const int size; 275 275 const int align; 276 - const int is_signed; 276 + const unsigned int is_signed:1; 277 + unsigned int needs_test:1; 277 278 const int filter_type; 278 279 const int len; 279 280 }; ··· 325 324 TRACE_EVENT_FL_EPROBE_BIT, 326 325 TRACE_EVENT_FL_FPROBE_BIT, 327 326 TRACE_EVENT_FL_CUSTOM_BIT, 327 + TRACE_EVENT_FL_TEST_STR_BIT, 328 328 }; 329 329 330 330 /* ··· 342 340 * CUSTOM - Event is a custom event (to be attached to an exsiting tracepoint) 343 341 * This is set when the custom event has not been attached 344 342 * to a tracepoint yet, then it is cleared when it is. 343 + * TEST_STR - The event has a "%s" that points to a string outside the event 345 344 */ 346 345 enum { 347 346 TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT), ··· 355 352 TRACE_EVENT_FL_EPROBE = (1 << TRACE_EVENT_FL_EPROBE_BIT), 356 353 TRACE_EVENT_FL_FPROBE = (1 << TRACE_EVENT_FL_FPROBE_BIT), 357 354 TRACE_EVENT_FL_CUSTOM = (1 << TRACE_EVENT_FL_CUSTOM_BIT), 355 + TRACE_EVENT_FL_TEST_STR = (1 << TRACE_EVENT_FL_TEST_STR_BIT), 358 356 }; 359 357 360 358 #define TRACE_EVENT_FL_UKPROBE (TRACE_EVENT_FL_KPROBE | TRACE_EVENT_FL_UPROBE)
include/soc/arc/aux.h include/soc/arc/arc_aux.h
+1 -1
include/soc/arc/mcip.h
··· 8 8 #ifndef __SOC_ARC_MCIP_H 9 9 #define __SOC_ARC_MCIP_H 10 10 11 - #include <soc/arc/aux.h> 11 + #include <soc/arc/arc_aux.h> 12 12 13 13 #define ARC_REG_MCIP_BCR 0x0d0 14 14 #define ARC_REG_MCIP_IDU_BCR 0x0D5
+1 -1
include/soc/arc/timers.h
··· 6 6 #ifndef __SOC_ARC_TIMERS_H 7 7 #define __SOC_ARC_TIMERS_H 8 8 9 - #include <soc/arc/aux.h> 9 + #include <soc/arc/arc_aux.h> 10 10 11 11 /* Timer related Aux registers */ 12 12 #define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */
-6
include/sound/cs35l56.h
··· 271 271 struct gpio_desc *reset_gpio; 272 272 }; 273 273 274 - /* Temporary to avoid a build break with the HDA driver */ 275 - static inline int cs35l56_force_sync_asp1_registers_from_cache(struct cs35l56_base *cs35l56_base) 276 - { 277 - return 0; 278 - } 279 - 280 274 static inline bool cs35l56_is_otp_register(unsigned int reg) 281 275 { 282 276 return (reg >> 16) == 3;
+4 -2
io_uring/rsrc.c
··· 1036 1036 out_put_free: 1037 1037 i = data.nr; 1038 1038 while (i--) { 1039 - io_buffer_unmap(src_ctx, data.nodes[i]); 1040 - kfree(data.nodes[i]); 1039 + if (data.nodes[i]) { 1040 + io_buffer_unmap(src_ctx, data.nodes[i]); 1041 + kfree(data.nodes[i]); 1042 + } 1041 1043 } 1042 1044 out_unlock: 1043 1045 io_rsrc_data_free(ctx, &data);
+6
kernel/bpf/Makefile
··· 53 53 obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o 54 54 obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o 55 55 obj-$(CONFIG_BPF_SYSCALL) += kmem_cache_iter.o 56 + 57 + CFLAGS_REMOVE_percpu_freelist.o = $(CC_FLAGS_FTRACE) 58 + CFLAGS_REMOVE_bpf_lru_list.o = $(CC_FLAGS_FTRACE) 59 + CFLAGS_REMOVE_queue_stack_maps.o = $(CC_FLAGS_FTRACE) 60 + CFLAGS_REMOVE_lpm_trie.o = $(CC_FLAGS_FTRACE) 61 + CFLAGS_REMOVE_ringbuf.o = $(CC_FLAGS_FTRACE)
+145 -4
kernel/bpf/btf.c
··· 6439 6439 return off; 6440 6440 } 6441 6441 6442 + struct bpf_raw_tp_null_args { 6443 + const char *func; 6444 + u64 mask; 6445 + }; 6446 + 6447 + static const struct bpf_raw_tp_null_args raw_tp_null_args[] = { 6448 + /* sched */ 6449 + { "sched_pi_setprio", 0x10 }, 6450 + /* ... from sched_numa_pair_template event class */ 6451 + { "sched_stick_numa", 0x100 }, 6452 + { "sched_swap_numa", 0x100 }, 6453 + /* afs */ 6454 + { "afs_make_fs_call", 0x10 }, 6455 + { "afs_make_fs_calli", 0x10 }, 6456 + { "afs_make_fs_call1", 0x10 }, 6457 + { "afs_make_fs_call2", 0x10 }, 6458 + { "afs_protocol_error", 0x1 }, 6459 + { "afs_flock_ev", 0x10 }, 6460 + /* cachefiles */ 6461 + { "cachefiles_lookup", 0x1 | 0x200 }, 6462 + { "cachefiles_unlink", 0x1 }, 6463 + { "cachefiles_rename", 0x1 }, 6464 + { "cachefiles_prep_read", 0x1 }, 6465 + { "cachefiles_mark_active", 0x1 }, 6466 + { "cachefiles_mark_failed", 0x1 }, 6467 + { "cachefiles_mark_inactive", 0x1 }, 6468 + { "cachefiles_vfs_error", 0x1 }, 6469 + { "cachefiles_io_error", 0x1 }, 6470 + { "cachefiles_ondemand_open", 0x1 }, 6471 + { "cachefiles_ondemand_copen", 0x1 }, 6472 + { "cachefiles_ondemand_close", 0x1 }, 6473 + { "cachefiles_ondemand_read", 0x1 }, 6474 + { "cachefiles_ondemand_cread", 0x1 }, 6475 + { "cachefiles_ondemand_fd_write", 0x1 }, 6476 + { "cachefiles_ondemand_fd_release", 0x1 }, 6477 + /* ext4, from ext4__mballoc event class */ 6478 + { "ext4_mballoc_discard", 0x10 }, 6479 + { "ext4_mballoc_free", 0x10 }, 6480 + /* fib */ 6481 + { "fib_table_lookup", 0x100 }, 6482 + /* filelock */ 6483 + /* ... from filelock_lock event class */ 6484 + { "posix_lock_inode", 0x10 }, 6485 + { "fcntl_setlk", 0x10 }, 6486 + { "locks_remove_posix", 0x10 }, 6487 + { "flock_lock_inode", 0x10 }, 6488 + /* ... from filelock_lease event class */ 6489 + { "break_lease_noblock", 0x10 }, 6490 + { "break_lease_block", 0x10 }, 6491 + { "break_lease_unblock", 0x10 }, 6492 + { "generic_delete_lease", 0x10 }, 6493 + { "time_out_leases", 0x10 }, 6494 + /* host1x */ 6495 + { "host1x_cdma_push_gather", 0x10000 }, 6496 + /* huge_memory */ 6497 + { "mm_khugepaged_scan_pmd", 0x10 }, 6498 + { "mm_collapse_huge_page_isolate", 0x1 }, 6499 + { "mm_khugepaged_scan_file", 0x10 }, 6500 + { "mm_khugepaged_collapse_file", 0x10 }, 6501 + /* kmem */ 6502 + { "mm_page_alloc", 0x1 }, 6503 + { "mm_page_pcpu_drain", 0x1 }, 6504 + /* .. from mm_page event class */ 6505 + { "mm_page_alloc_zone_locked", 0x1 }, 6506 + /* netfs */ 6507 + { "netfs_failure", 0x10 }, 6508 + /* power */ 6509 + { "device_pm_callback_start", 0x10 }, 6510 + /* qdisc */ 6511 + { "qdisc_dequeue", 0x1000 }, 6512 + /* rxrpc */ 6513 + { "rxrpc_recvdata", 0x1 }, 6514 + { "rxrpc_resend", 0x10 }, 6515 + /* sunrpc */ 6516 + { "xs_stream_read_data", 0x1 }, 6517 + /* ... from xprt_cong_event event class */ 6518 + { "xprt_reserve_cong", 0x10 }, 6519 + { "xprt_release_cong", 0x10 }, 6520 + { "xprt_get_cong", 0x10 }, 6521 + { "xprt_put_cong", 0x10 }, 6522 + /* tcp */ 6523 + { "tcp_send_reset", 0x11 }, 6524 + /* tegra_apb_dma */ 6525 + { "tegra_dma_tx_status", 0x100 }, 6526 + /* timer_migration */ 6527 + { "tmigr_update_events", 0x1 }, 6528 + /* writeback, from writeback_folio_template event class */ 6529 + { "writeback_dirty_folio", 0x10 }, 6530 + { "folio_wait_writeback", 0x10 }, 6531 + /* rdma */ 6532 + { "mr_integ_alloc", 0x2000 }, 6533 + /* bpf_testmod */ 6534 + { "bpf_testmod_test_read", 0x0 }, 6535 + }; 6536 + 6442 6537 bool btf_ctx_access(int off, int size, enum bpf_access_type type, 6443 6538 const struct bpf_prog *prog, 6444 6539 struct bpf_insn_access_aux *info) ··· 6544 6449 const char *tname = prog->aux->attach_func_name; 6545 6450 struct bpf_verifier_log *log = info->log; 6546 6451 const struct btf_param *args; 6452 + bool ptr_err_raw_tp = false; 6547 6453 const char *tag_value; 6548 6454 u32 nr_args, arg; 6549 6455 int i, ret; ··· 6639 6543 return false; 6640 6544 } 6641 6545 6546 + if (size != sizeof(u64)) { 6547 + bpf_log(log, "func '%s' size %d must be 8\n", 6548 + tname, size); 6549 + return false; 6550 + } 6551 + 6642 6552 /* check for PTR_TO_RDONLY_BUF_OR_NULL or PTR_TO_RDWR_BUF_OR_NULL */ 6643 6553 for (i = 0; i < prog->aux->ctx_arg_info_size; i++) { 6644 6554 const struct bpf_ctx_arg_aux *ctx_arg_info = &prog->aux->ctx_arg_info[i]; ··· 6690 6588 if (prog_args_trusted(prog)) 6691 6589 info->reg_type |= PTR_TRUSTED; 6692 6590 6693 - /* Raw tracepoint arguments always get marked as maybe NULL */ 6694 - if (bpf_prog_is_raw_tp(prog)) 6591 + if (btf_param_match_suffix(btf, &args[arg], "__nullable")) 6695 6592 info->reg_type |= PTR_MAYBE_NULL; 6696 - else if (btf_param_match_suffix(btf, &args[arg], "__nullable")) 6697 - info->reg_type |= PTR_MAYBE_NULL; 6593 + 6594 + if (prog->expected_attach_type == BPF_TRACE_RAW_TP) { 6595 + struct btf *btf = prog->aux->attach_btf; 6596 + const struct btf_type *t; 6597 + const char *tname; 6598 + 6599 + /* BTF lookups cannot fail, return false on error */ 6600 + t = btf_type_by_id(btf, prog->aux->attach_btf_id); 6601 + if (!t) 6602 + return false; 6603 + tname = btf_name_by_offset(btf, t->name_off); 6604 + if (!tname) 6605 + return false; 6606 + /* Checked by bpf_check_attach_target */ 6607 + tname += sizeof("btf_trace_") - 1; 6608 + for (i = 0; i < ARRAY_SIZE(raw_tp_null_args); i++) { 6609 + /* Is this a func with potential NULL args? */ 6610 + if (strcmp(tname, raw_tp_null_args[i].func)) 6611 + continue; 6612 + if (raw_tp_null_args[i].mask & (0x1 << (arg * 4))) 6613 + info->reg_type |= PTR_MAYBE_NULL; 6614 + /* Is the current arg IS_ERR? */ 6615 + if (raw_tp_null_args[i].mask & (0x2 << (arg * 4))) 6616 + ptr_err_raw_tp = true; 6617 + break; 6618 + } 6619 + /* If we don't know NULL-ness specification and the tracepoint 6620 + * is coming from a loadable module, be conservative and mark 6621 + * argument as PTR_MAYBE_NULL. 6622 + */ 6623 + if (i == ARRAY_SIZE(raw_tp_null_args) && btf_is_module(btf)) 6624 + info->reg_type |= PTR_MAYBE_NULL; 6625 + } 6698 6626 6699 6627 if (tgt_prog) { 6700 6628 enum bpf_prog_type tgt_type; ··· 6770 6638 bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", 6771 6639 tname, arg, info->btf_id, btf_type_str(t), 6772 6640 __btf_name_by_offset(btf, t->name_off)); 6641 + 6642 + /* Perform all checks on the validity of type for this argument, but if 6643 + * we know it can be IS_ERR at runtime, scrub pointer type and mark as 6644 + * scalar. 6645 + */ 6646 + if (ptr_err_raw_tp) { 6647 + bpf_log(log, "marking pointer arg%d as scalar as it may encode error", arg); 6648 + info->reg_type = SCALAR_VALUE; 6649 + } 6773 6650 return true; 6774 6651 } 6775 6652 EXPORT_SYMBOL_GPL(btf_ctx_access);
+6 -2
kernel/bpf/core.c
··· 539 539 540 540 int bpf_remove_insns(struct bpf_prog *prog, u32 off, u32 cnt) 541 541 { 542 + int err; 543 + 542 544 /* Branch offsets can't overflow when program is shrinking, no need 543 545 * to call bpf_adj_branches(..., true) here 544 546 */ ··· 548 546 sizeof(struct bpf_insn) * (prog->len - off - cnt)); 549 547 prog->len -= cnt; 550 548 551 - return WARN_ON_ONCE(bpf_adj_branches(prog, off, off + cnt, off, false)); 549 + err = bpf_adj_branches(prog, off, off + cnt, off, false); 550 + WARN_ON_ONCE(err); 551 + return err; 552 552 } 553 553 554 554 static void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp) ··· 2940 2936 { 2941 2937 } 2942 2938 2943 - bool __weak bpf_helper_changes_pkt_data(void *func) 2939 + bool __weak bpf_helper_changes_pkt_data(enum bpf_func_id func_id) 2944 2940 { 2945 2941 return false; 2946 2942 }
+78 -82
kernel/bpf/verifier.c
··· 420 420 return rec; 421 421 } 422 422 423 - static bool mask_raw_tp_reg_cond(const struct bpf_verifier_env *env, struct bpf_reg_state *reg) { 424 - return reg->type == (PTR_TO_BTF_ID | PTR_TRUSTED | PTR_MAYBE_NULL) && 425 - bpf_prog_is_raw_tp(env->prog) && !reg->ref_obj_id; 426 - } 427 - 428 - static bool mask_raw_tp_reg(const struct bpf_verifier_env *env, struct bpf_reg_state *reg) 429 - { 430 - if (!mask_raw_tp_reg_cond(env, reg)) 431 - return false; 432 - reg->type &= ~PTR_MAYBE_NULL; 433 - return true; 434 - } 435 - 436 - static void unmask_raw_tp_reg(struct bpf_reg_state *reg, bool result) 437 - { 438 - if (result) 439 - reg->type |= PTR_MAYBE_NULL; 440 - } 441 - 442 423 static bool subprog_is_global(const struct bpf_verifier_env *env, int subprog) 443 424 { 444 425 struct bpf_func_info_aux *aux = env->prog->aux->func_info_aux; ··· 2578 2597 ((struct bpf_subprog_info *)b)->start; 2579 2598 } 2580 2599 2600 + /* Find subprogram that contains instruction at 'off' */ 2601 + static struct bpf_subprog_info *find_containing_subprog(struct bpf_verifier_env *env, int off) 2602 + { 2603 + struct bpf_subprog_info *vals = env->subprog_info; 2604 + int l, r, m; 2605 + 2606 + if (off >= env->prog->len || off < 0 || env->subprog_cnt == 0) 2607 + return NULL; 2608 + 2609 + l = 0; 2610 + r = env->subprog_cnt - 1; 2611 + while (l < r) { 2612 + m = l + (r - l + 1) / 2; 2613 + if (vals[m].start <= off) 2614 + l = m; 2615 + else 2616 + r = m - 1; 2617 + } 2618 + return &vals[l]; 2619 + } 2620 + 2621 + /* Find subprogram that starts exactly at 'off' */ 2581 2622 static int find_subprog(struct bpf_verifier_env *env, int off) 2582 2623 { 2583 2624 struct bpf_subprog_info *p; 2584 2625 2585 - p = bsearch(&off, env->subprog_info, env->subprog_cnt, 2586 - sizeof(env->subprog_info[0]), cmp_subprogs); 2587 - if (!p) 2626 + p = find_containing_subprog(env, off); 2627 + if (!p || p->start != off) 2588 2628 return -ENOENT; 2589 2629 return p - env->subprog_info; 2590 - 2591 2630 } 2592 2631 2593 2632 static int add_subprog(struct bpf_verifier_env *env, int off) ··· 6782 6781 const char *field_name = NULL; 6783 6782 enum bpf_type_flag flag = 0; 6784 6783 u32 btf_id = 0; 6785 - bool mask; 6786 6784 int ret; 6787 6785 6788 6786 if (!env->allow_ptr_leaks) { ··· 6853 6853 6854 6854 if (ret < 0) 6855 6855 return ret; 6856 - /* For raw_tp progs, we allow dereference of PTR_MAYBE_NULL 6857 - * trusted PTR_TO_BTF_ID, these are the ones that are possibly 6858 - * arguments to the raw_tp. Since internal checks in for trusted 6859 - * reg in check_ptr_to_btf_access would consider PTR_MAYBE_NULL 6860 - * modifier as problematic, mask it out temporarily for the 6861 - * check. Don't apply this to pointers with ref_obj_id > 0, as 6862 - * those won't be raw_tp args. 6863 - * 6864 - * We may end up applying this relaxation to other trusted 6865 - * PTR_TO_BTF_ID with maybe null flag, since we cannot 6866 - * distinguish PTR_MAYBE_NULL tagged for arguments vs normal 6867 - * tagging, but that should expand allowed behavior, and not 6868 - * cause regression for existing behavior. 6869 - */ 6870 - mask = mask_raw_tp_reg(env, reg); 6856 + 6871 6857 if (ret != PTR_TO_BTF_ID) { 6872 6858 /* just mark; */ 6873 6859 ··· 6914 6928 clear_trusted_flags(&flag); 6915 6929 } 6916 6930 6917 - if (atype == BPF_READ && value_regno >= 0) { 6931 + if (atype == BPF_READ && value_regno >= 0) 6918 6932 mark_btf_ld_reg(env, regs, value_regno, ret, reg->btf, btf_id, flag); 6919 - /* We've assigned a new type to regno, so don't undo masking. */ 6920 - if (regno == value_regno) 6921 - mask = false; 6922 - } 6923 - unmask_raw_tp_reg(reg, mask); 6924 6933 6925 6934 return 0; 6926 6935 } ··· 7290 7309 if (!err && t == BPF_READ && value_regno >= 0) 7291 7310 mark_reg_unknown(env, regs, value_regno); 7292 7311 } else if (base_type(reg->type) == PTR_TO_BTF_ID && 7293 - (mask_raw_tp_reg_cond(env, reg) || !type_may_be_null(reg->type))) { 7312 + !type_may_be_null(reg->type)) { 7294 7313 err = check_ptr_to_btf_access(env, regs, regno, off, size, t, 7295 7314 value_regno); 7296 7315 } else if (reg->type == CONST_PTR_TO_MAP) { ··· 8993 9012 enum bpf_reg_type type = reg->type; 8994 9013 u32 *arg_btf_id = NULL; 8995 9014 int err = 0; 8996 - bool mask; 8997 9015 8998 9016 if (arg_type == ARG_DONTCARE) 8999 9017 return 0; ··· 9033 9053 base_type(arg_type) == ARG_PTR_TO_SPIN_LOCK) 9034 9054 arg_btf_id = fn->arg_btf_id[arg]; 9035 9055 9036 - mask = mask_raw_tp_reg(env, reg); 9037 9056 err = check_reg_type(env, regno, arg_type, arg_btf_id, meta); 9057 + if (err) 9058 + return err; 9038 9059 9039 - err = err ?: check_func_arg_reg_off(env, reg, regno, arg_type); 9040 - unmask_raw_tp_reg(reg, mask); 9060 + err = check_func_arg_reg_off(env, reg, regno, arg_type); 9041 9061 if (err) 9042 9062 return err; 9043 9063 ··· 9832 9852 return ret; 9833 9853 } else if (base_type(arg->arg_type) == ARG_PTR_TO_BTF_ID) { 9834 9854 struct bpf_call_arg_meta meta; 9835 - bool mask; 9836 9855 int err; 9837 9856 9838 9857 if (register_is_null(reg) && type_may_be_null(arg->arg_type)) 9839 9858 continue; 9840 9859 9841 9860 memset(&meta, 0, sizeof(meta)); /* leave func_id as zero */ 9842 - mask = mask_raw_tp_reg(env, reg); 9843 9861 err = check_reg_type(env, regno, arg->arg_type, &arg->btf_id, &meta); 9844 9862 err = err ?: check_func_arg_reg_off(env, reg, regno, arg->arg_type); 9845 - unmask_raw_tp_reg(reg, mask); 9846 9863 if (err) 9847 9864 return err; 9848 9865 } else { ··· 9999 10022 10000 10023 verbose(env, "Func#%d ('%s') is global and assumed valid.\n", 10001 10024 subprog, sub_name); 10025 + if (env->subprog_info[subprog].changes_pkt_data) 10026 + clear_all_pkt_pointers(env); 10002 10027 /* mark global subprog for verifying after main prog */ 10003 10028 subprog_aux(env, subprog)->called = true; 10004 10029 clear_caller_saved_regs(env, caller->regs); ··· 10687 10708 } 10688 10709 10689 10710 /* With LD_ABS/IND some JITs save/restore skb from r1. */ 10690 - changes_data = bpf_helper_changes_pkt_data(fn->func); 10711 + changes_data = bpf_helper_changes_pkt_data(func_id); 10691 10712 if (changes_data && fn->arg1_type != ARG_PTR_TO_CTX) { 10692 10713 verbose(env, "kernel subsystem misconfigured func %s#%d: r1 != ctx\n", 10693 10714 func_id_name(func_id), func_id); ··· 12162 12183 enum bpf_arg_type arg_type = ARG_DONTCARE; 12163 12184 u32 regno = i + 1, ref_id, type_size; 12164 12185 bool is_ret_buf_sz = false; 12165 - bool mask = false; 12166 12186 int kf_arg_type; 12167 12187 12168 12188 t = btf_type_skip_modifiers(btf, args[i].type, NULL); ··· 12220 12242 return -EINVAL; 12221 12243 } 12222 12244 12223 - mask = mask_raw_tp_reg(env, reg); 12224 12245 if ((is_kfunc_trusted_args(meta) || is_kfunc_rcu(meta)) && 12225 12246 (register_is_null(reg) || type_may_be_null(reg->type)) && 12226 12247 !is_kfunc_arg_nullable(meta->btf, &args[i])) { 12227 12248 verbose(env, "Possibly NULL pointer passed to trusted arg%d\n", i); 12228 - unmask_raw_tp_reg(reg, mask); 12229 12249 return -EACCES; 12230 12250 } 12231 - unmask_raw_tp_reg(reg, mask); 12232 12251 12233 12252 if (reg->ref_obj_id) { 12234 12253 if (is_kfunc_release(meta) && meta->ref_obj_id) { ··· 12283 12308 if (!is_kfunc_trusted_args(meta) && !is_kfunc_rcu(meta)) 12284 12309 break; 12285 12310 12286 - /* Allow passing maybe NULL raw_tp arguments to 12287 - * kfuncs for compatibility. Don't apply this to 12288 - * arguments with ref_obj_id > 0. 12289 - */ 12290 - mask = mask_raw_tp_reg(env, reg); 12291 12311 if (!is_trusted_reg(reg)) { 12292 12312 if (!is_kfunc_rcu(meta)) { 12293 12313 verbose(env, "R%d must be referenced or trusted\n", regno); 12294 - unmask_raw_tp_reg(reg, mask); 12295 12314 return -EINVAL; 12296 12315 } 12297 12316 if (!is_rcu_reg(reg)) { 12298 12317 verbose(env, "R%d must be a rcu pointer\n", regno); 12299 - unmask_raw_tp_reg(reg, mask); 12300 12318 return -EINVAL; 12301 12319 } 12302 12320 } 12303 - unmask_raw_tp_reg(reg, mask); 12304 12321 fallthrough; 12305 12322 case KF_ARG_PTR_TO_CTX: 12306 12323 case KF_ARG_PTR_TO_DYNPTR: ··· 12315 12348 12316 12349 if (is_kfunc_release(meta) && reg->ref_obj_id) 12317 12350 arg_type |= OBJ_RELEASE; 12318 - mask = mask_raw_tp_reg(env, reg); 12319 12351 ret = check_func_arg_reg_off(env, reg, regno, arg_type); 12320 - unmask_raw_tp_reg(reg, mask); 12321 12352 if (ret < 0) 12322 12353 return ret; 12323 12354 ··· 12492 12527 ref_tname = btf_name_by_offset(btf, ref_t->name_off); 12493 12528 fallthrough; 12494 12529 case KF_ARG_PTR_TO_BTF_ID: 12495 - mask = mask_raw_tp_reg(env, reg); 12496 12530 /* Only base_type is checked, further checks are done here */ 12497 12531 if ((base_type(reg->type) != PTR_TO_BTF_ID || 12498 12532 (bpf_type_has_unsafe_modifiers(reg->type) && !is_rcu_reg(reg))) && ··· 12500 12536 verbose(env, "expected %s or socket\n", 12501 12537 reg_type_str(env, base_type(reg->type) | 12502 12538 (type_flag(reg->type) & BPF_REG_TRUSTED_MODIFIERS))); 12503 - unmask_raw_tp_reg(reg, mask); 12504 12539 return -EINVAL; 12505 12540 } 12506 12541 ret = process_kf_arg_ptr_to_btf_id(env, reg, ref_t, ref_tname, ref_id, meta, i); 12507 - unmask_raw_tp_reg(reg, mask); 12508 12542 if (ret < 0) 12509 12543 return ret; 12510 12544 break; ··· 13475 13513 */ 13476 13514 static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, 13477 13515 struct bpf_insn *insn, 13478 - struct bpf_reg_state *ptr_reg, 13516 + const struct bpf_reg_state *ptr_reg, 13479 13517 const struct bpf_reg_state *off_reg) 13480 13518 { 13481 13519 struct bpf_verifier_state *vstate = env->cur_state; ··· 13489 13527 struct bpf_sanitize_info info = {}; 13490 13528 u8 opcode = BPF_OP(insn->code); 13491 13529 u32 dst = insn->dst_reg; 13492 - bool mask; 13493 13530 int ret; 13494 13531 13495 13532 dst_reg = &regs[dst]; ··· 13515 13554 return -EACCES; 13516 13555 } 13517 13556 13518 - mask = mask_raw_tp_reg(env, ptr_reg); 13519 13557 if (ptr_reg->type & PTR_MAYBE_NULL) { 13520 13558 verbose(env, "R%d pointer arithmetic on %s prohibited, null-check it first\n", 13521 13559 dst, reg_type_str(env, ptr_reg->type)); 13522 - unmask_raw_tp_reg(ptr_reg, mask); 13523 13560 return -EACCES; 13524 13561 } 13525 - unmask_raw_tp_reg(ptr_reg, mask); 13526 13562 13527 13563 switch (base_type(ptr_reg->type)) { 13528 13564 case PTR_TO_CTX: ··· 16184 16226 return 0; 16185 16227 } 16186 16228 16229 + static void mark_subprog_changes_pkt_data(struct bpf_verifier_env *env, int off) 16230 + { 16231 + struct bpf_subprog_info *subprog; 16232 + 16233 + subprog = find_containing_subprog(env, off); 16234 + subprog->changes_pkt_data = true; 16235 + } 16236 + 16237 + /* 't' is an index of a call-site. 16238 + * 'w' is a callee entry point. 16239 + * Eventually this function would be called when env->cfg.insn_state[w] == EXPLORED. 16240 + * Rely on DFS traversal order and absence of recursive calls to guarantee that 16241 + * callee's change_pkt_data marks would be correct at that moment. 16242 + */ 16243 + static void merge_callee_effects(struct bpf_verifier_env *env, int t, int w) 16244 + { 16245 + struct bpf_subprog_info *caller, *callee; 16246 + 16247 + caller = find_containing_subprog(env, t); 16248 + callee = find_containing_subprog(env, w); 16249 + caller->changes_pkt_data |= callee->changes_pkt_data; 16250 + } 16251 + 16187 16252 /* non-recursive DFS pseudo code 16188 16253 * 1 procedure DFS-iterative(G,v): 16189 16254 * 2 label v as discovered ··· 16340 16359 bool visit_callee) 16341 16360 { 16342 16361 int ret, insn_sz; 16362 + int w; 16343 16363 16344 16364 insn_sz = bpf_is_ldimm64(&insns[t]) ? 2 : 1; 16345 16365 ret = push_insn(t, t + insn_sz, FALLTHROUGH, env); ··· 16352 16370 mark_jmp_point(env, t + insn_sz); 16353 16371 16354 16372 if (visit_callee) { 16373 + w = t + insns[t].imm + 1; 16355 16374 mark_prune_point(env, t); 16356 - ret = push_insn(t, t + insns[t].imm + 1, BRANCH, env); 16375 + merge_callee_effects(env, t, w); 16376 + ret = push_insn(t, w, BRANCH, env); 16357 16377 } 16358 16378 return ret; 16359 16379 } ··· 16672 16688 mark_prune_point(env, t); 16673 16689 mark_jmp_point(env, t); 16674 16690 } 16691 + if (bpf_helper_call(insn) && bpf_helper_changes_pkt_data(insn->imm)) 16692 + mark_subprog_changes_pkt_data(env, t); 16675 16693 if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL) { 16676 16694 struct bpf_kfunc_call_arg_meta meta; 16677 16695 ··· 16808 16822 } 16809 16823 } 16810 16824 ret = 0; /* cfg looks good */ 16825 + env->prog->aux->changes_pkt_data = env->subprog_info[0].changes_pkt_data; 16811 16826 16812 16827 err_free: 16813 16828 kvfree(insn_state); ··· 20062 20075 * for this case. 20063 20076 */ 20064 20077 case PTR_TO_BTF_ID | MEM_ALLOC | PTR_UNTRUSTED: 20065 - case PTR_TO_BTF_ID | PTR_TRUSTED | PTR_MAYBE_NULL: 20066 20078 if (type == BPF_READ) { 20067 20079 if (BPF_MODE(insn->code) == BPF_MEM) 20068 20080 insn->code = BPF_LDX | BPF_PROBE_MEM | ··· 20297 20311 func[i]->aux->num_exentries = num_exentries; 20298 20312 func[i]->aux->tail_call_reachable = env->subprog_info[i].tail_call_reachable; 20299 20313 func[i]->aux->exception_cb = env->subprog_info[i].is_exception_cb; 20314 + func[i]->aux->changes_pkt_data = env->subprog_info[i].changes_pkt_data; 20300 20315 if (!i) 20301 20316 func[i]->aux->exception_boundary = env->seen_exception; 20302 20317 func[i] = bpf_int_jit_compile(func[i]); ··· 22128 22141 } 22129 22142 if (tgt_prog) { 22130 22143 struct bpf_prog_aux *aux = tgt_prog->aux; 22144 + bool tgt_changes_pkt_data; 22131 22145 22132 22146 if (bpf_prog_is_dev_bound(prog->aux) && 22133 22147 !bpf_prog_dev_bound_match(prog, tgt_prog)) { ··· 22161 22173 if (!prog->jit_requested) { 22162 22174 bpf_log(log, 22163 22175 "Extension programs should be JITed\n"); 22176 + return -EINVAL; 22177 + } 22178 + tgt_changes_pkt_data = aux->func 22179 + ? aux->func[subprog]->aux->changes_pkt_data 22180 + : aux->changes_pkt_data; 22181 + if (prog->aux->changes_pkt_data && !tgt_changes_pkt_data) { 22182 + bpf_log(log, 22183 + "Extension program changes packet data, while original does not\n"); 22164 22184 return -EINVAL; 22165 22185 } 22166 22186 } ··· 22636 22640 if (ret < 0) 22637 22641 goto skip_full_check; 22638 22642 22639 - ret = check_attach_btf_id(env); 22640 - if (ret) 22641 - goto skip_full_check; 22642 - 22643 22643 ret = resolve_pseudo_ldimm64(env); 22644 22644 if (ret < 0) 22645 22645 goto skip_full_check; ··· 22648 22656 22649 22657 ret = check_cfg(env); 22650 22658 if (ret < 0) 22659 + goto skip_full_check; 22660 + 22661 + ret = check_attach_btf_id(env); 22662 + if (ret) 22651 22663 goto skip_full_check; 22652 22664 22653 22665 ret = mark_fastcall_patterns(env);
+1 -1
kernel/sched/core.c
··· 1341 1341 if (scx_enabled() && !scx_can_stop_tick(rq)) 1342 1342 return false; 1343 1343 1344 - if (rq->cfs.nr_running > 1) 1344 + if (rq->cfs.h_nr_running > 1) 1345 1345 return false; 1346 1346 1347 1347 /*
+6 -2
kernel/sched/deadline.c
··· 1647 1647 if (!dl_se->dl_runtime) 1648 1648 return; 1649 1649 1650 + dl_se->dl_server_active = 1; 1650 1651 enqueue_dl_entity(dl_se, ENQUEUE_WAKEUP); 1651 1652 if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl)) 1652 1653 resched_curr(dl_se->rq); ··· 1662 1661 hrtimer_try_to_cancel(&dl_se->dl_timer); 1663 1662 dl_se->dl_defer_armed = 0; 1664 1663 dl_se->dl_throttled = 0; 1664 + dl_se->dl_server_active = 0; 1665 1665 } 1666 1666 1667 1667 void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq, ··· 2423 2421 if (dl_server(dl_se)) { 2424 2422 p = dl_se->server_pick_task(dl_se); 2425 2423 if (!p) { 2426 - dl_se->dl_yielded = 1; 2427 - update_curr_dl_se(rq, dl_se, 0); 2424 + if (dl_server_active(dl_se)) { 2425 + dl_se->dl_yielded = 1; 2426 + update_curr_dl_se(rq, dl_se, 0); 2427 + } 2428 2428 goto again; 2429 2429 } 2430 2430 rq->dl_server = dl_se;
+1
kernel/sched/debug.c
··· 845 845 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread", SPLIT_NS(spread)); 846 846 SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running); 847 847 SEQ_printf(m, " .%-30s: %d\n", "h_nr_running", cfs_rq->h_nr_running); 848 + SEQ_printf(m, " .%-30s: %d\n", "h_nr_delayed", cfs_rq->h_nr_delayed); 848 849 SEQ_printf(m, " .%-30s: %d\n", "idle_nr_running", 849 850 cfs_rq->idle_nr_running); 850 851 SEQ_printf(m, " .%-30s: %d\n", "idle_h_nr_running",
+57 -16
kernel/sched/fair.c
··· 1159 1159 trace_sched_stat_runtime(p, delta_exec); 1160 1160 account_group_exec_runtime(p, delta_exec); 1161 1161 cgroup_account_cputime(p, delta_exec); 1162 - if (p->dl_server) 1163 - dl_server_update(p->dl_server, delta_exec); 1164 1162 } 1165 1163 1166 1164 static inline bool did_preempt_short(struct cfs_rq *cfs_rq, struct sched_entity *curr) ··· 1235 1237 update_curr_task(p, delta_exec); 1236 1238 1237 1239 /* 1238 - * Any fair task that runs outside of fair_server should 1239 - * account against fair_server such that it can account for 1240 - * this time and possibly avoid running this period. 1240 + * If the fair_server is active, we need to account for the 1241 + * fair_server time whether or not the task is running on 1242 + * behalf of fair_server or not: 1243 + * - If the task is running on behalf of fair_server, we need 1244 + * to limit its time based on the assigned runtime. 1245 + * - Fair task that runs outside of fair_server should account 1246 + * against fair_server such that it can account for this time 1247 + * and possibly avoid running this period. 1241 1248 */ 1242 - if (p->dl_server != &rq->fair_server) 1249 + if (dl_server_active(&rq->fair_server)) 1243 1250 dl_server_update(&rq->fair_server, delta_exec); 1244 1251 } 1245 1252 ··· 5474 5471 5475 5472 static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq); 5476 5473 5477 - static inline void finish_delayed_dequeue_entity(struct sched_entity *se) 5474 + static void set_delayed(struct sched_entity *se) 5475 + { 5476 + se->sched_delayed = 1; 5477 + for_each_sched_entity(se) { 5478 + struct cfs_rq *cfs_rq = cfs_rq_of(se); 5479 + 5480 + cfs_rq->h_nr_delayed++; 5481 + if (cfs_rq_throttled(cfs_rq)) 5482 + break; 5483 + } 5484 + } 5485 + 5486 + static void clear_delayed(struct sched_entity *se) 5478 5487 { 5479 5488 se->sched_delayed = 0; 5489 + for_each_sched_entity(se) { 5490 + struct cfs_rq *cfs_rq = cfs_rq_of(se); 5491 + 5492 + cfs_rq->h_nr_delayed--; 5493 + if (cfs_rq_throttled(cfs_rq)) 5494 + break; 5495 + } 5496 + } 5497 + 5498 + static inline void finish_delayed_dequeue_entity(struct sched_entity *se) 5499 + { 5500 + clear_delayed(se); 5480 5501 if (sched_feat(DELAY_ZERO) && se->vlag > 0) 5481 5502 se->vlag = 0; 5482 5503 } ··· 5511 5484 bool sleep = flags & DEQUEUE_SLEEP; 5512 5485 5513 5486 update_curr(cfs_rq); 5487 + clear_buddies(cfs_rq, se); 5514 5488 5515 5489 if (flags & DEQUEUE_DELAYED) { 5516 5490 SCHED_WARN_ON(!se->sched_delayed); ··· 5528 5500 5529 5501 if (sched_feat(DELAY_DEQUEUE) && delay && 5530 5502 !entity_eligible(cfs_rq, se)) { 5531 - if (cfs_rq->next == se) 5532 - cfs_rq->next = NULL; 5533 5503 update_load_avg(cfs_rq, se, 0); 5534 - se->sched_delayed = 1; 5504 + set_delayed(se); 5535 5505 return false; 5536 5506 } 5537 5507 } ··· 5551 5525 se_update_runnable(se); 5552 5526 5553 5527 update_stats_dequeue_fair(cfs_rq, se, flags); 5554 - 5555 - clear_buddies(cfs_rq, se); 5556 5528 5557 5529 update_entity_lag(cfs_rq, se); 5558 5530 if (sched_feat(PLACE_REL_DEADLINE) && !sleep) { ··· 5941 5917 struct rq *rq = rq_of(cfs_rq); 5942 5918 struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); 5943 5919 struct sched_entity *se; 5944 - long task_delta, idle_task_delta, dequeue = 1; 5920 + long task_delta, idle_task_delta, delayed_delta, dequeue = 1; 5945 5921 long rq_h_nr_running = rq->cfs.h_nr_running; 5946 5922 5947 5923 raw_spin_lock(&cfs_b->lock); ··· 5974 5950 5975 5951 task_delta = cfs_rq->h_nr_running; 5976 5952 idle_task_delta = cfs_rq->idle_h_nr_running; 5953 + delayed_delta = cfs_rq->h_nr_delayed; 5977 5954 for_each_sched_entity(se) { 5978 5955 struct cfs_rq *qcfs_rq = cfs_rq_of(se); 5979 5956 int flags; ··· 5998 5973 5999 5974 qcfs_rq->h_nr_running -= task_delta; 6000 5975 qcfs_rq->idle_h_nr_running -= idle_task_delta; 5976 + qcfs_rq->h_nr_delayed -= delayed_delta; 6001 5977 6002 5978 if (qcfs_rq->load.weight) { 6003 5979 /* Avoid re-evaluating load for this entity: */ ··· 6021 5995 6022 5996 qcfs_rq->h_nr_running -= task_delta; 6023 5997 qcfs_rq->idle_h_nr_running -= idle_task_delta; 5998 + qcfs_rq->h_nr_delayed -= delayed_delta; 6024 5999 } 6025 6000 6026 6001 /* At this point se is NULL and we are at root level*/ ··· 6047 6020 struct rq *rq = rq_of(cfs_rq); 6048 6021 struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); 6049 6022 struct sched_entity *se; 6050 - long task_delta, idle_task_delta; 6023 + long task_delta, idle_task_delta, delayed_delta; 6051 6024 long rq_h_nr_running = rq->cfs.h_nr_running; 6052 6025 6053 6026 se = cfs_rq->tg->se[cpu_of(rq)]; ··· 6083 6056 6084 6057 task_delta = cfs_rq->h_nr_running; 6085 6058 idle_task_delta = cfs_rq->idle_h_nr_running; 6059 + delayed_delta = cfs_rq->h_nr_delayed; 6086 6060 for_each_sched_entity(se) { 6087 6061 struct cfs_rq *qcfs_rq = cfs_rq_of(se); 6088 6062 ··· 6101 6073 6102 6074 qcfs_rq->h_nr_running += task_delta; 6103 6075 qcfs_rq->idle_h_nr_running += idle_task_delta; 6076 + qcfs_rq->h_nr_delayed += delayed_delta; 6104 6077 6105 6078 /* end evaluation on encountering a throttled cfs_rq */ 6106 6079 if (cfs_rq_throttled(qcfs_rq)) ··· 6119 6090 6120 6091 qcfs_rq->h_nr_running += task_delta; 6121 6092 qcfs_rq->idle_h_nr_running += idle_task_delta; 6093 + qcfs_rq->h_nr_delayed += delayed_delta; 6122 6094 6123 6095 /* end evaluation on encountering a throttled cfs_rq */ 6124 6096 if (cfs_rq_throttled(qcfs_rq)) ··· 6973 6943 } 6974 6944 6975 6945 update_load_avg(cfs_rq, se, 0); 6976 - se->sched_delayed = 0; 6946 + clear_delayed(se); 6977 6947 } 6978 6948 6979 6949 /* ··· 6987 6957 struct cfs_rq *cfs_rq; 6988 6958 struct sched_entity *se = &p->se; 6989 6959 int idle_h_nr_running = task_has_idle_policy(p); 6960 + int h_nr_delayed = 0; 6990 6961 int task_new = !(flags & ENQUEUE_WAKEUP); 6991 6962 int rq_h_nr_running = rq->cfs.h_nr_running; 6992 6963 u64 slice = 0; ··· 7014 6983 if (p->in_iowait) 7015 6984 cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT); 7016 6985 6986 + if (task_new) 6987 + h_nr_delayed = !!se->sched_delayed; 6988 + 7017 6989 for_each_sched_entity(se) { 7018 6990 if (se->on_rq) { 7019 6991 if (se->sched_delayed) ··· 7039 7005 7040 7006 cfs_rq->h_nr_running++; 7041 7007 cfs_rq->idle_h_nr_running += idle_h_nr_running; 7008 + cfs_rq->h_nr_delayed += h_nr_delayed; 7042 7009 7043 7010 if (cfs_rq_is_idle(cfs_rq)) 7044 7011 idle_h_nr_running = 1; ··· 7063 7028 7064 7029 cfs_rq->h_nr_running++; 7065 7030 cfs_rq->idle_h_nr_running += idle_h_nr_running; 7031 + cfs_rq->h_nr_delayed += h_nr_delayed; 7066 7032 7067 7033 if (cfs_rq_is_idle(cfs_rq)) 7068 7034 idle_h_nr_running = 1; ··· 7126 7090 struct task_struct *p = NULL; 7127 7091 int idle_h_nr_running = 0; 7128 7092 int h_nr_running = 0; 7093 + int h_nr_delayed = 0; 7129 7094 struct cfs_rq *cfs_rq; 7130 7095 u64 slice = 0; 7131 7096 ··· 7134 7097 p = task_of(se); 7135 7098 h_nr_running = 1; 7136 7099 idle_h_nr_running = task_has_idle_policy(p); 7100 + if (!task_sleep && !task_delayed) 7101 + h_nr_delayed = !!se->sched_delayed; 7137 7102 } else { 7138 7103 cfs_rq = group_cfs_rq(se); 7139 7104 slice = cfs_rq_min_slice(cfs_rq); ··· 7153 7114 7154 7115 cfs_rq->h_nr_running -= h_nr_running; 7155 7116 cfs_rq->idle_h_nr_running -= idle_h_nr_running; 7117 + cfs_rq->h_nr_delayed -= h_nr_delayed; 7156 7118 7157 7119 if (cfs_rq_is_idle(cfs_rq)) 7158 7120 idle_h_nr_running = h_nr_running; ··· 7192 7152 7193 7153 cfs_rq->h_nr_running -= h_nr_running; 7194 7154 cfs_rq->idle_h_nr_running -= idle_h_nr_running; 7155 + cfs_rq->h_nr_delayed -= h_nr_delayed; 7195 7156 7196 7157 if (cfs_rq_is_idle(cfs_rq)) 7197 7158 idle_h_nr_running = h_nr_running; ··· 8821 8780 if (unlikely(throttled_hierarchy(cfs_rq_of(pse)))) 8822 8781 return; 8823 8782 8824 - if (sched_feat(NEXT_BUDDY) && !(wake_flags & WF_FORK)) { 8783 + if (sched_feat(NEXT_BUDDY) && !(wake_flags & WF_FORK) && !pse->sched_delayed) { 8825 8784 set_next_buddy(pse); 8826 8785 } 8827 8786
+1 -1
kernel/sched/pelt.c
··· 321 321 { 322 322 if (___update_load_sum(now, &cfs_rq->avg, 323 323 scale_load_down(cfs_rq->load.weight), 324 - cfs_rq->h_nr_running, 324 + cfs_rq->h_nr_running - cfs_rq->h_nr_delayed, 325 325 cfs_rq->curr != NULL)) { 326 326 327 327 ___update_load_avg(&cfs_rq->avg, 1);
+11 -2
kernel/sched/sched.h
··· 398 398 extern int dl_server_apply_params(struct sched_dl_entity *dl_se, 399 399 u64 runtime, u64 period, bool init); 400 400 401 + static inline bool dl_server_active(struct sched_dl_entity *dl_se) 402 + { 403 + return dl_se->dl_server_active; 404 + } 405 + 401 406 #ifdef CONFIG_CGROUP_SCHED 402 407 403 408 extern struct list_head task_groups; ··· 654 649 unsigned int h_nr_running; /* SCHED_{NORMAL,BATCH,IDLE} */ 655 650 unsigned int idle_nr_running; /* SCHED_IDLE */ 656 651 unsigned int idle_h_nr_running; /* SCHED_IDLE */ 652 + unsigned int h_nr_delayed; 657 653 658 654 s64 avg_vruntime; 659 655 u64 avg_load; ··· 904 898 905 899 static inline void se_update_runnable(struct sched_entity *se) 906 900 { 907 - if (!entity_is_task(se)) 908 - se->runnable_weight = se->my_q->h_nr_running; 901 + if (!entity_is_task(se)) { 902 + struct cfs_rq *cfs_rq = se->my_q; 903 + 904 + se->runnable_weight = cfs_rq->h_nr_running - cfs_rq->h_nr_delayed; 905 + } 909 906 } 910 907 911 908 static inline long se_runnable(struct sched_entity *se)
+1 -1
kernel/static_call_inline.c
··· 15 15 extern struct static_call_tramp_key __start_static_call_tramp_key[], 16 16 __stop_static_call_tramp_key[]; 17 17 18 - static int static_call_initialized; 18 + int static_call_initialized; 19 19 20 20 /* 21 21 * Must be called before early_initcall() to be effective.
+11
kernel/trace/bpf_trace.c
··· 2250 2250 goto unlock; 2251 2251 2252 2252 old_array = bpf_event_rcu_dereference(event->tp_event->prog_array); 2253 + if (!old_array) 2254 + goto put; 2255 + 2253 2256 ret = bpf_prog_array_copy(old_array, event->prog, NULL, 0, &new_array); 2254 2257 if (ret < 0) { 2255 2258 bpf_prog_array_delete_safe(old_array, event->prog); ··· 2260 2257 rcu_assign_pointer(event->tp_event->prog_array, new_array); 2261 2258 bpf_prog_array_free_sleepable(old_array); 2262 2259 } 2260 + 2261 + put: 2262 + /* 2263 + * It could be that the bpf_prog is not sleepable (and will be freed 2264 + * via normal RCU), but is called from a point that supports sleepable 2265 + * programs and uses tasks-trace-RCU. 2266 + */ 2267 + synchronize_rcu_tasks_trace(); 2263 2268 2264 2269 bpf_prog_put(event->prog); 2265 2270 event->prog = NULL;
+7 -1
kernel/trace/fgraph.c
··· 1215 1215 static int start_graph_tracing(void) 1216 1216 { 1217 1217 unsigned long **ret_stack_list; 1218 - int ret; 1218 + int ret, cpu; 1219 1219 1220 1220 ret_stack_list = kcalloc(FTRACE_RETSTACK_ALLOC_SIZE, 1221 1221 sizeof(*ret_stack_list), GFP_KERNEL); 1222 1222 1223 1223 if (!ret_stack_list) 1224 1224 return -ENOMEM; 1225 + 1226 + /* The cpu_boot init_task->ret_stack will never be freed */ 1227 + for_each_online_cpu(cpu) { 1228 + if (!idle_task(cpu)->ret_stack) 1229 + ftrace_graph_init_idle_task(idle_task(cpu), cpu); 1230 + } 1225 1231 1226 1232 do { 1227 1233 ret = alloc_retstack_tasklist(ret_stack_list);
+53 -202
kernel/trace/trace.c
··· 3611 3611 } 3612 3612 3613 3613 /* Returns true if the string is safe to dereference from an event */ 3614 - static bool trace_safe_str(struct trace_iterator *iter, const char *str, 3615 - bool star, int len) 3614 + static bool trace_safe_str(struct trace_iterator *iter, const char *str) 3616 3615 { 3617 3616 unsigned long addr = (unsigned long)str; 3618 3617 struct trace_event *trace_event; 3619 3618 struct trace_event_call *event; 3620 - 3621 - /* Ignore strings with no length */ 3622 - if (star && !len) 3623 - return true; 3624 3619 3625 3620 /* OK if part of the event data */ 3626 3621 if ((addr >= (unsigned long)iter->ent) && ··· 3656 3661 return false; 3657 3662 } 3658 3663 3659 - static DEFINE_STATIC_KEY_FALSE(trace_no_verify); 3660 - 3661 - static int test_can_verify_check(const char *fmt, ...) 3662 - { 3663 - char buf[16]; 3664 - va_list ap; 3665 - int ret; 3666 - 3667 - /* 3668 - * The verifier is dependent on vsnprintf() modifies the va_list 3669 - * passed to it, where it is sent as a reference. Some architectures 3670 - * (like x86_32) passes it by value, which means that vsnprintf() 3671 - * does not modify the va_list passed to it, and the verifier 3672 - * would then need to be able to understand all the values that 3673 - * vsnprintf can use. If it is passed by value, then the verifier 3674 - * is disabled. 3675 - */ 3676 - va_start(ap, fmt); 3677 - vsnprintf(buf, 16, "%d", ap); 3678 - ret = va_arg(ap, int); 3679 - va_end(ap); 3680 - 3681 - return ret; 3682 - } 3683 - 3684 - static void test_can_verify(void) 3685 - { 3686 - if (!test_can_verify_check("%d %d", 0, 1)) { 3687 - pr_info("trace event string verifier disabled\n"); 3688 - static_branch_inc(&trace_no_verify); 3689 - } 3690 - } 3691 - 3692 3664 /** 3693 - * trace_check_vprintf - Check dereferenced strings while writing to the seq buffer 3665 + * ignore_event - Check dereferenced fields while writing to the seq buffer 3694 3666 * @iter: The iterator that holds the seq buffer and the event being printed 3695 - * @fmt: The format used to print the event 3696 - * @ap: The va_list holding the data to print from @fmt. 3697 3667 * 3698 - * This writes the data into the @iter->seq buffer using the data from 3699 - * @fmt and @ap. If the format has a %s, then the source of the string 3700 - * is examined to make sure it is safe to print, otherwise it will 3701 - * warn and print "[UNSAFE MEMORY]" in place of the dereferenced string 3702 - * pointer. 3668 + * At boot up, test_event_printk() will flag any event that dereferences 3669 + * a string with "%s" that does exist in the ring buffer. It may still 3670 + * be valid, as the string may point to a static string in the kernel 3671 + * rodata that never gets freed. But if the string pointer is pointing 3672 + * to something that was allocated, there's a chance that it can be freed 3673 + * by the time the user reads the trace. This would cause a bad memory 3674 + * access by the kernel and possibly crash the system. 3675 + * 3676 + * This function will check if the event has any fields flagged as needing 3677 + * to be checked at runtime and perform those checks. 3678 + * 3679 + * If it is found that a field is unsafe, it will write into the @iter->seq 3680 + * a message stating what was found to be unsafe. 3681 + * 3682 + * @return: true if the event is unsafe and should be ignored, 3683 + * false otherwise. 3703 3684 */ 3704 - void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, 3705 - va_list ap) 3685 + bool ignore_event(struct trace_iterator *iter) 3706 3686 { 3707 - long text_delta = 0; 3708 - long data_delta = 0; 3709 - const char *p = fmt; 3710 - const char *str; 3711 - bool good; 3712 - int i, j; 3687 + struct ftrace_event_field *field; 3688 + struct trace_event *trace_event; 3689 + struct trace_event_call *event; 3690 + struct list_head *head; 3691 + struct trace_seq *seq; 3692 + const void *ptr; 3713 3693 3714 - if (WARN_ON_ONCE(!fmt)) 3715 - return; 3694 + trace_event = ftrace_find_event(iter->ent->type); 3716 3695 3717 - if (static_branch_unlikely(&trace_no_verify)) 3718 - goto print; 3696 + seq = &iter->seq; 3719 3697 3720 - /* 3721 - * When the kernel is booted with the tp_printk command line 3722 - * parameter, trace events go directly through to printk(). 3723 - * It also is checked by this function, but it does not 3724 - * have an associated trace_array (tr) for it. 3725 - */ 3726 - if (iter->tr) { 3727 - text_delta = iter->tr->text_delta; 3728 - data_delta = iter->tr->data_delta; 3698 + if (!trace_event) { 3699 + trace_seq_printf(seq, "EVENT ID %d NOT FOUND?\n", iter->ent->type); 3700 + return true; 3729 3701 } 3730 3702 3731 - /* Don't bother checking when doing a ftrace_dump() */ 3732 - if (iter->fmt == static_fmt_buf) 3733 - goto print; 3703 + event = container_of(trace_event, struct trace_event_call, event); 3704 + if (!(event->flags & TRACE_EVENT_FL_TEST_STR)) 3705 + return false; 3734 3706 3735 - while (*p) { 3736 - bool star = false; 3737 - int len = 0; 3707 + head = trace_get_fields(event); 3708 + if (!head) { 3709 + trace_seq_printf(seq, "FIELDS FOR EVENT '%s' NOT FOUND?\n", 3710 + trace_event_name(event)); 3711 + return true; 3712 + } 3738 3713 3739 - j = 0; 3714 + /* Offsets are from the iter->ent that points to the raw event */ 3715 + ptr = iter->ent; 3740 3716 3741 - /* 3742 - * We only care about %s and variants 3743 - * as well as %p[sS] if delta is non-zero 3744 - */ 3745 - for (i = 0; p[i]; i++) { 3746 - if (i + 1 >= iter->fmt_size) { 3747 - /* 3748 - * If we can't expand the copy buffer, 3749 - * just print it. 3750 - */ 3751 - if (!trace_iter_expand_format(iter)) 3752 - goto print; 3753 - } 3717 + list_for_each_entry(field, head, link) { 3718 + const char *str; 3719 + bool good; 3754 3720 3755 - if (p[i] == '\\' && p[i+1]) { 3756 - i++; 3757 - continue; 3758 - } 3759 - if (p[i] == '%') { 3760 - /* Need to test cases like %08.*s */ 3761 - for (j = 1; p[i+j]; j++) { 3762 - if (isdigit(p[i+j]) || 3763 - p[i+j] == '.') 3764 - continue; 3765 - if (p[i+j] == '*') { 3766 - star = true; 3767 - continue; 3768 - } 3769 - break; 3770 - } 3771 - if (p[i+j] == 's') 3772 - break; 3773 - 3774 - if (text_delta && p[i+1] == 'p' && 3775 - ((p[i+2] == 's' || p[i+2] == 'S'))) 3776 - break; 3777 - 3778 - star = false; 3779 - } 3780 - j = 0; 3781 - } 3782 - /* If no %s found then just print normally */ 3783 - if (!p[i]) 3784 - break; 3785 - 3786 - /* Copy up to the %s, and print that */ 3787 - strncpy(iter->fmt, p, i); 3788 - iter->fmt[i] = '\0'; 3789 - trace_seq_vprintf(&iter->seq, iter->fmt, ap); 3790 - 3791 - /* Add delta to %pS pointers */ 3792 - if (p[i+1] == 'p') { 3793 - unsigned long addr; 3794 - char fmt[4]; 3795 - 3796 - fmt[0] = '%'; 3797 - fmt[1] = 'p'; 3798 - fmt[2] = p[i+2]; /* Either %ps or %pS */ 3799 - fmt[3] = '\0'; 3800 - 3801 - addr = va_arg(ap, unsigned long); 3802 - addr += text_delta; 3803 - trace_seq_printf(&iter->seq, fmt, (void *)addr); 3804 - 3805 - p += i + 3; 3721 + if (!field->needs_test) 3806 3722 continue; 3807 - } 3808 3723 3809 - /* 3810 - * If iter->seq is full, the above call no longer guarantees 3811 - * that ap is in sync with fmt processing, and further calls 3812 - * to va_arg() can return wrong positional arguments. 3813 - * 3814 - * Ensure that ap is no longer used in this case. 3815 - */ 3816 - if (iter->seq.full) { 3817 - p = ""; 3818 - break; 3819 - } 3724 + str = *(const char **)(ptr + field->offset); 3820 3725 3821 - if (star) 3822 - len = va_arg(ap, int); 3823 - 3824 - /* The ap now points to the string data of the %s */ 3825 - str = va_arg(ap, const char *); 3826 - 3827 - good = trace_safe_str(iter, str, star, len); 3828 - 3829 - /* Could be from the last boot */ 3830 - if (data_delta && !good) { 3831 - str += data_delta; 3832 - good = trace_safe_str(iter, str, star, len); 3833 - } 3726 + good = trace_safe_str(iter, str); 3834 3727 3835 3728 /* 3836 3729 * If you hit this warning, it is likely that the ··· 3729 3846 * instead. See samples/trace_events/trace-events-sample.h 3730 3847 * for reference. 3731 3848 */ 3732 - if (WARN_ONCE(!good, "fmt: '%s' current_buffer: '%s'", 3733 - fmt, seq_buf_str(&iter->seq.seq))) { 3734 - int ret; 3735 - 3736 - /* Try to safely read the string */ 3737 - if (star) { 3738 - if (len + 1 > iter->fmt_size) 3739 - len = iter->fmt_size - 1; 3740 - if (len < 0) 3741 - len = 0; 3742 - ret = copy_from_kernel_nofault(iter->fmt, str, len); 3743 - iter->fmt[len] = 0; 3744 - star = false; 3745 - } else { 3746 - ret = strncpy_from_kernel_nofault(iter->fmt, str, 3747 - iter->fmt_size); 3748 - } 3749 - if (ret < 0) 3750 - trace_seq_printf(&iter->seq, "(0x%px)", str); 3751 - else 3752 - trace_seq_printf(&iter->seq, "(0x%px:%s)", 3753 - str, iter->fmt); 3754 - str = "[UNSAFE-MEMORY]"; 3755 - strcpy(iter->fmt, "%s"); 3756 - } else { 3757 - strncpy(iter->fmt, p + i, j + 1); 3758 - iter->fmt[j+1] = '\0'; 3849 + if (WARN_ONCE(!good, "event '%s' has unsafe pointer field '%s'", 3850 + trace_event_name(event), field->name)) { 3851 + trace_seq_printf(seq, "EVENT %s: HAS UNSAFE POINTER FIELD '%s'\n", 3852 + trace_event_name(event), field->name); 3853 + return true; 3759 3854 } 3760 - if (star) 3761 - trace_seq_printf(&iter->seq, iter->fmt, len, str); 3762 - else 3763 - trace_seq_printf(&iter->seq, iter->fmt, str); 3764 - 3765 - p += i + j + 1; 3766 3855 } 3767 - print: 3768 - if (*p) 3769 - trace_seq_vprintf(&iter->seq, p, ap); 3856 + return false; 3770 3857 } 3771 3858 3772 3859 const char *trace_event_format(struct trace_iterator *iter, const char *fmt) ··· 10629 10776 apply_trace_boot_options(); 10630 10777 10631 10778 register_snapshot_cmd(); 10632 - 10633 - test_can_verify(); 10634 10779 10635 10780 return 0; 10636 10781
+3 -3
kernel/trace/trace.h
··· 667 667 668 668 bool trace_is_tracepoint_string(const char *str); 669 669 const char *trace_event_format(struct trace_iterator *iter, const char *fmt); 670 - void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, 671 - va_list ap) __printf(2, 0); 672 670 char *trace_iter_expand_format(struct trace_iterator *iter); 671 + bool ignore_event(struct trace_iterator *iter); 673 672 674 673 int trace_empty(struct trace_iterator *iter); 675 674 ··· 1412 1413 int filter_type; 1413 1414 int offset; 1414 1415 int size; 1415 - int is_signed; 1416 + unsigned int is_signed:1; 1417 + unsigned int needs_test:1; 1416 1418 int len; 1417 1419 }; 1418 1420
+177 -50
kernel/trace/trace_events.c
··· 82 82 } 83 83 84 84 static struct ftrace_event_field * 85 - __find_event_field(struct list_head *head, char *name) 85 + __find_event_field(struct list_head *head, const char *name) 86 86 { 87 87 struct ftrace_event_field *field; 88 88 ··· 114 114 115 115 static int __trace_define_field(struct list_head *head, const char *type, 116 116 const char *name, int offset, int size, 117 - int is_signed, int filter_type, int len) 117 + int is_signed, int filter_type, int len, 118 + int need_test) 118 119 { 119 120 struct ftrace_event_field *field; 120 121 ··· 134 133 field->offset = offset; 135 134 field->size = size; 136 135 field->is_signed = is_signed; 136 + field->needs_test = need_test; 137 137 field->len = len; 138 138 139 139 list_add(&field->link, head); ··· 153 151 154 152 head = trace_get_fields(call); 155 153 return __trace_define_field(head, type, name, offset, size, 156 - is_signed, filter_type, 0); 154 + is_signed, filter_type, 0, 0); 157 155 } 158 156 EXPORT_SYMBOL_GPL(trace_define_field); 159 157 160 158 static int trace_define_field_ext(struct trace_event_call *call, const char *type, 161 159 const char *name, int offset, int size, int is_signed, 162 - int filter_type, int len) 160 + int filter_type, int len, int need_test) 163 161 { 164 162 struct list_head *head; 165 163 ··· 168 166 169 167 head = trace_get_fields(call); 170 168 return __trace_define_field(head, type, name, offset, size, 171 - is_signed, filter_type, len); 169 + is_signed, filter_type, len, need_test); 172 170 } 173 171 174 172 #define __generic_field(type, item, filter_type) \ 175 173 ret = __trace_define_field(&ftrace_generic_fields, #type, \ 176 174 #item, 0, 0, is_signed_type(type), \ 177 - filter_type, 0); \ 175 + filter_type, 0, 0); \ 178 176 if (ret) \ 179 177 return ret; 180 178 ··· 183 181 "common_" #item, \ 184 182 offsetof(typeof(ent), item), \ 185 183 sizeof(ent.item), \ 186 - is_signed_type(type), FILTER_OTHER, 0); \ 184 + is_signed_type(type), FILTER_OTHER, \ 185 + 0, 0); \ 187 186 if (ret) \ 188 187 return ret; 189 188 ··· 247 244 return tail->offset + tail->size; 248 245 } 249 246 250 - /* 251 - * Check if the referenced field is an array and return true, 252 - * as arrays are OK to dereference. 253 - */ 254 - static bool test_field(const char *fmt, struct trace_event_call *call) 247 + 248 + static struct trace_event_fields *find_event_field(const char *fmt, 249 + struct trace_event_call *call) 255 250 { 256 251 struct trace_event_fields *field = call->class->fields_array; 257 - const char *array_descriptor; 258 252 const char *p = fmt; 259 253 int len; 260 254 261 255 if (!(len = str_has_prefix(fmt, "REC->"))) 262 - return false; 256 + return NULL; 263 257 fmt += len; 264 258 for (p = fmt; *p; p++) { 265 259 if (!isalnum(*p) && *p != '_') ··· 265 265 len = p - fmt; 266 266 267 267 for (; field->type; field++) { 268 - if (strncmp(field->name, fmt, len) || 269 - field->name[len]) 268 + if (strncmp(field->name, fmt, len) || field->name[len]) 270 269 continue; 271 - array_descriptor = strchr(field->type, '['); 272 - /* This is an array and is OK to dereference. */ 273 - return array_descriptor != NULL; 270 + 271 + return field; 272 + } 273 + return NULL; 274 + } 275 + 276 + /* 277 + * Check if the referenced field is an array and return true, 278 + * as arrays are OK to dereference. 279 + */ 280 + static bool test_field(const char *fmt, struct trace_event_call *call) 281 + { 282 + struct trace_event_fields *field; 283 + 284 + field = find_event_field(fmt, call); 285 + if (!field) 286 + return false; 287 + 288 + /* This is an array and is OK to dereference. */ 289 + return strchr(field->type, '[') != NULL; 290 + } 291 + 292 + /* Look for a string within an argument */ 293 + static bool find_print_string(const char *arg, const char *str, const char *end) 294 + { 295 + const char *r; 296 + 297 + r = strstr(arg, str); 298 + return r && r < end; 299 + } 300 + 301 + /* Return true if the argument pointer is safe */ 302 + static bool process_pointer(const char *fmt, int len, struct trace_event_call *call) 303 + { 304 + const char *r, *e, *a; 305 + 306 + e = fmt + len; 307 + 308 + /* Find the REC-> in the argument */ 309 + r = strstr(fmt, "REC->"); 310 + if (r && r < e) { 311 + /* 312 + * Addresses of events on the buffer, or an array on the buffer is 313 + * OK to dereference. There's ways to fool this, but 314 + * this is to catch common mistakes, not malicious code. 315 + */ 316 + a = strchr(fmt, '&'); 317 + if ((a && (a < r)) || test_field(r, call)) 318 + return true; 319 + } else if (find_print_string(fmt, "__get_dynamic_array(", e)) { 320 + return true; 321 + } else if (find_print_string(fmt, "__get_rel_dynamic_array(", e)) { 322 + return true; 323 + } else if (find_print_string(fmt, "__get_dynamic_array_len(", e)) { 324 + return true; 325 + } else if (find_print_string(fmt, "__get_rel_dynamic_array_len(", e)) { 326 + return true; 327 + } else if (find_print_string(fmt, "__get_sockaddr(", e)) { 328 + return true; 329 + } else if (find_print_string(fmt, "__get_rel_sockaddr(", e)) { 330 + return true; 274 331 } 275 332 return false; 333 + } 334 + 335 + /* Return true if the string is safe */ 336 + static bool process_string(const char *fmt, int len, struct trace_event_call *call) 337 + { 338 + struct trace_event_fields *field; 339 + const char *r, *e, *s; 340 + 341 + e = fmt + len; 342 + 343 + /* 344 + * There are several helper functions that return strings. 345 + * If the argument contains a function, then assume its field is valid. 346 + * It is considered that the argument has a function if it has: 347 + * alphanumeric or '_' before a parenthesis. 348 + */ 349 + s = fmt; 350 + do { 351 + r = strstr(s, "("); 352 + if (!r || r >= e) 353 + break; 354 + for (int i = 1; r - i >= s; i++) { 355 + char ch = *(r - i); 356 + if (isspace(ch)) 357 + continue; 358 + if (isalnum(ch) || ch == '_') 359 + return true; 360 + /* Anything else, this isn't a function */ 361 + break; 362 + } 363 + /* A function could be wrapped in parethesis, try the next one */ 364 + s = r + 1; 365 + } while (s < e); 366 + 367 + /* 368 + * If there's any strings in the argument consider this arg OK as it 369 + * could be: REC->field ? "foo" : "bar" and we don't want to get into 370 + * verifying that logic here. 371 + */ 372 + if (find_print_string(fmt, "\"", e)) 373 + return true; 374 + 375 + /* Dereferenced strings are also valid like any other pointer */ 376 + if (process_pointer(fmt, len, call)) 377 + return true; 378 + 379 + /* Make sure the field is found */ 380 + field = find_event_field(fmt, call); 381 + if (!field) 382 + return false; 383 + 384 + /* Test this field's string before printing the event */ 385 + call->flags |= TRACE_EVENT_FL_TEST_STR; 386 + field->needs_test = 1; 387 + 388 + return true; 276 389 } 277 390 278 391 /* ··· 397 284 static void test_event_printk(struct trace_event_call *call) 398 285 { 399 286 u64 dereference_flags = 0; 287 + u64 string_flags = 0; 400 288 bool first = true; 401 - const char *fmt, *c, *r, *a; 289 + const char *fmt; 402 290 int parens = 0; 403 291 char in_quote = 0; 404 292 int start_arg = 0; 405 293 int arg = 0; 406 - int i; 294 + int i, e; 407 295 408 296 fmt = call->print_fmt; 409 297 ··· 488 374 star = true; 489 375 continue; 490 376 } 491 - if ((fmt[i + j] == 's') && star) 492 - arg++; 377 + if ((fmt[i + j] == 's')) { 378 + if (star) 379 + arg++; 380 + if (WARN_ONCE(arg == 63, 381 + "Too many args for event: %s", 382 + trace_event_name(call))) 383 + return; 384 + dereference_flags |= 1ULL << arg; 385 + string_flags |= 1ULL << arg; 386 + } 493 387 break; 494 388 } 495 389 break; ··· 525 403 case ',': 526 404 if (in_quote || parens) 527 405 continue; 406 + e = i; 528 407 i++; 529 408 while (isspace(fmt[i])) 530 409 i++; 531 - start_arg = i; 532 - if (!(dereference_flags & (1ULL << arg))) 533 - goto next_arg; 534 410 535 - /* Find the REC-> in the argument */ 536 - c = strchr(fmt + i, ','); 537 - r = strstr(fmt + i, "REC->"); 538 - if (r && (!c || r < c)) { 539 - /* 540 - * Addresses of events on the buffer, 541 - * or an array on the buffer is 542 - * OK to dereference. 543 - * There's ways to fool this, but 544 - * this is to catch common mistakes, 545 - * not malicious code. 546 - */ 547 - a = strchr(fmt + i, '&'); 548 - if ((a && (a < r)) || test_field(r, call)) 549 - dereference_flags &= ~(1ULL << arg); 550 - } else if ((r = strstr(fmt + i, "__get_dynamic_array(")) && 551 - (!c || r < c)) { 552 - dereference_flags &= ~(1ULL << arg); 553 - } else if ((r = strstr(fmt + i, "__get_sockaddr(")) && 554 - (!c || r < c)) { 555 - dereference_flags &= ~(1ULL << arg); 411 + /* 412 + * If start_arg is zero, then this is the start of the 413 + * first argument. The processing of the argument happens 414 + * when the end of the argument is found, as it needs to 415 + * handle paranthesis and such. 416 + */ 417 + if (!start_arg) { 418 + start_arg = i; 419 + /* Balance out the i++ in the for loop */ 420 + i--; 421 + continue; 556 422 } 557 423 558 - next_arg: 559 - i--; 424 + if (dereference_flags & (1ULL << arg)) { 425 + if (string_flags & (1ULL << arg)) { 426 + if (process_string(fmt + start_arg, e - start_arg, call)) 427 + dereference_flags &= ~(1ULL << arg); 428 + } else if (process_pointer(fmt + start_arg, e - start_arg, call)) 429 + dereference_flags &= ~(1ULL << arg); 430 + } 431 + 432 + start_arg = i; 560 433 arg++; 434 + /* Balance out the i++ in the for loop */ 435 + i--; 561 436 } 437 + } 438 + 439 + if (dereference_flags & (1ULL << arg)) { 440 + if (string_flags & (1ULL << arg)) { 441 + if (process_string(fmt + start_arg, i - start_arg, call)) 442 + dereference_flags &= ~(1ULL << arg); 443 + } else if (process_pointer(fmt + start_arg, i - start_arg, call)) 444 + dereference_flags &= ~(1ULL << arg); 562 445 } 563 446 564 447 /* ··· 2598 2471 ret = trace_define_field_ext(call, field->type, field->name, 2599 2472 offset, field->size, 2600 2473 field->is_signed, field->filter_type, 2601 - field->len); 2474 + field->len, field->needs_test); 2602 2475 if (WARN_ON_ONCE(ret)) { 2603 2476 pr_err("error code is %d\n", ret); 2604 2477 break;
+2 -1
kernel/trace/trace_functions.c
··· 176 176 tracing_reset_online_cpus(&tr->array_buffer); 177 177 } 178 178 179 - #ifdef CONFIG_FUNCTION_GRAPH_TRACER 179 + /* fregs are guaranteed not to be NULL if HAVE_DYNAMIC_FTRACE_WITH_ARGS is set */ 180 + #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) 180 181 static __always_inline unsigned long 181 182 function_get_true_parent_ip(unsigned long parent_ip, struct ftrace_regs *fregs) 182 183 {
+5 -1
kernel/trace/trace_output.c
··· 317 317 318 318 void trace_event_printf(struct trace_iterator *iter, const char *fmt, ...) 319 319 { 320 + struct trace_seq *s = &iter->seq; 320 321 va_list ap; 321 322 323 + if (ignore_event(iter)) 324 + return; 325 + 322 326 va_start(ap, fmt); 323 - trace_check_vprintf(iter, trace_event_format(iter, fmt), ap); 327 + trace_seq_vprintf(s, trace_event_format(iter, fmt), ap); 324 328 va_end(ap); 325 329 } 326 330 EXPORT_SYMBOL(trace_event_printf);
+5 -1
kernel/trace/trace_uprobe.c
··· 1402 1402 1403 1403 #ifdef CONFIG_BPF_EVENTS 1404 1404 if (bpf_prog_array_valid(call)) { 1405 + const struct bpf_prog_array *array; 1405 1406 u32 ret; 1406 1407 1407 - ret = bpf_prog_run_array_uprobe(call->prog_array, regs, bpf_prog_run); 1408 + rcu_read_lock_trace(); 1409 + array = rcu_dereference_check(call->prog_array, rcu_read_lock_trace_held()); 1410 + ret = bpf_prog_run_array_uprobe(array, regs, bpf_prog_run); 1411 + rcu_read_unlock_trace(); 1408 1412 if (!ret) 1409 1413 return; 1410 1414 }
+18 -3
mm/slub.c
··· 2189 2189 2190 2190 folio = virt_to_folio(p); 2191 2191 if (!folio_test_slab(folio)) { 2192 - return folio_memcg_kmem(folio) || 2193 - (__memcg_kmem_charge_page(folio_page(folio, 0), flags, 2194 - folio_order(folio)) == 0); 2192 + int size; 2193 + 2194 + if (folio_memcg_kmem(folio)) 2195 + return true; 2196 + 2197 + if (__memcg_kmem_charge_page(folio_page(folio, 0), flags, 2198 + folio_order(folio))) 2199 + return false; 2200 + 2201 + /* 2202 + * This folio has already been accounted in the global stats but 2203 + * not in the memcg stats. So, subtract from the global and use 2204 + * the interface which adds to both global and memcg stats. 2205 + */ 2206 + size = folio_size(folio); 2207 + node_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, -size); 2208 + lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, size); 2209 + return true; 2195 2210 } 2196 2211 2197 2212 slab = folio_slab(folio);
+29 -34
net/core/filter.c
··· 7898 7898 7899 7899 #endif /* CONFIG_INET */ 7900 7900 7901 - bool bpf_helper_changes_pkt_data(void *func) 7901 + bool bpf_helper_changes_pkt_data(enum bpf_func_id func_id) 7902 7902 { 7903 - if (func == bpf_skb_vlan_push || 7904 - func == bpf_skb_vlan_pop || 7905 - func == bpf_skb_store_bytes || 7906 - func == bpf_skb_change_proto || 7907 - func == bpf_skb_change_head || 7908 - func == sk_skb_change_head || 7909 - func == bpf_skb_change_tail || 7910 - func == sk_skb_change_tail || 7911 - func == bpf_skb_adjust_room || 7912 - func == sk_skb_adjust_room || 7913 - func == bpf_skb_pull_data || 7914 - func == sk_skb_pull_data || 7915 - func == bpf_clone_redirect || 7916 - func == bpf_l3_csum_replace || 7917 - func == bpf_l4_csum_replace || 7918 - func == bpf_xdp_adjust_head || 7919 - func == bpf_xdp_adjust_meta || 7920 - func == bpf_msg_pull_data || 7921 - func == bpf_msg_push_data || 7922 - func == bpf_msg_pop_data || 7923 - func == bpf_xdp_adjust_tail || 7924 - #if IS_ENABLED(CONFIG_IPV6_SEG6_BPF) 7925 - func == bpf_lwt_seg6_store_bytes || 7926 - func == bpf_lwt_seg6_adjust_srh || 7927 - func == bpf_lwt_seg6_action || 7928 - #endif 7929 - #ifdef CONFIG_INET 7930 - func == bpf_sock_ops_store_hdr_opt || 7931 - #endif 7932 - func == bpf_lwt_in_push_encap || 7933 - func == bpf_lwt_xmit_push_encap) 7903 + switch (func_id) { 7904 + case BPF_FUNC_clone_redirect: 7905 + case BPF_FUNC_l3_csum_replace: 7906 + case BPF_FUNC_l4_csum_replace: 7907 + case BPF_FUNC_lwt_push_encap: 7908 + case BPF_FUNC_lwt_seg6_action: 7909 + case BPF_FUNC_lwt_seg6_adjust_srh: 7910 + case BPF_FUNC_lwt_seg6_store_bytes: 7911 + case BPF_FUNC_msg_pop_data: 7912 + case BPF_FUNC_msg_pull_data: 7913 + case BPF_FUNC_msg_push_data: 7914 + case BPF_FUNC_skb_adjust_room: 7915 + case BPF_FUNC_skb_change_head: 7916 + case BPF_FUNC_skb_change_proto: 7917 + case BPF_FUNC_skb_change_tail: 7918 + case BPF_FUNC_skb_pull_data: 7919 + case BPF_FUNC_skb_store_bytes: 7920 + case BPF_FUNC_skb_vlan_pop: 7921 + case BPF_FUNC_skb_vlan_push: 7922 + case BPF_FUNC_store_hdr_opt: 7923 + case BPF_FUNC_xdp_adjust_head: 7924 + case BPF_FUNC_xdp_adjust_meta: 7925 + case BPF_FUNC_xdp_adjust_tail: 7926 + /* tail-called program could call any of the above */ 7927 + case BPF_FUNC_tail_call: 7934 7928 return true; 7935 - 7936 - return false; 7929 + default: 7930 + return false; 7931 + } 7937 7932 } 7938 7933 7939 7934 const struct bpf_func_proto bpf_event_output_data_proto __weak;
+8 -11
net/core/netdev-genl.c
··· 430 430 netdev_nl_queue_fill(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx, 431 431 u32 q_type, const struct genl_info *info) 432 432 { 433 - int err = 0; 433 + int err; 434 434 435 435 if (!(netdev->flags & IFF_UP)) 436 - return err; 436 + return -ENOENT; 437 437 438 438 err = netdev_nl_queue_validate(netdev, q_idx, q_type); 439 439 if (err) ··· 488 488 struct netdev_nl_dump_ctx *ctx) 489 489 { 490 490 int err = 0; 491 - int i; 492 491 493 492 if (!(netdev->flags & IFF_UP)) 494 493 return err; 495 494 496 - for (i = ctx->rxq_idx; i < netdev->real_num_rx_queues;) { 497 - err = netdev_nl_queue_fill_one(rsp, netdev, i, 495 + for (; ctx->rxq_idx < netdev->real_num_rx_queues; ctx->rxq_idx++) { 496 + err = netdev_nl_queue_fill_one(rsp, netdev, ctx->rxq_idx, 498 497 NETDEV_QUEUE_TYPE_RX, info); 499 498 if (err) 500 499 return err; 501 - ctx->rxq_idx = i++; 502 500 } 503 - for (i = ctx->txq_idx; i < netdev->real_num_tx_queues;) { 504 - err = netdev_nl_queue_fill_one(rsp, netdev, i, 501 + for (; ctx->txq_idx < netdev->real_num_tx_queues; ctx->txq_idx++) { 502 + err = netdev_nl_queue_fill_one(rsp, netdev, ctx->txq_idx, 505 503 NETDEV_QUEUE_TYPE_TX, info); 506 504 if (err) 507 505 return err; 508 - ctx->txq_idx = i++; 509 506 } 510 507 511 508 return err; ··· 668 671 i, info); 669 672 if (err) 670 673 return err; 671 - ctx->rxq_idx = i++; 674 + ctx->rxq_idx = ++i; 672 675 } 673 676 i = ctx->txq_idx; 674 677 while (ops->get_queue_stats_tx && i < netdev->real_num_tx_queues) { ··· 676 679 i, info); 677 680 if (err) 678 681 return err; 679 - ctx->txq_idx = i++; 682 + ctx->txq_idx = ++i; 680 683 } 681 684 682 685 ctx->rxq_idx = 0;
+3 -2
net/core/rtnetlink.c
··· 3819 3819 } 3820 3820 3821 3821 static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops, 3822 + struct nlattr *tbp[], 3822 3823 struct nlattr *data[], 3823 3824 struct netlink_ext_ack *extack) 3824 3825 { ··· 3827 3826 int err; 3828 3827 3829 3828 if (!data || !data[ops->peer_type]) 3830 - return NULL; 3829 + return rtnl_link_get_net_ifla(tbp); 3831 3830 3832 3831 err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack); 3833 3832 if (err < 0) ··· 3972 3971 } 3973 3972 3974 3973 if (ops->peer_type) { 3975 - peer_net = rtnl_get_peer_net(ops, data, extack); 3974 + peer_net = rtnl_get_peer_net(ops, tb, data, extack); 3976 3975 if (IS_ERR(peer_net)) { 3977 3976 ret = PTR_ERR(peer_net); 3978 3977 goto put_ops;
+3 -3
net/core/sock_map.c
··· 159 159 verdict_stop = true; 160 160 list_del(&link->list); 161 161 sk_psock_free_link(link); 162 + break; 162 163 } 163 164 } 164 165 spin_unlock_bh(&psock->link_lock); ··· 412 411 static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test, 413 412 struct sock **psk) 414 413 { 415 - struct sock *sk; 414 + struct sock *sk = NULL; 416 415 int err = 0; 417 416 418 417 spin_lock_bh(&stab->lock); 419 - sk = *psk; 420 - if (!sk_test || sk_test == sk) 418 + if (!sk_test || sk_test == *psk) 421 419 sk = xchg(psk, NULL); 422 420 423 421 if (likely(sk))
+11 -5
net/dsa/tag.h
··· 138 138 * dsa_software_vlan_untag: Software VLAN untagging in DSA receive path 139 139 * @skb: Pointer to socket buffer (packet) 140 140 * 141 - * Receive path method for switches which cannot avoid tagging all packets 142 - * towards the CPU port. Called when ds->untag_bridge_pvid (legacy) or 143 - * ds->untag_vlan_aware_bridge_pvid is set to true. 141 + * Receive path method for switches which send some packets as VLAN-tagged 142 + * towards the CPU port (generally from VLAN-aware bridge ports) even when the 143 + * packet was not tagged on the wire. Called when ds->untag_bridge_pvid 144 + * (legacy) or ds->untag_vlan_aware_bridge_pvid is set to true. 144 145 * 145 146 * As a side effect of this method, any VLAN tag from the skb head is moved 146 147 * to hwaccel. ··· 150 149 { 151 150 struct dsa_port *dp = dsa_user_to_port(skb->dev); 152 151 struct net_device *br = dsa_port_bridge_dev_get(dp); 153 - u16 vid; 152 + u16 vid, proto; 153 + int err; 154 154 155 155 /* software untagging for standalone ports not yet necessary */ 156 156 if (!br) 157 157 return skb; 158 158 159 + err = br_vlan_get_proto(br, &proto); 160 + if (err) 161 + return skb; 162 + 159 163 /* Move VLAN tag from data to hwaccel */ 160 - if (!skb_vlan_tag_present(skb)) { 164 + if (!skb_vlan_tag_present(skb) && skb->protocol == htons(proto)) { 161 165 skb = skb_vlan_untag(skb); 162 166 if (!skb) 163 167 return NULL;
+26 -10
net/mctp/route.c
··· 374 374 msk = NULL; 375 375 rc = -EINVAL; 376 376 377 - /* we may be receiving a locally-routed packet; drop source sk 378 - * accounting 377 + /* We may be receiving a locally-routed packet; drop source sk 378 + * accounting. 379 + * 380 + * From here, we will either queue the skb - either to a frag_queue, or 381 + * to a receiving socket. When that succeeds, we clear the skb pointer; 382 + * a non-NULL skb on exit will be otherwise unowned, and hence 383 + * kfree_skb()-ed. 379 384 */ 380 385 skb_orphan(skb); 381 386 ··· 439 434 * pending key. 440 435 */ 441 436 if (flags & MCTP_HDR_FLAG_EOM) { 442 - sock_queue_rcv_skb(&msk->sk, skb); 437 + rc = sock_queue_rcv_skb(&msk->sk, skb); 438 + if (!rc) 439 + skb = NULL; 443 440 if (key) { 444 441 /* we've hit a pending reassembly; not much we 445 442 * can do but drop it ··· 450 443 MCTP_TRACE_KEY_REPLIED); 451 444 key = NULL; 452 445 } 453 - rc = 0; 454 446 goto out_unlock; 455 447 } 456 448 ··· 476 470 * this function. 477 471 */ 478 472 rc = mctp_key_add(key, msk); 479 - if (!rc) 473 + if (!rc) { 480 474 trace_mctp_key_acquire(key); 475 + skb = NULL; 476 + } 481 477 482 478 /* we don't need to release key->lock on exit, so 483 479 * clean up here and suppress the unlock via ··· 497 489 key = NULL; 498 490 } else { 499 491 rc = mctp_frag_queue(key, skb); 492 + if (!rc) 493 + skb = NULL; 500 494 } 501 495 } 502 496 ··· 513 503 else 514 504 rc = mctp_frag_queue(key, skb); 515 505 506 + if (rc) 507 + goto out_unlock; 508 + 509 + /* we've queued; the queue owns the skb now */ 510 + skb = NULL; 511 + 516 512 /* end of message? deliver to socket, and we're done with 517 513 * the reassembly/response key 518 514 */ 519 - if (!rc && flags & MCTP_HDR_FLAG_EOM) { 520 - sock_queue_rcv_skb(key->sk, key->reasm_head); 521 - key->reasm_head = NULL; 515 + if (flags & MCTP_HDR_FLAG_EOM) { 516 + rc = sock_queue_rcv_skb(key->sk, key->reasm_head); 517 + if (!rc) 518 + key->reasm_head = NULL; 522 519 __mctp_key_done_in(key, net, f, MCTP_TRACE_KEY_REPLIED); 523 520 key = NULL; 524 521 } ··· 544 527 if (any_key) 545 528 mctp_key_unref(any_key); 546 529 out: 547 - if (rc) 548 - kfree_skb(skb); 530 + kfree_skb(skb); 549 531 return rc; 550 532 } 551 533
+86
net/mctp/test/route-test.c
··· 837 837 mctp_test_route_input_multiple_nets_key_fini(test, &t2); 838 838 } 839 839 840 + /* Input route to socket, using a single-packet message, where sock delivery 841 + * fails. Ensure we're handling the failure appropriately. 842 + */ 843 + static void mctp_test_route_input_sk_fail_single(struct kunit *test) 844 + { 845 + const struct mctp_hdr hdr = RX_HDR(1, 10, 8, FL_S | FL_E | FL_TO); 846 + struct mctp_test_route *rt; 847 + struct mctp_test_dev *dev; 848 + struct socket *sock; 849 + struct sk_buff *skb; 850 + int rc; 851 + 852 + __mctp_route_test_init(test, &dev, &rt, &sock, MCTP_NET_ANY); 853 + 854 + /* No rcvbuf space, so delivery should fail. __sock_set_rcvbuf will 855 + * clamp the minimum to SOCK_MIN_RCVBUF, so we open-code this. 856 + */ 857 + lock_sock(sock->sk); 858 + WRITE_ONCE(sock->sk->sk_rcvbuf, 0); 859 + release_sock(sock->sk); 860 + 861 + skb = mctp_test_create_skb(&hdr, 10); 862 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb); 863 + skb_get(skb); 864 + 865 + mctp_test_skb_set_dev(skb, dev); 866 + 867 + /* do route input, which should fail */ 868 + rc = mctp_route_input(&rt->rt, skb); 869 + KUNIT_EXPECT_NE(test, rc, 0); 870 + 871 + /* we should hold the only reference to skb */ 872 + KUNIT_EXPECT_EQ(test, refcount_read(&skb->users), 1); 873 + kfree_skb(skb); 874 + 875 + __mctp_route_test_fini(test, dev, rt, sock); 876 + } 877 + 878 + /* Input route to socket, using a fragmented message, where sock delivery fails. 879 + */ 880 + static void mctp_test_route_input_sk_fail_frag(struct kunit *test) 881 + { 882 + const struct mctp_hdr hdrs[2] = { RX_FRAG(FL_S, 0), RX_FRAG(FL_E, 1) }; 883 + struct mctp_test_route *rt; 884 + struct mctp_test_dev *dev; 885 + struct sk_buff *skbs[2]; 886 + struct socket *sock; 887 + unsigned int i; 888 + int rc; 889 + 890 + __mctp_route_test_init(test, &dev, &rt, &sock, MCTP_NET_ANY); 891 + 892 + lock_sock(sock->sk); 893 + WRITE_ONCE(sock->sk->sk_rcvbuf, 0); 894 + release_sock(sock->sk); 895 + 896 + for (i = 0; i < ARRAY_SIZE(skbs); i++) { 897 + skbs[i] = mctp_test_create_skb(&hdrs[i], 10); 898 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skbs[i]); 899 + skb_get(skbs[i]); 900 + 901 + mctp_test_skb_set_dev(skbs[i], dev); 902 + } 903 + 904 + /* first route input should succeed, we're only queueing to the 905 + * frag list 906 + */ 907 + rc = mctp_route_input(&rt->rt, skbs[0]); 908 + KUNIT_EXPECT_EQ(test, rc, 0); 909 + 910 + /* final route input should fail to deliver to the socket */ 911 + rc = mctp_route_input(&rt->rt, skbs[1]); 912 + KUNIT_EXPECT_NE(test, rc, 0); 913 + 914 + /* we should hold the only reference to both skbs */ 915 + KUNIT_EXPECT_EQ(test, refcount_read(&skbs[0]->users), 1); 916 + kfree_skb(skbs[0]); 917 + 918 + KUNIT_EXPECT_EQ(test, refcount_read(&skbs[1]->users), 1); 919 + kfree_skb(skbs[1]); 920 + 921 + __mctp_route_test_fini(test, dev, rt, sock); 922 + } 923 + 840 924 #if IS_ENABLED(CONFIG_MCTP_FLOWS) 841 925 842 926 static void mctp_test_flow_init(struct kunit *test, ··· 1137 1053 mctp_route_input_sk_reasm_gen_params), 1138 1054 KUNIT_CASE_PARAM(mctp_test_route_input_sk_keys, 1139 1055 mctp_route_input_sk_keys_gen_params), 1056 + KUNIT_CASE(mctp_test_route_input_sk_fail_single), 1057 + KUNIT_CASE(mctp_test_route_input_sk_fail_frag), 1140 1058 KUNIT_CASE(mctp_test_route_input_multiple_nets_bind), 1141 1059 KUNIT_CASE(mctp_test_route_input_multiple_nets_key), 1142 1060 KUNIT_CASE(mctp_test_packet_flow),
+3
net/netfilter/ipset/ip_set_list_set.c
··· 611 611 return true; 612 612 } 613 613 614 + static struct lock_class_key list_set_lockdep_key; 615 + 614 616 static int 615 617 list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[], 616 618 u32 flags) ··· 629 627 if (size < IP_SET_LIST_MIN_SIZE) 630 628 size = IP_SET_LIST_MIN_SIZE; 631 629 630 + lockdep_set_class(&set->lock, &list_set_lockdep_key); 632 631 set->variant = &set_variant; 633 632 set->dsize = ip_set_elem_len(set, tb, sizeof(struct set_elem), 634 633 __alignof__(struct set_elem));
+2 -2
net/netfilter/ipvs/ip_vs_conn.c
··· 1495 1495 max_avail -= 2; /* ~4 in hash row */ 1496 1496 max_avail -= 1; /* IPVS up to 1/2 of mem */ 1497 1497 max_avail -= order_base_2(sizeof(struct ip_vs_conn)); 1498 - max = clamp(max, min, max_avail); 1499 - ip_vs_conn_tab_bits = clamp_val(ip_vs_conn_tab_bits, min, max); 1498 + max = clamp(max_avail, min, max); 1499 + ip_vs_conn_tab_bits = clamp(ip_vs_conn_tab_bits, min, max); 1500 1500 ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits; 1501 1501 ip_vs_conn_tab_mask = ip_vs_conn_tab_size - 1; 1502 1502
+6 -3
net/psample/psample.c
··· 393 393 nla_total_size_64bit(sizeof(u64)) + /* timestamp */ 394 394 nla_total_size(sizeof(u16)) + /* protocol */ 395 395 (md->user_cookie_len ? 396 - nla_total_size(md->user_cookie_len) : 0); /* user cookie */ 396 + nla_total_size(md->user_cookie_len) : 0) + /* user cookie */ 397 + (md->rate_as_probability ? 398 + nla_total_size(0) : 0); /* rate as probability */ 397 399 398 400 #ifdef CONFIG_INET 399 401 tun_info = skb_tunnel_info(skb); ··· 500 498 md->user_cookie)) 501 499 goto error; 502 500 503 - if (md->rate_as_probability) 504 - nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY); 501 + if (md->rate_as_probability && 502 + nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY)) 503 + goto error; 505 504 506 505 genlmsg_end(nl_skb, data); 507 506 genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
+16 -2
net/smc/af_smc.c
··· 2035 2035 if (pclc->hdr.typev1 == SMC_TYPE_N) 2036 2036 return 0; 2037 2037 pclc_prfx = smc_clc_proposal_get_prefix(pclc); 2038 + if (!pclc_prfx) 2039 + return -EPROTO; 2038 2040 if (smc_clc_prfx_match(newclcsock, pclc_prfx)) 2039 2041 return SMC_CLC_DECL_DIFFPREFIX; 2040 2042 ··· 2150 2148 pclc_smcd = smc_get_clc_msg_smcd(pclc); 2151 2149 smc_v2_ext = smc_get_clc_v2_ext(pclc); 2152 2150 smcd_v2_ext = smc_get_clc_smcd_v2_ext(smc_v2_ext); 2151 + if (!pclc_smcd || !smc_v2_ext || !smcd_v2_ext) 2152 + goto not_found; 2153 2153 2154 2154 mutex_lock(&smcd_dev_list.mutex); 2155 2155 if (pclc_smcd->ism.chid) { ··· 2228 2224 int rc = 0; 2229 2225 2230 2226 /* check if ISM V1 is available */ 2231 - if (!(ini->smcd_version & SMC_V1) || !smcd_indicated(ini->smc_type_v1)) 2227 + if (!(ini->smcd_version & SMC_V1) || 2228 + !smcd_indicated(ini->smc_type_v1) || 2229 + !pclc_smcd) 2232 2230 goto not_found; 2233 2231 ini->is_smcd = true; /* prepare ISM check */ 2234 2232 ini->ism_peer_gid[0].gid = ntohll(pclc_smcd->ism.gid); ··· 2281 2275 goto not_found; 2282 2276 2283 2277 smc_v2_ext = smc_get_clc_v2_ext(pclc); 2284 - if (!smc_clc_match_eid(ini->negotiated_eid, smc_v2_ext, NULL, NULL)) 2278 + if (!smc_v2_ext || 2279 + !smc_clc_match_eid(ini->negotiated_eid, smc_v2_ext, NULL, NULL)) 2285 2280 goto not_found; 2286 2281 2287 2282 /* prepare RDMA check */ ··· 2891 2884 } else { 2892 2885 sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 2893 2886 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 2887 + 2888 + if (sk->sk_state != SMC_INIT) { 2889 + /* Race breaker the same way as tcp_poll(). */ 2890 + smp_mb__after_atomic(); 2891 + if (atomic_read(&smc->conn.sndbuf_space)) 2892 + mask |= EPOLLOUT | EPOLLWRNORM; 2893 + } 2894 2894 } 2895 2895 if (atomic_read(&smc->conn.bytes_to_rcv)) 2896 2896 mask |= EPOLLIN | EPOLLRDNORM;
+16 -1
net/smc/smc_clc.c
··· 352 352 struct smc_clc_msg_hdr *hdr = &pclc->hdr; 353 353 struct smc_clc_v2_extension *v2_ext; 354 354 355 - v2_ext = smc_get_clc_v2_ext(pclc); 356 355 pclc_prfx = smc_clc_proposal_get_prefix(pclc); 356 + if (!pclc_prfx || 357 + pclc_prfx->ipv6_prefixes_cnt > SMC_CLC_MAX_V6_PREFIX) 358 + return false; 359 + 357 360 if (hdr->version == SMC_V1) { 358 361 if (hdr->typev1 == SMC_TYPE_N) 359 362 return false; ··· 368 365 sizeof(struct smc_clc_msg_trail)) 369 366 return false; 370 367 } else { 368 + v2_ext = smc_get_clc_v2_ext(pclc); 369 + if ((hdr->typev2 != SMC_TYPE_N && 370 + (!v2_ext || v2_ext->hdr.eid_cnt > SMC_CLC_MAX_UEID)) || 371 + (smcd_indicated(hdr->typev2) && 372 + v2_ext->hdr.ism_gid_cnt > SMCD_CLC_MAX_V2_GID_ENTRIES)) 373 + return false; 374 + 371 375 if (ntohs(hdr->length) != 372 376 sizeof(*pclc) + 373 377 sizeof(struct smc_clc_msg_smcd) + ··· 774 764 SMC_CLC_RECV_BUF_LEN : datlen; 775 765 iov_iter_kvec(&msg.msg_iter, ITER_DEST, &vec, 1, recvlen); 776 766 len = sock_recvmsg(smc->clcsock, &msg, krflags); 767 + if (len < recvlen) { 768 + smc->sk.sk_err = EPROTO; 769 + reason_code = -EPROTO; 770 + goto out; 771 + } 777 772 datlen -= len; 778 773 } 779 774 if (clcm->type == SMC_CLC_DECLINE) {
+19 -3
net/smc/smc_clc.h
··· 336 336 static inline struct smc_clc_msg_proposal_prefix * 337 337 smc_clc_proposal_get_prefix(struct smc_clc_msg_proposal *pclc) 338 338 { 339 + u16 offset = ntohs(pclc->iparea_offset); 340 + 341 + if (offset > sizeof(struct smc_clc_msg_smcd)) 342 + return NULL; 339 343 return (struct smc_clc_msg_proposal_prefix *) 340 - ((u8 *)pclc + sizeof(*pclc) + ntohs(pclc->iparea_offset)); 344 + ((u8 *)pclc + sizeof(*pclc) + offset); 341 345 } 342 346 343 347 static inline bool smcr_indicated(int smc_type) ··· 380 376 smc_get_clc_v2_ext(struct smc_clc_msg_proposal *prop) 381 377 { 382 378 struct smc_clc_msg_smcd *prop_smcd = smc_get_clc_msg_smcd(prop); 379 + u16 max_offset; 383 380 384 - if (!prop_smcd || !ntohs(prop_smcd->v2_ext_offset)) 381 + max_offset = offsetof(struct smc_clc_msg_proposal_area, pclc_v2_ext) - 382 + offsetof(struct smc_clc_msg_proposal_area, pclc_smcd) - 383 + offsetofend(struct smc_clc_msg_smcd, v2_ext_offset); 384 + 385 + if (!prop_smcd || !ntohs(prop_smcd->v2_ext_offset) || 386 + ntohs(prop_smcd->v2_ext_offset) > max_offset) 385 387 return NULL; 386 388 387 389 return (struct smc_clc_v2_extension *) ··· 400 390 static inline struct smc_clc_smcd_v2_extension * 401 391 smc_get_clc_smcd_v2_ext(struct smc_clc_v2_extension *prop_v2ext) 402 392 { 393 + u16 max_offset = offsetof(struct smc_clc_msg_proposal_area, pclc_smcd_v2_ext) - 394 + offsetof(struct smc_clc_msg_proposal_area, pclc_v2_ext) - 395 + offsetof(struct smc_clc_v2_extension, hdr) - 396 + offsetofend(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset); 397 + 403 398 if (!prop_v2ext) 404 399 return NULL; 405 - if (!ntohs(prop_v2ext->hdr.smcd_v2_ext_offset)) 400 + if (!ntohs(prop_v2ext->hdr.smcd_v2_ext_offset) || 401 + ntohs(prop_v2ext->hdr.smcd_v2_ext_offset) > max_offset) 406 402 return NULL; 407 403 408 404 return (struct smc_clc_smcd_v2_extension *)
+7 -2
net/smc/smc_core.c
··· 1823 1823 { 1824 1824 if (smc_link_downing(&lnk->state)) { 1825 1825 trace_smcr_link_down(lnk, __builtin_return_address(0)); 1826 - schedule_work(&lnk->link_down_wrk); 1826 + smcr_link_hold(lnk); /* smcr_link_put in link_down_wrk */ 1827 + if (!schedule_work(&lnk->link_down_wrk)) 1828 + smcr_link_put(lnk); 1827 1829 } 1828 1830 } 1829 1831 ··· 1857 1855 struct smc_link_group *lgr = link->lgr; 1858 1856 1859 1857 if (list_empty(&lgr->list)) 1860 - return; 1858 + goto out; 1861 1859 wake_up_all(&lgr->llc_msg_waiter); 1862 1860 down_write(&lgr->llc_conf_mutex); 1863 1861 smcr_link_down(link); 1864 1862 up_write(&lgr->llc_conf_mutex); 1863 + 1864 + out: 1865 + smcr_link_put(link); /* smcr_link_hold by schedulers of link_down_work */ 1865 1866 } 1866 1867 1867 1868 static int smc_vlan_by_tcpsk_walk(struct net_device *lower_dev,
+14 -1
rust/Makefile
··· 280 280 # architecture instead of generating `usize`. 281 281 bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__ 282 282 283 + # Each `bindgen` release may upgrade the list of Rust target versions. By 284 + # default, the highest stable release in their list is used. Thus we need to set 285 + # a `--rust-target` to avoid future `bindgen` releases emitting code that 286 + # `rustc` may not understand. On top of that, `bindgen` does not support passing 287 + # an unknown Rust target version. 288 + # 289 + # Therefore, the Rust target for `bindgen` can be only as high as the minimum 290 + # Rust version the kernel supports and only as high as the greatest stable Rust 291 + # target supported by the minimum `bindgen` version the kernel supports (that 292 + # is, if we do not test the actual `rustc`/`bindgen` versions running). 293 + # 294 + # Starting with `bindgen` 0.71.0, we will be able to set any future Rust version 295 + # instead, i.e. we will be able to set here our minimum supported Rust version. 283 296 quiet_cmd_bindgen = BINDGEN $@ 284 297 cmd_bindgen = \ 285 - $(BINDGEN) $< $(bindgen_target_flags) \ 298 + $(BINDGEN) $< $(bindgen_target_flags) --rust-target 1.68 \ 286 299 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests \ 287 300 --no-debug '.*' --enable-function-attribute-detection \ 288 301 -o $@ -- $(bindgen_c_flags_final) -DMODULE \
+2 -2
rust/kernel/net/phy.rs
··· 860 860 /// ]; 861 861 /// #[cfg(MODULE)] 862 862 /// #[no_mangle] 863 - /// static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = _DEVICE_TABLE; 863 + /// static __mod_device_table__mdio__phydev: [::kernel::bindings::mdio_device_id; 2] = _DEVICE_TABLE; 864 864 /// ``` 865 865 #[macro_export] 866 866 macro_rules! module_phy_driver { ··· 883 883 884 884 #[cfg(MODULE)] 885 885 #[no_mangle] 886 - static __mod_mdio__phydev_device_table: [$crate::bindings::mdio_device_id; 886 + static __mod_device_table__mdio__phydev: [$crate::bindings::mdio_device_id; 887 887 $crate::module_phy_driver!(@count_devices $($dev),+) + 1] = _DEVICE_TABLE; 888 888 }; 889 889
-1
scripts/head-object-list.txt
··· 24 24 arch/m68k/kernel/sun3-head.o 25 25 arch/microblaze/kernel/head.o 26 26 arch/nios2/kernel/head.o 27 - arch/openrisc/kernel/head.o 28 27 arch/parisc/kernel/head.o 29 28 arch/powerpc/kernel/head_44x.o 30 29 arch/powerpc/kernel/head_64.o
+1 -1
scripts/kernel-doc
··· 267 267 my $doc_inline_end = '^\s*\*/\s*$'; 268 268 my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$'; 269 269 my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;'; 270 - my $export_symbol_ns = '^\s*EXPORT_SYMBOL_NS(_GPL)?\s*\(\s*(\w+)\s*,\s*\w+\)\s*;'; 270 + my $export_symbol_ns = '^\s*EXPORT_SYMBOL_NS(_GPL)?\s*\(\s*(\w+)\s*,\s*"\S+"\)\s*;'; 271 271 my $function_pointer = qr{([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)}; 272 272 my $attribute = qr{__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)}i; 273 273
+6 -2
security/selinux/ss/services.c
··· 979 979 return; 980 980 break; 981 981 default: 982 - BUG(); 982 + pr_warn_once( 983 + "SELinux: unknown extended permission (%u) will be ignored\n", 984 + node->datum.u.xperms->specified); 985 + return; 983 986 } 984 987 985 988 if (node->key.specified == AVTAB_XPERMS_ALLOWED) { ··· 1001 998 &node->datum.u.xperms->perms, 1002 999 xpermd->dontaudit); 1003 1000 } else { 1004 - BUG(); 1001 + pr_warn_once("SELinux: unknown specified key (%u)\n", 1002 + node->key.specified); 1005 1003 } 1006 1004 } 1007 1005
+10 -4
sound/core/control_led.c
··· 668 668 goto cerr; 669 669 led->cards[card->number] = led_card; 670 670 snprintf(link_name, sizeof(link_name), "led-%s", led->name); 671 - WARN(sysfs_create_link(&card->ctl_dev->kobj, &led_card->dev.kobj, link_name), 672 - "can't create symlink to controlC%i device\n", card->number); 673 - WARN(sysfs_create_link(&led_card->dev.kobj, &card->card_dev.kobj, "card"), 674 - "can't create symlink to card%i\n", card->number); 671 + if (sysfs_create_link(&card->ctl_dev->kobj, &led_card->dev.kobj, 672 + link_name)) 673 + dev_err(card->dev, 674 + "%s: can't create symlink to controlC%i device\n", 675 + __func__, card->number); 676 + if (sysfs_create_link(&led_card->dev.kobj, &card->card_dev.kobj, 677 + "card")) 678 + dev_err(card->dev, 679 + "%s: can't create symlink to card%i\n", 680 + __func__, card->number); 675 681 676 682 continue; 677 683 cerr:
-8
sound/pci/hda/cs35l56_hda.c
··· 151 151 } 152 152 } 153 153 154 - ret = cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base); 155 - if (ret) 156 - goto err; 157 - 158 154 return 0; 159 155 160 156 err: ··· 1055 1059 1056 1060 regmap_multi_reg_write(cs35l56->base.regmap, cs35l56_hda_dai_config, 1057 1061 ARRAY_SIZE(cs35l56_hda_dai_config)); 1058 - ret = cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base); 1059 - if (ret) 1060 - goto dsp_err; 1061 1062 1062 1063 /* 1063 1064 * By default only enable one ASP1TXn, where n=amplifier index, ··· 1080 1087 1081 1088 pm_err: 1082 1089 pm_runtime_disable(cs35l56->base.dev); 1083 - dsp_err: 1084 1090 cs_dsp_remove(&cs35l56->cs_dsp); 1085 1091 err: 1086 1092 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0);
+21 -16
sound/pci/hda/patch_ca0132.c
··· 1134 1134 1135 1135 struct hda_codec *codec; 1136 1136 struct delayed_work unsol_hp_work; 1137 - int quirk; 1138 1137 1139 1138 #ifdef ENABLE_TUNING_CONTROLS 1140 1139 long cur_ctl_vals[TUNING_CTLS_COUNT]; ··· 1165 1166 * CA0132 quirks table 1166 1167 */ 1167 1168 enum { 1168 - QUIRK_NONE, 1169 1169 QUIRK_ALIENWARE, 1170 1170 QUIRK_ALIENWARE_M17XR4, 1171 1171 QUIRK_SBZ, ··· 1174 1176 QUIRK_R3D, 1175 1177 QUIRK_AE5, 1176 1178 QUIRK_AE7, 1179 + QUIRK_NONE = HDA_FIXUP_ID_NOT_SET, 1177 1180 }; 1178 1181 1179 1182 #ifdef CONFIG_PCI 1180 - #define ca0132_quirk(spec) ((spec)->quirk) 1183 + #define ca0132_quirk(spec) ((spec)->codec->fixup_id) 1181 1184 #define ca0132_use_pci_mmio(spec) ((spec)->use_pci_mmio) 1182 1185 #define ca0132_use_alt_functions(spec) ((spec)->use_alt_functions) 1183 1186 #define ca0132_use_alt_controls(spec) ((spec)->use_alt_controls) ··· 1292 1293 {} 1293 1294 }; 1294 1295 1295 - static const struct snd_pci_quirk ca0132_quirks[] = { 1296 + static const struct hda_quirk ca0132_quirks[] = { 1296 1297 SND_PCI_QUIRK(0x1028, 0x057b, "Alienware M17x R4", QUIRK_ALIENWARE_M17XR4), 1297 1298 SND_PCI_QUIRK(0x1028, 0x0685, "Alienware 15 2015", QUIRK_ALIENWARE), 1298 1299 SND_PCI_QUIRK(0x1028, 0x0688, "Alienware 17 2015", QUIRK_ALIENWARE), ··· 1312 1313 SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5), 1313 1314 SND_PCI_QUIRK(0x1102, 0x0191, "Sound Blaster AE-5 Plus", QUIRK_AE5), 1314 1315 SND_PCI_QUIRK(0x1102, 0x0081, "Sound Blaster AE-7", QUIRK_AE7), 1316 + {} 1317 + }; 1318 + 1319 + static const struct hda_model_fixup ca0132_quirk_models[] = { 1320 + { .id = QUIRK_ALIENWARE, .name = "alienware" }, 1321 + { .id = QUIRK_ALIENWARE_M17XR4, .name = "alienware-m17xr4" }, 1322 + { .id = QUIRK_SBZ, .name = "sbz" }, 1323 + { .id = QUIRK_ZXR, .name = "zxr" }, 1324 + { .id = QUIRK_ZXR_DBPRO, .name = "zxr-dbpro" }, 1325 + { .id = QUIRK_R3DI, .name = "r3di" }, 1326 + { .id = QUIRK_R3D, .name = "r3d" }, 1327 + { .id = QUIRK_AE5, .name = "ae5" }, 1328 + { .id = QUIRK_AE7, .name = "ae7" }, 1315 1329 {} 1316 1330 }; 1317 1331 ··· 9969 9957 */ 9970 9958 static void sbz_detect_quirk(struct hda_codec *codec) 9971 9959 { 9972 - struct ca0132_spec *spec = codec->spec; 9973 - 9974 9960 switch (codec->core.subsystem_id) { 9975 9961 case 0x11020033: 9976 - spec->quirk = QUIRK_ZXR; 9962 + codec->fixup_id = QUIRK_ZXR; 9977 9963 break; 9978 9964 case 0x1102003f: 9979 - spec->quirk = QUIRK_ZXR_DBPRO; 9965 + codec->fixup_id = QUIRK_ZXR_DBPRO; 9980 9966 break; 9981 9967 default: 9982 - spec->quirk = QUIRK_SBZ; 9968 + codec->fixup_id = QUIRK_SBZ; 9983 9969 break; 9984 9970 } 9985 9971 } ··· 9986 9976 { 9987 9977 struct ca0132_spec *spec; 9988 9978 int err; 9989 - const struct snd_pci_quirk *quirk; 9990 9979 9991 9980 codec_dbg(codec, "patch_ca0132\n"); 9992 9981 ··· 9996 9987 spec->codec = codec; 9997 9988 9998 9989 /* Detect codec quirk */ 9999 - quirk = snd_pci_quirk_lookup(codec->bus->pci, ca0132_quirks); 10000 - if (quirk) 10001 - spec->quirk = quirk->value; 10002 - else 10003 - spec->quirk = QUIRK_NONE; 9990 + snd_hda_pick_fixup(codec, ca0132_quirk_models, ca0132_quirks, NULL); 10004 9991 if (ca0132_quirk(spec) == QUIRK_SBZ) 10005 9992 sbz_detect_quirk(codec); 10006 9993 ··· 10073 10068 spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20); 10074 10069 if (spec->mem_base == NULL) { 10075 10070 codec_warn(codec, "pci_iomap failed! Setting quirk to QUIRK_NONE."); 10076 - spec->quirk = QUIRK_NONE; 10071 + codec->fixup_id = QUIRK_NONE; 10077 10072 } 10078 10073 } 10079 10074 #endif
+24
sound/pci/hda/patch_realtek.c
··· 7714 7714 ALC274_FIXUP_HP_MIC, 7715 7715 ALC274_FIXUP_HP_HEADSET_MIC, 7716 7716 ALC274_FIXUP_HP_ENVY_GPIO, 7717 + ALC274_FIXUP_ASUS_ZEN_AIO_27, 7717 7718 ALC256_FIXUP_ASUS_HPE, 7718 7719 ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK, 7719 7720 ALC287_FIXUP_HP_GPIO_LED, ··· 9517 9516 .type = HDA_FIXUP_FUNC, 9518 9517 .v.func = alc274_fixup_hp_envy_gpio, 9519 9518 }, 9519 + [ALC274_FIXUP_ASUS_ZEN_AIO_27] = { 9520 + .type = HDA_FIXUP_VERBS, 9521 + .v.verbs = (const struct hda_verb[]) { 9522 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x10 }, 9523 + { 0x20, AC_VERB_SET_PROC_COEF, 0xc420 }, 9524 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 }, 9525 + { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 }, 9526 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x49 }, 9527 + { 0x20, AC_VERB_SET_PROC_COEF, 0x0249 }, 9528 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x4a }, 9529 + { 0x20, AC_VERB_SET_PROC_COEF, 0x202b }, 9530 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x62 }, 9531 + { 0x20, AC_VERB_SET_PROC_COEF, 0xa007 }, 9532 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x6b }, 9533 + { 0x20, AC_VERB_SET_PROC_COEF, 0x5060 }, 9534 + {} 9535 + }, 9536 + .chained = true, 9537 + .chain_id = ALC2XX_FIXUP_HEADSET_MIC, 9538 + }, 9520 9539 [ALC256_FIXUP_ASUS_HPE] = { 9521 9540 .type = HDA_FIXUP_VERBS, 9522 9541 .v.verbs = (const struct hda_verb[]) { ··· 10163 10142 SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 10164 10143 SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), 10165 10144 SND_PCI_QUIRK(0x1025, 0x1534, "Acer Predator PH315-54", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), 10145 + SND_PCI_QUIRK(0x1025, 0x159c, "Acer Nitro 5 AN515-58", ALC2XX_FIXUP_HEADSET_MIC), 10166 10146 SND_PCI_QUIRK(0x1025, 0x169a, "Acer Swift SFG16", ALC256_FIXUP_ACER_SFG16_MICMUTE_LED), 10167 10147 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 10168 10148 SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X), ··· 10652 10630 SND_PCI_QUIRK(0x1043, 0x1f62, "ASUS UX7602ZM", ALC245_FIXUP_CS35L41_SPI_2), 10653 10631 SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401), 10654 10632 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 10633 + SND_PCI_QUIRK(0x1043, 0x31d0, "ASUS Zen AIO 27 Z272SD_A272SD", ALC274_FIXUP_ASUS_ZEN_AIO_27), 10655 10634 SND_PCI_QUIRK(0x1043, 0x3a20, "ASUS G614JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), 10656 10635 SND_PCI_QUIRK(0x1043, 0x3a30, "ASUS G814JVR/JIR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), 10657 10636 SND_PCI_QUIRK(0x1043, 0x3a40, "ASUS G814JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), ··· 11200 11177 {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"}, 11201 11178 {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"}, 11202 11179 {.id = ALC236_FIXUP_LENOVO_INV_DMIC, .name = "alc236-fixup-lenovo-inv-mic"}, 11180 + {.id = ALC2XX_FIXUP_HEADSET_MIC, .name = "alc2xx-fixup-headset-mic"}, 11203 11181 {} 11204 11182 }; 11205 11183 #define ALC225_STANDARD_PINS \
+9 -4
sound/soc/amd/yc/acp6x-mach.c
··· 578 578 579 579 handle = ACPI_HANDLE(pdev->dev.parent); 580 580 ret = acpi_evaluate_integer(handle, "_WOV", NULL, &dmic_status); 581 - if (!ACPI_FAILURE(ret)) 581 + if (!ACPI_FAILURE(ret)) { 582 582 wov_en = dmic_status; 583 + if (!wov_en) 584 + return -ENODEV; 585 + } else { 586 + /* Incase of ACPI method read failure then jump to check_dmi_entry */ 587 + goto check_dmi_entry; 588 + } 583 589 584 - if (is_dmic_enable && wov_en) 590 + if (is_dmic_enable) 585 591 platform_set_drvdata(pdev, &acp6x_card); 586 - else 587 - return 0; 588 592 593 + check_dmi_entry: 589 594 /* check for any DMI overrides */ 590 595 dmi_id = dmi_first_match(yc_acp_quirk_table); 591 596 if (dmi_id)
+1 -1
sound/soc/codecs/tas2781-i2c.c
··· 370 370 tasdevice_dev_read(tas_priv, i, p[j].reg, 371 371 (int *)&p[j].val[0]); 372 372 } else { 373 - switch (p[j].reg) { 373 + switch (tas2781_cali_start_reg[j].reg) { 374 374 case 0: { 375 375 if (!reg[0]) 376 376 continue;
+1 -1
sound/soc/fsl/Kconfig
··· 29 29 config SND_SOC_FSL_MQS 30 30 tristate "Medium Quality Sound (MQS) module support" 31 31 depends on SND_SOC_FSL_SAI 32 + depends on IMX_SCMI_MISC_DRV || !IMX_SCMI_MISC_DRV 32 33 select REGMAP_MMIO 33 - select IMX_SCMI_MISC_DRV if IMX_SCMI_MISC_EXT !=n 34 34 help 35 35 Say Y if you want to add Medium Quality Sound (MQS) 36 36 support for the Freescale CPUs.
+1 -1
sound/soc/fsl/fsl_spdif.c
··· 1204 1204 }, 1205 1205 /* DPLL lock info get controller */ 1206 1206 { 1207 - .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1207 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1208 1208 .name = RX_SAMPLE_RATE_KCONTROL, 1209 1209 .access = SNDRV_CTL_ELEM_ACCESS_READ | 1210 1210 SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+1 -1
sound/soc/fsl/fsl_xcvr.c
··· 171 171 } 172 172 173 173 static struct snd_kcontrol_new fsl_xcvr_earc_capds_kctl = { 174 - .iface = SNDRV_CTL_ELEM_IFACE_PCM, 174 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 175 175 .name = "Capabilities Data Structure", 176 176 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 177 177 .info = fsl_xcvr_type_capds_bytes_info,
+1 -1
sound/soc/generic/audio-graph-card2.c
··· 771 771 of_node_get(port_codec); 772 772 if (graph_lnk_is_multi(port_codec)) { 773 773 ep_codec = graph_get_next_multi_ep(&port_codec); 774 - of_node_put(port_cpu); 774 + of_node_put(port_codec); 775 775 port_codec = ep_to_port(ep_codec); 776 776 } else { 777 777 ep_codec = of_graph_get_next_port_endpoint(port_codec, NULL);
+6 -2
sound/soc/intel/boards/sof_sdw.c
··· 1067 1067 return ret; 1068 1068 } 1069 1069 1070 - /* One per DAI link, worst case is a DAI link for every endpoint */ 1071 - sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL); 1070 + /* 1071 + * One per DAI link, worst case is a DAI link for every endpoint, also 1072 + * add one additional to act as a terminator such that code can iterate 1073 + * until it hits an uninitialised DAI. 1074 + */ 1075 + sof_dais = kcalloc(num_ends + 1, sizeof(*sof_dais), GFP_KERNEL); 1072 1076 if (!sof_dais) 1073 1077 return -ENOMEM; 1074 1078
+6 -1
sound/usb/format.c
··· 60 60 pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL; 61 61 /* flag potentially raw DSD capable altsettings */ 62 62 fp->dsd_raw = true; 63 + /* clear special format bit to avoid "unsupported format" msg below */ 64 + format &= ~UAC2_FORMAT_TYPE_I_RAW_DATA; 63 65 } 64 66 65 67 format <<= 1; ··· 73 71 sample_width = as->bBitResolution; 74 72 sample_bytes = as->bSubslotSize; 75 73 76 - if (format & UAC3_FORMAT_TYPE_I_RAW_DATA) 74 + if (format & UAC3_FORMAT_TYPE_I_RAW_DATA) { 77 75 pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL; 76 + /* clear special format bit to avoid "unsupported format" msg below */ 77 + format &= ~UAC3_FORMAT_TYPE_I_RAW_DATA; 78 + } 78 79 79 80 format <<= 1; 80 81 break;
+4
sound/usb/quirks.c
··· 2179 2179 QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIC_RES_384), 2180 2180 DEVICE_FLG(0x046d, 0x09a4, /* Logitech QuickCam E 3500 */ 2181 2181 QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_IGNORE_CTL_ERROR), 2182 + DEVICE_FLG(0x0499, 0x1506, /* Yamaha THR5 */ 2183 + QUIRK_FLAG_GENERIC_IMPLICIT_FB), 2182 2184 DEVICE_FLG(0x0499, 0x1509, /* Steinberg UR22 */ 2183 2185 QUIRK_FLAG_GENERIC_IMPLICIT_FB), 2184 2186 DEVICE_FLG(0x0499, 0x3108, /* Yamaha YIT-W12TX */ ··· 2325 2323 QUIRK_FLAG_DSD_RAW), 2326 2324 DEVICE_FLG(0x2522, 0x0007, /* LH Labs Geek Out HD Audio 1V5 */ 2327 2325 QUIRK_FLAG_SET_IFACE_FIRST), 2326 + DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */ 2327 + QUIRK_FLAG_DSD_RAW), 2328 2328 DEVICE_FLG(0x2708, 0x0002, /* Audient iD14 */ 2329 2329 QUIRK_FLAG_IGNORE_CTL_ERROR), 2330 2330 DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */
+6
tools/arch/arm64/include/uapi/asm/kvm.h
··· 484 484 */ 485 485 #define KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 (1ULL << 0) 486 486 487 + /* 488 + * Shutdown caused by a PSCI v1.3 SYSTEM_OFF2 call. 489 + * Valid only when the system event has a type of KVM_SYSTEM_EVENT_SHUTDOWN. 490 + */ 491 + #define KVM_SYSTEM_EVENT_SHUTDOWN_FLAG_PSCI_OFF2 (1ULL << 0) 492 + 487 493 /* run->fail_entry.hardware_entry_failure_reason codes. */ 488 494 #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED (1ULL << 0) 489 495
+9 -2
tools/arch/x86/include/asm/cpufeatures.h
··· 215 215 #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE ( 7*32+23) /* Disable Speculative Store Bypass. */ 216 216 #define X86_FEATURE_LS_CFG_SSBD ( 7*32+24) /* AMD SSBD implementation via LS_CFG MSR */ 217 217 #define X86_FEATURE_IBRS ( 7*32+25) /* "ibrs" Indirect Branch Restricted Speculation */ 218 - #define X86_FEATURE_IBPB ( 7*32+26) /* "ibpb" Indirect Branch Prediction Barrier */ 218 + #define X86_FEATURE_IBPB ( 7*32+26) /* "ibpb" Indirect Branch Prediction Barrier without a guaranteed RSB flush */ 219 219 #define X86_FEATURE_STIBP ( 7*32+27) /* "stibp" Single Thread Indirect Branch Predictors */ 220 220 #define X86_FEATURE_ZEN ( 7*32+28) /* Generic flag for all Zen and newer */ 221 221 #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* L1TF workaround PTE inversion */ ··· 317 317 #define X86_FEATURE_ZEN1 (11*32+31) /* CPU based on Zen1 microarchitecture */ 318 318 319 319 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ 320 + #define X86_FEATURE_SHA512 (12*32+ 0) /* SHA512 instructions */ 321 + #define X86_FEATURE_SM3 (12*32+ 1) /* SM3 instructions */ 322 + #define X86_FEATURE_SM4 (12*32+ 2) /* SM4 instructions */ 320 323 #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* "avx_vnni" AVX VNNI instructions */ 321 324 #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* "avx512_bf16" AVX512 BFLOAT16 instructions */ 322 325 #define X86_FEATURE_CMPCCXADD (12*32+ 7) /* CMPccXADD instructions */ ··· 351 348 #define X86_FEATURE_CPPC (13*32+27) /* "cppc" Collaborative Processor Performance Control */ 352 349 #define X86_FEATURE_AMD_PSFD (13*32+28) /* Predictive Store Forwarding Disable */ 353 350 #define X86_FEATURE_BTC_NO (13*32+29) /* Not vulnerable to Branch Type Confusion */ 351 + #define X86_FEATURE_AMD_IBPB_RET (13*32+30) /* IBPB clears return address predictor */ 354 352 #define X86_FEATURE_BRS (13*32+31) /* "brs" Branch Sampling available */ 355 353 356 354 /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ ··· 476 472 #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */ 477 473 #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */ 478 474 #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ 479 - #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ 475 + #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ 476 + #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */ 477 + #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */ 480 478 481 479 /* 482 480 * BUG word(s) ··· 529 523 #define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */ 530 524 #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ 531 525 #define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */ 526 + #define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */ 532 527 #endif /* _ASM_X86_CPUFEATURES_H */
+1
tools/arch/x86/include/uapi/asm/kvm.h
··· 440 440 #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5) 441 441 #define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6) 442 442 #define KVM_X86_QUIRK_SLOT_ZAP_ALL (1 << 7) 443 + #define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8) 443 444 444 445 #define KVM_STATE_NESTED_FORMAT_VMX 0 445 446 #define KVM_STATE_NESTED_FORMAT_SVM 1
+3
tools/hv/.gitignore
··· 1 + hv_fcopy_uio_daemon 2 + hv_kvp_daemon 3 + hv_vss_daemon
+6 -6
tools/hv/hv_fcopy_uio_daemon.c
··· 35 35 #define WIN8_SRV_MINOR 1 36 36 #define WIN8_SRV_VERSION (WIN8_SRV_MAJOR << 16 | WIN8_SRV_MINOR) 37 37 38 - #define MAX_FOLDER_NAME 15 39 - #define MAX_PATH_LEN 15 40 38 #define FCOPY_UIO "/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio" 41 39 42 40 #define FCOPY_VER_COUNT 1 ··· 49 51 50 52 #define HV_RING_SIZE 0x4000 /* 16KB ring buffer size */ 51 53 52 - unsigned char desc[HV_RING_SIZE]; 54 + static unsigned char desc[HV_RING_SIZE]; 53 55 54 56 static int target_fd; 55 57 static char target_fname[PATH_MAX]; ··· 407 409 struct vmbus_br txbr, rxbr; 408 410 void *ring; 409 411 uint32_t len = HV_RING_SIZE; 410 - char uio_name[MAX_FOLDER_NAME] = {0}; 411 - char uio_dev_path[MAX_PATH_LEN] = {0}; 412 + char uio_name[NAME_MAX] = {0}; 413 + char uio_dev_path[PATH_MAX] = {0}; 412 414 413 415 static struct option long_options[] = { 414 416 {"help", no_argument, 0, 'h' }, ··· 466 468 */ 467 469 ret = pread(fcopy_fd, &tmp, sizeof(int), 0); 468 470 if (ret < 0) { 471 + if (errno == EINTR || errno == EAGAIN) 472 + continue; 469 473 syslog(LOG_ERR, "pread failed: %s", strerror(errno)); 470 - continue; 474 + goto close; 471 475 } 472 476 473 477 len = HV_RING_SIZE;
+2 -2
tools/hv/hv_get_dns_info.sh
··· 1 - #!/bin/bash 1 + #!/bin/sh 2 2 3 3 # This example script parses /etc/resolv.conf to retrive DNS information. 4 4 # In the interest of keeping the KVP daemon code free of distro specific ··· 10 10 # this script can be based on the Network Manager APIs for retrieving DNS 11 11 # entries. 12 12 13 - cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 13 + exec awk '/^nameserver/ { print $2 }' /etc/resolv.conf 2>/dev/null
+5 -4
tools/hv/hv_kvp_daemon.c
··· 725 725 * . 726 726 */ 727 727 728 - sprintf(cmd, KVP_SCRIPTS_PATH "%s", "hv_get_dns_info"); 728 + sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dns_info", if_name); 729 729 730 730 /* 731 731 * Execute the command to gather DNS info. ··· 742 742 * Enabled: DHCP enabled. 743 743 */ 744 744 745 - sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name); 745 + sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dhcp_info", if_name); 746 746 747 747 file = popen(cmd, "r"); 748 748 if (file == NULL) ··· 1606 1606 * invoke the external script to do its magic. 1607 1607 */ 1608 1608 1609 - str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s %s", 1610 - "hv_set_ifconfig", if_filename, nm_filename); 1609 + str_len = snprintf(cmd, sizeof(cmd), "exec %s %s %s", 1610 + KVP_SCRIPTS_PATH "hv_set_ifconfig", 1611 + if_filename, nm_filename); 1611 1612 /* 1612 1613 * This is a little overcautious, but it's necessary to suppress some 1613 1614 * false warnings from gcc 8.0.1.
+1 -1
tools/hv/hv_set_ifconfig.sh
··· 81 81 82 82 cp $1 /etc/sysconfig/network-scripts/ 83 83 84 - chmod 600 $2 84 + umask 0177 85 85 interface=$(echo $2 | awk -F - '{ print $2 }') 86 86 filename="${2##*/}" 87 87
+4
tools/include/uapi/asm-generic/mman.h
··· 19 19 #define MCL_FUTURE 2 /* lock all future mappings */ 20 20 #define MCL_ONFAULT 4 /* lock all pages that are faulted in */ 21 21 22 + #define SHADOW_STACK_SET_TOKEN (1ULL << 0) /* Set up a restore token in the shadow stack */ 23 + #define SHADOW_STACK_SET_MARKER (1ULL << 1) /* Set up a top of stack marker in the shadow stack */ 24 + 25 + 22 26 #endif /* __ASM_GENERIC_MMAN_H */
+10 -1
tools/include/uapi/asm-generic/unistd.h
··· 841 841 #define __NR_mseal 462 842 842 __SYSCALL(__NR_mseal, sys_mseal) 843 843 844 + #define __NR_setxattrat 463 845 + __SYSCALL(__NR_setxattrat, sys_setxattrat) 846 + #define __NR_getxattrat 464 847 + __SYSCALL(__NR_getxattrat, sys_getxattrat) 848 + #define __NR_listxattrat 465 849 + __SYSCALL(__NR_listxattrat, sys_listxattrat) 850 + #define __NR_removexattrat 466 851 + __SYSCALL(__NR_removexattrat, sys_removexattrat) 852 + 844 853 #undef __NR_syscalls 845 - #define __NR_syscalls 463 854 + #define __NR_syscalls 467 846 855 847 856 /* 848 857 * 32 bit systems traditionally used different
+17
tools/include/uapi/drm/drm.h
··· 1024 1024 __u64 user_data; /* user data passed to event */ 1025 1025 }; 1026 1026 1027 + #define DRM_CLIENT_NAME_MAX_LEN 64 1028 + struct drm_set_client_name { 1029 + __u64 name_len; 1030 + __u64 name; 1031 + }; 1032 + 1033 + 1027 1034 #if defined(__cplusplus) 1028 1035 } 1029 1036 #endif ··· 1294 1287 * framebuffers attached to a plane can be read back by the next DRM master. 1295 1288 */ 1296 1289 #define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, struct drm_mode_closefb) 1290 + 1291 + /** 1292 + * DRM_IOCTL_SET_CLIENT_NAME - Attach a name to a drm_file 1293 + * 1294 + * Having a name allows for easier tracking and debugging. 1295 + * The length of the name (without null ending char) must be 1296 + * <= DRM_CLIENT_NAME_MAX_LEN. 1297 + * The call will fail if the name contains whitespaces or non-printable chars. 1298 + */ 1299 + #define DRM_IOCTL_SET_CLIENT_NAME DRM_IOWR(0xD1, struct drm_set_client_name) 1297 1300 1298 1301 /* 1299 1302 * Device specific ioctls should only be in their respective headers
+8
tools/include/uapi/linux/kvm.h
··· 1158 1158 #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME 1159 1159 KVM_DEV_TYPE_RISCV_AIA, 1160 1160 #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA 1161 + KVM_DEV_TYPE_LOONGARCH_IPI, 1162 + #define KVM_DEV_TYPE_LOONGARCH_IPI KVM_DEV_TYPE_LOONGARCH_IPI 1163 + KVM_DEV_TYPE_LOONGARCH_EIOINTC, 1164 + #define KVM_DEV_TYPE_LOONGARCH_EIOINTC KVM_DEV_TYPE_LOONGARCH_EIOINTC 1165 + KVM_DEV_TYPE_LOONGARCH_PCHPIC, 1166 + #define KVM_DEV_TYPE_LOONGARCH_PCHPIC KVM_DEV_TYPE_LOONGARCH_PCHPIC 1167 + 1161 1168 KVM_DEV_TYPE_MAX, 1169 + 1162 1170 }; 1163 1171 1164 1172 struct kvm_vfio_spapr_tce {
+10 -1
tools/include/uapi/linux/perf_event.h
··· 511 511 __u16 sample_max_stack; 512 512 __u16 __reserved_2; 513 513 __u32 aux_sample_size; 514 - __u32 __reserved_3; 514 + 515 + union { 516 + __u32 aux_action; 517 + struct { 518 + __u32 aux_start_paused : 1, /* start AUX area tracing paused */ 519 + aux_pause : 1, /* on overflow, pause AUX area tracing */ 520 + aux_resume : 1, /* on overflow, resume AUX area tracing */ 521 + __reserved_3 : 29; 522 + }; 523 + }; 515 524 516 525 /* 517 526 * User provided data if sigtrap=1, passed back to user via
+16 -2
tools/lib/perf/evlist.c
··· 47 47 */ 48 48 perf_cpu_map__put(evsel->cpus); 49 49 evsel->cpus = perf_cpu_map__intersect(evlist->user_requested_cpus, evsel->own_cpus); 50 + 51 + /* 52 + * Empty cpu lists would eventually get opened as "any" so remove 53 + * genuinely empty ones before they're opened in the wrong place. 54 + */ 55 + if (perf_cpu_map__is_empty(evsel->cpus)) { 56 + struct perf_evsel *next = perf_evlist__next(evlist, evsel); 57 + 58 + perf_evlist__remove(evlist, evsel); 59 + /* Keep idx contiguous */ 60 + if (next) 61 + list_for_each_entry_from(next, &evlist->entries, node) 62 + next->idx--; 63 + } 50 64 } else if (!evsel->own_cpus || evlist->has_user_cpus || 51 65 (!evsel->requires_cpu && perf_cpu_map__has_any_cpu(evlist->user_requested_cpus))) { 52 66 /* ··· 94 80 95 81 static void perf_evlist__propagate_maps(struct perf_evlist *evlist) 96 82 { 97 - struct perf_evsel *evsel; 83 + struct perf_evsel *evsel, *n; 98 84 99 85 evlist->needs_map_propagation = true; 100 86 101 - perf_evlist__for_each_evsel(evlist, evsel) 87 + list_for_each_entry_safe(evsel, n, &evlist->entries, node) 102 88 __perf_evlist__propagate_maps(evlist, evsel); 103 89 } 104 90
+3 -3
tools/net/ynl/lib/ynl.py
··· 556 556 if attr["type"] == 'nest': 557 557 nl_type |= Netlink.NLA_F_NESTED 558 558 attr_payload = b'' 559 - sub_attrs = SpaceAttrs(self.attr_sets[space], value, search_attrs) 559 + sub_space = attr['nested-attributes'] 560 + sub_attrs = SpaceAttrs(self.attr_sets[sub_space], value, search_attrs) 560 561 for subname, subvalue in value.items(): 561 - attr_payload += self._add_attr(attr['nested-attributes'], 562 - subname, subvalue, sub_attrs) 562 + attr_payload += self._add_attr(sub_space, subname, subvalue, sub_attrs) 563 563 elif attr["type"] == 'flag': 564 564 if not value: 565 565 # If value is absent or false then skip attribute creation.
+6 -3
tools/objtool/check.c
··· 3820 3820 break; 3821 3821 3822 3822 case INSN_CONTEXT_SWITCH: 3823 - if (func && (!next_insn || !next_insn->hint)) { 3824 - WARN_INSN(insn, "unsupported instruction in callable function"); 3825 - return 1; 3823 + if (func) { 3824 + if (!next_insn || !next_insn->hint) { 3825 + WARN_INSN(insn, "unsupported instruction in callable function"); 3826 + return 1; 3827 + } 3828 + break; 3826 3829 } 3827 3830 return 0; 3828 3831
+4
tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
··· 377 377 460 n64 lsm_set_self_attr sys_lsm_set_self_attr 378 378 461 n64 lsm_list_modules sys_lsm_list_modules 379 379 462 n64 mseal sys_mseal 380 + 463 n64 setxattrat sys_setxattrat 381 + 464 n64 getxattrat sys_getxattrat 382 + 465 n64 listxattrat sys_listxattrat 383 + 466 n64 removexattrat sys_removexattrat
+4
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
··· 553 553 460 common lsm_set_self_attr sys_lsm_set_self_attr 554 554 461 common lsm_list_modules sys_lsm_list_modules 555 555 462 common mseal sys_mseal 556 + 463 common setxattrat sys_setxattrat 557 + 464 common getxattrat sys_getxattrat 558 + 465 common listxattrat sys_listxattrat 559 + 466 common removexattrat sys_removexattrat
+4
tools/perf/arch/s390/entry/syscalls/syscall.tbl
··· 465 465 460 common lsm_set_self_attr sys_lsm_set_self_attr sys_lsm_set_self_attr 466 466 461 common lsm_list_modules sys_lsm_list_modules sys_lsm_list_modules 467 467 462 common mseal sys_mseal sys_mseal 468 + 463 common setxattrat sys_setxattrat sys_setxattrat 469 + 464 common getxattrat sys_getxattrat sys_getxattrat 470 + 465 common listxattrat sys_listxattrat sys_listxattrat 471 + 466 common removexattrat sys_removexattrat sys_removexattrat
+4
tools/perf/arch/x86/entry/syscalls/syscall_32.tbl
··· 468 468 460 i386 lsm_set_self_attr sys_lsm_set_self_attr 469 469 461 i386 lsm_list_modules sys_lsm_list_modules 470 470 462 i386 mseal sys_mseal 471 + 463 i386 setxattrat sys_setxattrat 472 + 464 i386 getxattrat sys_getxattrat 473 + 465 i386 listxattrat sys_listxattrat 474 + 466 i386 removexattrat sys_removexattrat
+4
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 386 386 460 common lsm_set_self_attr sys_lsm_set_self_attr 387 387 461 common lsm_list_modules sys_lsm_list_modules 388 388 462 common mseal sys_mseal 389 + 463 common setxattrat sys_setxattrat 390 + 464 common getxattrat sys_getxattrat 391 + 465 common listxattrat sys_listxattrat 392 + 466 common removexattrat sys_removexattrat 389 393 390 394 # 391 395 # Due to a historical design error, certain syscalls are numbered differently
+2 -1
tools/perf/builtin-ftrace.c
··· 1151 1151 1152 1152 if (v1 > v2) 1153 1153 return -1; 1154 - else 1154 + if (v1 < v2) 1155 1155 return 1; 1156 + return 0; 1156 1157 } 1157 1158 1158 1159 static void print_profile_result(struct perf_ftrace *ftrace)
+1 -1
tools/perf/tests/builtin-test.c
··· 508 508 for (size_t x = 0; x < num_tests; x++) { 509 509 struct child_test *child_test = child_tests[x]; 510 510 511 - if (!child_test) 511 + if (!child_test || child_test->process.pid <= 0) 512 512 continue; 513 513 514 514 pr_debug3("Killing %d pid %d\n",
+12 -7
tools/perf/tests/expr.c
··· 75 75 double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages; 76 76 int ret; 77 77 struct expr_parse_ctx *ctx; 78 - bool is_intel = false; 79 78 char strcmp_cpuid_buf[256]; 80 79 struct perf_cpu cpu = {-1}; 81 80 char *cpuid = get_cpuid_allow_env_override(cpu); 82 81 char *escaped_cpuid1, *escaped_cpuid2; 83 82 84 83 TEST_ASSERT_VAL("get_cpuid", cpuid); 85 - is_intel = strstr(cpuid, "Intel") != NULL; 86 84 87 85 TEST_ASSERT_EQUAL("ids_union", test_ids_union(), 0); 88 86 ··· 243 245 if (num_dies) // Some platforms do not have CPU die support, for example s390 244 246 TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages); 245 247 246 - TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0); 247 - if (is_intel) 248 - TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0); 249 - else 250 - TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO); 251 248 249 + if (expr__parse(&val, ctx, "#system_tsc_freq") == 0) { 250 + bool is_intel = strstr(cpuid, "Intel") != NULL; 251 + 252 + if (is_intel) 253 + TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0); 254 + else 255 + TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO); 256 + } else { 257 + #if defined(__i386__) || defined(__x86_64__) 258 + TEST_ASSERT_VAL("#system_tsc_freq unsupported", 0); 259 + #endif 260 + } 252 261 /* 253 262 * Source count returns the number of events aggregating in a leader 254 263 * event including the leader. Check parsing yields an id.
+18 -11
tools/perf/tests/hwmon_pmu.c
··· 65 65 { "temp2_label", "test hwmon event2\n", }, 66 66 { "temp2_input", "50000\n", }, 67 67 }; 68 - int dirfd, file; 68 + int hwmon_dirfd = -1, test_dirfd = -1, file; 69 69 struct perf_pmu *hwm = NULL; 70 70 ssize_t len; 71 71 ··· 76 76 dir[0] = '\0'; 77 77 return NULL; 78 78 } 79 - dirfd = open(dir, O_DIRECTORY); 80 - if (dirfd < 0) { 79 + test_dirfd = open(dir, O_PATH|O_DIRECTORY); 80 + if (test_dirfd < 0) { 81 81 pr_err("Failed to open test directory \"%s\"\n", dir); 82 82 goto err_out; 83 83 } 84 84 85 85 /* Create the test hwmon directory and give it a name. */ 86 - if (mkdirat(dirfd, "hwmon1234", 0755) < 0) { 86 + if (mkdirat(test_dirfd, "hwmon1234", 0755) < 0) { 87 87 pr_err("Failed to mkdir hwmon directory\n"); 88 88 goto err_out; 89 89 } 90 - file = openat(dirfd, "hwmon1234/name", O_WRONLY | O_CREAT, 0600); 91 - if (!file) { 90 + hwmon_dirfd = openat(test_dirfd, "hwmon1234", O_DIRECTORY); 91 + if (hwmon_dirfd < 0) { 92 + pr_err("Failed to open test hwmon directory \"%s/hwmon1234\"\n", dir); 93 + goto err_out; 94 + } 95 + file = openat(hwmon_dirfd, "name", O_WRONLY | O_CREAT, 0600); 96 + if (file < 0) { 92 97 pr_err("Failed to open for writing file \"name\"\n"); 93 98 goto err_out; 94 99 } ··· 109 104 for (size_t i = 0; i < ARRAY_SIZE(test_items); i++) { 110 105 const struct test_item *item = &test_items[i]; 111 106 112 - file = openat(dirfd, item->name, O_WRONLY | O_CREAT, 0600); 113 - if (!file) { 107 + file = openat(hwmon_dirfd, item->name, O_WRONLY | O_CREAT, 0600); 108 + if (file < 0) { 114 109 pr_err("Failed to open for writing file \"%s\"\n", item->name); 115 110 goto err_out; 116 111 } ··· 124 119 } 125 120 126 121 /* Make the PMU reading the files created above. */ 127 - hwm = perf_pmus__add_test_hwmon_pmu(dirfd, "hwmon1234", test_hwmon_name); 122 + hwm = perf_pmus__add_test_hwmon_pmu(hwmon_dirfd, "hwmon1234", test_hwmon_name); 128 123 if (!hwm) 129 124 pr_err("Test hwmon creation failed\n"); 130 125 131 126 err_out: 132 127 if (!hwm) { 133 128 test_pmu_put(dir, hwm); 134 - if (dirfd >= 0) 135 - close(dirfd); 129 + if (hwmon_dirfd >= 0) 130 + close(hwmon_dirfd); 136 131 } 132 + if (test_dirfd >= 0) 133 + close(test_dirfd); 137 134 return hwm; 138 135 } 139 136
+2 -1
tools/perf/trace/beauty/fs_at_flags.sh
··· 13 13 regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+AT_([^_]+[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' 14 14 # AT_EACCESS is only meaningful to faccessat, so we will special case it there... 15 15 # AT_STATX_SYNC_TYPE is not a bit, its a mask of AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC and AT_STATX_DONT_SYNC 16 - # AT_HANDLE_FID and AT_HANDLE_MNT_ID_UNIQUE are reusing values and are valid only for name_to_handle_at() 16 + # AT_HANDLE_FID, AT_HANDLE_MNT_ID_UNIQUE and AT_HANDLE_CONNECTABLE are reusing values and are valid only for name_to_handle_at() 17 17 # AT_RENAME_NOREPLACE reuses 0x1 and is valid only for renameat2() 18 18 grep -E $regex ${linux_fcntl} | \ 19 19 grep -v AT_EACCESS | \ 20 20 grep -v AT_STATX_SYNC_TYPE | \ 21 21 grep -v AT_HANDLE_FID | \ 22 22 grep -v AT_HANDLE_MNT_ID_UNIQUE | \ 23 + grep -v AT_HANDLE_CONNECTABLE | \ 23 24 grep -v AT_RENAME_NOREPLACE | \ 24 25 sed -r "s/$regex/\2 \1/g" | \ 25 26 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
+1 -4
tools/perf/trace/beauty/include/uapi/linux/fcntl.h
··· 153 153 object identity and may not be 154 154 usable with open_by_handle_at(2). */ 155 155 #define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */ 156 - 157 - #if defined(__KERNEL__) 158 - #define AT_GETATTR_NOSEC 0x80000000 159 - #endif 156 + #define AT_HANDLE_CONNECTABLE 0x002 /* Request a connectable file handle */ 160 157 161 158 #endif /* _UAPI_LINUX_FCNTL_H */
+12 -2
tools/perf/trace/beauty/include/uapi/linux/mount.h
··· 154 154 */ 155 155 struct statmount { 156 156 __u32 size; /* Total size, including strings */ 157 - __u32 mnt_opts; /* [str] Mount options of the mount */ 157 + __u32 mnt_opts; /* [str] Options (comma separated, escaped) */ 158 158 __u64 mask; /* What results were written */ 159 159 __u32 sb_dev_major; /* Device ID */ 160 160 __u32 sb_dev_minor; ··· 173 173 __u32 mnt_root; /* [str] Root of mount relative to root of fs */ 174 174 __u32 mnt_point; /* [str] Mountpoint relative to current root */ 175 175 __u64 mnt_ns_id; /* ID of the mount namespace */ 176 - __u64 __spare2[49]; 176 + __u32 fs_subtype; /* [str] Subtype of fs_type (if any) */ 177 + __u32 sb_source; /* [str] Source string of the mount */ 178 + __u32 opt_num; /* Number of fs options */ 179 + __u32 opt_array; /* [str] Array of nul terminated fs options */ 180 + __u32 opt_sec_num; /* Number of security options */ 181 + __u32 opt_sec_array; /* [str] Array of nul terminated security options */ 182 + __u64 __spare2[46]; 177 183 char str[]; /* Variable size part containing strings */ 178 184 }; 179 185 ··· 213 207 #define STATMOUNT_FS_TYPE 0x00000020U /* Want/got fs_type */ 214 208 #define STATMOUNT_MNT_NS_ID 0x00000040U /* Want/got mnt_ns_id */ 215 209 #define STATMOUNT_MNT_OPTS 0x00000080U /* Want/got mnt_opts */ 210 + #define STATMOUNT_FS_SUBTYPE 0x00000100U /* Want/got fs_subtype */ 211 + #define STATMOUNT_SB_SOURCE 0x00000200U /* Want/got sb_source */ 212 + #define STATMOUNT_OPT_ARRAY 0x00000400U /* Want/got opt_... */ 213 + #define STATMOUNT_OPT_SEC_ARRAY 0x00000800U /* Want/got opt_sec... */ 216 214 217 215 /* 218 216 * Special @mnt_id values that can be passed to listmount
+26 -1
tools/perf/trace/beauty/include/uapi/linux/prctl.h
··· 230 230 # define PR_PAC_APDBKEY (1UL << 3) 231 231 # define PR_PAC_APGAKEY (1UL << 4) 232 232 233 - /* Tagged user address controls for arm64 */ 233 + /* Tagged user address controls for arm64 and RISC-V */ 234 234 #define PR_SET_TAGGED_ADDR_CTRL 55 235 235 #define PR_GET_TAGGED_ADDR_CTRL 56 236 236 # define PR_TAGGED_ADDR_ENABLE (1UL << 0) ··· 244 244 # define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) 245 245 /* Unused; kept only for source compatibility */ 246 246 # define PR_MTE_TCF_SHIFT 1 247 + /* RISC-V pointer masking tag length */ 248 + # define PR_PMLEN_SHIFT 24 249 + # define PR_PMLEN_MASK (0x7fUL << PR_PMLEN_SHIFT) 247 250 248 251 /* Control reclaim behavior when allocating memory */ 249 252 #define PR_SET_IO_FLUSHER 57 ··· 330 327 # define PR_PPC_DEXCR_CTRL_SET_ONEXEC 0x8 /* Set the aspect on exec */ 331 328 # define PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC 0x10 /* Clear the aspect on exec */ 332 329 # define PR_PPC_DEXCR_CTRL_MASK 0x1f 330 + 331 + /* 332 + * Get the current shadow stack configuration for the current thread, 333 + * this will be the value configured via PR_SET_SHADOW_STACK_STATUS. 334 + */ 335 + #define PR_GET_SHADOW_STACK_STATUS 74 336 + 337 + /* 338 + * Set the current shadow stack configuration. Enabling the shadow 339 + * stack will cause a shadow stack to be allocated for the thread. 340 + */ 341 + #define PR_SET_SHADOW_STACK_STATUS 75 342 + # define PR_SHADOW_STACK_ENABLE (1UL << 0) 343 + # define PR_SHADOW_STACK_WRITE (1UL << 1) 344 + # define PR_SHADOW_STACK_PUSH (1UL << 2) 345 + 346 + /* 347 + * Prevent further changes to the specified shadow stack 348 + * configuration. All bits may be locked via this call, including 349 + * undefined bits. 350 + */ 351 + #define PR_LOCK_SHADOW_STACK_STATUS 76 333 352 334 353 #endif /* _LINUX_PRCTL_H */
+2 -2
tools/perf/util/build-id.c
··· 277 277 struct perf_record_header_build_id b; 278 278 size_t len; 279 279 280 - len = sizeof(b) + name_len + 1; 280 + len = name_len + 1; 281 281 len = PERF_ALIGN(len, sizeof(u64)); 282 282 283 283 memset(&b, 0, sizeof(b)); ··· 286 286 misc |= PERF_RECORD_MISC_BUILD_ID_SIZE; 287 287 b.pid = pid; 288 288 b.header.misc = misc; 289 - b.header.size = len; 289 + b.header.size = sizeof(b) + len; 290 290 291 291 err = do_write(fd, &b, sizeof(b)); 292 292 if (err < 0)
+3 -3
tools/perf/util/evsel.c
··· 2571 2571 if (err == -EMFILE && rlimit__increase_nofile(&set_rlimit)) 2572 2572 goto retry_open; 2573 2573 2574 - if (err == -EOPNOTSUPP && evsel__precise_ip_fallback(evsel)) 2575 - goto retry_open; 2576 - 2577 2574 if (err == -EINVAL && evsel__detect_missing_features(evsel)) 2578 2575 goto fallback_missing_features; 2576 + 2577 + if (evsel__precise_ip_fallback(evsel)) 2578 + goto retry_open; 2579 2579 2580 2580 if (evsel__handle_error_quirks(evsel, err)) 2581 2581 goto retry_open;
+11 -4
tools/perf/util/hwmon_pmu.c
··· 258 258 if (pmu->pmu.sysfs_aliases_loaded) 259 259 return 0; 260 260 261 - /* Use a dup-ed fd as closedir will close it. */ 262 - dup_fd = dup(pmu->hwmon_dir_fd); 261 + /* 262 + * Use a dup-ed fd as closedir will close it. Use openat so that the 263 + * directory contents are refreshed. 264 + */ 265 + dup_fd = openat(pmu->hwmon_dir_fd, ".", O_DIRECTORY); 266 + 263 267 if (dup_fd == -1) 264 268 return -ENOMEM; 265 269 ··· 340 336 close(fd); 341 337 } 342 338 } 339 + if (hashmap__size(&pmu->events) == 0) 340 + pr_debug2("hwmon_pmu: %s has no events\n", pmu->pmu.name); 341 + 343 342 hashmap__for_each_entry_safe((&pmu->events), cur, tmp, bkt) { 344 343 union hwmon_pmu_event_key key = { 345 344 .type_and_num = cur->key, ··· 350 343 struct hwmon_pmu_event_value *value = cur->pvalue; 351 344 352 345 if (!test_bit(HWMON_ITEM_INPUT, value->items)) { 353 - pr_debug("hwmon_pmu: removing event '%s%d' that has no input file\n", 354 - hwmon_type_strs[key.type], key.num); 346 + pr_debug("hwmon_pmu: %s removing event '%s%d' that has no input file\n", 347 + pmu->pmu.name, hwmon_type_strs[key.type], key.num); 355 348 hashmap__delete(&pmu->events, key.type_and_num, &key, &value); 356 349 zfree(&value->label); 357 350 zfree(&value->name);
+2
tools/perf/util/machine.c
··· 134 134 135 135 if (machine__create_kernel_maps(machine) < 0) 136 136 goto out_delete; 137 + 138 + machine->env = &perf_env; 137 139 } 138 140 139 141 return machine;
+1 -1
tools/perf/util/probe-event.c
··· 1370 1370 { 1371 1371 char *buf = strdup(arg); 1372 1372 char *p; 1373 - int err; 1373 + int err = 0; 1374 1374 1375 1375 if (!buf) 1376 1376 return -ENOMEM;
+15 -17
tools/testing/selftests/arm64/abi/syscall-abi-asm.S
··· 81 81 stp x27, x28, [sp, #96] 82 82 83 83 // Set SVCR if we're doing SME 84 - cbz x1, 1f 84 + cbz x1, load_gpr 85 85 adrp x2, svcr_in 86 86 ldr x2, [x2, :lo12:svcr_in] 87 87 msr S3_3_C4_C2_2, x2 88 - 1: 89 88 90 89 // Load ZA and ZT0 if enabled - uses x12 as scratch due to SME LDR 91 - tbz x2, #SVCR_ZA_SHIFT, 1f 90 + tbz x2, #SVCR_ZA_SHIFT, load_gpr 92 91 mov w12, #0 93 92 ldr x2, =za_in 94 - 2: _ldr_za 12, 2 93 + 1: _ldr_za 12, 2 95 94 add x2, x2, x1 96 95 add x12, x12, #1 97 96 cmp x1, x12 98 - bne 2b 97 + bne 1b 99 98 100 99 // ZT0 101 100 mrs x2, S3_0_C0_C4_5 // ID_AA64SMFR0_EL1 102 101 ubfx x2, x2, #ID_AA64SMFR0_EL1_SMEver_SHIFT, \ 103 102 #ID_AA64SMFR0_EL1_SMEver_WIDTH 104 - cbz x2, 1f 103 + cbz x2, load_gpr 105 104 adrp x2, zt_in 106 105 add x2, x2, :lo12:zt_in 107 106 _ldr_zt 2 108 - 1: 109 107 108 + load_gpr: 110 109 // Load GPRs x8-x28, and save our SP/FP for later comparison 111 110 ldr x2, =gpr_in 112 111 add x2, x2, #64 ··· 124 125 str x30, [x2], #8 // LR 125 126 126 127 // Load FPRs if we're not doing neither SVE nor streaming SVE 127 - cbnz x0, 1f 128 + cbnz x0, check_sve_in 128 129 ldr x2, =svcr_in 129 - tbnz x2, #SVCR_SM_SHIFT, 1f 130 + tbnz x2, #SVCR_SM_SHIFT, check_sve_in 130 131 131 132 ldr x2, =fpr_in 132 133 ldp q0, q1, [x2] ··· 147 148 ldp q30, q31, [x2, #16 * 30] 148 149 149 150 b 2f 150 - 1: 151 151 152 + check_sve_in: 152 153 // Load the SVE registers if we're doing SVE/SME 153 154 154 155 ldr x2, =z_in ··· 255 256 stp q30, q31, [x2, #16 * 30] 256 257 257 258 // Save SVCR if we're doing SME 258 - cbz x1, 1f 259 + cbz x1, check_sve_out 259 260 mrs x2, S3_3_C4_C2_2 260 261 adrp x3, svcr_out 261 262 str x2, [x3, :lo12:svcr_out] 262 - 1: 263 263 264 264 // Save ZA if it's enabled - uses x12 as scratch due to SME STR 265 - tbz x2, #SVCR_ZA_SHIFT, 1f 265 + tbz x2, #SVCR_ZA_SHIFT, check_sve_out 266 266 mov w12, #0 267 267 ldr x2, =za_out 268 - 2: _str_za 12, 2 268 + 1: _str_za 12, 2 269 269 add x2, x2, x1 270 270 add x12, x12, #1 271 271 cmp x1, x12 272 - bne 2b 272 + bne 1b 273 273 274 274 // ZT0 275 275 mrs x2, S3_0_C0_C4_5 // ID_AA64SMFR0_EL1 276 276 ubfx x2, x2, #ID_AA64SMFR0_EL1_SMEver_SHIFT, \ 277 277 #ID_AA64SMFR0_EL1_SMEver_WIDTH 278 - cbz x2, 1f 278 + cbz x2, check_sve_out 279 279 adrp x2, zt_out 280 280 add x2, x2, :lo12:zt_out 281 281 _str_zt 2 282 - 1: 283 282 283 + check_sve_out: 284 284 // Save the SVE state if we have some 285 285 cbz x0, 1f 286 286
+107
tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "bpf/libbpf.h" 3 + #include "changes_pkt_data_freplace.skel.h" 4 + #include "changes_pkt_data.skel.h" 5 + #include <test_progs.h> 6 + 7 + static void print_verifier_log(const char *log) 8 + { 9 + if (env.verbosity >= VERBOSE_VERY) 10 + fprintf(stdout, "VERIFIER LOG:\n=============\n%s=============\n", log); 11 + } 12 + 13 + static void test_aux(const char *main_prog_name, 14 + const char *to_be_replaced, 15 + const char *replacement, 16 + bool expect_load) 17 + { 18 + struct changes_pkt_data_freplace *freplace = NULL; 19 + struct bpf_program *freplace_prog = NULL; 20 + struct bpf_program *main_prog = NULL; 21 + LIBBPF_OPTS(bpf_object_open_opts, opts); 22 + struct changes_pkt_data *main = NULL; 23 + char log[16*1024]; 24 + int err; 25 + 26 + opts.kernel_log_buf = log; 27 + opts.kernel_log_size = sizeof(log); 28 + if (env.verbosity >= VERBOSE_SUPER) 29 + opts.kernel_log_level = 1 | 2 | 4; 30 + main = changes_pkt_data__open_opts(&opts); 31 + if (!ASSERT_OK_PTR(main, "changes_pkt_data__open")) 32 + goto out; 33 + main_prog = bpf_object__find_program_by_name(main->obj, main_prog_name); 34 + if (!ASSERT_OK_PTR(main_prog, "main_prog")) 35 + goto out; 36 + bpf_program__set_autoload(main_prog, true); 37 + err = changes_pkt_data__load(main); 38 + print_verifier_log(log); 39 + if (!ASSERT_OK(err, "changes_pkt_data__load")) 40 + goto out; 41 + freplace = changes_pkt_data_freplace__open_opts(&opts); 42 + if (!ASSERT_OK_PTR(freplace, "changes_pkt_data_freplace__open")) 43 + goto out; 44 + freplace_prog = bpf_object__find_program_by_name(freplace->obj, replacement); 45 + if (!ASSERT_OK_PTR(freplace_prog, "freplace_prog")) 46 + goto out; 47 + bpf_program__set_autoload(freplace_prog, true); 48 + bpf_program__set_autoattach(freplace_prog, true); 49 + bpf_program__set_attach_target(freplace_prog, 50 + bpf_program__fd(main_prog), 51 + to_be_replaced); 52 + err = changes_pkt_data_freplace__load(freplace); 53 + print_verifier_log(log); 54 + if (expect_load) { 55 + ASSERT_OK(err, "changes_pkt_data_freplace__load"); 56 + } else { 57 + ASSERT_ERR(err, "changes_pkt_data_freplace__load"); 58 + ASSERT_HAS_SUBSTR(log, "Extension program changes packet data", "error log"); 59 + } 60 + 61 + out: 62 + changes_pkt_data_freplace__destroy(freplace); 63 + changes_pkt_data__destroy(main); 64 + } 65 + 66 + /* There are two global subprograms in both changes_pkt_data.skel.h: 67 + * - one changes packet data; 68 + * - another does not. 69 + * It is ok to freplace subprograms that change packet data with those 70 + * that either do or do not. It is only ok to freplace subprograms 71 + * that do not change packet data with those that do not as well. 72 + * The below tests check outcomes for each combination of such freplace. 73 + * Also test a case when main subprogram itself is replaced and is a single 74 + * subprogram in a program. 75 + */ 76 + void test_changes_pkt_data_freplace(void) 77 + { 78 + struct { 79 + const char *main; 80 + const char *to_be_replaced; 81 + bool changes; 82 + } mains[] = { 83 + { "main_with_subprogs", "changes_pkt_data", true }, 84 + { "main_with_subprogs", "does_not_change_pkt_data", false }, 85 + { "main_changes", "main_changes", true }, 86 + { "main_does_not_change", "main_does_not_change", false }, 87 + }; 88 + struct { 89 + const char *func; 90 + bool changes; 91 + } replacements[] = { 92 + { "changes_pkt_data", true }, 93 + { "does_not_change_pkt_data", false } 94 + }; 95 + char buf[64]; 96 + 97 + for (int i = 0; i < ARRAY_SIZE(mains); ++i) { 98 + for (int j = 0; j < ARRAY_SIZE(replacements); ++j) { 99 + snprintf(buf, sizeof(buf), "%s_with_%s", 100 + mains[i].to_be_replaced, replacements[j].func); 101 + if (!test__start_subtest(buf)) 102 + continue; 103 + test_aux(mains[i].main, mains[i].to_be_replaced, replacements[j].func, 104 + mains[i].changes || !replacements[j].changes); 105 + } 106 + } 107 + }
+3
tools/testing/selftests/bpf/prog_tests/raw_tp_null.c
··· 3 3 4 4 #include <test_progs.h> 5 5 #include "raw_tp_null.skel.h" 6 + #include "raw_tp_null_fail.skel.h" 6 7 7 8 void test_raw_tp_null(void) 8 9 { 9 10 struct raw_tp_null *skel; 11 + 12 + RUN_TESTS(raw_tp_null_fail); 10 13 11 14 skel = raw_tp_null__open_and_load(); 12 15 if (!ASSERT_OK_PTR(skel, "raw_tp_null__open_and_load"))
+5 -3
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
··· 934 934 935 935 err = socketpair(AF_UNIX, SOCK_STREAM, 0, stream); 936 936 ASSERT_OK(err, "socketpair(af_unix, sock_stream)"); 937 - if (err) 937 + if (err) { 938 + close(tcp); 938 939 goto out; 940 + } 939 941 940 942 for (i = 0; i < 2; i++) { 941 943 err = bpf_map_update_elem(map, &zero, &stream[0], BPF_ANY); ··· 956 954 ASSERT_OK(err, "bpf_map_update_elem(tcp)"); 957 955 } 958 956 957 + close(tcp); 959 958 err = bpf_map_delete_elem(map, &zero); 960 - ASSERT_OK(err, "bpf_map_delete_elem(entry)"); 959 + ASSERT_ERR(err, "bpf_map_delete_elem(entry)"); 961 960 962 961 close(stream[0]); 963 962 close(stream[1]); 964 963 out: 965 964 close(dgram); 966 - close(tcp); 967 965 close(udp); 968 966 test_sockmap_pass_prog__destroy(skel); 969 967 }
+39
tools/testing/selftests/bpf/progs/changes_pkt_data.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/bpf.h> 4 + #include <bpf/bpf_helpers.h> 5 + 6 + __noinline 7 + long changes_pkt_data(struct __sk_buff *sk) 8 + { 9 + return bpf_skb_pull_data(sk, 0); 10 + } 11 + 12 + __noinline __weak 13 + long does_not_change_pkt_data(struct __sk_buff *sk) 14 + { 15 + return 0; 16 + } 17 + 18 + SEC("?tc") 19 + int main_with_subprogs(struct __sk_buff *sk) 20 + { 21 + changes_pkt_data(sk); 22 + does_not_change_pkt_data(sk); 23 + return 0; 24 + } 25 + 26 + SEC("?tc") 27 + int main_changes(struct __sk_buff *sk) 28 + { 29 + bpf_skb_pull_data(sk, 0); 30 + return 0; 31 + } 32 + 33 + SEC("?tc") 34 + int main_does_not_change(struct __sk_buff *sk) 35 + { 36 + return 0; 37 + } 38 + 39 + char _license[] SEC("license") = "GPL";
+18
tools/testing/selftests/bpf/progs/changes_pkt_data_freplace.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/bpf.h> 4 + #include <bpf/bpf_helpers.h> 5 + 6 + SEC("?freplace") 7 + long changes_pkt_data(struct __sk_buff *sk) 8 + { 9 + return bpf_skb_pull_data(sk, 0); 10 + } 11 + 12 + SEC("?freplace") 13 + long does_not_change_pkt_data(struct __sk_buff *sk) 14 + { 15 + return 0; 16 + } 17 + 18 + char _license[] SEC("license") = "GPL";
+9 -10
tools/testing/selftests/bpf/progs/raw_tp_null.c
··· 3 3 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 + #include "bpf_misc.h" 6 7 7 8 char _license[] SEC("license") = "GPL"; 8 9 ··· 18 17 if (task->pid != tid) 19 18 return 0; 20 19 21 - i = i + skb->mark + 1; 22 - /* The compiler may move the NULL check before this deref, which causes 23 - * the load to fail as deref of scalar. Prevent that by using a barrier. 20 + /* If dead code elimination kicks in, the increment +=2 will be 21 + * removed. For raw_tp programs attaching to tracepoints in kernel 22 + * modules, we mark input arguments as PTR_MAYBE_NULL, so branch 23 + * prediction should never kick in. 24 24 */ 25 - barrier(); 26 - /* If dead code elimination kicks in, the increment below will 27 - * be removed. For raw_tp programs, we mark input arguments as 28 - * PTR_MAYBE_NULL, so branch prediction should never kick in. 29 - */ 30 - if (!skb) 31 - i += 2; 25 + asm volatile ("%[i] += 1; if %[ctx] != 0 goto +1; %[i] += 2;" 26 + : [i]"+r"(i) 27 + : [ctx]"r"(skb) 28 + : "memory"); 32 29 return 0; 33 30 }
+24
tools/testing/selftests/bpf/progs/raw_tp_null_fail.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 + 4 + #include <vmlinux.h> 5 + #include <bpf/bpf_tracing.h> 6 + #include "bpf_misc.h" 7 + 8 + char _license[] SEC("license") = "GPL"; 9 + 10 + /* Ensure module parameter has PTR_MAYBE_NULL */ 11 + SEC("tp_btf/bpf_testmod_test_raw_tp_null") 12 + __failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'") 13 + int test_raw_tp_null_bpf_testmod_test_raw_tp_null_arg_1(void *ctx) { 14 + asm volatile("r1 = *(u64 *)(r1 +0); r1 = *(u64 *)(r1 +0);" ::: __clobber_all); 15 + return 0; 16 + } 17 + 18 + /* Check NULL marking */ 19 + SEC("tp_btf/sched_pi_setprio") 20 + __failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'") 21 + int test_raw_tp_null_sched_pi_setprio_arg_2(void *ctx) { 22 + asm volatile("r1 = *(u64 *)(r1 +8); r1 = *(u64 *)(r1 +0);" ::: __clobber_all); 23 + return 0; 24 + }
+2
tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
··· 11 11 12 12 __sink(skb); 13 13 __sink(ret); 14 + /* let verifier know that 'subprog_tc' can change pointers to skb->data */ 15 + bpf_skb_change_proto(skb, 0, 0); 14 16 return ret; 15 17 } 16 18
+1 -5
tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c
··· 7 7 #include "bpf_misc.h" 8 8 9 9 SEC("tp_btf/bpf_testmod_test_nullable_bare") 10 - /* This used to be a failure test, but raw_tp nullable arguments can now 11 - * directly be dereferenced, whether they have nullable annotation or not, 12 - * and don't need to be explicitly checked. 13 - */ 14 - __success 10 + __failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'") 15 11 int BPF_PROG(handle_tp_btf_nullable_bare1, struct bpf_testmod_test_read_ctx *nullable_ctx) 16 12 { 17 13 return nullable_ctx->len;
+38 -2
tools/testing/selftests/bpf/progs/verifier_btf_ctx_access.c
··· 11 11 __naked void btf_ctx_access_accept(void) 12 12 { 13 13 asm volatile (" \ 14 - r2 = *(u32*)(r1 + 8); /* load 2nd argument value (int pointer) */\ 14 + r2 = *(u64 *)(r1 + 8); /* load 2nd argument value (int pointer) */\ 15 15 r0 = 0; \ 16 16 exit; \ 17 17 " ::: __clobber_all); ··· 23 23 __naked void ctx_access_u32_pointer_accept(void) 24 24 { 25 25 asm volatile (" \ 26 - r2 = *(u32*)(r1 + 0); /* load 1nd argument value (u32 pointer) */\ 26 + r2 = *(u64 *)(r1 + 0); /* load 1nd argument value (u32 pointer) */\ 27 + r0 = 0; \ 28 + exit; \ 29 + " ::: __clobber_all); 30 + } 31 + 32 + SEC("fentry/bpf_fentry_test9") 33 + __description("btf_ctx_access u32 pointer reject u32") 34 + __failure __msg("size 4 must be 8") 35 + __naked void ctx_access_u32_pointer_reject_32(void) 36 + { 37 + asm volatile (" \ 38 + r2 = *(u32 *)(r1 + 0); /* load 1st argument with narrow load */\ 39 + r0 = 0; \ 40 + exit; \ 41 + " ::: __clobber_all); 42 + } 43 + 44 + SEC("fentry/bpf_fentry_test9") 45 + __description("btf_ctx_access u32 pointer reject u16") 46 + __failure __msg("size 2 must be 8") 47 + __naked void ctx_access_u32_pointer_reject_16(void) 48 + { 49 + asm volatile (" \ 50 + r2 = *(u16 *)(r1 + 0); /* load 1st argument with narrow load */\ 51 + r0 = 0; \ 52 + exit; \ 53 + " ::: __clobber_all); 54 + } 55 + 56 + SEC("fentry/bpf_fentry_test9") 57 + __description("btf_ctx_access u32 pointer reject u8") 58 + __failure __msg("size 1 must be 8") 59 + __naked void ctx_access_u32_pointer_reject_8(void) 60 + { 61 + asm volatile (" \ 62 + r2 = *(u8 *)(r1 + 0); /* load 1st argument with narrow load */\ 27 63 r0 = 0; \ 28 64 exit; \ 29 65 " ::: __clobber_all);
+2 -2
tools/testing/selftests/bpf/progs/verifier_d_path.c
··· 11 11 __naked void d_path_accept(void) 12 12 { 13 13 asm volatile (" \ 14 - r1 = *(u32*)(r1 + 0); \ 14 + r1 = *(u64 *)(r1 + 0); \ 15 15 r2 = r10; \ 16 16 r2 += -8; \ 17 17 r6 = 0; \ ··· 31 31 __naked void d_path_reject(void) 32 32 { 33 33 asm volatile (" \ 34 - r1 = *(u32*)(r1 + 0); \ 34 + r1 = *(u64 *)(r1 + 0); \ 35 35 r2 = r10; \ 36 36 r2 += -8; \ 37 37 r6 = 0; \
+56
tools/testing/selftests/bpf/progs/verifier_sock.c
··· 50 50 __uint(map_flags, BPF_F_NO_PREALLOC); 51 51 } sk_storage_map SEC(".maps"); 52 52 53 + struct { 54 + __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 55 + __uint(max_entries, 1); 56 + __uint(key_size, sizeof(__u32)); 57 + __uint(value_size, sizeof(__u32)); 58 + } jmp_table SEC(".maps"); 59 + 53 60 SEC("cgroup/skb") 54 61 __description("skb->sk: no NULL check") 55 62 __failure __msg("invalid mem access 'sock_common_or_null'") ··· 1042 1035 " : 1043 1036 : __imm_const(bpf_sock_src_port, offsetof(struct bpf_sock, src_port)) 1044 1037 : __clobber_all); 1038 + } 1039 + 1040 + __noinline 1041 + long skb_pull_data2(struct __sk_buff *sk, __u32 len) 1042 + { 1043 + return bpf_skb_pull_data(sk, len); 1044 + } 1045 + 1046 + __noinline 1047 + long skb_pull_data1(struct __sk_buff *sk, __u32 len) 1048 + { 1049 + return skb_pull_data2(sk, len); 1050 + } 1051 + 1052 + /* global function calls bpf_skb_pull_data(), which invalidates packet 1053 + * pointers established before global function call. 1054 + */ 1055 + SEC("tc") 1056 + __failure __msg("invalid mem access") 1057 + int invalidate_pkt_pointers_from_global_func(struct __sk_buff *sk) 1058 + { 1059 + int *p = (void *)(long)sk->data; 1060 + 1061 + if ((void *)(p + 1) > (void *)(long)sk->data_end) 1062 + return TCX_DROP; 1063 + skb_pull_data1(sk, 0); 1064 + *p = 42; /* this is unsafe */ 1065 + return TCX_PASS; 1066 + } 1067 + 1068 + __noinline 1069 + int tail_call(struct __sk_buff *sk) 1070 + { 1071 + bpf_tail_call_static(sk, &jmp_table, 0); 1072 + return 0; 1073 + } 1074 + 1075 + /* Tail calls invalidate packet pointers. */ 1076 + SEC("tc") 1077 + __failure __msg("invalid mem access") 1078 + int invalidate_pkt_pointers_by_tail_call(struct __sk_buff *sk) 1079 + { 1080 + int *p = (void *)(long)sk->data; 1081 + 1082 + if ((void *)(p + 1) > (void *)(long)sk->data_end) 1083 + return TCX_DROP; 1084 + tail_call(sk); 1085 + *p = 42; /* this is unsafe */ 1086 + return TCX_PASS; 1045 1087 } 1046 1088 1047 1089 char _license[] SEC("license") = "GPL";
+13 -10
tools/testing/selftests/drivers/net/queues.py
··· 8 8 import glob 9 9 10 10 11 - def sys_get_queues(ifname) -> int: 12 - folders = glob.glob(f'/sys/class/net/{ifname}/queues/rx-*') 11 + def sys_get_queues(ifname, qtype='rx') -> int: 12 + folders = glob.glob(f'/sys/class/net/{ifname}/queues/{qtype}-*') 13 13 return len(folders) 14 14 15 15 16 - def nl_get_queues(cfg, nl): 16 + def nl_get_queues(cfg, nl, qtype='rx'): 17 17 queues = nl.queue_get({'ifindex': cfg.ifindex}, dump=True) 18 18 if queues: 19 - return len([q for q in queues if q['type'] == 'rx']) 19 + return len([q for q in queues if q['type'] == qtype]) 20 20 return None 21 21 22 22 23 23 def get_queues(cfg, nl) -> None: 24 - queues = nl_get_queues(cfg, nl) 25 - if not queues: 26 - raise KsftSkipEx('queue-get not supported by device') 24 + snl = NetdevFamily(recv_size=4096) 27 25 28 - expected = sys_get_queues(cfg.dev['ifname']) 29 - ksft_eq(queues, expected) 26 + for qtype in ['rx', 'tx']: 27 + queues = nl_get_queues(cfg, snl, qtype) 28 + if not queues: 29 + raise KsftSkipEx('queue-get not supported by device') 30 + 31 + expected = sys_get_queues(cfg.dev['ifname'], qtype) 32 + ksft_eq(queues, expected) 30 33 31 34 32 35 def addremove_queues(cfg, nl) -> None: ··· 60 57 61 58 62 59 def main() -> None: 63 - with NetDrvEnv(__file__, queue_count=3) as cfg: 60 + with NetDrvEnv(__file__, queue_count=100) as cfg: 64 61 ksft_run([get_queues, addremove_queues], args=(cfg, NetdevFamily())) 65 62 ksft_exit() 66 63
+18 -1
tools/testing/selftests/drivers/net/stats.py
··· 110 110 ksft_ge(triple[1][key], triple[0][key], comment="bad key: " + key) 111 111 ksft_ge(triple[2][key], triple[1][key], comment="bad key: " + key) 112 112 113 + # Sanity check the dumps 114 + queues = NetdevFamily(recv_size=4096).qstats_get({"scope": "queue"}, dump=True) 115 + # Reformat the output into {ifindex: {rx: [id, id, ...], tx: [id, id, ...]}} 116 + parsed = {} 117 + for entry in queues: 118 + ifindex = entry["ifindex"] 119 + if ifindex not in parsed: 120 + parsed[ifindex] = {"rx":[], "tx": []} 121 + parsed[ifindex][entry["queue-type"]].append(entry['queue-id']) 122 + # Now, validate 123 + for ifindex, queues in parsed.items(): 124 + for qtype in ['rx', 'tx']: 125 + ksft_eq(len(queues[qtype]), len(set(queues[qtype])), 126 + comment="repeated queue keys") 127 + ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, 128 + comment="missing queue keys") 129 + 113 130 # Test invalid dumps 114 131 # 0 is invalid 115 132 with ksft_raises(NlError) as cm: ··· 175 158 176 159 177 160 def main() -> None: 178 - with NetDrvEnv(__file__) as cfg: 161 + with NetDrvEnv(__file__, queue_count=100) as cfg: 179 162 ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex, 180 163 check_down], 181 164 args=(cfg, ))
+8 -8
tools/testing/selftests/net/lib/py/ynl.py
··· 32 32 # Set schema='' to avoid jsonschema validation, it's slow 33 33 # 34 34 class EthtoolFamily(YnlFamily): 35 - def __init__(self): 35 + def __init__(self, recv_size=0): 36 36 super().__init__((SPEC_PATH / Path('ethtool.yaml')).as_posix(), 37 - schema='') 37 + schema='', recv_size=recv_size) 38 38 39 39 40 40 class RtnlFamily(YnlFamily): 41 - def __init__(self): 41 + def __init__(self, recv_size=0): 42 42 super().__init__((SPEC_PATH / Path('rt_link.yaml')).as_posix(), 43 - schema='') 43 + schema='', recv_size=recv_size) 44 44 45 45 46 46 class NetdevFamily(YnlFamily): 47 - def __init__(self): 47 + def __init__(self, recv_size=0): 48 48 super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(), 49 - schema='') 49 + schema='', recv_size=recv_size) 50 50 51 51 class NetshaperFamily(YnlFamily): 52 - def __init__(self): 52 + def __init__(self, recv_size=0): 53 53 super().__init__((SPEC_PATH / Path('net_shaper.yaml')).as_posix(), 54 - schema='') 54 + schema='', recv_size=recv_size)
+4 -2
tools/testing/selftests/net/openvswitch/openvswitch.sh
··· 171 171 ovs_add_if "$1" "$2" "$4" -u || return 1 172 172 fi 173 173 174 - [ $TRACING -eq 1 ] && ovs_netns_spawn_daemon "$1" "$ns" \ 175 - tcpdump -i any -s 65535 174 + if [ $TRACING -eq 1 ]; then 175 + ovs_netns_spawn_daemon "$1" "$3" tcpdump -l -i any -s 6553 176 + ovs_wait grep -q "listening on any" ${ovs_dir}/stderr 177 + fi 176 178 177 179 return 0 178 180 }