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

Merge branch 'perf/urgent' into perf/core, to pick up fixes

Signed-off-by: Ingo Molnar <mingo@kernel.org>

+1608 -727
+1 -1
Documentation/networking/index.rst
··· 9 9 batman-adv 10 10 kapi 11 11 z8530book 12 + msg_zerocopy 12 13 13 14 .. only:: subproject 14 15 ··· 17 16 ======= 18 17 19 18 * :ref:`genindex` 20 -
+4
Documentation/networking/msg_zerocopy.rst
··· 72 72 if (setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &one, sizeof(one))) 73 73 error(1, errno, "setsockopt zerocopy"); 74 74 75 + Setting the socket option only works when the socket is in its initial 76 + (TCP_CLOSED) state. Trying to set the option for a socket returned by accept(), 77 + for example, will lead to an EBUSY error. In this case, the option should be set 78 + to the listening socket and it will be inherited by the accepted sockets. 75 79 76 80 Transmission 77 81 ------------
+1 -1
MAINTAINERS
··· 10134 10134 F: drivers/irqchip/irq-or1k-* 10135 10135 10136 10136 OPENVSWITCH 10137 - M: Pravin Shelar <pshelar@nicira.com> 10137 + M: Pravin B Shelar <pshelar@ovn.org> 10138 10138 L: netdev@vger.kernel.org 10139 10139 L: dev@openvswitch.org 10140 10140 W: http://openvswitch.org
+1 -1
Makefile
··· 2 2 VERSION = 4 3 3 PATCHLEVEL = 15 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc6 5 + EXTRAVERSION = -rc7 6 6 NAME = Fearless Coyote 7 7 8 8 # *DOCUMENTATION*
+8
arch/arc/boot/dts/axc003.dtsi
··· 35 35 reg = <0x80 0x10>, <0x100 0x10>; 36 36 #clock-cells = <0>; 37 37 clocks = <&input_clk>; 38 + 39 + /* 40 + * Set initial core pll output frequency to 90MHz. 41 + * It will be applied at the core pll driver probing 42 + * on early boot. 43 + */ 44 + assigned-clocks = <&core_clk>; 45 + assigned-clock-rates = <90000000>; 38 46 }; 39 47 40 48 core_intc: archs-intc@cpu {
+8
arch/arc/boot/dts/axc003_idu.dtsi
··· 35 35 reg = <0x80 0x10>, <0x100 0x10>; 36 36 #clock-cells = <0>; 37 37 clocks = <&input_clk>; 38 + 39 + /* 40 + * Set initial core pll output frequency to 100MHz. 41 + * It will be applied at the core pll driver probing 42 + * on early boot. 43 + */ 44 + assigned-clocks = <&core_clk>; 45 + assigned-clock-rates = <100000000>; 38 46 }; 39 47 40 48 core_intc: archs-intc@cpu {
+8
arch/arc/boot/dts/hsdk.dts
··· 114 114 reg = <0x00 0x10>, <0x14B8 0x4>; 115 115 #clock-cells = <0>; 116 116 clocks = <&input_clk>; 117 + 118 + /* 119 + * Set initial core pll output frequency to 1GHz. 120 + * It will be applied at the core pll driver probing 121 + * on early boot. 122 + */ 123 + assigned-clocks = <&core_clk>; 124 + assigned-clock-rates = <1000000000>; 117 125 }; 118 126 119 127 serial: serial@5000 {
+3 -2
arch/arc/configs/hsdk_defconfig
··· 49 49 CONFIG_SERIAL_OF_PLATFORM=y 50 50 # CONFIG_HW_RANDOM is not set 51 51 # CONFIG_HWMON is not set 52 + CONFIG_DRM=y 53 + # CONFIG_DRM_FBDEV_EMULATION is not set 54 + CONFIG_DRM_UDL=y 52 55 CONFIG_FB=y 53 - CONFIG_FB_UDL=y 54 56 CONFIG_FRAMEBUFFER_CONSOLE=y 55 - CONFIG_USB=y 56 57 CONFIG_USB_EHCI_HCD=y 57 58 CONFIG_USB_EHCI_HCD_PLATFORM=y 58 59 CONFIG_USB_OHCI_HCD=y
+3 -2
arch/arc/include/asm/uaccess.h
··· 668 668 return 0; 669 669 670 670 __asm__ __volatile__( 671 + " mov lp_count, %5 \n" 671 672 " lp 3f \n" 672 673 "1: ldb.ab %3, [%2, 1] \n" 673 674 " breq.d %3, 0, 3f \n" ··· 685 684 " .word 1b, 4b \n" 686 685 " .previous \n" 687 686 : "+r"(res), "+r"(dst), "+r"(src), "=r"(val) 688 - : "g"(-EFAULT), "l"(count) 689 - : "memory"); 687 + : "g"(-EFAULT), "r"(count) 688 + : "lp_count", "lp_start", "lp_end", "memory"); 690 689 691 690 return res; 692 691 }
+1 -1
arch/arc/kernel/setup.c
··· 199 199 unsigned int exec_ctrl; 200 200 201 201 READ_BCR(AUX_EXEC_CTRL, exec_ctrl); 202 - cpu->extn.dual_enb = exec_ctrl & 1; 202 + cpu->extn.dual_enb = !(exec_ctrl & 1); 203 203 204 204 /* dual issue always present for this core */ 205 205 cpu->extn.dual = 1;
+1 -1
arch/arc/kernel/stacktrace.c
··· 163 163 */ 164 164 static int __print_sym(unsigned int address, void *unused) 165 165 { 166 - __print_symbol(" %s\n", address); 166 + printk(" %pS\n", (void *)address); 167 167 return 0; 168 168 } 169 169
+14
arch/arc/kernel/traps.c
··· 83 83 DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", __weak do_memory_error, BUS_ADRERR) 84 84 DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT) 85 85 DO_ERROR_INFO(SIGBUS, "Misaligned Access", do_misaligned_error, BUS_ADRALN) 86 + DO_ERROR_INFO(SIGSEGV, "gcc generated __builtin_trap", do_trap5_error, 0) 86 87 87 88 /* 88 89 * Entry Point for Misaligned Data access Exception, for emulating in software ··· 116 115 * Thus TRAP_S <n> can be used for specific purpose 117 116 * -1 used for software breakpointing (gdb) 118 117 * -2 used by kprobes 118 + * -5 __builtin_trap() generated by gcc (2018.03 onwards) for toggle such as 119 + * -fno-isolate-erroneous-paths-dereference 119 120 */ 120 121 void do_non_swi_trap(unsigned long address, struct pt_regs *regs) 121 122 { ··· 137 134 kgdb_trap(regs); 138 135 break; 139 136 137 + case 5: 138 + do_trap5_error(address, regs); 139 + break; 140 140 default: 141 141 break; 142 142 } ··· 160 154 return; 161 155 162 156 insterror_is_error(address, regs); 157 + } 158 + 159 + /* 160 + * abort() call generated by older gcc for __builtin_trap() 161 + */ 162 + void abort(void) 163 + { 164 + __asm__ __volatile__("trap_s 5\n"); 163 165 }
+3
arch/arc/kernel/troubleshoot.c
··· 163 163 else 164 164 pr_cont("Bus Error, check PRM\n"); 165 165 #endif 166 + } else if (vec == ECR_V_TRAP) { 167 + if (regs->ecr_param == 5) 168 + pr_cont("gcc generated __builtin_trap\n"); 166 169 } else { 167 170 pr_cont("Check Programmer's Manual\n"); 168 171 }
+8 -10
arch/arc/plat-axs10x/axs10x.c
··· 317 317 * Instead of duplicating defconfig/DT for SMP/QUAD, add a small hack 318 318 * of fudging the freq in DT 319 319 */ 320 + #define AXS103_QUAD_CORE_CPU_FREQ_HZ 50000000 321 + 320 322 unsigned int num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F; 321 323 if (num_cores > 2) { 322 - u32 freq = 50, orig; 323 - /* 324 - * TODO: use cpu node "cpu-freq" param instead of platform-specific 325 - * "/cpu_card/core_clk" as it works only if we use fixed-clock for cpu. 326 - */ 324 + u32 freq; 327 325 int off = fdt_path_offset(initial_boot_params, "/cpu_card/core_clk"); 328 326 const struct fdt_property *prop; 329 327 330 328 prop = fdt_get_property(initial_boot_params, off, 331 - "clock-frequency", NULL); 332 - orig = be32_to_cpu(*(u32*)(prop->data)) / 1000000; 329 + "assigned-clock-rates", NULL); 330 + freq = be32_to_cpu(*(u32 *)(prop->data)); 333 331 334 332 /* Patching .dtb in-place with new core clock value */ 335 - if (freq != orig ) { 336 - freq = cpu_to_be32(freq * 1000000); 333 + if (freq != AXS103_QUAD_CORE_CPU_FREQ_HZ) { 334 + freq = cpu_to_be32(AXS103_QUAD_CORE_CPU_FREQ_HZ); 337 335 fdt_setprop_inplace(initial_boot_params, off, 338 - "clock-frequency", &freq, sizeof(freq)); 336 + "assigned-clock-rates", &freq, sizeof(freq)); 339 337 } 340 338 } 341 339 #endif
-42
arch/arc/plat-hsdk/platform.c
··· 38 38 #define CREG_PAE (CREG_BASE + 0x180) 39 39 #define CREG_PAE_UPDATE (CREG_BASE + 0x194) 40 40 41 - #define CREG_CORE_IF_CLK_DIV (CREG_BASE + 0x4B8) 42 - #define CREG_CORE_IF_CLK_DIV_2 0x1 43 - #define CGU_BASE ARC_PERIPHERAL_BASE 44 - #define CGU_PLL_STATUS (ARC_PERIPHERAL_BASE + 0x4) 45 - #define CGU_PLL_CTRL (ARC_PERIPHERAL_BASE + 0x0) 46 - #define CGU_PLL_STATUS_LOCK BIT(0) 47 - #define CGU_PLL_STATUS_ERR BIT(1) 48 - #define CGU_PLL_CTRL_1GHZ 0x3A10 49 - #define HSDK_PLL_LOCK_TIMEOUT 500 50 - 51 - #define HSDK_PLL_LOCKED() \ 52 - !!(ioread32((void __iomem *) CGU_PLL_STATUS) & CGU_PLL_STATUS_LOCK) 53 - 54 - #define HSDK_PLL_ERR() \ 55 - !!(ioread32((void __iomem *) CGU_PLL_STATUS) & CGU_PLL_STATUS_ERR) 56 - 57 - static void __init hsdk_set_cpu_freq_1ghz(void) 58 - { 59 - u32 timeout = HSDK_PLL_LOCK_TIMEOUT; 60 - 61 - /* 62 - * As we set cpu clock which exceeds 500MHz, the divider for the interface 63 - * clock must be programmed to div-by-2. 64 - */ 65 - iowrite32(CREG_CORE_IF_CLK_DIV_2, (void __iomem *) CREG_CORE_IF_CLK_DIV); 66 - 67 - /* Set cpu clock to 1GHz */ 68 - iowrite32(CGU_PLL_CTRL_1GHZ, (void __iomem *) CGU_PLL_CTRL); 69 - 70 - while (!HSDK_PLL_LOCKED() && timeout--) 71 - cpu_relax(); 72 - 73 - if (!HSDK_PLL_LOCKED() || HSDK_PLL_ERR()) 74 - pr_err("Failed to setup CPU frequency to 1GHz!"); 75 - } 76 - 77 41 #define SDIO_BASE (ARC_PERIPHERAL_BASE + 0xA000) 78 42 #define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108) 79 43 #define SDIO_UHS_REG_EXT_DIV_2 (2 << 30) ··· 62 98 * minimum possible div-by-2. 63 99 */ 64 100 iowrite32(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT); 65 - 66 - /* 67 - * Setup CPU frequency to 1GHz. 68 - * TODO: remove it after smart hsdk pll driver will be introduced. 69 - */ 70 - hsdk_set_cpu_freq_1ghz(); 71 101 } 72 102 73 103 static const char *hsdk_compat[] __initconst = {
+2
arch/mips/kernel/cps-vec.S
··· 235 235 has_mt t0, 3f 236 236 237 237 .set push 238 + .set MIPS_ISA_LEVEL_RAW 238 239 .set mt 239 240 240 241 /* Only allow 1 TC per VPE to execute... */ ··· 389 388 #elif defined(CONFIG_MIPS_MT) 390 389 391 390 .set push 391 + .set MIPS_ISA_LEVEL_RAW 392 392 .set mt 393 393 394 394 /* If the core doesn't support MT then return */
+12
arch/mips/kernel/process.c
··· 705 705 struct task_struct *t; 706 706 int max_users; 707 707 708 + /* If nothing to change, return right away, successfully. */ 709 + if (value == mips_get_process_fp_mode(task)) 710 + return 0; 711 + 712 + /* Only accept a mode change if 64-bit FP enabled for o32. */ 713 + if (!IS_ENABLED(CONFIG_MIPS_O32_FP64_SUPPORT)) 714 + return -EOPNOTSUPP; 715 + 716 + /* And only for o32 tasks. */ 717 + if (IS_ENABLED(CONFIG_64BIT) && !test_thread_flag(TIF_32BIT_REGS)) 718 + return -EOPNOTSUPP; 719 + 708 720 /* Check the value is valid */ 709 721 if (value & ~known_bits) 710 722 return -EOPNOTSUPP;
+125 -28
arch/mips/kernel/ptrace.c
··· 419 419 420 420 #endif /* CONFIG_64BIT */ 421 421 422 - static int fpr_get(struct task_struct *target, 423 - const struct user_regset *regset, 424 - unsigned int pos, unsigned int count, 425 - void *kbuf, void __user *ubuf) 422 + /* 423 + * Copy the floating-point context to the supplied NT_PRFPREG buffer, 424 + * !CONFIG_CPU_HAS_MSA variant. FP context's general register slots 425 + * correspond 1:1 to buffer slots. Only general registers are copied. 426 + */ 427 + static int fpr_get_fpa(struct task_struct *target, 428 + unsigned int *pos, unsigned int *count, 429 + void **kbuf, void __user **ubuf) 426 430 { 427 - unsigned i; 428 - int err; 431 + return user_regset_copyout(pos, count, kbuf, ubuf, 432 + &target->thread.fpu, 433 + 0, NUM_FPU_REGS * sizeof(elf_fpreg_t)); 434 + } 435 + 436 + /* 437 + * Copy the floating-point context to the supplied NT_PRFPREG buffer, 438 + * CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's 439 + * general register slots are copied to buffer slots. Only general 440 + * registers are copied. 441 + */ 442 + static int fpr_get_msa(struct task_struct *target, 443 + unsigned int *pos, unsigned int *count, 444 + void **kbuf, void __user **ubuf) 445 + { 446 + unsigned int i; 429 447 u64 fpr_val; 448 + int err; 430 449 431 - /* XXX fcr31 */ 432 - 433 - if (sizeof(target->thread.fpu.fpr[i]) == sizeof(elf_fpreg_t)) 434 - return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 435 - &target->thread.fpu, 436 - 0, sizeof(elf_fpregset_t)); 437 - 450 + BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t)); 438 451 for (i = 0; i < NUM_FPU_REGS; i++) { 439 452 fpr_val = get_fpr64(&target->thread.fpu.fpr[i], 0); 440 - err = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 453 + err = user_regset_copyout(pos, count, kbuf, ubuf, 441 454 &fpr_val, i * sizeof(elf_fpreg_t), 442 455 (i + 1) * sizeof(elf_fpreg_t)); 443 456 if (err) ··· 460 447 return 0; 461 448 } 462 449 463 - static int fpr_set(struct task_struct *target, 450 + /* 451 + * Copy the floating-point context to the supplied NT_PRFPREG buffer. 452 + * Choose the appropriate helper for general registers, and then copy 453 + * the FCSR register separately. 454 + */ 455 + static int fpr_get(struct task_struct *target, 464 456 const struct user_regset *regset, 465 457 unsigned int pos, unsigned int count, 466 - const void *kbuf, const void __user *ubuf) 458 + void *kbuf, void __user *ubuf) 467 459 { 468 - unsigned i; 460 + const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); 469 461 int err; 462 + 463 + if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t)) 464 + err = fpr_get_fpa(target, &pos, &count, &kbuf, &ubuf); 465 + else 466 + err = fpr_get_msa(target, &pos, &count, &kbuf, &ubuf); 467 + if (err) 468 + return err; 469 + 470 + err = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 471 + &target->thread.fpu.fcr31, 472 + fcr31_pos, fcr31_pos + sizeof(u32)); 473 + 474 + return err; 475 + } 476 + 477 + /* 478 + * Copy the supplied NT_PRFPREG buffer to the floating-point context, 479 + * !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP 480 + * context's general register slots. Only general registers are copied. 481 + */ 482 + static int fpr_set_fpa(struct task_struct *target, 483 + unsigned int *pos, unsigned int *count, 484 + const void **kbuf, const void __user **ubuf) 485 + { 486 + return user_regset_copyin(pos, count, kbuf, ubuf, 487 + &target->thread.fpu, 488 + 0, NUM_FPU_REGS * sizeof(elf_fpreg_t)); 489 + } 490 + 491 + /* 492 + * Copy the supplied NT_PRFPREG buffer to the floating-point context, 493 + * CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 494 + * bits only of FP context's general register slots. Only general 495 + * registers are copied. 496 + */ 497 + static int fpr_set_msa(struct task_struct *target, 498 + unsigned int *pos, unsigned int *count, 499 + const void **kbuf, const void __user **ubuf) 500 + { 501 + unsigned int i; 470 502 u64 fpr_val; 471 - 472 - /* XXX fcr31 */ 473 - 474 - init_fp_ctx(target); 475 - 476 - if (sizeof(target->thread.fpu.fpr[i]) == sizeof(elf_fpreg_t)) 477 - return user_regset_copyin(&pos, &count, &kbuf, &ubuf, 478 - &target->thread.fpu, 479 - 0, sizeof(elf_fpregset_t)); 503 + int err; 480 504 481 505 BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t)); 482 - for (i = 0; i < NUM_FPU_REGS && count >= sizeof(elf_fpreg_t); i++) { 483 - err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 506 + for (i = 0; i < NUM_FPU_REGS && *count > 0; i++) { 507 + err = user_regset_copyin(pos, count, kbuf, ubuf, 484 508 &fpr_val, i * sizeof(elf_fpreg_t), 485 509 (i + 1) * sizeof(elf_fpreg_t)); 486 510 if (err) ··· 526 476 } 527 477 528 478 return 0; 479 + } 480 + 481 + /* 482 + * Copy the supplied NT_PRFPREG buffer to the floating-point context. 483 + * Choose the appropriate helper for general registers, and then copy 484 + * the FCSR register separately. 485 + * 486 + * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', 487 + * which is supposed to have been guaranteed by the kernel before 488 + * calling us, e.g. in `ptrace_regset'. We enforce that requirement, 489 + * so that we can safely avoid preinitializing temporaries for 490 + * partial register writes. 491 + */ 492 + static int fpr_set(struct task_struct *target, 493 + const struct user_regset *regset, 494 + unsigned int pos, unsigned int count, 495 + const void *kbuf, const void __user *ubuf) 496 + { 497 + const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); 498 + u32 fcr31; 499 + int err; 500 + 501 + BUG_ON(count % sizeof(elf_fpreg_t)); 502 + 503 + if (pos + count > sizeof(elf_fpregset_t)) 504 + return -EIO; 505 + 506 + init_fp_ctx(target); 507 + 508 + if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t)) 509 + err = fpr_set_fpa(target, &pos, &count, &kbuf, &ubuf); 510 + else 511 + err = fpr_set_msa(target, &pos, &count, &kbuf, &ubuf); 512 + if (err) 513 + return err; 514 + 515 + if (count > 0) { 516 + err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 517 + &fcr31, 518 + fcr31_pos, fcr31_pos + sizeof(u32)); 519 + if (err) 520 + return err; 521 + 522 + ptrace_setfcr31(target, fcr31); 523 + } 524 + 525 + return err; 529 526 } 530 527 531 528 enum mips_regset {
+2
arch/parisc/include/asm/ldcw.h
··· 12 12 for the semaphore. */ 13 13 14 14 #define __PA_LDCW_ALIGNMENT 16 15 + #define __PA_LDCW_ALIGN_ORDER 4 15 16 #define __ldcw_align(a) ({ \ 16 17 unsigned long __ret = (unsigned long) &(a)->lock[0]; \ 17 18 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \ ··· 30 29 ldcd). */ 31 30 32 31 #define __PA_LDCW_ALIGNMENT 4 32 + #define __PA_LDCW_ALIGN_ORDER 2 33 33 #define __ldcw_align(a) (&(a)->slock) 34 34 #define __LDCW "ldcw,co" 35 35
+1 -1
arch/parisc/kernel/drivers.c
··· 870 870 static int count; 871 871 872 872 print_pa_hwpath(dev, hw_path); 873 - printk(KERN_INFO "%d. %s at 0x%p [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }", 873 + printk(KERN_INFO "%d. %s at 0x%px [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }", 874 874 ++count, dev->name, (void*) dev->hpa.start, hw_path, dev->id.hw_type, 875 875 dev->id.hversion_rev, dev->id.hversion, dev->id.sversion); 876 876
+11 -2
arch/parisc/kernel/entry.S
··· 35 35 #include <asm/pgtable.h> 36 36 #include <asm/signal.h> 37 37 #include <asm/unistd.h> 38 + #include <asm/ldcw.h> 38 39 #include <asm/thread_info.h> 39 40 40 41 #include <linux/linkage.h> ··· 47 46 #endif 48 47 49 48 .import pa_tlb_lock,data 49 + .macro load_pa_tlb_lock reg 50 + #if __PA_LDCW_ALIGNMENT > 4 51 + load32 PA(pa_tlb_lock) + __PA_LDCW_ALIGNMENT-1, \reg 52 + depi 0,31,__PA_LDCW_ALIGN_ORDER, \reg 53 + #else 54 + load32 PA(pa_tlb_lock), \reg 55 + #endif 56 + .endm 50 57 51 58 /* space_to_prot macro creates a prot id from a space id */ 52 59 ··· 466 457 .macro tlb_lock spc,ptp,pte,tmp,tmp1,fault 467 458 #ifdef CONFIG_SMP 468 459 cmpib,COND(=),n 0,\spc,2f 469 - load32 PA(pa_tlb_lock),\tmp 460 + load_pa_tlb_lock \tmp 470 461 1: LDCW 0(\tmp),\tmp1 471 462 cmpib,COND(=) 0,\tmp1,1b 472 463 nop ··· 489 480 /* Release pa_tlb_lock lock. */ 490 481 .macro tlb_unlock1 spc,tmp 491 482 #ifdef CONFIG_SMP 492 - load32 PA(pa_tlb_lock),\tmp 483 + load_pa_tlb_lock \tmp 493 484 tlb_unlock0 \spc,\tmp 494 485 #endif 495 486 .endm
+7 -2
arch/parisc/kernel/pacache.S
··· 36 36 #include <asm/assembly.h> 37 37 #include <asm/pgtable.h> 38 38 #include <asm/cache.h> 39 + #include <asm/ldcw.h> 39 40 #include <linux/linkage.h> 40 41 41 42 .text ··· 334 333 335 334 .macro tlb_lock la,flags,tmp 336 335 #ifdef CONFIG_SMP 337 - ldil L%pa_tlb_lock,%r1 338 - ldo R%pa_tlb_lock(%r1),\la 336 + #if __PA_LDCW_ALIGNMENT > 4 337 + load32 pa_tlb_lock + __PA_LDCW_ALIGNMENT-1, \la 338 + depi 0,31,__PA_LDCW_ALIGN_ORDER, \la 339 + #else 340 + load32 pa_tlb_lock, \la 341 + #endif 339 342 rsm PSW_SM_I,\flags 340 343 1: LDCW 0(\la),\tmp 341 344 cmpib,<>,n 0,\tmp,3f
+39
arch/parisc/kernel/process.c
··· 39 39 #include <linux/kernel.h> 40 40 #include <linux/mm.h> 41 41 #include <linux/fs.h> 42 + #include <linux/cpu.h> 42 43 #include <linux/module.h> 43 44 #include <linux/personality.h> 44 45 #include <linux/ptrace.h> ··· 183 182 memcpy(r, tsk->thread.regs.fr, sizeof(*r)); 184 183 return 1; 185 184 } 185 + 186 + /* 187 + * Idle thread support 188 + * 189 + * Detect when running on QEMU with SeaBIOS PDC Firmware and let 190 + * QEMU idle the host too. 191 + */ 192 + 193 + int running_on_qemu __read_mostly; 194 + 195 + void __cpuidle arch_cpu_idle_dead(void) 196 + { 197 + /* nop on real hardware, qemu will offline CPU. */ 198 + asm volatile("or %%r31,%%r31,%%r31\n":::); 199 + } 200 + 201 + void __cpuidle arch_cpu_idle(void) 202 + { 203 + local_irq_enable(); 204 + 205 + /* nop on real hardware, qemu will idle sleep. */ 206 + asm volatile("or %%r10,%%r10,%%r10\n":::); 207 + } 208 + 209 + static int __init parisc_idle_init(void) 210 + { 211 + const char *marker; 212 + 213 + /* check QEMU/SeaBIOS marker in PAGE0 */ 214 + marker = (char *) &PAGE0->pad0; 215 + running_on_qemu = (memcmp(marker, "SeaBIOS", 8) == 0); 216 + 217 + if (!running_on_qemu) 218 + cpu_idle_poll_ctrl(1); 219 + 220 + return 0; 221 + } 222 + arch_initcall(parisc_idle_init); 186 223 187 224 /* 188 225 * Copy architecture-specific thread state
+5 -5
arch/parisc/mm/init.c
··· 631 631 mem_init_print_info(NULL); 632 632 #ifdef CONFIG_DEBUG_KERNEL /* double-sanity-check paranoia */ 633 633 printk("virtual kernel memory layout:\n" 634 - " vmalloc : 0x%p - 0x%p (%4ld MB)\n" 635 - " memory : 0x%p - 0x%p (%4ld MB)\n" 636 - " .init : 0x%p - 0x%p (%4ld kB)\n" 637 - " .data : 0x%p - 0x%p (%4ld kB)\n" 638 - " .text : 0x%p - 0x%p (%4ld kB)\n", 634 + " vmalloc : 0x%px - 0x%px (%4ld MB)\n" 635 + " memory : 0x%px - 0x%px (%4ld MB)\n" 636 + " .init : 0x%px - 0x%px (%4ld kB)\n" 637 + " .data : 0x%px - 0x%px (%4ld kB)\n" 638 + " .text : 0x%px - 0x%px (%4ld kB)\n", 639 639 640 640 (void*)VMALLOC_START, (void*)VMALLOC_END, 641 641 (VMALLOC_END - VMALLOC_START) >> 20,
+6 -1
arch/powerpc/mm/fault.c
··· 145 145 return __bad_area(regs, address, SEGV_MAPERR); 146 146 } 147 147 148 + static noinline int bad_access(struct pt_regs *regs, unsigned long address) 149 + { 150 + return __bad_area(regs, address, SEGV_ACCERR); 151 + } 152 + 148 153 static int do_sigbus(struct pt_regs *regs, unsigned long address, 149 154 unsigned int fault) 150 155 { ··· 495 490 496 491 good_area: 497 492 if (unlikely(access_error(is_write, is_exec, vma))) 498 - return bad_area(regs, address); 493 + return bad_access(regs, address); 499 494 500 495 /* 501 496 * If for any reason at all we couldn't handle the fault,
+75
arch/riscv/configs/defconfig
··· 1 + CONFIG_SMP=y 2 + CONFIG_PCI=y 3 + CONFIG_PCIE_XILINX=y 4 + CONFIG_SYSVIPC=y 5 + CONFIG_POSIX_MQUEUE=y 6 + CONFIG_IKCONFIG=y 7 + CONFIG_IKCONFIG_PROC=y 8 + CONFIG_CGROUPS=y 9 + CONFIG_CGROUP_SCHED=y 10 + CONFIG_CFS_BANDWIDTH=y 11 + CONFIG_CGROUP_BPF=y 12 + CONFIG_NAMESPACES=y 13 + CONFIG_USER_NS=y 14 + CONFIG_BLK_DEV_INITRD=y 15 + CONFIG_EXPERT=y 16 + CONFIG_CHECKPOINT_RESTORE=y 17 + CONFIG_BPF_SYSCALL=y 18 + CONFIG_NET=y 19 + CONFIG_PACKET=y 20 + CONFIG_UNIX=y 21 + CONFIG_INET=y 22 + CONFIG_IP_MULTICAST=y 23 + CONFIG_IP_ADVANCED_ROUTER=y 24 + CONFIG_IP_PNP=y 25 + CONFIG_IP_PNP_DHCP=y 26 + CONFIG_IP_PNP_BOOTP=y 27 + CONFIG_IP_PNP_RARP=y 28 + CONFIG_NETLINK_DIAG=y 29 + CONFIG_DEVTMPFS=y 30 + CONFIG_BLK_DEV_LOOP=y 31 + CONFIG_VIRTIO_BLK=y 32 + CONFIG_BLK_DEV_SD=y 33 + CONFIG_BLK_DEV_SR=y 34 + CONFIG_ATA=y 35 + CONFIG_SATA_AHCI=y 36 + CONFIG_SATA_AHCI_PLATFORM=y 37 + CONFIG_NETDEVICES=y 38 + CONFIG_VIRTIO_NET=y 39 + CONFIG_MACB=y 40 + CONFIG_E1000E=y 41 + CONFIG_R8169=y 42 + CONFIG_MICROSEMI_PHY=y 43 + CONFIG_INPUT_MOUSEDEV=y 44 + CONFIG_SERIAL_8250=y 45 + CONFIG_SERIAL_8250_CONSOLE=y 46 + CONFIG_SERIAL_OF_PLATFORM=y 47 + # CONFIG_PTP_1588_CLOCK is not set 48 + CONFIG_DRM=y 49 + CONFIG_DRM_RADEON=y 50 + CONFIG_FRAMEBUFFER_CONSOLE=y 51 + CONFIG_USB=y 52 + CONFIG_USB_XHCI_HCD=y 53 + CONFIG_USB_XHCI_PLATFORM=y 54 + CONFIG_USB_EHCI_HCD=y 55 + CONFIG_USB_EHCI_HCD_PLATFORM=y 56 + CONFIG_USB_OHCI_HCD=y 57 + CONFIG_USB_OHCI_HCD_PLATFORM=y 58 + CONFIG_USB_STORAGE=y 59 + CONFIG_USB_UAS=y 60 + CONFIG_VIRTIO_MMIO=y 61 + CONFIG_RAS=y 62 + CONFIG_EXT4_FS=y 63 + CONFIG_EXT4_FS_POSIX_ACL=y 64 + CONFIG_AUTOFS4_FS=y 65 + CONFIG_MSDOS_FS=y 66 + CONFIG_VFAT_FS=y 67 + CONFIG_TMPFS=y 68 + CONFIG_TMPFS_POSIX_ACL=y 69 + CONFIG_NFS_FS=y 70 + CONFIG_NFS_V4=y 71 + CONFIG_NFS_V4_1=y 72 + CONFIG_NFS_V4_2=y 73 + CONFIG_ROOT_NFS=y 74 + # CONFIG_RCU_TRACE is not set 75 + CONFIG_CRYPTO_USER_API_HASH=y
+4 -4
arch/riscv/include/asm/csr.h
··· 17 17 #include <linux/const.h> 18 18 19 19 /* Status register flags */ 20 - #define SR_IE _AC(0x00000002, UL) /* Interrupt Enable */ 21 - #define SR_PIE _AC(0x00000020, UL) /* Previous IE */ 22 - #define SR_PS _AC(0x00000100, UL) /* Previously Supervisor */ 23 - #define SR_SUM _AC(0x00040000, UL) /* Supervisor may access User Memory */ 20 + #define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */ 21 + #define SR_SPIE _AC(0x00000020, UL) /* Previous Supervisor IE */ 22 + #define SR_SPP _AC(0x00000100, UL) /* Previously Supervisor */ 23 + #define SR_SUM _AC(0x00040000, UL) /* Supervisor may access User Memory */ 24 24 25 25 #define SR_FS _AC(0x00006000, UL) /* Floating-point Status */ 26 26 #define SR_FS_OFF _AC(0x00000000, UL)
-4
arch/riscv/include/asm/io.h
··· 21 21 22 22 #include <linux/types.h> 23 23 24 - #ifdef CONFIG_MMU 25 - 26 24 extern void __iomem *ioremap(phys_addr_t offset, unsigned long size); 27 25 28 26 /* ··· 33 35 #define ioremap_wt(addr, size) ioremap((addr), (size)) 34 36 35 37 extern void iounmap(volatile void __iomem *addr); 36 - 37 - #endif /* CONFIG_MMU */ 38 38 39 39 /* Generic IO read/write. These perform native-endian accesses. */ 40 40 #define __raw_writeb __raw_writeb
+5 -5
arch/riscv/include/asm/irqflags.h
··· 27 27 /* unconditionally enable interrupts */ 28 28 static inline void arch_local_irq_enable(void) 29 29 { 30 - csr_set(sstatus, SR_IE); 30 + csr_set(sstatus, SR_SIE); 31 31 } 32 32 33 33 /* unconditionally disable interrupts */ 34 34 static inline void arch_local_irq_disable(void) 35 35 { 36 - csr_clear(sstatus, SR_IE); 36 + csr_clear(sstatus, SR_SIE); 37 37 } 38 38 39 39 /* get status and disable interrupts */ 40 40 static inline unsigned long arch_local_irq_save(void) 41 41 { 42 - return csr_read_clear(sstatus, SR_IE); 42 + return csr_read_clear(sstatus, SR_SIE); 43 43 } 44 44 45 45 /* test flags */ 46 46 static inline int arch_irqs_disabled_flags(unsigned long flags) 47 47 { 48 - return !(flags & SR_IE); 48 + return !(flags & SR_SIE); 49 49 } 50 50 51 51 /* test hardware interrupt enable bit */ ··· 57 57 /* set interrupt enabled status */ 58 58 static inline void arch_local_irq_restore(unsigned long flags) 59 59 { 60 - csr_set(sstatus, flags & SR_IE); 60 + csr_set(sstatus, flags & SR_SIE); 61 61 } 62 62 63 63 #endif /* _ASM_RISCV_IRQFLAGS_H */
-4
arch/riscv/include/asm/pgtable.h
··· 20 20 21 21 #ifndef __ASSEMBLY__ 22 22 23 - #ifdef CONFIG_MMU 24 - 25 23 /* Page Upper Directory not used in RISC-V */ 26 24 #include <asm-generic/pgtable-nopud.h> 27 25 #include <asm/page.h> ··· 410 412 { 411 413 /* No page table caches to initialize */ 412 414 } 413 - 414 - #endif /* CONFIG_MMU */ 415 415 416 416 #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) 417 417 #define VMALLOC_END (PAGE_OFFSET - 1)
+1 -1
arch/riscv/include/asm/ptrace.h
··· 66 66 #define REG_FMT "%08lx" 67 67 #endif 68 68 69 - #define user_mode(regs) (((regs)->sstatus & SR_PS) == 0) 69 + #define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0) 70 70 71 71 72 72 /* Helpers for working with the instruction pointer */
-4
arch/riscv/include/asm/tlbflush.h
··· 15 15 #ifndef _ASM_RISCV_TLBFLUSH_H 16 16 #define _ASM_RISCV_TLBFLUSH_H 17 17 18 - #ifdef CONFIG_MMU 19 - 20 18 #include <linux/mm_types.h> 21 19 22 20 /* ··· 61 63 { 62 64 flush_tlb_all(); 63 65 } 64 - 65 - #endif /* CONFIG_MMU */ 66 66 67 67 #endif /* _ASM_RISCV_TLBFLUSH_H */
-12
arch/riscv/include/asm/uaccess.h
··· 127 127 * call. 128 128 */ 129 129 130 - #ifdef CONFIG_MMU 131 130 #define __get_user_asm(insn, x, ptr, err) \ 132 131 do { \ 133 132 uintptr_t __tmp; \ ··· 152 153 __disable_user_access(); \ 153 154 (x) = __x; \ 154 155 } while (0) 155 - #endif /* CONFIG_MMU */ 156 156 157 157 #ifdef CONFIG_64BIT 158 158 #define __get_user_8(x, ptr, err) \ 159 159 __get_user_asm("ld", x, ptr, err) 160 160 #else /* !CONFIG_64BIT */ 161 - #ifdef CONFIG_MMU 162 161 #define __get_user_8(x, ptr, err) \ 163 162 do { \ 164 163 u32 __user *__ptr = (u32 __user *)(ptr); \ ··· 190 193 (x) = (__typeof__(x))((__typeof__((x)-(x)))( \ 191 194 (((u64)__hi << 32) | __lo))); \ 192 195 } while (0) 193 - #endif /* CONFIG_MMU */ 194 196 #endif /* CONFIG_64BIT */ 195 197 196 198 ··· 263 267 ((x) = 0, -EFAULT); \ 264 268 }) 265 269 266 - 267 - #ifdef CONFIG_MMU 268 270 #define __put_user_asm(insn, x, ptr, err) \ 269 271 do { \ 270 272 uintptr_t __tmp; \ ··· 286 292 : "rJ" (__x), "i" (-EFAULT)); \ 287 293 __disable_user_access(); \ 288 294 } while (0) 289 - #endif /* CONFIG_MMU */ 290 - 291 295 292 296 #ifdef CONFIG_64BIT 293 297 #define __put_user_8(x, ptr, err) \ 294 298 __put_user_asm("sd", x, ptr, err) 295 299 #else /* !CONFIG_64BIT */ 296 - #ifdef CONFIG_MMU 297 300 #define __put_user_8(x, ptr, err) \ 298 301 do { \ 299 302 u32 __user *__ptr = (u32 __user *)(ptr); \ ··· 320 329 : "rJ" (__x), "rJ" (__x >> 32), "i" (-EFAULT)); \ 321 330 __disable_user_access(); \ 322 331 } while (0) 323 - #endif /* CONFIG_MMU */ 324 332 #endif /* CONFIG_64BIT */ 325 333 326 334 ··· 428 438 * will set "err" to -EFAULT, while successful accesses return the previous 429 439 * value. 430 440 */ 431 - #ifdef CONFIG_MMU 432 441 #define __cmpxchg_user(ptr, old, new, err, size, lrb, scb) \ 433 442 ({ \ 434 443 __typeof__(ptr) __ptr = (ptr); \ ··· 497 508 (err) = __err; \ 498 509 __ret; \ 499 510 }) 500 - #endif /* CONFIG_MMU */ 501 511 502 512 #endif /* _ASM_RISCV_UACCESS_H */
+1
arch/riscv/include/asm/unistd.h
··· 14 14 #define __ARCH_HAVE_MMU 15 15 #define __ARCH_WANT_SYS_CLONE 16 16 #include <uapi/asm/unistd.h> 17 + #include <uapi/asm/syscalls.h>
-28
arch/riscv/include/asm/vdso-syscalls.h
··· 1 - /* 2 - * Copyright (C) 2017 SiFive 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, 9 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 - * GNU General Public License for more details. 12 - * 13 - * You should have received a copy of the GNU General Public License 14 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 - */ 16 - 17 - #ifndef _ASM_RISCV_VDSO_SYSCALLS_H 18 - #define _ASM_RISCV_VDSO_SYSCALLS_H 19 - 20 - #ifdef CONFIG_SMP 21 - 22 - /* These syscalls are only used by the vDSO and are not in the uapi. */ 23 - #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15) 24 - __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache) 25 - 26 - #endif 27 - 28 - #endif /* _ASM_RISCV_VDSO_H */
+26
arch/riscv/include/uapi/asm/syscalls.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2017 SiFive 4 + */ 5 + 6 + #ifndef _ASM__UAPI__SYSCALLS_H 7 + #define _ASM__UAPI__SYSCALLS_H 8 + 9 + /* 10 + * Allows the instruction cache to be flushed from userspace. Despite RISC-V 11 + * having a direct 'fence.i' instruction available to userspace (which we 12 + * can't trap!), that's not actually viable when running on Linux because the 13 + * kernel might schedule a process on another hart. There is no way for 14 + * userspace to handle this without invoking the kernel (as it doesn't know the 15 + * thread->hart mappings), so we've defined a RISC-V specific system call to 16 + * flush the instruction cache. 17 + * 18 + * __NR_riscv_flush_icache is defined to flush the instruction cache over an 19 + * address range, with the flush applying to either all threads or just the 20 + * caller. We don't currently do anything with the address range, that's just 21 + * in there for forwards compatibility. 22 + */ 23 + #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15) 24 + __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache) 25 + 26 + #endif
+4 -4
arch/riscv/kernel/entry.S
··· 196 196 addi s2, s2, 0x4 197 197 REG_S s2, PT_SEPC(sp) 198 198 /* System calls run with interrupts enabled */ 199 - csrs sstatus, SR_IE 199 + csrs sstatus, SR_SIE 200 200 /* Trace syscalls, but only if requested by the user. */ 201 201 REG_L t0, TASK_TI_FLAGS(tp) 202 202 andi t0, t0, _TIF_SYSCALL_TRACE ··· 224 224 225 225 ret_from_exception: 226 226 REG_L s0, PT_SSTATUS(sp) 227 - csrc sstatus, SR_IE 228 - andi s0, s0, SR_PS 227 + csrc sstatus, SR_SIE 228 + andi s0, s0, SR_SPP 229 229 bnez s0, restore_all 230 230 231 231 resume_userspace: ··· 255 255 bnez s1, work_resched 256 256 work_notifysig: 257 257 /* Handle pending signals and notify-resume requests */ 258 - csrs sstatus, SR_IE /* Enable interrupts for do_notify_resume() */ 258 + csrs sstatus, SR_SIE /* Enable interrupts for do_notify_resume() */ 259 259 move a0, sp /* pt_regs */ 260 260 move a1, s0 /* current_thread_info->flags */ 261 261 tail do_notify_resume
+2 -2
arch/riscv/kernel/process.c
··· 76 76 void start_thread(struct pt_regs *regs, unsigned long pc, 77 77 unsigned long sp) 78 78 { 79 - regs->sstatus = SR_PIE /* User mode, irqs on */ | SR_FS_INITIAL; 79 + regs->sstatus = SR_SPIE /* User mode, irqs on */ | SR_FS_INITIAL; 80 80 regs->sepc = pc; 81 81 regs->sp = sp; 82 82 set_fs(USER_DS); ··· 110 110 const register unsigned long gp __asm__ ("gp"); 111 111 memset(childregs, 0, sizeof(struct pt_regs)); 112 112 childregs->gp = gp; 113 - childregs->sstatus = SR_PS | SR_PIE; /* Supervisor, irqs on */ 113 + childregs->sstatus = SR_SPP | SR_SPIE; /* Supervisor, irqs on */ 114 114 115 115 p->thread.ra = (unsigned long)ret_from_kernel_thread; 116 116 p->thread.s[0] = usp; /* fn */
-1
arch/riscv/kernel/syscall_table.c
··· 23 23 void *sys_call_table[__NR_syscalls] = { 24 24 [0 ... __NR_syscalls - 1] = sys_ni_syscall, 25 25 #include <asm/unistd.h> 26 - #include <asm/vdso-syscalls.h> 27 26 };
-1
arch/riscv/kernel/vdso/flush_icache.S
··· 13 13 14 14 #include <linux/linkage.h> 15 15 #include <asm/unistd.h> 16 - #include <asm/vdso-syscalls.h> 17 16 18 17 .text 19 18 /* int __vdso_flush_icache(void *start, void *end, unsigned long flags); */
+1 -1
arch/riscv/mm/fault.c
··· 63 63 goto vmalloc_fault; 64 64 65 65 /* Enable interrupts if they were enabled in the parent context. */ 66 - if (likely(regs->sstatus & SR_PIE)) 66 + if (likely(regs->sstatus & SR_SPIE)) 67 67 local_irq_enable(); 68 68 69 69 /*
+5 -4
arch/s390/kvm/kvm-s390.c
··· 792 792 793 793 if (kvm->arch.use_cmma) { 794 794 /* 795 - * Get the last slot. They should be sorted by base_gfn, so the 796 - * last slot is also the one at the end of the address space. 797 - * We have verified above that at least one slot is present. 795 + * Get the first slot. They are reverse sorted by base_gfn, so 796 + * the first slot is also the one at the end of the address 797 + * space. We have verified above that at least one slot is 798 + * present. 798 799 */ 799 - ms = slots->memslots + slots->used_slots - 1; 800 + ms = slots->memslots; 800 801 /* round up so we only use full longs */ 801 802 ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG); 802 803 /* allocate enough bytes to store all the bits */
+1 -1
arch/s390/kvm/priv.c
··· 1006 1006 cbrlo[entries] = gfn << PAGE_SHIFT; 1007 1007 } 1008 1008 1009 - if (orc) { 1009 + if (orc && gfn < ms->bitmap_size) { 1010 1010 /* increment only if we are really flipping the bit to 1 */ 1011 1011 if (!test_and_set_bit(gfn, ms->pgste_bitmap)) 1012 1012 atomic64_inc(&ms->dirty_pages);
+20 -4
arch/sh/boards/mach-se/770x/setup.c
··· 9 9 */ 10 10 #include <linux/init.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/sh_eth.h> 12 13 #include <mach-se/mach/se.h> 13 14 #include <mach-se/mach/mrshpc.h> 14 15 #include <asm/machvec.h> ··· 116 115 #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\ 117 116 defined(CONFIG_CPU_SUBTYPE_SH7712) 118 117 /* SH771X Ethernet driver */ 118 + static struct sh_eth_plat_data sh_eth_plat = { 119 + .phy = PHY_ID, 120 + .phy_interface = PHY_INTERFACE_MODE_MII, 121 + }; 122 + 119 123 static struct resource sh_eth0_resources[] = { 120 124 [0] = { 121 125 .start = SH_ETH0_BASE, 122 - .end = SH_ETH0_BASE + 0x1B8, 126 + .end = SH_ETH0_BASE + 0x1B8 - 1, 123 127 .flags = IORESOURCE_MEM, 124 128 }, 125 129 [1] = { 130 + .start = SH_TSU_BASE, 131 + .end = SH_TSU_BASE + 0x200 - 1, 132 + .flags = IORESOURCE_MEM, 133 + }, 134 + [2] = { 126 135 .start = SH_ETH0_IRQ, 127 136 .end = SH_ETH0_IRQ, 128 137 .flags = IORESOURCE_IRQ, ··· 143 132 .name = "sh771x-ether", 144 133 .id = 0, 145 134 .dev = { 146 - .platform_data = PHY_ID, 135 + .platform_data = &sh_eth_plat, 147 136 }, 148 137 .num_resources = ARRAY_SIZE(sh_eth0_resources), 149 138 .resource = sh_eth0_resources, ··· 152 141 static struct resource sh_eth1_resources[] = { 153 142 [0] = { 154 143 .start = SH_ETH1_BASE, 155 - .end = SH_ETH1_BASE + 0x1B8, 144 + .end = SH_ETH1_BASE + 0x1B8 - 1, 156 145 .flags = IORESOURCE_MEM, 157 146 }, 158 147 [1] = { 148 + .start = SH_TSU_BASE, 149 + .end = SH_TSU_BASE + 0x200 - 1, 150 + .flags = IORESOURCE_MEM, 151 + }, 152 + [2] = { 159 153 .start = SH_ETH1_IRQ, 160 154 .end = SH_ETH1_IRQ, 161 155 .flags = IORESOURCE_IRQ, ··· 171 155 .name = "sh771x-ether", 172 156 .id = 1, 173 157 .dev = { 174 - .platform_data = PHY_ID, 158 + .platform_data = &sh_eth_plat, 175 159 }, 176 160 .num_resources = ARRAY_SIZE(sh_eth1_resources), 177 161 .resource = sh_eth1_resources,
+1
arch/sh/include/mach-se/mach/se.h
··· 100 100 /* Base address */ 101 101 #define SH_ETH0_BASE 0xA7000000 102 102 #define SH_ETH1_BASE 0xA7000400 103 + #define SH_TSU_BASE 0xA7000800 103 104 /* PHY ID */ 104 105 #if defined(CONFIG_CPU_SUBTYPE_SH7710) 105 106 # define PHY_ID 0x00
+2 -2
arch/x86/events/intel/rapl.c
··· 755 755 X86_RAPL_MODEL_MATCH(INTEL_FAM6_IVYBRIDGE_X, snbep_rapl_init), 756 756 757 757 X86_RAPL_MODEL_MATCH(INTEL_FAM6_HASWELL_CORE, hsw_rapl_init), 758 - X86_RAPL_MODEL_MATCH(INTEL_FAM6_HASWELL_X, hsw_rapl_init), 758 + X86_RAPL_MODEL_MATCH(INTEL_FAM6_HASWELL_X, hsx_rapl_init), 759 759 X86_RAPL_MODEL_MATCH(INTEL_FAM6_HASWELL_ULT, hsw_rapl_init), 760 760 X86_RAPL_MODEL_MATCH(INTEL_FAM6_HASWELL_GT3E, hsw_rapl_init), 761 761 762 762 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_CORE, hsw_rapl_init), 763 763 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_GT3E, hsw_rapl_init), 764 764 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_X, hsx_rapl_init), 765 - X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_XEON_D, hsw_rapl_init), 765 + X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_XEON_D, hsx_rapl_init), 766 766 767 767 X86_RAPL_MODEL_MATCH(INTEL_FAM6_XEON_PHI_KNL, knl_rapl_init), 768 768 X86_RAPL_MODEL_MATCH(INTEL_FAM6_XEON_PHI_KNM, knl_rapl_init),
+19
arch/x86/kvm/svm.c
··· 4986 4986 "mov %%r14, %c[r14](%[svm]) \n\t" 4987 4987 "mov %%r15, %c[r15](%[svm]) \n\t" 4988 4988 #endif 4989 + /* 4990 + * Clear host registers marked as clobbered to prevent 4991 + * speculative use. 4992 + */ 4993 + "xor %%" _ASM_BX ", %%" _ASM_BX " \n\t" 4994 + "xor %%" _ASM_CX ", %%" _ASM_CX " \n\t" 4995 + "xor %%" _ASM_DX ", %%" _ASM_DX " \n\t" 4996 + "xor %%" _ASM_SI ", %%" _ASM_SI " \n\t" 4997 + "xor %%" _ASM_DI ", %%" _ASM_DI " \n\t" 4998 + #ifdef CONFIG_X86_64 4999 + "xor %%r8, %%r8 \n\t" 5000 + "xor %%r9, %%r9 \n\t" 5001 + "xor %%r10, %%r10 \n\t" 5002 + "xor %%r11, %%r11 \n\t" 5003 + "xor %%r12, %%r12 \n\t" 5004 + "xor %%r13, %%r13 \n\t" 5005 + "xor %%r14, %%r14 \n\t" 5006 + "xor %%r15, %%r15 \n\t" 5007 + #endif 4989 5008 "pop %%" _ASM_BP 4990 5009 : 4991 5010 : [svm]"a"(svm),
+13 -1
arch/x86/kvm/vmx.c
··· 9415 9415 /* Save guest registers, load host registers, keep flags */ 9416 9416 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t" 9417 9417 "pop %0 \n\t" 9418 + "setbe %c[fail](%0)\n\t" 9418 9419 "mov %%" _ASM_AX ", %c[rax](%0) \n\t" 9419 9420 "mov %%" _ASM_BX ", %c[rbx](%0) \n\t" 9420 9421 __ASM_SIZE(pop) " %c[rcx](%0) \n\t" ··· 9432 9431 "mov %%r13, %c[r13](%0) \n\t" 9433 9432 "mov %%r14, %c[r14](%0) \n\t" 9434 9433 "mov %%r15, %c[r15](%0) \n\t" 9434 + "xor %%r8d, %%r8d \n\t" 9435 + "xor %%r9d, %%r9d \n\t" 9436 + "xor %%r10d, %%r10d \n\t" 9437 + "xor %%r11d, %%r11d \n\t" 9438 + "xor %%r12d, %%r12d \n\t" 9439 + "xor %%r13d, %%r13d \n\t" 9440 + "xor %%r14d, %%r14d \n\t" 9441 + "xor %%r15d, %%r15d \n\t" 9435 9442 #endif 9436 9443 "mov %%cr2, %%" _ASM_AX " \n\t" 9437 9444 "mov %%" _ASM_AX ", %c[cr2](%0) \n\t" 9438 9445 9446 + "xor %%eax, %%eax \n\t" 9447 + "xor %%ebx, %%ebx \n\t" 9448 + "xor %%esi, %%esi \n\t" 9449 + "xor %%edi, %%edi \n\t" 9439 9450 "pop %%" _ASM_BP "; pop %%" _ASM_DX " \n\t" 9440 - "setbe %c[fail](%0) \n\t" 9441 9451 ".pushsection .rodata \n\t" 9442 9452 ".global vmx_return \n\t" 9443 9453 "vmx_return: " _ASM_PTR " 2b \n\t"
+7 -2
block/blk-core.c
··· 562 562 } 563 563 } 564 564 565 + void blk_drain_queue(struct request_queue *q) 566 + { 567 + spin_lock_irq(q->queue_lock); 568 + __blk_drain_queue(q, true); 569 + spin_unlock_irq(q->queue_lock); 570 + } 571 + 565 572 /** 566 573 * blk_queue_bypass_start - enter queue bypass mode 567 574 * @q: queue of interest ··· 696 689 */ 697 690 blk_freeze_queue(q); 698 691 spin_lock_irq(lock); 699 - if (!q->mq_ops) 700 - __blk_drain_queue(q, true); 701 692 queue_flag_set(QUEUE_FLAG_DEAD, q); 702 693 spin_unlock_irq(lock); 703 694
+2
block/blk-mq.c
··· 161 161 * exported to drivers as the only user for unfreeze is blk_mq. 162 162 */ 163 163 blk_freeze_queue_start(q); 164 + if (!q->mq_ops) 165 + blk_drain_queue(q); 164 166 blk_mq_freeze_queue_wait(q); 165 167 } 166 168
+2
block/blk.h
··· 330 330 } 331 331 #endif /* CONFIG_BOUNCE */ 332 332 333 + extern void blk_drain_queue(struct request_queue *q); 334 + 333 335 #endif /* BLK_INTERNAL_H */
+8 -2
drivers/block/loop.c
··· 1581 1581 return err; 1582 1582 } 1583 1583 1584 - static void lo_release(struct gendisk *disk, fmode_t mode) 1584 + static void __lo_release(struct loop_device *lo) 1585 1585 { 1586 - struct loop_device *lo = disk->private_data; 1587 1586 int err; 1588 1587 1589 1588 if (atomic_dec_return(&lo->lo_refcnt)) ··· 1607 1608 } 1608 1609 1609 1610 mutex_unlock(&lo->lo_ctl_mutex); 1611 + } 1612 + 1613 + static void lo_release(struct gendisk *disk, fmode_t mode) 1614 + { 1615 + mutex_lock(&loop_index_mutex); 1616 + __lo_release(disk->private_data); 1617 + mutex_unlock(&loop_index_mutex); 1610 1618 } 1611 1619 1612 1620 static const struct block_device_operations lo_fops = {
+12 -6
drivers/block/rbd.c
··· 3047 3047 mutex_unlock(&rbd_dev->watch_mutex); 3048 3048 } 3049 3049 3050 + static void __rbd_lock(struct rbd_device *rbd_dev, const char *cookie) 3051 + { 3052 + struct rbd_client_id cid = rbd_get_cid(rbd_dev); 3053 + 3054 + strcpy(rbd_dev->lock_cookie, cookie); 3055 + rbd_set_owner_cid(rbd_dev, &cid); 3056 + queue_work(rbd_dev->task_wq, &rbd_dev->acquired_lock_work); 3057 + } 3058 + 3050 3059 /* 3051 3060 * lock_rwsem must be held for write 3052 3061 */ 3053 3062 static int rbd_lock(struct rbd_device *rbd_dev) 3054 3063 { 3055 3064 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; 3056 - struct rbd_client_id cid = rbd_get_cid(rbd_dev); 3057 3065 char cookie[32]; 3058 3066 int ret; 3059 3067 ··· 3076 3068 return ret; 3077 3069 3078 3070 rbd_dev->lock_state = RBD_LOCK_STATE_LOCKED; 3079 - strcpy(rbd_dev->lock_cookie, cookie); 3080 - rbd_set_owner_cid(rbd_dev, &cid); 3081 - queue_work(rbd_dev->task_wq, &rbd_dev->acquired_lock_work); 3071 + __rbd_lock(rbd_dev, cookie); 3082 3072 return 0; 3083 3073 } 3084 3074 ··· 3862 3856 queue_delayed_work(rbd_dev->task_wq, 3863 3857 &rbd_dev->lock_dwork, 0); 3864 3858 } else { 3865 - strcpy(rbd_dev->lock_cookie, cookie); 3859 + __rbd_lock(rbd_dev, cookie); 3866 3860 } 3867 3861 } 3868 3862 ··· 4387 4381 segment_size = rbd_obj_bytes(&rbd_dev->header); 4388 4382 blk_queue_max_hw_sectors(q, segment_size / SECTOR_SIZE); 4389 4383 q->limits.max_sectors = queue_max_hw_sectors(q); 4390 - blk_queue_max_segments(q, segment_size / SECTOR_SIZE); 4384 + blk_queue_max_segments(q, USHRT_MAX); 4391 4385 blk_queue_max_segment_size(q, segment_size); 4392 4386 blk_queue_io_min(q, segment_size); 4393 4387 blk_queue_io_opt(q, segment_size);
+23 -12
drivers/gpio/gpiolib.c
··· 2893 2893 EXPORT_SYMBOL_GPL(gpiod_set_raw_value); 2894 2894 2895 2895 /** 2896 + * gpiod_set_value_nocheck() - set a GPIO line value without checking 2897 + * @desc: the descriptor to set the value on 2898 + * @value: value to set 2899 + * 2900 + * This sets the value of a GPIO line backing a descriptor, applying 2901 + * different semantic quirks like active low and open drain/source 2902 + * handling. 2903 + */ 2904 + static void gpiod_set_value_nocheck(struct gpio_desc *desc, int value) 2905 + { 2906 + if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) 2907 + value = !value; 2908 + if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) 2909 + gpio_set_open_drain_value_commit(desc, value); 2910 + else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) 2911 + gpio_set_open_source_value_commit(desc, value); 2912 + else 2913 + gpiod_set_raw_value_commit(desc, value); 2914 + } 2915 + 2916 + /** 2896 2917 * gpiod_set_value() - assign a gpio's value 2897 2918 * @desc: gpio whose value will be assigned 2898 2919 * @value: value to assign ··· 2927 2906 void gpiod_set_value(struct gpio_desc *desc, int value) 2928 2907 { 2929 2908 VALIDATE_DESC_VOID(desc); 2930 - /* Should be using gpiod_set_value_cansleep() */ 2931 2909 WARN_ON(desc->gdev->chip->can_sleep); 2932 - if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) 2933 - value = !value; 2934 - if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) 2935 - gpio_set_open_drain_value_commit(desc, value); 2936 - else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) 2937 - gpio_set_open_source_value_commit(desc, value); 2938 - else 2939 - gpiod_set_raw_value_commit(desc, value); 2910 + gpiod_set_value_nocheck(desc, value); 2940 2911 } 2941 2912 EXPORT_SYMBOL_GPL(gpiod_set_value); 2942 2913 ··· 3256 3243 { 3257 3244 might_sleep_if(extra_checks); 3258 3245 VALIDATE_DESC_VOID(desc); 3259 - if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) 3260 - value = !value; 3261 - gpiod_set_raw_value_commit(desc, value); 3246 + gpiod_set_value_nocheck(desc, value); 3262 3247 } 3263 3248 EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); 3264 3249
+1 -1
drivers/infiniband/core/core_priv.h
··· 314 314 } 315 315 #endif 316 316 317 - struct ib_device *__ib_device_get_by_index(u32 ifindex); 317 + struct ib_device *ib_device_get_by_index(u32 ifindex); 318 318 /* RDMA device netlink */ 319 319 void nldev_init(void); 320 320 void nldev_exit(void);
+17 -1
drivers/infiniband/core/device.c
··· 134 134 return 0; 135 135 } 136 136 137 - struct ib_device *__ib_device_get_by_index(u32 index) 137 + static struct ib_device *__ib_device_get_by_index(u32 index) 138 138 { 139 139 struct ib_device *device; 140 140 ··· 143 143 return device; 144 144 145 145 return NULL; 146 + } 147 + 148 + /* 149 + * Caller is responsible to return refrerence count by calling put_device() 150 + */ 151 + struct ib_device *ib_device_get_by_index(u32 index) 152 + { 153 + struct ib_device *device; 154 + 155 + down_read(&lists_rwsem); 156 + device = __ib_device_get_by_index(index); 157 + if (device) 158 + get_device(&device->dev); 159 + 160 + up_read(&lists_rwsem); 161 + return device; 146 162 } 147 163 148 164 static struct ib_device *__ib_device_get_by_name(const char *name)
+36 -18
drivers/infiniband/core/nldev.c
··· 142 142 143 143 index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]); 144 144 145 - device = __ib_device_get_by_index(index); 145 + device = ib_device_get_by_index(index); 146 146 if (!device) 147 147 return -EINVAL; 148 148 149 149 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 150 - if (!msg) 151 - return -ENOMEM; 150 + if (!msg) { 151 + err = -ENOMEM; 152 + goto err; 153 + } 152 154 153 155 nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 154 156 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET), 155 157 0, 0); 156 158 157 159 err = fill_dev_info(msg, device); 158 - if (err) { 159 - nlmsg_free(msg); 160 - return err; 161 - } 160 + if (err) 161 + goto err_free; 162 162 163 163 nlmsg_end(msg, nlh); 164 164 165 + put_device(&device->dev); 165 166 return rdma_nl_unicast(msg, NETLINK_CB(skb).portid); 167 + 168 + err_free: 169 + nlmsg_free(msg); 170 + err: 171 + put_device(&device->dev); 172 + return err; 166 173 } 167 174 168 175 static int _nldev_get_dumpit(struct ib_device *device, ··· 227 220 return -EINVAL; 228 221 229 222 index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]); 230 - device = __ib_device_get_by_index(index); 223 + device = ib_device_get_by_index(index); 231 224 if (!device) 232 225 return -EINVAL; 233 226 234 227 port = nla_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]); 235 - if (!rdma_is_port_valid(device, port)) 236 - return -EINVAL; 228 + if (!rdma_is_port_valid(device, port)) { 229 + err = -EINVAL; 230 + goto err; 231 + } 237 232 238 233 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 239 - if (!msg) 240 - return -ENOMEM; 234 + if (!msg) { 235 + err = -ENOMEM; 236 + goto err; 237 + } 241 238 242 239 nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 243 240 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET), 244 241 0, 0); 245 242 246 243 err = fill_port_info(msg, device, port); 247 - if (err) { 248 - nlmsg_free(msg); 249 - return err; 250 - } 244 + if (err) 245 + goto err_free; 251 246 252 247 nlmsg_end(msg, nlh); 248 + put_device(&device->dev); 253 249 254 250 return rdma_nl_unicast(msg, NETLINK_CB(skb).portid); 251 + 252 + err_free: 253 + nlmsg_free(msg); 254 + err: 255 + put_device(&device->dev); 256 + return err; 255 257 } 256 258 257 259 static int nldev_port_get_dumpit(struct sk_buff *skb, ··· 281 265 return -EINVAL; 282 266 283 267 ifindex = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]); 284 - device = __ib_device_get_by_index(ifindex); 268 + device = ib_device_get_by_index(ifindex); 285 269 if (!device) 286 270 return -EINVAL; 287 271 ··· 315 299 nlmsg_end(skb, nlh); 316 300 } 317 301 318 - out: cb->args[0] = idx; 302 + out: 303 + put_device(&device->dev); 304 + cb->args[0] = idx; 319 305 return skb->len; 320 306 } 321 307
+1 -1
drivers/infiniband/hw/mlx4/mr.c
··· 642 642 goto err_free_mr; 643 643 644 644 mr->max_pages = max_num_sg; 645 - 646 645 err = mlx4_mr_enable(dev->dev, &mr->mmr); 647 646 if (err) 648 647 goto err_free_pl; ··· 652 653 return &mr->ibmr; 653 654 654 655 err_free_pl: 656 + mr->ibmr.device = pd->device; 655 657 mlx4_free_priv_pages(mr); 656 658 err_free_mr: 657 659 (void) mlx4_mr_free(dev->dev, &mr->mmr);
+18 -7
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 902 902 return 0; 903 903 } 904 904 905 - static void neigh_add_path(struct sk_buff *skb, u8 *daddr, 906 - struct net_device *dev) 905 + static struct ipoib_neigh *neigh_add_path(struct sk_buff *skb, u8 *daddr, 906 + struct net_device *dev) 907 907 { 908 908 struct ipoib_dev_priv *priv = ipoib_priv(dev); 909 909 struct rdma_netdev *rn = netdev_priv(dev); ··· 917 917 spin_unlock_irqrestore(&priv->lock, flags); 918 918 ++dev->stats.tx_dropped; 919 919 dev_kfree_skb_any(skb); 920 - return; 920 + return NULL; 921 + } 922 + 923 + /* To avoid race condition, make sure that the 924 + * neigh will be added only once. 925 + */ 926 + if (unlikely(!list_empty(&neigh->list))) { 927 + spin_unlock_irqrestore(&priv->lock, flags); 928 + return neigh; 921 929 } 922 930 923 931 path = __path_find(dev, daddr + 4); ··· 964 956 path->ah->last_send = rn->send(dev, skb, path->ah->ah, 965 957 IPOIB_QPN(daddr)); 966 958 ipoib_neigh_put(neigh); 967 - return; 959 + return NULL; 968 960 } 969 961 } else { 970 962 neigh->ah = NULL; ··· 981 973 982 974 spin_unlock_irqrestore(&priv->lock, flags); 983 975 ipoib_neigh_put(neigh); 984 - return; 976 + return NULL; 985 977 986 978 err_path: 987 979 ipoib_neigh_free(neigh); ··· 991 983 992 984 spin_unlock_irqrestore(&priv->lock, flags); 993 985 ipoib_neigh_put(neigh); 986 + 987 + return NULL; 994 988 } 995 989 996 990 static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, ··· 1101 1091 case htons(ETH_P_TIPC): 1102 1092 neigh = ipoib_neigh_get(dev, phdr->hwaddr); 1103 1093 if (unlikely(!neigh)) { 1104 - neigh_add_path(skb, phdr->hwaddr, dev); 1105 - return NETDEV_TX_OK; 1094 + neigh = neigh_add_path(skb, phdr->hwaddr, dev); 1095 + if (likely(!neigh)) 1096 + return NETDEV_TX_OK; 1106 1097 } 1107 1098 break; 1108 1099 case htons(ETH_P_ARP):
+4 -1
drivers/infiniband/ulp/ipoib/ipoib_multicast.c
··· 816 816 spin_lock_irqsave(&priv->lock, flags); 817 817 if (!neigh) { 818 818 neigh = ipoib_neigh_alloc(daddr, dev); 819 - if (neigh) { 819 + /* Make sure that the neigh will be added only 820 + * once to mcast list. 821 + */ 822 + if (neigh && list_empty(&neigh->list)) { 820 823 kref_get(&mcast->ah->ref); 821 824 neigh->ah = mcast->ah; 822 825 list_add_tail(&neigh->list, &mcast->neigh_list);
+2 -3
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 1013 1013 return -ENOMEM; 1014 1014 1015 1015 attr->qp_state = IB_QPS_INIT; 1016 - attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ | 1017 - IB_ACCESS_REMOTE_WRITE; 1016 + attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE; 1018 1017 attr->port_num = ch->sport->port; 1019 1018 attr->pkey_index = 0; 1020 1019 ··· 2077 2078 goto destroy_ib; 2078 2079 } 2079 2080 2080 - guid = (__be16 *)&param->primary_path->sgid.global.interface_id; 2081 + guid = (__be16 *)&param->primary_path->dgid.global.interface_id; 2081 2082 snprintf(ch->ini_guid, sizeof(ch->ini_guid), "%04x:%04x:%04x:%04x", 2082 2083 be16_to_cpu(guid[0]), be16_to_cpu(guid[1]), 2083 2084 be16_to_cpu(guid[2]), be16_to_cpu(guid[3]));
+1 -1
drivers/input/joystick/analog.c
··· 163 163 #define GET_TIME(x) do { x = (unsigned int)rdtsc(); } while (0) 164 164 #define DELTA(x,y) ((y)-(x)) 165 165 #define TIME_NAME "TSC" 166 - #elif defined(__alpha__) || defined(CONFIG_MN10300) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_TILE) 166 + #elif defined(__alpha__) || defined(CONFIG_MN10300) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_TILE) 167 167 #define GET_TIME(x) do { x = get_cycles(); } while (0) 168 168 #define DELTA(x,y) ((y)-(x)) 169 169 #define TIME_NAME "get_cycles"
+1 -1
drivers/input/misc/ims-pcu.c
··· 1651 1651 return union_desc; 1652 1652 1653 1653 dev_err(&intf->dev, 1654 - "Union descriptor to short (%d vs %zd\n)", 1654 + "Union descriptor too short (%d vs %zd)\n", 1655 1655 union_desc->bLength, sizeof(*union_desc)); 1656 1656 return NULL; 1657 1657 }
-2
drivers/input/misc/xen-kbdfront.c
··· 326 326 0, width, 0, 0); 327 327 input_set_abs_params(mtouch, ABS_MT_POSITION_Y, 328 328 0, height, 0, 0); 329 - input_set_abs_params(mtouch, ABS_MT_PRESSURE, 330 - 0, 255, 0, 0); 331 329 332 330 ret = input_mt_init_slots(mtouch, num_cont, INPUT_MT_DIRECT); 333 331 if (ret) {
+1 -1
drivers/input/mouse/elantech.c
··· 1613 1613 case 5: 1614 1614 etd->hw_version = 3; 1615 1615 break; 1616 - case 6 ... 14: 1616 + case 6 ... 15: 1617 1617 etd->hw_version = 4; 1618 1618 break; 1619 1619 default:
+7 -3
drivers/input/touchscreen/elants_i2c.c
··· 27 27 #include <linux/module.h> 28 28 #include <linux/input.h> 29 29 #include <linux/interrupt.h> 30 + #include <linux/irq.h> 30 31 #include <linux/platform_device.h> 31 32 #include <linux/async.h> 32 33 #include <linux/i2c.h> ··· 1262 1261 } 1263 1262 1264 1263 /* 1265 - * Systems using device tree should set up interrupt via DTS, 1266 - * the rest will use the default falling edge interrupts. 1264 + * Platform code (ACPI, DTS) should normally set up interrupt 1265 + * for us, but in case it did not let's fall back to using falling 1266 + * edge to be compatible with older Chromebooks. 1267 1267 */ 1268 - irqflags = client->dev.of_node ? 0 : IRQF_TRIGGER_FALLING; 1268 + irqflags = irq_get_trigger_type(client->irq); 1269 + if (!irqflags) 1270 + irqflags = IRQF_TRIGGER_FALLING; 1269 1271 1270 1272 error = devm_request_threaded_irq(&client->dev, client->irq, 1271 1273 NULL, elants_i2c_irq,
+1 -2
drivers/input/touchscreen/hideep.c
··· 10 10 #include <linux/of.h> 11 11 #include <linux/firmware.h> 12 12 #include <linux/delay.h> 13 - #include <linux/gpio.h> 14 - #include <linux/gpio/machine.h> 13 + #include <linux/gpio/consumer.h> 15 14 #include <linux/i2c.h> 16 15 #include <linux/acpi.h> 17 16 #include <linux/interrupt.h>
+13 -4
drivers/iommu/arm-smmu-v3.c
··· 1698 1698 domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; 1699 1699 domain->geometry.aperture_end = (1UL << ias) - 1; 1700 1700 domain->geometry.force_aperture = true; 1701 - smmu_domain->pgtbl_ops = pgtbl_ops; 1702 1701 1703 1702 ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg); 1704 - if (ret < 0) 1703 + if (ret < 0) { 1705 1704 free_io_pgtable_ops(pgtbl_ops); 1705 + return ret; 1706 + } 1706 1707 1707 - return ret; 1708 + smmu_domain->pgtbl_ops = pgtbl_ops; 1709 + return 0; 1708 1710 } 1709 1711 1710 1712 static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid) ··· 1733 1731 1734 1732 static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec) 1735 1733 { 1736 - int i; 1734 + int i, j; 1737 1735 struct arm_smmu_master_data *master = fwspec->iommu_priv; 1738 1736 struct arm_smmu_device *smmu = master->smmu; 1739 1737 1740 1738 for (i = 0; i < fwspec->num_ids; ++i) { 1741 1739 u32 sid = fwspec->ids[i]; 1742 1740 __le64 *step = arm_smmu_get_step_for_sid(smmu, sid); 1741 + 1742 + /* Bridged PCI devices may end up with duplicated IDs */ 1743 + for (j = 0; j < i; j++) 1744 + if (fwspec->ids[j] == sid) 1745 + break; 1746 + if (j < i) 1747 + continue; 1743 1748 1744 1749 arm_smmu_write_strtab_ent(smmu, sid, step, &master->ste); 1745 1750 }
+2 -1
drivers/leds/led-core.c
··· 186 186 unsigned long *delay_on, 187 187 unsigned long *delay_off) 188 188 { 189 - led_stop_software_blink(led_cdev); 189 + del_timer_sync(&led_cdev->blink_timer); 190 190 191 + clear_bit(LED_BLINK_SW, &led_cdev->work_flags); 191 192 clear_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags); 192 193 clear_bit(LED_BLINK_ONESHOT_STOP, &led_cdev->work_flags); 193 194
+1
drivers/mtd/nand/pxa3xx_nand.c
··· 963 963 964 964 switch (command) { 965 965 case NAND_CMD_READ0: 966 + case NAND_CMD_READOOB: 966 967 case NAND_CMD_PAGEPROG: 967 968 info->use_ecc = 1; 968 969 break;
+1 -1
drivers/net/can/flexcan.c
··· 526 526 data = be32_to_cpup((__be32 *)&cf->data[0]); 527 527 flexcan_write(data, &priv->tx_mb->data[0]); 528 528 } 529 - if (cf->can_dlc > 3) { 529 + if (cf->can_dlc > 4) { 530 530 data = be32_to_cpup((__be32 *)&cf->data[4]); 531 531 flexcan_write(data, &priv->tx_mb->data[1]); 532 532 }
+1
drivers/net/can/usb/ems_usb.c
··· 395 395 396 396 if (dev->can.state == CAN_STATE_ERROR_WARNING || 397 397 dev->can.state == CAN_STATE_ERROR_PASSIVE) { 398 + cf->can_id |= CAN_ERR_CRTL; 398 399 cf->data[1] = (txerr > rxerr) ? 399 400 CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE; 400 401 }
+1 -1
drivers/net/can/usb/gs_usb.c
··· 449 449 dev_err(netdev->dev.parent, "Couldn't set bittimings (err=%d)", 450 450 rc); 451 451 452 - return rc; 452 + return (rc > 0) ? 0 : rc; 453 453 } 454 454 455 455 static void gs_usb_xmit_callback(struct urb *urb)
+1 -1
drivers/net/can/vxcan.c
··· 194 194 tbp = peer_tb; 195 195 } 196 196 197 - if (tbp[IFLA_IFNAME]) { 197 + if (ifmp && tbp[IFLA_IFNAME]) { 198 198 nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ); 199 199 name_assign_type = NET_NAME_USER; 200 200 } else {
+6 -3
drivers/net/dsa/b53/b53_common.c
··· 1500 1500 { 1501 1501 struct b53_device *dev = ds->priv; 1502 1502 1503 - /* Older models support a different tag format that we do not 1504 - * support in net/dsa/tag_brcm.c yet. 1503 + /* Older models (5325, 5365) support a different tag format that we do 1504 + * not support in net/dsa/tag_brcm.c yet. 539x and 531x5 require managed 1505 + * mode to be turned on which means we need to specifically manage ARL 1506 + * misses on multicast addresses (TBD). 1505 1507 */ 1506 - if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds, port)) 1508 + if (is5325(dev) || is5365(dev) || is539x(dev) || is531x5(dev) || 1509 + !b53_can_enable_brcm_tags(ds, port)) 1507 1510 return DSA_TAG_PROTO_NONE; 1508 1511 1509 1512 /* Broadcom BCM58xx chips have a flow accelerator on Port 8
+38 -52
drivers/net/ethernet/3com/3c59x.c
··· 602 602 struct sk_buff* rx_skbuff[RX_RING_SIZE]; 603 603 struct sk_buff* tx_skbuff[TX_RING_SIZE]; 604 604 unsigned int cur_rx, cur_tx; /* The next free ring entry */ 605 - unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */ 605 + unsigned int dirty_tx; /* The ring entries to be free()ed. */ 606 606 struct vortex_extra_stats xstats; /* NIC-specific extra stats */ 607 607 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */ 608 608 dma_addr_t tx_skb_dma; /* Allocated DMA address for bus master ctrl DMA. */ ··· 618 618 619 619 /* The remainder are related to chip state, mostly media selection. */ 620 620 struct timer_list timer; /* Media selection timer. */ 621 - struct timer_list rx_oom_timer; /* Rx skb allocation retry timer */ 622 621 int options; /* User-settable misc. driver options. */ 623 622 unsigned int media_override:4, /* Passed-in media type. */ 624 623 default_media:4, /* Read from the EEPROM/Wn3_Config. */ ··· 759 760 static int mdio_read(struct net_device *dev, int phy_id, int location); 760 761 static void mdio_write(struct net_device *vp, int phy_id, int location, int value); 761 762 static void vortex_timer(struct timer_list *t); 762 - static void rx_oom_timer(struct timer_list *t); 763 763 static netdev_tx_t vortex_start_xmit(struct sk_buff *skb, 764 764 struct net_device *dev); 765 765 static netdev_tx_t boomerang_start_xmit(struct sk_buff *skb, ··· 1599 1601 1600 1602 timer_setup(&vp->timer, vortex_timer, 0); 1601 1603 mod_timer(&vp->timer, RUN_AT(media_tbl[dev->if_port].wait)); 1602 - timer_setup(&vp->rx_oom_timer, rx_oom_timer, 0); 1603 1604 1604 1605 if (vortex_debug > 1) 1605 1606 pr_debug("%s: Initial media type %s.\n", ··· 1673 1676 window_write16(vp, 0x0040, 4, Wn4_NetDiag); 1674 1677 1675 1678 if (vp->full_bus_master_rx) { /* Boomerang bus master. */ 1676 - vp->cur_rx = vp->dirty_rx = 0; 1679 + vp->cur_rx = 0; 1677 1680 /* Initialize the RxEarly register as recommended. */ 1678 1681 iowrite16(SetRxThreshold + (1536>>2), ioaddr + EL3_CMD); 1679 1682 iowrite32(0x0020, ioaddr + PktStatus); ··· 1726 1729 struct vortex_private *vp = netdev_priv(dev); 1727 1730 int i; 1728 1731 int retval; 1732 + dma_addr_t dma; 1729 1733 1730 1734 /* Use the now-standard shared IRQ implementation. */ 1731 1735 if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? ··· 1751 1753 break; /* Bad news! */ 1752 1754 1753 1755 skb_reserve(skb, NET_IP_ALIGN); /* Align IP on 16 byte boundaries */ 1754 - vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); 1756 + dma = pci_map_single(VORTEX_PCI(vp), skb->data, 1757 + PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 1758 + if (dma_mapping_error(&VORTEX_PCI(vp)->dev, dma)) 1759 + break; 1760 + vp->rx_ring[i].addr = cpu_to_le32(dma); 1755 1761 } 1756 1762 if (i != RX_RING_SIZE) { 1757 1763 pr_emerg("%s: no memory for rx ring\n", dev->name); ··· 2069 2067 int len = (skb->len + 3) & ~3; 2070 2068 vp->tx_skb_dma = pci_map_single(VORTEX_PCI(vp), skb->data, len, 2071 2069 PCI_DMA_TODEVICE); 2070 + if (dma_mapping_error(&VORTEX_PCI(vp)->dev, vp->tx_skb_dma)) { 2071 + dev_kfree_skb_any(skb); 2072 + dev->stats.tx_dropped++; 2073 + return NETDEV_TX_OK; 2074 + } 2075 + 2072 2076 spin_lock_irq(&vp->window_lock); 2073 2077 window_set(vp, 7); 2074 2078 iowrite32(vp->tx_skb_dma, ioaddr + Wn7_MasterAddr); ··· 2601 2593 int entry = vp->cur_rx % RX_RING_SIZE; 2602 2594 void __iomem *ioaddr = vp->ioaddr; 2603 2595 int rx_status; 2604 - int rx_work_limit = vp->dirty_rx + RX_RING_SIZE - vp->cur_rx; 2596 + int rx_work_limit = RX_RING_SIZE; 2605 2597 2606 2598 if (vortex_debug > 5) 2607 2599 pr_debug("boomerang_rx(): status %4.4x\n", ioread16(ioaddr+EL3_STATUS)); ··· 2622 2614 } else { 2623 2615 /* The packet length: up to 4.5K!. */ 2624 2616 int pkt_len = rx_status & 0x1fff; 2625 - struct sk_buff *skb; 2617 + struct sk_buff *skb, *newskb; 2618 + dma_addr_t newdma; 2626 2619 dma_addr_t dma = le32_to_cpu(vp->rx_ring[entry].addr); 2627 2620 2628 2621 if (vortex_debug > 4) ··· 2642 2633 pci_dma_sync_single_for_device(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2643 2634 vp->rx_copy++; 2644 2635 } else { 2636 + /* Pre-allocate the replacement skb. If it or its 2637 + * mapping fails then recycle the buffer thats already 2638 + * in place 2639 + */ 2640 + newskb = netdev_alloc_skb_ip_align(dev, PKT_BUF_SZ); 2641 + if (!newskb) { 2642 + dev->stats.rx_dropped++; 2643 + goto clear_complete; 2644 + } 2645 + newdma = pci_map_single(VORTEX_PCI(vp), newskb->data, 2646 + PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2647 + if (dma_mapping_error(&VORTEX_PCI(vp)->dev, newdma)) { 2648 + dev->stats.rx_dropped++; 2649 + consume_skb(newskb); 2650 + goto clear_complete; 2651 + } 2652 + 2645 2653 /* Pass up the skbuff already on the Rx ring. */ 2646 2654 skb = vp->rx_skbuff[entry]; 2647 - vp->rx_skbuff[entry] = NULL; 2655 + vp->rx_skbuff[entry] = newskb; 2656 + vp->rx_ring[entry].addr = cpu_to_le32(newdma); 2648 2657 skb_put(skb, pkt_len); 2649 2658 pci_unmap_single(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2650 2659 vp->rx_nocopy++; ··· 2680 2653 netif_rx(skb); 2681 2654 dev->stats.rx_packets++; 2682 2655 } 2683 - entry = (++vp->cur_rx) % RX_RING_SIZE; 2684 - } 2685 - /* Refill the Rx ring buffers. */ 2686 - for (; vp->cur_rx - vp->dirty_rx > 0; vp->dirty_rx++) { 2687 - struct sk_buff *skb; 2688 - entry = vp->dirty_rx % RX_RING_SIZE; 2689 - if (vp->rx_skbuff[entry] == NULL) { 2690 - skb = netdev_alloc_skb_ip_align(dev, PKT_BUF_SZ); 2691 - if (skb == NULL) { 2692 - static unsigned long last_jif; 2693 - if (time_after(jiffies, last_jif + 10 * HZ)) { 2694 - pr_warn("%s: memory shortage\n", 2695 - dev->name); 2696 - last_jif = jiffies; 2697 - } 2698 - if ((vp->cur_rx - vp->dirty_rx) == RX_RING_SIZE) 2699 - mod_timer(&vp->rx_oom_timer, RUN_AT(HZ * 1)); 2700 - break; /* Bad news! */ 2701 - } 2702 2656 2703 - vp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); 2704 - vp->rx_skbuff[entry] = skb; 2705 - } 2657 + clear_complete: 2706 2658 vp->rx_ring[entry].status = 0; /* Clear complete bit. */ 2707 2659 iowrite16(UpUnstall, ioaddr + EL3_CMD); 2660 + entry = (++vp->cur_rx) % RX_RING_SIZE; 2708 2661 } 2709 2662 return 0; 2710 - } 2711 - 2712 - /* 2713 - * If we've hit a total OOM refilling the Rx ring we poll once a second 2714 - * for some memory. Otherwise there is no way to restart the rx process. 2715 - */ 2716 - static void 2717 - rx_oom_timer(struct timer_list *t) 2718 - { 2719 - struct vortex_private *vp = from_timer(vp, t, rx_oom_timer); 2720 - struct net_device *dev = vp->mii.dev; 2721 - 2722 - spin_lock_irq(&vp->lock); 2723 - if ((vp->cur_rx - vp->dirty_rx) == RX_RING_SIZE) /* This test is redundant, but makes me feel good */ 2724 - boomerang_rx(dev); 2725 - if (vortex_debug > 1) { 2726 - pr_debug("%s: rx_oom_timer %s\n", dev->name, 2727 - ((vp->cur_rx - vp->dirty_rx) != RX_RING_SIZE) ? "succeeded" : "retrying"); 2728 - } 2729 - spin_unlock_irq(&vp->lock); 2730 2663 } 2731 2664 2732 2665 static void ··· 2698 2711 netdev_reset_queue(dev); 2699 2712 netif_stop_queue(dev); 2700 2713 2701 - del_timer_sync(&vp->rx_oom_timer); 2702 2714 del_timer_sync(&vp->timer); 2703 2715 2704 2716 /* Turn off statistics ASAP. We update dev->stats below. */
+30 -15
drivers/net/ethernet/amazon/ena/ena_netdev.c
··· 75 75 MODULE_DEVICE_TABLE(pci, ena_pci_tbl); 76 76 77 77 static int ena_rss_init_default(struct ena_adapter *adapter); 78 + static void check_for_admin_com_state(struct ena_adapter *adapter); 79 + static void ena_destroy_device(struct ena_adapter *adapter); 80 + static int ena_restore_device(struct ena_adapter *adapter); 78 81 79 82 static void ena_tx_timeout(struct net_device *dev) 80 83 { ··· 1568 1565 1569 1566 static int ena_up_complete(struct ena_adapter *adapter) 1570 1567 { 1571 - int rc, i; 1568 + int rc; 1572 1569 1573 1570 rc = ena_rss_configure(adapter); 1574 1571 if (rc) ··· 1586 1583 ena_restore_ethtool_params(adapter); 1587 1584 1588 1585 ena_napi_enable_all(adapter); 1589 - 1590 - /* Enable completion queues interrupt */ 1591 - for (i = 0; i < adapter->num_queues; i++) 1592 - ena_unmask_interrupt(&adapter->tx_ring[i], 1593 - &adapter->rx_ring[i]); 1594 - 1595 - /* schedule napi in case we had pending packets 1596 - * from the last time we disable napi 1597 - */ 1598 - for (i = 0; i < adapter->num_queues; i++) 1599 - napi_schedule(&adapter->ena_napi[i].napi); 1600 1586 1601 1587 return 0; 1602 1588 } ··· 1723 1731 1724 1732 static int ena_up(struct ena_adapter *adapter) 1725 1733 { 1726 - int rc; 1734 + int rc, i; 1727 1735 1728 1736 netdev_dbg(adapter->netdev, "%s\n", __func__); 1729 1737 ··· 1765 1773 u64_stats_update_end(&adapter->syncp); 1766 1774 1767 1775 set_bit(ENA_FLAG_DEV_UP, &adapter->flags); 1776 + 1777 + /* Enable completion queues interrupt */ 1778 + for (i = 0; i < adapter->num_queues; i++) 1779 + ena_unmask_interrupt(&adapter->tx_ring[i], 1780 + &adapter->rx_ring[i]); 1781 + 1782 + /* schedule napi in case we had pending packets 1783 + * from the last time we disable napi 1784 + */ 1785 + for (i = 0; i < adapter->num_queues; i++) 1786 + napi_schedule(&adapter->ena_napi[i].napi); 1768 1787 1769 1788 return rc; 1770 1789 ··· 1886 1883 1887 1884 if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) 1888 1885 ena_down(adapter); 1886 + 1887 + /* Check for device status and issue reset if needed*/ 1888 + check_for_admin_com_state(adapter); 1889 + if (unlikely(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))) { 1890 + netif_err(adapter, ifdown, adapter->netdev, 1891 + "Destroy failure, restarting device\n"); 1892 + ena_dump_stats_to_dmesg(adapter); 1893 + /* rtnl lock already obtained in dev_ioctl() layer */ 1894 + ena_destroy_device(adapter); 1895 + ena_restore_device(adapter); 1896 + } 1889 1897 1890 1898 return 0; 1891 1899 } ··· 2558 2544 2559 2545 ena_com_set_admin_running_state(ena_dev, false); 2560 2546 2561 - ena_close(netdev); 2547 + if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) 2548 + ena_down(adapter); 2562 2549 2563 2550 /* Before releasing the ENA resources, a device reset is required. 2564 2551 * (to prevent the device from accessing them). 2565 - * In case the reset flag is set and the device is up, ena_close 2552 + * In case the reset flag is set and the device is up, ena_down() 2566 2553 * already perform the reset, so it can be skipped. 2567 2554 */ 2568 2555 if (!(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags) && dev_up))
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
··· 70 70 netdev_err(bp->dev, "vf ndo called though sriov is disabled\n"); 71 71 return -EINVAL; 72 72 } 73 - if (vf_id >= bp->pf.max_vfs) { 73 + if (vf_id >= bp->pf.active_vfs) { 74 74 netdev_err(bp->dev, "Invalid VF id %d\n", vf_id); 75 75 return -EINVAL; 76 76 }
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
··· 421 421 } 422 422 423 423 /* If all IP and L4 fields are wildcarded then this is an L2 flow */ 424 - if (is_wildcard(&l3_mask, sizeof(l3_mask)) && 424 + if (is_wildcard(l3_mask, sizeof(*l3_mask)) && 425 425 is_wildcard(&flow->l4_mask, sizeof(flow->l4_mask))) { 426 426 flow_flags |= CFA_FLOW_ALLOC_REQ_FLAGS_FLOWTYPE_L2; 427 427 } else {
-1
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 344 344 345 345 unsigned int sf_size; /* serial flash size in bytes */ 346 346 unsigned int sf_nsec; /* # of flash sectors */ 347 - unsigned int sf_fw_start; /* start of FW image in flash */ 348 347 349 348 unsigned int fw_vers; /* firmware version */ 350 349 unsigned int bs_vers; /* bootstrap version */
+8 -9
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 2844 2844 SF_RD_DATA_FAST = 0xb, /* read flash */ 2845 2845 SF_RD_ID = 0x9f, /* read ID */ 2846 2846 SF_ERASE_SECTOR = 0xd8, /* erase sector */ 2847 - 2848 - FW_MAX_SIZE = 16 * SF_SEC_SIZE, 2849 2847 }; 2850 2848 2851 2849 /** ··· 3556 3558 const __be32 *p = (const __be32 *)fw_data; 3557 3559 const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data; 3558 3560 unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec; 3559 - unsigned int fw_img_start = adap->params.sf_fw_start; 3560 - unsigned int fw_start_sec = fw_img_start / sf_sec_size; 3561 + unsigned int fw_start_sec = FLASH_FW_START_SEC; 3562 + unsigned int fw_size = FLASH_FW_MAX_SIZE; 3563 + unsigned int fw_start = FLASH_FW_START; 3561 3564 3562 3565 if (!size) { 3563 3566 dev_err(adap->pdev_dev, "FW image has no data\n"); ··· 3574 3575 "FW image size differs from size in FW header\n"); 3575 3576 return -EINVAL; 3576 3577 } 3577 - if (size > FW_MAX_SIZE) { 3578 + if (size > fw_size) { 3578 3579 dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n", 3579 - FW_MAX_SIZE); 3580 + fw_size); 3580 3581 return -EFBIG; 3581 3582 } 3582 3583 if (!t4_fw_matches_chip(adap, hdr)) ··· 3603 3604 */ 3604 3605 memcpy(first_page, fw_data, SF_PAGE_SIZE); 3605 3606 ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff); 3606 - ret = t4_write_flash(adap, fw_img_start, SF_PAGE_SIZE, first_page); 3607 + ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page); 3607 3608 if (ret) 3608 3609 goto out; 3609 3610 3610 - addr = fw_img_start; 3611 + addr = fw_start; 3611 3612 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { 3612 3613 addr += SF_PAGE_SIZE; 3613 3614 fw_data += SF_PAGE_SIZE; ··· 3617 3618 } 3618 3619 3619 3620 ret = t4_write_flash(adap, 3620 - fw_img_start + offsetof(struct fw_hdr, fw_ver), 3621 + fw_start + offsetof(struct fw_hdr, fw_ver), 3621 3622 sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver); 3622 3623 out: 3623 3624 if (ret)
+6 -1
drivers/net/ethernet/freescale/fec_main.c
··· 3469 3469 goto failed_regulator; 3470 3470 } 3471 3471 } else { 3472 + if (PTR_ERR(fep->reg_phy) == -EPROBE_DEFER) { 3473 + ret = -EPROBE_DEFER; 3474 + goto failed_regulator; 3475 + } 3472 3476 fep->reg_phy = NULL; 3473 3477 } 3474 3478 ··· 3556 3552 failed_clk: 3557 3553 if (of_phy_is_fixed_link(np)) 3558 3554 of_phy_deregister_fixed_link(np); 3559 - failed_phy: 3560 3555 of_node_put(phy_node); 3556 + failed_phy: 3557 + dev_id--; 3561 3558 failed_ioremap: 3562 3559 free_netdev(ndev); 3563 3560
+1 -2
drivers/net/ethernet/freescale/gianfar_ptp.c
··· 319 319 now = tmr_cnt_read(etsects); 320 320 now += delta; 321 321 tmr_cnt_write(etsects, now); 322 + set_fipers(etsects); 322 323 323 324 spin_unlock_irqrestore(&etsects->lock, flags); 324 - 325 - set_fipers(etsects); 326 325 327 326 return 0; 328 327 }
+2 -1
drivers/net/ethernet/intel/e1000/e1000.h
··· 331 331 enum e1000_state_t { 332 332 __E1000_TESTING, 333 333 __E1000_RESETTING, 334 - __E1000_DOWN 334 + __E1000_DOWN, 335 + __E1000_DISABLED 335 336 }; 336 337 337 338 #undef pr_fmt
+22 -5
drivers/net/ethernet/intel/e1000/e1000_main.c
··· 945 945 static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 946 946 { 947 947 struct net_device *netdev; 948 - struct e1000_adapter *adapter; 948 + struct e1000_adapter *adapter = NULL; 949 949 struct e1000_hw *hw; 950 950 951 951 static int cards_found; ··· 955 955 u16 tmp = 0; 956 956 u16 eeprom_apme_mask = E1000_EEPROM_APME; 957 957 int bars, need_ioport; 958 + bool disable_dev = false; 958 959 959 960 /* do not allocate ioport bars when not needed */ 960 961 need_ioport = e1000_is_need_ioport(pdev); ··· 1260 1259 iounmap(hw->ce4100_gbe_mdio_base_virt); 1261 1260 iounmap(hw->hw_addr); 1262 1261 err_ioremap: 1262 + disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags); 1263 1263 free_netdev(netdev); 1264 1264 err_alloc_etherdev: 1265 1265 pci_release_selected_regions(pdev, bars); 1266 1266 err_pci_reg: 1267 - pci_disable_device(pdev); 1267 + if (!adapter || disable_dev) 1268 + pci_disable_device(pdev); 1268 1269 return err; 1269 1270 } 1270 1271 ··· 1284 1281 struct net_device *netdev = pci_get_drvdata(pdev); 1285 1282 struct e1000_adapter *adapter = netdev_priv(netdev); 1286 1283 struct e1000_hw *hw = &adapter->hw; 1284 + bool disable_dev; 1287 1285 1288 1286 e1000_down_and_stop(adapter); 1289 1287 e1000_release_manageability(adapter); ··· 1303 1299 iounmap(hw->flash_address); 1304 1300 pci_release_selected_regions(pdev, adapter->bars); 1305 1301 1302 + disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags); 1306 1303 free_netdev(netdev); 1307 1304 1308 - pci_disable_device(pdev); 1305 + if (disable_dev) 1306 + pci_disable_device(pdev); 1309 1307 } 1310 1308 1311 1309 /** ··· 5162 5156 if (netif_running(netdev)) 5163 5157 e1000_free_irq(adapter); 5164 5158 5165 - pci_disable_device(pdev); 5159 + if (!test_and_set_bit(__E1000_DISABLED, &adapter->flags)) 5160 + pci_disable_device(pdev); 5166 5161 5167 5162 return 0; 5168 5163 } ··· 5207 5200 pr_err("Cannot enable PCI device from suspend\n"); 5208 5201 return err; 5209 5202 } 5203 + 5204 + /* flush memory to make sure state is correct */ 5205 + smp_mb__before_atomic(); 5206 + clear_bit(__E1000_DISABLED, &adapter->flags); 5210 5207 pci_set_master(pdev); 5211 5208 5212 5209 pci_enable_wake(pdev, PCI_D3hot, 0); ··· 5285 5274 5286 5275 if (netif_running(netdev)) 5287 5276 e1000_down(adapter); 5288 - pci_disable_device(pdev); 5277 + 5278 + if (!test_and_set_bit(__E1000_DISABLED, &adapter->flags)) 5279 + pci_disable_device(pdev); 5289 5280 5290 5281 /* Request a slot slot reset. */ 5291 5282 return PCI_ERS_RESULT_NEED_RESET; ··· 5315 5302 pr_err("Cannot re-enable PCI device after reset.\n"); 5316 5303 return PCI_ERS_RESULT_DISCONNECT; 5317 5304 } 5305 + 5306 + /* flush memory to make sure state is correct */ 5307 + smp_mb__before_atomic(); 5308 + clear_bit(__E1000_DISABLED, &adapter->flags); 5318 5309 pci_set_master(pdev); 5319 5310 5320 5311 pci_enable_wake(pdev, PCI_D3hot, 0);
+8 -3
drivers/net/ethernet/intel/e1000e/ich8lan.c
··· 1367 1367 * Checks to see of the link status of the hardware has changed. If a 1368 1368 * change in link status has been detected, then we read the PHY registers 1369 1369 * to get the current speed/duplex if link exists. 1370 + * 1371 + * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link 1372 + * up). 1370 1373 **/ 1371 1374 static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) 1372 1375 { ··· 1385 1382 * Change or Rx Sequence Error interrupt. 1386 1383 */ 1387 1384 if (!mac->get_link_status) 1388 - return 0; 1385 + return 1; 1389 1386 1390 1387 /* First we want to see if the MII Status Register reports 1391 1388 * link. If so, then we want to get the current speed/duplex ··· 1616 1613 * different link partner. 1617 1614 */ 1618 1615 ret_val = e1000e_config_fc_after_link_up(hw); 1619 - if (ret_val) 1616 + if (ret_val) { 1620 1617 e_dbg("Error configuring flow control\n"); 1618 + return ret_val; 1619 + } 1621 1620 1622 - return ret_val; 1621 + return 1; 1623 1622 } 1624 1623 1625 1624 static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
+26 -11
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 1573 1573 else 1574 1574 netdev_info(netdev, "set new mac address %pM\n", addr->sa_data); 1575 1575 1576 + /* Copy the address first, so that we avoid a possible race with 1577 + * .set_rx_mode(). If we copy after changing the address in the filter 1578 + * list, we might open ourselves to a narrow race window where 1579 + * .set_rx_mode could delete our dev_addr filter and prevent traffic 1580 + * from passing. 1581 + */ 1582 + ether_addr_copy(netdev->dev_addr, addr->sa_data); 1583 + 1576 1584 spin_lock_bh(&vsi->mac_filter_hash_lock); 1577 1585 i40e_del_mac_filter(vsi, netdev->dev_addr); 1578 1586 i40e_add_mac_filter(vsi, addr->sa_data); 1579 1587 spin_unlock_bh(&vsi->mac_filter_hash_lock); 1580 - ether_addr_copy(netdev->dev_addr, addr->sa_data); 1581 1588 if (vsi->type == I40E_VSI_MAIN) { 1582 1589 i40e_status ret; 1583 1590 ··· 1929 1922 { 1930 1923 struct i40e_netdev_priv *np = netdev_priv(netdev); 1931 1924 struct i40e_vsi *vsi = np->vsi; 1925 + 1926 + /* Under some circumstances, we might receive a request to delete 1927 + * our own device address from our uc list. Because we store the 1928 + * device address in the VSI's MAC/VLAN filter list, we need to ignore 1929 + * such requests and not delete our device address from this list. 1930 + */ 1931 + if (ether_addr_equal(addr, netdev->dev_addr)) 1932 + return 0; 1932 1933 1933 1934 i40e_del_mac_filter(vsi, addr); 1934 1935 ··· 6053 6038 /* Set Bit 7 to be valid */ 6054 6039 mode = I40E_AQ_SET_SWITCH_BIT7_VALID; 6055 6040 6056 - /* Set L4type to both TCP and UDP support */ 6057 - mode |= I40E_AQ_SET_SWITCH_L4_TYPE_BOTH; 6041 + /* Set L4type for TCP support */ 6042 + mode |= I40E_AQ_SET_SWITCH_L4_TYPE_TCP; 6058 6043 6059 6044 /* Set cloud filter mode */ 6060 6045 mode |= I40E_AQ_SET_SWITCH_MODE_NON_TUNNEL; ··· 6984 6969 is_valid_ether_addr(filter->src_mac)) || 6985 6970 (is_multicast_ether_addr(filter->dst_mac) && 6986 6971 is_multicast_ether_addr(filter->src_mac))) 6987 - return -EINVAL; 6972 + return -EOPNOTSUPP; 6988 6973 6989 - /* Make sure port is specified, otherwise bail out, for channel 6990 - * specific cloud filter needs 'L4 port' to be non-zero 6974 + /* Big buffer cloud filter needs 'L4 port' to be non-zero. Also, UDP 6975 + * ports are not supported via big buffer now. 6991 6976 */ 6992 - if (!filter->dst_port) 6993 - return -EINVAL; 6977 + if (!filter->dst_port || filter->ip_proto == IPPROTO_UDP) 6978 + return -EOPNOTSUPP; 6994 6979 6995 6980 /* adding filter using src_port/src_ip is not supported at this stage */ 6996 6981 if (filter->src_port || filter->src_ipv4 || 6997 6982 !ipv6_addr_any(&filter->ip.v6.src_ip6)) 6998 - return -EINVAL; 6983 + return -EOPNOTSUPP; 6999 6984 7000 6985 /* copy element needed to add cloud filter from filter */ 7001 6986 i40e_set_cld_element(filter, &cld_filter.element); ··· 7006 6991 is_multicast_ether_addr(filter->src_mac)) { 7007 6992 /* MAC + IP : unsupported mode */ 7008 6993 if (filter->dst_ipv4) 7009 - return -EINVAL; 6994 + return -EOPNOTSUPP; 7010 6995 7011 6996 /* since we validated that L4 port must be valid before 7012 6997 * we get here, start with respective "flags" value ··· 7371 7356 7372 7357 if (tc < 0) { 7373 7358 dev_err(&vsi->back->pdev->dev, "Invalid traffic class\n"); 7374 - return -EINVAL; 7359 + return -EOPNOTSUPP; 7375 7360 } 7376 7361 7377 7362 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
+23 -3
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 3047 3047 /* Walk through fragments adding latest fragment, testing it, and 3048 3048 * then removing stale fragments from the sum. 3049 3049 */ 3050 - stale = &skb_shinfo(skb)->frags[0]; 3051 - for (;;) { 3050 + for (stale = &skb_shinfo(skb)->frags[0];; stale++) { 3051 + int stale_size = skb_frag_size(stale); 3052 + 3052 3053 sum += skb_frag_size(frag++); 3054 + 3055 + /* The stale fragment may present us with a smaller 3056 + * descriptor than the actual fragment size. To account 3057 + * for that we need to remove all the data on the front and 3058 + * figure out what the remainder would be in the last 3059 + * descriptor associated with the fragment. 3060 + */ 3061 + if (stale_size > I40E_MAX_DATA_PER_TXD) { 3062 + int align_pad = -(stale->page_offset) & 3063 + (I40E_MAX_READ_REQ_SIZE - 1); 3064 + 3065 + sum -= align_pad; 3066 + stale_size -= align_pad; 3067 + 3068 + do { 3069 + sum -= I40E_MAX_DATA_PER_TXD_ALIGNED; 3070 + stale_size -= I40E_MAX_DATA_PER_TXD_ALIGNED; 3071 + } while (stale_size > I40E_MAX_DATA_PER_TXD); 3072 + } 3053 3073 3054 3074 /* if sum is negative we failed to make sufficient progress */ 3055 3075 if (sum < 0) ··· 3078 3058 if (!nr_frags--) 3079 3059 break; 3080 3060 3081 - sum -= skb_frag_size(stale++); 3061 + sum -= stale_size; 3082 3062 } 3083 3063 3084 3064 return false;
+23 -3
drivers/net/ethernet/intel/i40evf/i40e_txrx.c
··· 2012 2012 /* Walk through fragments adding latest fragment, testing it, and 2013 2013 * then removing stale fragments from the sum. 2014 2014 */ 2015 - stale = &skb_shinfo(skb)->frags[0]; 2016 - for (;;) { 2015 + for (stale = &skb_shinfo(skb)->frags[0];; stale++) { 2016 + int stale_size = skb_frag_size(stale); 2017 + 2017 2018 sum += skb_frag_size(frag++); 2019 + 2020 + /* The stale fragment may present us with a smaller 2021 + * descriptor than the actual fragment size. To account 2022 + * for that we need to remove all the data on the front and 2023 + * figure out what the remainder would be in the last 2024 + * descriptor associated with the fragment. 2025 + */ 2026 + if (stale_size > I40E_MAX_DATA_PER_TXD) { 2027 + int align_pad = -(stale->page_offset) & 2028 + (I40E_MAX_READ_REQ_SIZE - 1); 2029 + 2030 + sum -= align_pad; 2031 + stale_size -= align_pad; 2032 + 2033 + do { 2034 + sum -= I40E_MAX_DATA_PER_TXD_ALIGNED; 2035 + stale_size -= I40E_MAX_DATA_PER_TXD_ALIGNED; 2036 + } while (stale_size > I40E_MAX_DATA_PER_TXD); 2037 + } 2018 2038 2019 2039 /* if sum is negative we failed to make sufficient progress */ 2020 2040 if (sum < 0) ··· 2043 2023 if (!nr_frags--) 2044 2024 break; 2045 2025 2046 - sum -= skb_frag_size(stale++); 2026 + sum -= stale_size; 2047 2027 } 2048 2028 2049 2029 return false;
+6 -1
drivers/net/ethernet/mellanox/mlxsw/pci.c
··· 1643 1643 return 0; 1644 1644 } 1645 1645 1646 - wmb(); /* reset needs to be written before we read control register */ 1646 + /* Reset needs to be written before we read control register, and 1647 + * we must wait for the HW to become responsive once again 1648 + */ 1649 + wmb(); 1650 + msleep(MLXSW_PCI_SW_RESET_WAIT_MSECS); 1651 + 1647 1652 end = jiffies + msecs_to_jiffies(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS); 1648 1653 do { 1649 1654 u32 val = mlxsw_pci_read32(mlxsw_pci, FW_READY);
+1
drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
··· 59 59 #define MLXSW_PCI_SW_RESET 0xF0010 60 60 #define MLXSW_PCI_SW_RESET_RST_BIT BIT(0) 61 61 #define MLXSW_PCI_SW_RESET_TIMEOUT_MSECS 5000 62 + #define MLXSW_PCI_SW_RESET_WAIT_MSECS 100 62 63 #define MLXSW_PCI_FW_READY 0xA1844 63 64 #define MLXSW_PCI_FW_READY_MASK 0xFFFF 64 65 #define MLXSW_PCI_FW_READY_MAGIC 0x5E
+9 -2
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 4376 4376 } 4377 4377 if (!info->linking) 4378 4378 break; 4379 - if (netdev_has_any_upper_dev(upper_dev)) { 4379 + if (netdev_has_any_upper_dev(upper_dev) && 4380 + (!netif_is_bridge_master(upper_dev) || 4381 + !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, 4382 + upper_dev))) { 4380 4383 NL_SET_ERR_MSG(extack, 4381 4384 "spectrum: Enslaving a port to a device that already has an upper device is not supported"); 4382 4385 return -EINVAL; ··· 4507 4504 u16 vid) 4508 4505 { 4509 4506 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); 4507 + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; 4510 4508 struct netdev_notifier_changeupper_info *info = ptr; 4511 4509 struct netlink_ext_ack *extack; 4512 4510 struct net_device *upper_dev; ··· 4524 4520 } 4525 4521 if (!info->linking) 4526 4522 break; 4527 - if (netdev_has_any_upper_dev(upper_dev)) { 4523 + if (netdev_has_any_upper_dev(upper_dev) && 4524 + (!netif_is_bridge_master(upper_dev) || 4525 + !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, 4526 + upper_dev))) { 4528 4527 NL_SET_ERR_MSG(extack, "spectrum: Enslaving a port to a device that already has an upper device is not supported"); 4529 4528 return -EINVAL; 4530 4529 }
+2
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
··· 365 365 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, 366 366 struct net_device *brport_dev, 367 367 struct net_device *br_dev); 368 + bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 369 + const struct net_device *br_dev); 368 370 369 371 /* spectrum.c */ 370 372 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
+4 -3
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
··· 46 46 int tclass_num, u32 min, u32 max, 47 47 u32 probability, bool is_ecn) 48 48 { 49 - char cwtp_cmd[max_t(u8, MLXSW_REG_CWTP_LEN, MLXSW_REG_CWTPM_LEN)]; 49 + char cwtpm_cmd[MLXSW_REG_CWTPM_LEN]; 50 + char cwtp_cmd[MLXSW_REG_CWTP_LEN]; 50 51 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; 51 52 int err; 52 53 ··· 61 60 if (err) 62 61 return err; 63 62 64 - mlxsw_reg_cwtpm_pack(cwtp_cmd, mlxsw_sp_port->local_port, tclass_num, 63 + mlxsw_reg_cwtpm_pack(cwtpm_cmd, mlxsw_sp_port->local_port, tclass_num, 65 64 MLXSW_REG_CWTP_DEFAULT_PROFILE, true, is_ecn); 66 65 67 - return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(cwtpm), cwtp_cmd); 66 + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(cwtpm), cwtpm_cmd); 68 67 } 69 68 70 69 static int
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 3228 3228 { 3229 3229 if (!removing) 3230 3230 nh->should_offload = 1; 3231 - else if (nh->offloaded) 3231 + else 3232 3232 nh->should_offload = 0; 3233 3233 nh->update = 1; 3234 3234 }
+6
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
··· 152 152 return NULL; 153 153 } 154 154 155 + bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 156 + const struct net_device *br_dev) 157 + { 158 + return !!mlxsw_sp_bridge_device_find(mlxsw_sp->bridge, br_dev); 159 + } 160 + 155 161 static struct mlxsw_sp_bridge_device * 156 162 mlxsw_sp_bridge_device_create(struct mlxsw_sp_bridge *bridge, 157 163 struct net_device *br_dev)
+2
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
··· 568 568 return err; 569 569 } 570 570 nn_writeb(nn, ctrl_offset, entry->entry); 571 + nfp_net_irq_unmask(nn, entry->entry); 571 572 572 573 return 0; 573 574 } ··· 583 582 unsigned int vector_idx) 584 583 { 585 584 nn_writeb(nn, ctrl_offset, 0xff); 585 + nn_pci_flush(nn); 586 586 free_irq(nn->irq_entries[vector_idx].vector, nn); 587 587 } 588 588
+26 -7
drivers/net/ethernet/renesas/sh_eth.c
··· 147 147 [FWNLCR0] = 0x0090, 148 148 [FWALCR0] = 0x0094, 149 149 [TXNLCR1] = 0x00a0, 150 - [TXALCR1] = 0x00a0, 150 + [TXALCR1] = 0x00a4, 151 151 [RXNLCR1] = 0x00a8, 152 152 [RXALCR1] = 0x00ac, 153 153 [FWNLCR1] = 0x00b0, ··· 399 399 [FWNLCR0] = 0x0090, 400 400 [FWALCR0] = 0x0094, 401 401 [TXNLCR1] = 0x00a0, 402 - [TXALCR1] = 0x00a0, 402 + [TXALCR1] = 0x00a4, 403 403 [RXNLCR1] = 0x00a8, 404 404 [RXALCR1] = 0x00ac, 405 405 [FWNLCR1] = 0x00b0, ··· 3225 3225 /* ioremap the TSU registers */ 3226 3226 if (mdp->cd->tsu) { 3227 3227 struct resource *rtsu; 3228 + 3228 3229 rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); 3229 - mdp->tsu_addr = devm_ioremap_resource(&pdev->dev, rtsu); 3230 - if (IS_ERR(mdp->tsu_addr)) { 3231 - ret = PTR_ERR(mdp->tsu_addr); 3230 + if (!rtsu) { 3231 + dev_err(&pdev->dev, "no TSU resource\n"); 3232 + ret = -ENODEV; 3233 + goto out_release; 3234 + } 3235 + /* We can only request the TSU region for the first port 3236 + * of the two sharing this TSU for the probe to succeed... 3237 + */ 3238 + if (devno % 2 == 0 && 3239 + !devm_request_mem_region(&pdev->dev, rtsu->start, 3240 + resource_size(rtsu), 3241 + dev_name(&pdev->dev))) { 3242 + dev_err(&pdev->dev, "can't request TSU resource.\n"); 3243 + ret = -EBUSY; 3244 + goto out_release; 3245 + } 3246 + mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start, 3247 + resource_size(rtsu)); 3248 + if (!mdp->tsu_addr) { 3249 + dev_err(&pdev->dev, "TSU region ioremap() failed.\n"); 3250 + ret = -ENOMEM; 3232 3251 goto out_release; 3233 3252 } 3234 3253 mdp->port = devno % 2; 3235 3254 ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER; 3236 3255 } 3237 3256 3238 - /* initialize first or needed device */ 3239 - if (!devno || pd->needs_init) { 3257 + /* Need to init only the first port of the two sharing a TSU */ 3258 + if (devno % 2 == 0) { 3240 3259 if (mdp->cd->chip_reset) 3241 3260 mdp->cd->chip_reset(ndev); 3242 3261
+6
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 364 364 bool stmmac_eee_init(struct stmmac_priv *priv) 365 365 { 366 366 struct net_device *ndev = priv->dev; 367 + int interface = priv->plat->interface; 367 368 unsigned long flags; 368 369 bool ret = false; 370 + 371 + if ((interface != PHY_INTERFACE_MODE_MII) && 372 + (interface != PHY_INTERFACE_MODE_GMII) && 373 + !phy_interface_mode_is_rgmii(interface)) 374 + goto out; 369 375 370 376 /* Using PCS we cannot dial with the phy registers at this stage 371 377 * so we do not support extra feature like EEE.
+14
drivers/net/geneve.c
··· 825 825 if (IS_ERR(rt)) 826 826 return PTR_ERR(rt); 827 827 828 + if (skb_dst(skb)) { 829 + int mtu = dst_mtu(&rt->dst) - sizeof(struct iphdr) - 830 + GENEVE_BASE_HLEN - info->options_len - 14; 831 + 832 + skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu); 833 + } 834 + 828 835 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 829 836 if (geneve->collect_md) { 830 837 tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb); ··· 870 863 dst = geneve_get_v6_dst(skb, dev, gs6, &fl6, info); 871 864 if (IS_ERR(dst)) 872 865 return PTR_ERR(dst); 866 + 867 + if (skb_dst(skb)) { 868 + int mtu = dst_mtu(dst) - sizeof(struct ipv6hdr) - 869 + GENEVE_BASE_HLEN - info->options_len - 14; 870 + 871 + skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu); 872 + } 873 873 874 874 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 875 875 if (geneve->collect_md) {
+6 -1
drivers/net/macvlan.c
··· 1444 1444 return 0; 1445 1445 1446 1446 unregister_netdev: 1447 + /* macvlan_uninit would free the macvlan port */ 1447 1448 unregister_netdevice(dev); 1449 + return err; 1448 1450 destroy_macvlan_port: 1449 - if (create) 1451 + /* the macvlan port may be freed by macvlan_uninit when fail to register. 1452 + * so we destroy the macvlan port only when it's valid. 1453 + */ 1454 + if (create && macvlan_port_get_rtnl(dev)) 1450 1455 macvlan_port_destroy(port->dev); 1451 1456 return err; 1452 1457 }
+4 -2
drivers/net/phy/mdio-sun4i.c
··· 118 118 119 119 data->regulator = devm_regulator_get(&pdev->dev, "phy"); 120 120 if (IS_ERR(data->regulator)) { 121 - if (PTR_ERR(data->regulator) == -EPROBE_DEFER) 122 - return -EPROBE_DEFER; 121 + if (PTR_ERR(data->regulator) == -EPROBE_DEFER) { 122 + ret = -EPROBE_DEFER; 123 + goto err_out_free_mdiobus; 124 + } 123 125 124 126 dev_info(&pdev->dev, "no regulator found\n"); 125 127 data->regulator = NULL;
+3 -2
drivers/net/phy/phylink.c
··· 1296 1296 switch (cmd) { 1297 1297 case SIOCGMIIPHY: 1298 1298 mii->phy_id = pl->phydev->mdio.addr; 1299 + /* fall through */ 1299 1300 1300 1301 case SIOCGMIIREG: 1301 1302 ret = phylink_phy_read(pl, mii->phy_id, mii->reg_num); ··· 1319 1318 switch (cmd) { 1320 1319 case SIOCGMIIPHY: 1321 1320 mii->phy_id = 0; 1321 + /* fall through */ 1322 1322 1323 1323 case SIOCGMIIREG: 1324 1324 ret = phylink_mii_read(pl, mii->phy_id, mii->reg_num); ··· 1431 1429 WARN_ON(!lockdep_rtnl_is_held()); 1432 1430 1433 1431 set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); 1432 + queue_work(system_power_efficient_wq, &pl->resolve); 1434 1433 flush_work(&pl->resolve); 1435 - 1436 - netif_carrier_off(pl->netdev); 1437 1434 } 1438 1435 1439 1436 static void phylink_sfp_link_up(void *upstream)
+4 -2
drivers/net/phy/sfp-bus.c
··· 356 356 void sfp_unregister_upstream(struct sfp_bus *bus) 357 357 { 358 358 rtnl_lock(); 359 - sfp_unregister_bus(bus); 359 + if (bus->sfp) 360 + sfp_unregister_bus(bus); 360 361 bus->upstream = NULL; 361 362 bus->netdev = NULL; 362 363 rtnl_unlock(); ··· 460 459 void sfp_unregister_socket(struct sfp_bus *bus) 461 460 { 462 461 rtnl_lock(); 463 - sfp_unregister_bus(bus); 462 + if (bus->netdev) 463 + sfp_unregister_bus(bus); 464 464 bus->sfp_dev = NULL; 465 465 bus->sfp = NULL; 466 466 bus->socket_ops = NULL;
+1
drivers/net/usb/qmi_wwan.c
··· 1100 1100 {QMI_FIXED_INTF(0x05c6, 0x9084, 4)}, 1101 1101 {QMI_FIXED_INTF(0x05c6, 0x920d, 0)}, 1102 1102 {QMI_FIXED_INTF(0x05c6, 0x920d, 5)}, 1103 + {QMI_QUIRK_SET_DTR(0x05c6, 0x9625, 4)}, /* YUGA CLM920-NC5 */ 1103 1104 {QMI_FIXED_INTF(0x0846, 0x68a2, 8)}, 1104 1105 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ 1105 1106 {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
+12 -11
drivers/net/wireless/ath/wcn36xx/main.c
··· 384 384 } 385 385 } 386 386 387 + if (changed & IEEE80211_CONF_CHANGE_PS) { 388 + list_for_each_entry(tmp, &wcn->vif_list, list) { 389 + vif = wcn36xx_priv_to_vif(tmp); 390 + if (hw->conf.flags & IEEE80211_CONF_PS) { 391 + if (vif->bss_conf.ps) /* ps allowed ? */ 392 + wcn36xx_pmc_enter_bmps_state(wcn, vif); 393 + } else { 394 + wcn36xx_pmc_exit_bmps_state(wcn, vif); 395 + } 396 + } 397 + } 398 + 387 399 mutex_unlock(&wcn->conf_mutex); 388 400 389 401 return 0; ··· 757 745 bss_conf->dtim_period); 758 746 759 747 vif_priv->dtim_period = bss_conf->dtim_period; 760 - } 761 - 762 - if (changed & BSS_CHANGED_PS) { 763 - wcn36xx_dbg(WCN36XX_DBG_MAC, 764 - "mac bss PS set %d\n", 765 - bss_conf->ps); 766 - if (bss_conf->ps) { 767 - wcn36xx_pmc_enter_bmps_state(wcn, vif); 768 - } else { 769 - wcn36xx_pmc_exit_bmps_state(wcn, vif); 770 - } 771 748 } 772 749 773 750 if (changed & BSS_CHANGED_BSSID) {
+4 -2
drivers/net/wireless/ath/wcn36xx/pmc.c
··· 45 45 struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); 46 46 47 47 if (WCN36XX_BMPS != vif_priv->pw_state) { 48 - wcn36xx_err("Not in BMPS mode, no need to exit from BMPS mode!\n"); 49 - return -EINVAL; 48 + /* Unbalanced call or last BMPS enter failed */ 49 + wcn36xx_dbg(WCN36XX_DBG_PMC, 50 + "Not in BMPS mode, no need to exit\n"); 51 + return -EALREADY; 50 52 } 51 53 wcn36xx_smd_exit_bmps(wcn, vif); 52 54 vif_priv->pw_state = WCN36XX_FULL_POWER;
+7 -3
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
··· 670 670 return index & (q->n_window - 1); 671 671 } 672 672 673 - static inline void *iwl_pcie_get_tfd(struct iwl_trans_pcie *trans_pcie, 673 + static inline void *iwl_pcie_get_tfd(struct iwl_trans *trans, 674 674 struct iwl_txq *txq, int idx) 675 675 { 676 - return txq->tfds + trans_pcie->tfd_size * iwl_pcie_get_cmd_index(txq, 677 - idx); 676 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 677 + 678 + if (trans->cfg->use_tfh) 679 + idx = iwl_pcie_get_cmd_index(txq, idx); 680 + 681 + return txq->tfds + trans_pcie->tfd_size * idx; 678 682 } 679 683 680 684 static inline void iwl_enable_rfkill_int(struct iwl_trans *trans)
+3 -8
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
··· 171 171 172 172 static void iwl_pcie_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 173 173 { 174 - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 175 - 176 174 /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 177 175 * idx is bounded by n_window 178 176 */ ··· 179 181 lockdep_assert_held(&txq->lock); 180 182 181 183 iwl_pcie_gen2_tfd_unmap(trans, &txq->entries[idx].meta, 182 - iwl_pcie_get_tfd(trans_pcie, txq, idx)); 184 + iwl_pcie_get_tfd(trans, txq, idx)); 183 185 184 186 /* free SKB */ 185 187 if (txq->entries) { ··· 362 364 struct sk_buff *skb, 363 365 struct iwl_cmd_meta *out_meta) 364 366 { 365 - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 366 367 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 367 368 int idx = iwl_pcie_get_cmd_index(txq, txq->write_ptr); 368 - struct iwl_tfh_tfd *tfd = 369 - iwl_pcie_get_tfd(trans_pcie, txq, idx); 369 + struct iwl_tfh_tfd *tfd = iwl_pcie_get_tfd(trans, txq, idx); 370 370 dma_addr_t tb_phys; 371 371 bool amsdu; 372 372 int i, len, tb1_len, tb2_len, hdr_len; ··· 561 565 u8 group_id = iwl_cmd_groupid(cmd->id); 562 566 const u8 *cmddata[IWL_MAX_CMD_TBS_PER_TFD]; 563 567 u16 cmdlen[IWL_MAX_CMD_TBS_PER_TFD]; 564 - struct iwl_tfh_tfd *tfd = 565 - iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr); 568 + struct iwl_tfh_tfd *tfd = iwl_pcie_get_tfd(trans, txq, txq->write_ptr); 566 569 567 570 memset(tfd, 0, sizeof(*tfd)); 568 571
+4 -4
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
··· 373 373 { 374 374 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 375 375 int i, num_tbs; 376 - void *tfd = iwl_pcie_get_tfd(trans_pcie, txq, index); 376 + void *tfd = iwl_pcie_get_tfd(trans, txq, index); 377 377 378 378 /* Sanity check on number of chunks */ 379 379 num_tbs = iwl_pcie_tfd_get_num_tbs(trans, tfd); ··· 2018 2018 } 2019 2019 2020 2020 trace_iwlwifi_dev_tx(trans->dev, skb, 2021 - iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr), 2021 + iwl_pcie_get_tfd(trans, txq, txq->write_ptr), 2022 2022 trans_pcie->tfd_size, 2023 2023 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 2024 2024 hdr_len); ··· 2092 2092 IEEE80211_CCMP_HDR_LEN : 0; 2093 2093 2094 2094 trace_iwlwifi_dev_tx(trans->dev, skb, 2095 - iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr), 2095 + iwl_pcie_get_tfd(trans, txq, txq->write_ptr), 2096 2096 trans_pcie->tfd_size, 2097 2097 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 0); 2098 2098 ··· 2425 2425 memcpy(&txq->first_tb_bufs[txq->write_ptr], &dev_cmd->hdr, 2426 2426 IWL_FIRST_TB_SIZE); 2427 2427 2428 - tfd = iwl_pcie_get_tfd(trans_pcie, txq, txq->write_ptr); 2428 + tfd = iwl_pcie_get_tfd(trans, txq, txq->write_ptr); 2429 2429 /* Set up entry for this TFD in Tx byte-count array */ 2430 2430 iwl_pcie_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len), 2431 2431 iwl_pcie_tfd_get_num_tbs(trans, tfd));
+1
drivers/net/xen-netfront.c
··· 1326 1326 1327 1327 netif_carrier_off(netdev); 1328 1328 1329 + xenbus_switch_state(dev, XenbusStateInitialising); 1329 1330 return netdev; 1330 1331 1331 1332 exit:
+6 -1
drivers/nvme/host/core.c
··· 1335 1335 struct nvme_ns *ns, struct nvme_id_ns *id) 1336 1336 { 1337 1337 sector_t capacity = le64_to_cpup(&id->nsze) << (ns->lba_shift - 9); 1338 + unsigned short bs = 1 << ns->lba_shift; 1338 1339 unsigned stream_alignment = 0; 1339 1340 1340 1341 if (ns->ctrl->nr_streams && ns->sws && ns->sgs) ··· 1344 1343 blk_mq_freeze_queue(disk->queue); 1345 1344 blk_integrity_unregister(disk); 1346 1345 1347 - blk_queue_logical_block_size(disk->queue, 1 << ns->lba_shift); 1346 + blk_queue_logical_block_size(disk->queue, bs); 1347 + blk_queue_physical_block_size(disk->queue, bs); 1348 + blk_queue_io_min(disk->queue, bs); 1349 + 1348 1350 if (ns->ms && !ns->ext && 1349 1351 (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED)) 1350 1352 nvme_init_integrity(disk, ns->ms, ns->pi_type); ··· 2991 2987 mutex_unlock(&ns->ctrl->namespaces_mutex); 2992 2988 2993 2989 synchronize_srcu(&ns->head->srcu); 2990 + nvme_mpath_check_last_path(ns); 2994 2991 nvme_put_ns(ns); 2995 2992 } 2996 2993
+12
drivers/nvme/host/nvme.h
··· 417 417 rcu_assign_pointer(head->current_path, NULL); 418 418 } 419 419 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); 420 + 421 + static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 422 + { 423 + struct nvme_ns_head *head = ns->head; 424 + 425 + if (head->disk && list_empty(&head->list)) 426 + kblockd_schedule_work(&head->requeue_work); 427 + } 428 + 420 429 #else 421 430 static inline void nvme_failover_req(struct request *req) 422 431 { ··· 455 446 { 456 447 } 457 448 static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) 449 + { 450 + } 451 + static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 458 452 { 459 453 } 460 454 #endif /* CONFIG_NVME_MULTIPATH */
+20 -22
drivers/nvme/host/pci.c
··· 448 448 return (void **)(iod->sg + blk_rq_nr_phys_segments(req)); 449 449 } 450 450 451 + static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req) 452 + { 453 + struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 454 + unsigned int avg_seg_size; 455 + 456 + avg_seg_size = DIV_ROUND_UP(blk_rq_payload_bytes(req), 457 + blk_rq_nr_phys_segments(req)); 458 + 459 + if (!(dev->ctrl.sgls & ((1 << 0) | (1 << 1)))) 460 + return false; 461 + if (!iod->nvmeq->qid) 462 + return false; 463 + if (!sgl_threshold || avg_seg_size < sgl_threshold) 464 + return false; 465 + return true; 466 + } 467 + 451 468 static blk_status_t nvme_init_iod(struct request *rq, struct nvme_dev *dev) 452 469 { 453 470 struct nvme_iod *iod = blk_mq_rq_to_pdu(rq); 454 471 int nseg = blk_rq_nr_phys_segments(rq); 455 472 unsigned int size = blk_rq_payload_bytes(rq); 473 + 474 + iod->use_sgl = nvme_pci_use_sgls(dev, rq); 456 475 457 476 if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) { 458 477 size_t alloc_size = nvme_pci_iod_alloc_size(dev, size, nseg, ··· 623 604 dma_addr_t prp_dma; 624 605 int nprps, i; 625 606 626 - iod->use_sgl = false; 627 - 628 607 length -= (page_size - offset); 629 608 if (length <= 0) { 630 609 iod->first_dma = 0; ··· 732 715 int entries = iod->nents, i = 0; 733 716 dma_addr_t sgl_dma; 734 717 735 - iod->use_sgl = true; 736 - 737 718 /* setting the transfer type as SGL */ 738 719 cmd->flags = NVME_CMD_SGL_METABUF; 739 720 ··· 785 770 return BLK_STS_OK; 786 771 } 787 772 788 - static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req) 789 - { 790 - struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 791 - unsigned int avg_seg_size; 792 - 793 - avg_seg_size = DIV_ROUND_UP(blk_rq_payload_bytes(req), 794 - blk_rq_nr_phys_segments(req)); 795 - 796 - if (!(dev->ctrl.sgls & ((1 << 0) | (1 << 1)))) 797 - return false; 798 - if (!iod->nvmeq->qid) 799 - return false; 800 - if (!sgl_threshold || avg_seg_size < sgl_threshold) 801 - return false; 802 - return true; 803 - } 804 - 805 773 static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, 806 774 struct nvme_command *cmnd) 807 775 { ··· 804 806 DMA_ATTR_NO_WARN)) 805 807 goto out; 806 808 807 - if (nvme_pci_use_sgls(dev, req)) 809 + if (iod->use_sgl) 808 810 ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw); 809 811 else 810 812 ret = nvme_pci_setup_prps(dev, req, &cmnd->rw);
+13 -1
drivers/nvme/host/rdma.c
··· 974 974 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); 975 975 nvme_start_queues(&ctrl->ctrl); 976 976 977 + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { 978 + /* state change failure should never happen */ 979 + WARN_ON_ONCE(1); 980 + return; 981 + } 982 + 977 983 nvme_rdma_reconnect_or_remove(ctrl); 978 984 } 979 985 980 986 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) 981 987 { 982 - if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) 988 + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) 983 989 return; 984 990 985 991 queue_work(nvme_wq, &ctrl->err_work); ··· 1758 1752 1759 1753 nvme_stop_ctrl(&ctrl->ctrl); 1760 1754 nvme_rdma_shutdown_ctrl(ctrl, false); 1755 + 1756 + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { 1757 + /* state change failure should never happen */ 1758 + WARN_ON_ONCE(1); 1759 + return; 1760 + } 1761 1761 1762 1762 ret = nvme_rdma_configure_admin_queue(ctrl, false); 1763 1763 if (ret)
+1 -1
drivers/nvme/target/fcloop.c
··· 1085 1085 const char *buf, size_t count) 1086 1086 { 1087 1087 struct fcloop_nport *nport = NULL, *tmpport; 1088 - struct fcloop_tport *tport; 1088 + struct fcloop_tport *tport = NULL; 1089 1089 u64 nodename, portname; 1090 1090 unsigned long flags; 1091 1091 int ret;
+7 -2
drivers/of/of_mdio.c
··· 231 231 rc = of_mdiobus_register_phy(mdio, child, addr); 232 232 else 233 233 rc = of_mdiobus_register_device(mdio, child, addr); 234 - if (rc) 234 + 235 + if (rc == -ENODEV) 236 + dev_err(&mdio->dev, 237 + "MDIO device at address %d is missing.\n", 238 + addr); 239 + else if (rc) 235 240 goto unregister; 236 241 } 237 242 ··· 260 255 261 256 if (of_mdiobus_child_is_phy(child)) { 262 257 rc = of_mdiobus_register_phy(mdio, child, addr); 263 - if (rc) 258 + if (rc && rc != -ENODEV) 264 259 goto unregister; 265 260 } 266 261 }
+5 -5
drivers/parisc/dino.c
··· 303 303 struct dino_device *dino_dev = irq_data_get_irq_chip_data(d); 304 304 int local_irq = gsc_find_local_irq(d->irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 305 305 306 - DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, d->irq); 306 + DBG(KERN_WARNING "%s(0x%px, %d)\n", __func__, dino_dev, d->irq); 307 307 308 308 /* Clear the matching bit in the IMR register */ 309 309 dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); ··· 316 316 int local_irq = gsc_find_local_irq(d->irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 317 317 u32 tmp; 318 318 319 - DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, d->irq); 319 + DBG(KERN_WARNING "%s(0x%px, %d)\n", __func__, dino_dev, d->irq); 320 320 321 321 /* 322 322 ** clear pending IRQ bits ··· 396 396 if (mask) { 397 397 if (--ilr_loop > 0) 398 398 goto ilr_again; 399 - printk(KERN_ERR "Dino 0x%p: stuck interrupt %d\n", 399 + printk(KERN_ERR "Dino 0x%px: stuck interrupt %d\n", 400 400 dino_dev->hba.base_addr, mask); 401 401 return IRQ_NONE; 402 402 } ··· 553 553 struct pci_dev *dev; 554 554 struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); 555 555 556 - DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n", 556 + DBG(KERN_WARNING "%s(0x%px) bus %d platform_data 0x%px\n", 557 557 __func__, bus, bus->busn_res.start, 558 558 bus->bridge->platform_data); 559 559 ··· 854 854 res->flags = IORESOURCE_IO; /* do not mark it busy ! */ 855 855 if (request_resource(&ioport_resource, res) < 0) { 856 856 printk(KERN_ERR "%s: request I/O Port region failed " 857 - "0x%lx/%lx (hpa 0x%p)\n", 857 + "0x%lx/%lx (hpa 0x%px)\n", 858 858 name, (unsigned long)res->start, (unsigned long)res->end, 859 859 dino_dev->hba.base_addr); 860 860 return 1;
+1 -1
drivers/parisc/eisa_eeprom.c
··· 106 106 return retval; 107 107 } 108 108 109 - printk(KERN_INFO "EISA EEPROM at 0x%p\n", eisa_eeprom_addr); 109 + printk(KERN_INFO "EISA EEPROM at 0x%px\n", eisa_eeprom_addr); 110 110 return 0; 111 111 } 112 112
+1 -1
drivers/platform/x86/wmi.c
··· 1458 1458 class_unregister(&wmi_bus_class); 1459 1459 } 1460 1460 1461 - subsys_initcall(acpi_wmi_init); 1461 + subsys_initcall_sync(acpi_wmi_init); 1462 1462 module_exit(acpi_wmi_exit);
+5 -1
fs/super.c
··· 517 517 hlist_add_head(&s->s_instances, &type->fs_supers); 518 518 spin_unlock(&sb_lock); 519 519 get_filesystem(type); 520 - register_shrinker(&s->s_shrink); 520 + err = register_shrinker(&s->s_shrink); 521 + if (err) { 522 + deactivate_locked_super(s); 523 + s = ERR_PTR(err); 524 + } 521 525 return s; 522 526 } 523 527
+28 -8
include/linux/bpf.h
··· 43 43 }; 44 44 45 45 struct bpf_map { 46 - atomic_t refcnt; 46 + /* 1st cacheline with read-mostly members of which some 47 + * are also accessed in fast-path (e.g. ops, max_entries). 48 + */ 49 + const struct bpf_map_ops *ops ____cacheline_aligned; 50 + struct bpf_map *inner_map_meta; 51 + #ifdef CONFIG_SECURITY 52 + void *security; 53 + #endif 47 54 enum bpf_map_type map_type; 48 55 u32 key_size; 49 56 u32 value_size; ··· 59 52 u32 pages; 60 53 u32 id; 61 54 int numa_node; 62 - struct user_struct *user; 63 - const struct bpf_map_ops *ops; 64 - struct work_struct work; 55 + bool unpriv_array; 56 + /* 7 bytes hole */ 57 + 58 + /* 2nd cacheline with misc members to avoid false sharing 59 + * particularly with refcounting. 60 + */ 61 + struct user_struct *user ____cacheline_aligned; 62 + atomic_t refcnt; 65 63 atomic_t usercnt; 66 - struct bpf_map *inner_map_meta; 64 + struct work_struct work; 67 65 char name[BPF_OBJ_NAME_LEN]; 68 - #ifdef CONFIG_SECURITY 69 - void *security; 70 - #endif 71 66 }; 72 67 73 68 /* function argument constraints */ ··· 230 221 struct bpf_array { 231 222 struct bpf_map map; 232 223 u32 elem_size; 224 + u32 index_mask; 233 225 /* 'ownership' of prog_array is claimed by the first program that 234 226 * is going to use this map or by the first program which FD is stored 235 227 * in the map to make sure that all callers and callees have the same ··· 429 419 attr->numa_node : NUMA_NO_NODE; 430 420 } 431 421 422 + struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type type); 423 + 432 424 #else /* !CONFIG_BPF_SYSCALL */ 433 425 static inline struct bpf_prog *bpf_prog_get(u32 ufd) 434 426 { ··· 518 506 { 519 507 return 0; 520 508 } 509 + 510 + static inline struct bpf_prog *bpf_prog_get_type_path(const char *name, 511 + enum bpf_prog_type type) 512 + { 513 + return ERR_PTR(-EOPNOTSUPP); 514 + } 521 515 #endif /* CONFIG_BPF_SYSCALL */ 522 516 523 517 static inline struct bpf_prog *bpf_prog_get_type(u32 ufd, ··· 531 513 { 532 514 return bpf_prog_get_type_dev(ufd, type, false); 533 515 } 516 + 517 + bool bpf_prog_get_ok(struct bpf_prog *, enum bpf_prog_type *, bool); 534 518 535 519 int bpf_prog_offload_compile(struct bpf_prog *prog); 536 520 void bpf_prog_offload_destroy(struct bpf_prog *prog);
-1
include/linux/sh_eth.h
··· 17 17 unsigned char mac_addr[ETH_ALEN]; 18 18 unsigned no_ether_link:1; 19 19 unsigned ether_link_active_low:1; 20 - unsigned needs_init:1; 21 20 }; 22 21 23 22 #endif
+1 -1
include/net/sctp/structs.h
··· 966 966 void sctp_transport_burst_reset(struct sctp_transport *); 967 967 unsigned long sctp_transport_timeout(struct sctp_transport *); 968 968 void sctp_transport_reset(struct sctp_transport *t); 969 - void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu); 969 + bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu); 970 970 void sctp_transport_immediate_rtx(struct sctp_transport *); 971 971 void sctp_transport_dst_release(struct sctp_transport *t); 972 972 void sctp_transport_dst_confirm(struct sctp_transport *t);
+1 -1
include/net/vxlan.h
··· 146 146 np_applied:1, 147 147 instance_applied:1, 148 148 version:2, 149 - reserved_flags2:2; 149 + reserved_flags2:2; 150 150 #elif defined(__BIG_ENDIAN_BITFIELD) 151 151 u8 reserved_flags2:2, 152 152 version:2,
+3
include/uapi/linux/if_ether.h
··· 23 23 #define _UAPI_LINUX_IF_ETHER_H 24 24 25 25 #include <linux/types.h> 26 + #include <linux/libc-compat.h> 26 27 27 28 /* 28 29 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble ··· 150 149 * This is an Ethernet frame header. 151 150 */ 152 151 152 + #if __UAPI_DEF_ETHHDR 153 153 struct ethhdr { 154 154 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 155 155 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 156 156 __be16 h_proto; /* packet type ID field */ 157 157 } __attribute__((packed)); 158 + #endif 158 159 159 160 160 161 #endif /* _UAPI_LINUX_IF_ETHER_H */
+60 -1
include/uapi/linux/libc-compat.h
··· 168 168 169 169 /* If we did not see any headers from any supported C libraries, 170 170 * or we are being included in the kernel, then define everything 171 - * that we need. */ 171 + * that we need. Check for previous __UAPI_* definitions to give 172 + * unsupported C libraries a way to opt out of any kernel definition. */ 172 173 #else /* !defined(__GLIBC__) */ 173 174 174 175 /* Definitions for if.h */ 176 + #ifndef __UAPI_DEF_IF_IFCONF 175 177 #define __UAPI_DEF_IF_IFCONF 1 178 + #endif 179 + #ifndef __UAPI_DEF_IF_IFMAP 176 180 #define __UAPI_DEF_IF_IFMAP 1 181 + #endif 182 + #ifndef __UAPI_DEF_IF_IFNAMSIZ 177 183 #define __UAPI_DEF_IF_IFNAMSIZ 1 184 + #endif 185 + #ifndef __UAPI_DEF_IF_IFREQ 178 186 #define __UAPI_DEF_IF_IFREQ 1 187 + #endif 179 188 /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ 189 + #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS 180 190 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 191 + #endif 181 192 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ 193 + #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 182 194 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 195 + #endif 183 196 184 197 /* Definitions for in.h */ 198 + #ifndef __UAPI_DEF_IN_ADDR 185 199 #define __UAPI_DEF_IN_ADDR 1 200 + #endif 201 + #ifndef __UAPI_DEF_IN_IPPROTO 186 202 #define __UAPI_DEF_IN_IPPROTO 1 203 + #endif 204 + #ifndef __UAPI_DEF_IN_PKTINFO 187 205 #define __UAPI_DEF_IN_PKTINFO 1 206 + #endif 207 + #ifndef __UAPI_DEF_IP_MREQ 188 208 #define __UAPI_DEF_IP_MREQ 1 209 + #endif 210 + #ifndef __UAPI_DEF_SOCKADDR_IN 189 211 #define __UAPI_DEF_SOCKADDR_IN 1 212 + #endif 213 + #ifndef __UAPI_DEF_IN_CLASS 190 214 #define __UAPI_DEF_IN_CLASS 1 215 + #endif 191 216 192 217 /* Definitions for in6.h */ 218 + #ifndef __UAPI_DEF_IN6_ADDR 193 219 #define __UAPI_DEF_IN6_ADDR 1 220 + #endif 221 + #ifndef __UAPI_DEF_IN6_ADDR_ALT 194 222 #define __UAPI_DEF_IN6_ADDR_ALT 1 223 + #endif 224 + #ifndef __UAPI_DEF_SOCKADDR_IN6 195 225 #define __UAPI_DEF_SOCKADDR_IN6 1 226 + #endif 227 + #ifndef __UAPI_DEF_IPV6_MREQ 196 228 #define __UAPI_DEF_IPV6_MREQ 1 229 + #endif 230 + #ifndef __UAPI_DEF_IPPROTO_V6 197 231 #define __UAPI_DEF_IPPROTO_V6 1 232 + #endif 233 + #ifndef __UAPI_DEF_IPV6_OPTIONS 198 234 #define __UAPI_DEF_IPV6_OPTIONS 1 235 + #endif 236 + #ifndef __UAPI_DEF_IN6_PKTINFO 199 237 #define __UAPI_DEF_IN6_PKTINFO 1 238 + #endif 239 + #ifndef __UAPI_DEF_IP6_MTUINFO 200 240 #define __UAPI_DEF_IP6_MTUINFO 1 241 + #endif 201 242 202 243 /* Definitions for ipx.h */ 244 + #ifndef __UAPI_DEF_SOCKADDR_IPX 203 245 #define __UAPI_DEF_SOCKADDR_IPX 1 246 + #endif 247 + #ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION 204 248 #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 249 + #endif 250 + #ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION 205 251 #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 252 + #endif 253 + #ifndef __UAPI_DEF_IPX_CONFIG_DATA 206 254 #define __UAPI_DEF_IPX_CONFIG_DATA 1 255 + #endif 256 + #ifndef __UAPI_DEF_IPX_ROUTE_DEF 207 257 #define __UAPI_DEF_IPX_ROUTE_DEF 1 258 + #endif 208 259 209 260 /* Definitions for xattr.h */ 261 + #ifndef __UAPI_DEF_XATTR 210 262 #define __UAPI_DEF_XATTR 1 263 + #endif 211 264 212 265 #endif /* __GLIBC__ */ 266 + 267 + /* Definitions for if_ether.h */ 268 + /* allow libcs like musl to deactivate this, glibc does not implement this. */ 269 + #ifndef __UAPI_DEF_ETHHDR 270 + #define __UAPI_DEF_ETHHDR 1 271 + #endif 213 272 214 273 #endif /* _UAPI_LIBC_COMPAT_H */
+1 -1
include/uapi/linux/netfilter/nf_conntrack_common.h
··· 36 36 37 37 #define NF_CT_STATE_INVALID_BIT (1 << 0) 38 38 #define NF_CT_STATE_BIT(ctinfo) (1 << ((ctinfo) % IP_CT_IS_REPLY + 1)) 39 - #define NF_CT_STATE_UNTRACKED_BIT (1 << (IP_CT_UNTRACKED + 1)) 39 + #define NF_CT_STATE_UNTRACKED_BIT (1 << 6) 40 40 41 41 /* Bitset representing status of connection. */ 42 42 enum ip_conntrack_status {
+7
init/Kconfig
··· 1396 1396 Enable the bpf() system call that allows to manipulate eBPF 1397 1397 programs and maps via file descriptors. 1398 1398 1399 + config BPF_JIT_ALWAYS_ON 1400 + bool "Permanently enable BPF JIT and remove BPF interpreter" 1401 + depends on BPF_SYSCALL && HAVE_EBPF_JIT && BPF_JIT 1402 + help 1403 + Enables BPF JIT and removes BPF interpreter to avoid 1404 + speculative execution of BPF instructions by the interpreter 1405 + 1399 1406 config USERFAULTFD 1400 1407 bool "Enable userfaultfd() system call" 1401 1408 select ANON_INODES
+36 -11
kernel/bpf/arraymap.c
··· 53 53 { 54 54 bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; 55 55 int numa_node = bpf_map_attr_numa_node(attr); 56 + u32 elem_size, index_mask, max_entries; 57 + bool unpriv = !capable(CAP_SYS_ADMIN); 56 58 struct bpf_array *array; 57 59 u64 array_size; 58 - u32 elem_size; 59 60 60 61 /* check sanity of attributes */ 61 62 if (attr->max_entries == 0 || attr->key_size != 4 || ··· 73 72 74 73 elem_size = round_up(attr->value_size, 8); 75 74 75 + max_entries = attr->max_entries; 76 + index_mask = roundup_pow_of_two(max_entries) - 1; 77 + 78 + if (unpriv) 79 + /* round up array size to nearest power of 2, 80 + * since cpu will speculate within index_mask limits 81 + */ 82 + max_entries = index_mask + 1; 83 + 76 84 array_size = sizeof(*array); 77 85 if (percpu) 78 - array_size += (u64) attr->max_entries * sizeof(void *); 86 + array_size += (u64) max_entries * sizeof(void *); 79 87 else 80 - array_size += (u64) attr->max_entries * elem_size; 88 + array_size += (u64) max_entries * elem_size; 81 89 82 90 /* make sure there is no u32 overflow later in round_up() */ 83 91 if (array_size >= U32_MAX - PAGE_SIZE) ··· 96 86 array = bpf_map_area_alloc(array_size, numa_node); 97 87 if (!array) 98 88 return ERR_PTR(-ENOMEM); 89 + array->index_mask = index_mask; 90 + array->map.unpriv_array = unpriv; 99 91 100 92 /* copy mandatory map attributes */ 101 93 array->map.map_type = attr->map_type; ··· 133 121 if (unlikely(index >= array->map.max_entries)) 134 122 return NULL; 135 123 136 - return array->value + array->elem_size * index; 124 + return array->value + array->elem_size * (index & array->index_mask); 137 125 } 138 126 139 127 /* emit BPF instructions equivalent to C code of array_map_lookup_elem() */ 140 128 static u32 array_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf) 141 129 { 130 + struct bpf_array *array = container_of(map, struct bpf_array, map); 142 131 struct bpf_insn *insn = insn_buf; 143 132 u32 elem_size = round_up(map->value_size, 8); 144 133 const int ret = BPF_REG_0; ··· 148 135 149 136 *insn++ = BPF_ALU64_IMM(BPF_ADD, map_ptr, offsetof(struct bpf_array, value)); 150 137 *insn++ = BPF_LDX_MEM(BPF_W, ret, index, 0); 151 - *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 3); 138 + if (map->unpriv_array) { 139 + *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 4); 140 + *insn++ = BPF_ALU32_IMM(BPF_AND, ret, array->index_mask); 141 + } else { 142 + *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 3); 143 + } 152 144 153 145 if (is_power_of_2(elem_size)) { 154 146 *insn++ = BPF_ALU64_IMM(BPF_LSH, ret, ilog2(elem_size)); ··· 175 157 if (unlikely(index >= array->map.max_entries)) 176 158 return NULL; 177 159 178 - return this_cpu_ptr(array->pptrs[index]); 160 + return this_cpu_ptr(array->pptrs[index & array->index_mask]); 179 161 } 180 162 181 163 int bpf_percpu_array_copy(struct bpf_map *map, void *key, void *value) ··· 195 177 */ 196 178 size = round_up(map->value_size, 8); 197 179 rcu_read_lock(); 198 - pptr = array->pptrs[index]; 180 + pptr = array->pptrs[index & array->index_mask]; 199 181 for_each_possible_cpu(cpu) { 200 182 bpf_long_memcpy(value + off, per_cpu_ptr(pptr, cpu), size); 201 183 off += size; ··· 243 225 return -EEXIST; 244 226 245 227 if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY) 246 - memcpy(this_cpu_ptr(array->pptrs[index]), 228 + memcpy(this_cpu_ptr(array->pptrs[index & array->index_mask]), 247 229 value, map->value_size); 248 230 else 249 - memcpy(array->value + array->elem_size * index, 231 + memcpy(array->value + 232 + array->elem_size * (index & array->index_mask), 250 233 value, map->value_size); 251 234 return 0; 252 235 } ··· 281 262 */ 282 263 size = round_up(map->value_size, 8); 283 264 rcu_read_lock(); 284 - pptr = array->pptrs[index]; 265 + pptr = array->pptrs[index & array->index_mask]; 285 266 for_each_possible_cpu(cpu) { 286 267 bpf_long_memcpy(per_cpu_ptr(pptr, cpu), value + off, size); 287 268 off += size; ··· 632 613 static u32 array_of_map_gen_lookup(struct bpf_map *map, 633 614 struct bpf_insn *insn_buf) 634 615 { 616 + struct bpf_array *array = container_of(map, struct bpf_array, map); 635 617 u32 elem_size = round_up(map->value_size, 8); 636 618 struct bpf_insn *insn = insn_buf; 637 619 const int ret = BPF_REG_0; ··· 641 621 642 622 *insn++ = BPF_ALU64_IMM(BPF_ADD, map_ptr, offsetof(struct bpf_array, value)); 643 623 *insn++ = BPF_LDX_MEM(BPF_W, ret, index, 0); 644 - *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 5); 624 + if (map->unpriv_array) { 625 + *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 6); 626 + *insn++ = BPF_ALU32_IMM(BPF_AND, ret, array->index_mask); 627 + } else { 628 + *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 5); 629 + } 645 630 if (is_power_of_2(elem_size)) 646 631 *insn++ = BPF_ALU64_IMM(BPF_LSH, ret, ilog2(elem_size)); 647 632 else
+19
kernel/bpf/core.c
··· 767 767 } 768 768 EXPORT_SYMBOL_GPL(__bpf_call_base); 769 769 770 + #ifndef CONFIG_BPF_JIT_ALWAYS_ON 770 771 /** 771 772 * __bpf_prog_run - run eBPF program on a given context 772 773 * @ctx: is the data we are operating on ··· 1318 1317 EVAL4(PROG_NAME_LIST, 416, 448, 480, 512) 1319 1318 }; 1320 1319 1320 + #else 1321 + static unsigned int __bpf_prog_ret0(const void *ctx, 1322 + const struct bpf_insn *insn) 1323 + { 1324 + return 0; 1325 + } 1326 + #endif 1327 + 1321 1328 bool bpf_prog_array_compatible(struct bpf_array *array, 1322 1329 const struct bpf_prog *fp) 1323 1330 { ··· 1373 1364 */ 1374 1365 struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err) 1375 1366 { 1367 + #ifndef CONFIG_BPF_JIT_ALWAYS_ON 1376 1368 u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); 1377 1369 1378 1370 fp->bpf_func = interpreters[(round_up(stack_depth, 32) / 32) - 1]; 1371 + #else 1372 + fp->bpf_func = __bpf_prog_ret0; 1373 + #endif 1379 1374 1380 1375 /* eBPF JITs can rewrite the program in case constant 1381 1376 * blinding is active. However, in case of error during ··· 1389 1376 */ 1390 1377 if (!bpf_prog_is_dev_bound(fp->aux)) { 1391 1378 fp = bpf_int_jit_compile(fp); 1379 + #ifdef CONFIG_BPF_JIT_ALWAYS_ON 1380 + if (!fp->jited) { 1381 + *err = -ENOTSUPP; 1382 + return fp; 1383 + } 1384 + #endif 1392 1385 } else { 1393 1386 *err = bpf_prog_offload_compile(fp); 1394 1387 if (*err)
+39 -1
kernel/bpf/inode.c
··· 368 368 putname(pname); 369 369 return ret; 370 370 } 371 - EXPORT_SYMBOL_GPL(bpf_obj_get_user); 371 + 372 + static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type) 373 + { 374 + struct bpf_prog *prog; 375 + int ret = inode_permission(inode, MAY_READ | MAY_WRITE); 376 + if (ret) 377 + return ERR_PTR(ret); 378 + 379 + if (inode->i_op == &bpf_map_iops) 380 + return ERR_PTR(-EINVAL); 381 + if (inode->i_op != &bpf_prog_iops) 382 + return ERR_PTR(-EACCES); 383 + 384 + prog = inode->i_private; 385 + 386 + ret = security_bpf_prog(prog); 387 + if (ret < 0) 388 + return ERR_PTR(ret); 389 + 390 + if (!bpf_prog_get_ok(prog, &type, false)) 391 + return ERR_PTR(-EINVAL); 392 + 393 + return bpf_prog_inc(prog); 394 + } 395 + 396 + struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type type) 397 + { 398 + struct bpf_prog *prog; 399 + struct path path; 400 + int ret = kern_path(name, LOOKUP_FOLLOW, &path); 401 + if (ret) 402 + return ERR_PTR(ret); 403 + prog = __get_prog_inode(d_backing_inode(path.dentry), type); 404 + if (!IS_ERR(prog)) 405 + touch_atime(&path); 406 + path_put(&path); 407 + return prog; 408 + } 409 + EXPORT_SYMBOL(bpf_prog_get_type_path); 372 410 373 411 static void bpf_evict_inode(struct inode *inode) 374 412 {
+9 -2
kernel/bpf/sockmap.c
··· 591 591 592 592 write_lock_bh(&sock->sk_callback_lock); 593 593 psock = smap_psock_sk(sock); 594 - smap_list_remove(psock, &stab->sock_map[i]); 595 - smap_release_sock(psock, sock); 594 + /* This check handles a racing sock event that can get the 595 + * sk_callback_lock before this case but after xchg happens 596 + * causing the refcnt to hit zero and sock user data (psock) 597 + * to be null and queued for garbage collection. 598 + */ 599 + if (likely(psock)) { 600 + smap_list_remove(psock, &stab->sock_map[i]); 601 + smap_release_sock(psock, sock); 602 + } 596 603 write_unlock_bh(&sock->sk_callback_lock); 597 604 } 598 605 rcu_read_unlock();
+1 -1
kernel/bpf/syscall.c
··· 1057 1057 } 1058 1058 EXPORT_SYMBOL_GPL(bpf_prog_inc_not_zero); 1059 1059 1060 - static bool bpf_prog_get_ok(struct bpf_prog *prog, 1060 + bool bpf_prog_get_ok(struct bpf_prog *prog, 1061 1061 enum bpf_prog_type *attach_type, bool attach_drv) 1062 1062 { 1063 1063 /* not an attachment, just a refcount inc, always allow */
+36
kernel/bpf/verifier.c
··· 1729 1729 err = check_func_arg(env, BPF_REG_2, fn->arg2_type, &meta); 1730 1730 if (err) 1731 1731 return err; 1732 + if (func_id == BPF_FUNC_tail_call) { 1733 + if (meta.map_ptr == NULL) { 1734 + verbose(env, "verifier bug\n"); 1735 + return -EINVAL; 1736 + } 1737 + env->insn_aux_data[insn_idx].map_ptr = meta.map_ptr; 1738 + } 1732 1739 err = check_func_arg(env, BPF_REG_3, fn->arg3_type, &meta); 1733 1740 if (err) 1734 1741 return err; ··· 4463 4456 */ 4464 4457 insn->imm = 0; 4465 4458 insn->code = BPF_JMP | BPF_TAIL_CALL; 4459 + 4460 + /* instead of changing every JIT dealing with tail_call 4461 + * emit two extra insns: 4462 + * if (index >= max_entries) goto out; 4463 + * index &= array->index_mask; 4464 + * to avoid out-of-bounds cpu speculation 4465 + */ 4466 + map_ptr = env->insn_aux_data[i + delta].map_ptr; 4467 + if (map_ptr == BPF_MAP_PTR_POISON) { 4468 + verbose(env, "tail_call obusing map_ptr\n"); 4469 + return -EINVAL; 4470 + } 4471 + if (!map_ptr->unpriv_array) 4472 + continue; 4473 + insn_buf[0] = BPF_JMP_IMM(BPF_JGE, BPF_REG_3, 4474 + map_ptr->max_entries, 2); 4475 + insn_buf[1] = BPF_ALU32_IMM(BPF_AND, BPF_REG_3, 4476 + container_of(map_ptr, 4477 + struct bpf_array, 4478 + map)->index_mask); 4479 + insn_buf[2] = *insn; 4480 + cnt = 3; 4481 + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); 4482 + if (!new_prog) 4483 + return -ENOMEM; 4484 + 4485 + delta += cnt - 1; 4486 + env->prog = prog = new_prog; 4487 + insn = new_prog->insnsi + i + delta; 4466 4488 continue; 4467 4489 } 4468 4490
+5 -1
kernel/cgroup/cgroup-v1.c
··· 123 123 */ 124 124 do { 125 125 css_task_iter_start(&from->self, 0, &it); 126 - task = css_task_iter_next(&it); 126 + 127 + do { 128 + task = css_task_iter_next(&it); 129 + } while (task && (task->flags & PF_EXITING)); 130 + 127 131 if (task) 128 132 get_task_struct(task); 129 133 css_task_iter_end(&it);
+9 -11
kernel/cgroup/cgroup.c
··· 1397 1397 cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, 1398 1398 cft->name); 1399 1399 else 1400 - strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX); 1400 + strlcpy(buf, cft->name, CGROUP_FILE_NAME_MAX); 1401 1401 return buf; 1402 1402 } 1403 1403 ··· 1864 1864 1865 1865 root->flags = opts->flags; 1866 1866 if (opts->release_agent) 1867 - strcpy(root->release_agent_path, opts->release_agent); 1867 + strlcpy(root->release_agent_path, opts->release_agent, PATH_MAX); 1868 1868 if (opts->name) 1869 - strcpy(root->name, opts->name); 1869 + strlcpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN); 1870 1870 if (opts->cpuset_clone_children) 1871 1871 set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags); 1872 1872 } ··· 4125 4125 4126 4126 static void css_task_iter_advance(struct css_task_iter *it) 4127 4127 { 4128 - struct list_head *l = it->task_pos; 4128 + struct list_head *next; 4129 4129 4130 4130 lockdep_assert_held(&css_set_lock); 4131 - WARN_ON_ONCE(!l); 4132 - 4133 4131 repeat: 4134 4132 /* 4135 4133 * Advance iterator to find next entry. cset->tasks is consumed 4136 4134 * first and then ->mg_tasks. After ->mg_tasks, we move onto the 4137 4135 * next cset. 4138 4136 */ 4139 - l = l->next; 4137 + next = it->task_pos->next; 4140 4138 4141 - if (l == it->tasks_head) 4142 - l = it->mg_tasks_head->next; 4139 + if (next == it->tasks_head) 4140 + next = it->mg_tasks_head->next; 4143 4141 4144 - if (l == it->mg_tasks_head) 4142 + if (next == it->mg_tasks_head) 4145 4143 css_task_iter_advance_css_set(it); 4146 4144 else 4147 - it->task_pos = l; 4145 + it->task_pos = next; 4148 4146 4149 4147 /* if PROCS, skip over tasks which aren't group leaders */ 4150 4148 if ((it->flags & CSS_TASK_ITER_PROCS) && it->task_pos &&
+7 -4
lib/test_bpf.c
··· 6250 6250 return NULL; 6251 6251 } 6252 6252 } 6253 - /* We don't expect to fail. */ 6254 6253 if (*err) { 6255 - pr_cont("FAIL to attach err=%d len=%d\n", 6254 + pr_cont("FAIL to prog_create err=%d len=%d\n", 6256 6255 *err, fprog.len); 6257 6256 return NULL; 6258 6257 } ··· 6275 6276 * checks. 6276 6277 */ 6277 6278 fp = bpf_prog_select_runtime(fp, err); 6279 + if (*err) { 6280 + pr_cont("FAIL to select_runtime err=%d\n", *err); 6281 + return NULL; 6282 + } 6278 6283 break; 6279 6284 } 6280 6285 ··· 6464 6461 pass_cnt++; 6465 6462 continue; 6466 6463 } 6467 - 6468 - return err; 6464 + err_cnt++; 6465 + continue; 6469 6466 } 6470 6467 6471 6468 pr_cont("jited:%u ", fp->jited);
+3
mm/vmscan.c
··· 297 297 */ 298 298 void unregister_shrinker(struct shrinker *shrinker) 299 299 { 300 + if (!shrinker->nr_deferred) 301 + return; 300 302 down_write(&shrinker_rwsem); 301 303 list_del(&shrinker->list); 302 304 up_write(&shrinker_rwsem); 303 305 kfree(shrinker->nr_deferred); 306 + shrinker->nr_deferred = NULL; 304 307 } 305 308 EXPORT_SYMBOL(unregister_shrinker); 306 309
+1 -6
net/8021q/vlan.c
··· 111 111 vlan_gvrp_uninit_applicant(real_dev); 112 112 } 113 113 114 - /* Take it out of our own structures, but be sure to interlock with 115 - * HW accelerating devices or SW vlan input packet processing if 116 - * VLAN is not 0 (leave it there for 802.1p). 117 - */ 118 - if (vlan_id) 119 - vlan_vid_del(real_dev, vlan->vlan_proto, vlan_id); 114 + vlan_vid_del(real_dev, vlan->vlan_proto, vlan_id); 120 115 121 116 /* Get rid of the vlan's reference to real_dev */ 122 117 dev_put(real_dev);
+2 -3
net/caif/caif_dev.c
··· 334 334 mutex_lock(&caifdevs->lock); 335 335 list_add_rcu(&caifd->list, &caifdevs->list); 336 336 337 - strncpy(caifd->layer.name, dev->name, 338 - sizeof(caifd->layer.name) - 1); 339 - caifd->layer.name[sizeof(caifd->layer.name) - 1] = 0; 337 + strlcpy(caifd->layer.name, dev->name, 338 + sizeof(caifd->layer.name)); 340 339 caifd->layer.transmit = transmit; 341 340 cfcnfg_add_phy_layer(cfg, 342 341 dev,
+1 -3
net/caif/caif_usb.c
··· 176 176 dev_add_pack(&caif_usb_type); 177 177 pack_added = true; 178 178 179 - strncpy(layer->name, dev->name, 180 - sizeof(layer->name) - 1); 181 - layer->name[sizeof(layer->name) - 1] = 0; 179 + strlcpy(layer->name, dev->name, sizeof(layer->name)); 182 180 183 181 return 0; 184 182 }
+4 -6
net/caif/cfcnfg.c
··· 268 268 case CAIFPROTO_RFM: 269 269 l->linktype = CFCTRL_SRV_RFM; 270 270 l->u.datagram.connid = s->sockaddr.u.rfm.connection_id; 271 - strncpy(l->u.rfm.volume, s->sockaddr.u.rfm.volume, 272 - sizeof(l->u.rfm.volume)-1); 273 - l->u.rfm.volume[sizeof(l->u.rfm.volume)-1] = 0; 271 + strlcpy(l->u.rfm.volume, s->sockaddr.u.rfm.volume, 272 + sizeof(l->u.rfm.volume)); 274 273 break; 275 274 case CAIFPROTO_UTIL: 276 275 l->linktype = CFCTRL_SRV_UTIL; 277 276 l->endpoint = 0x00; 278 277 l->chtype = 0x00; 279 - strncpy(l->u.utility.name, s->sockaddr.u.util.service, 280 - sizeof(l->u.utility.name)-1); 281 - l->u.utility.name[sizeof(l->u.utility.name)-1] = 0; 278 + strlcpy(l->u.utility.name, s->sockaddr.u.util.service, 279 + sizeof(l->u.utility.name)); 282 280 caif_assert(sizeof(l->u.utility.name) > 10); 283 281 l->u.utility.paramlen = s->param.size; 284 282 if (l->u.utility.paramlen > sizeof(l->u.utility.params))
+2 -2
net/caif/cfctrl.c
··· 258 258 tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs); 259 259 cfpkt_add_body(pkt, &tmp16, 2); 260 260 memset(utility_name, 0, sizeof(utility_name)); 261 - strncpy(utility_name, param->u.utility.name, 262 - UTILITY_NAME_LENGTH - 1); 261 + strlcpy(utility_name, param->u.utility.name, 262 + UTILITY_NAME_LENGTH); 263 263 cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH); 264 264 tmp8 = param->u.utility.paramlen; 265 265 cfpkt_add_body(pkt, &tmp8, 1);
+13 -1
net/core/dev.c
··· 1146 1146 int dev_get_valid_name(struct net *net, struct net_device *dev, 1147 1147 const char *name) 1148 1148 { 1149 - return dev_alloc_name_ns(net, dev, name); 1149 + BUG_ON(!net); 1150 + 1151 + if (!dev_valid_name(name)) 1152 + return -EINVAL; 1153 + 1154 + if (strchr(name, '%')) 1155 + return dev_alloc_name_ns(net, dev, name); 1156 + else if (__dev_get_by_name(net, name)) 1157 + return -EEXIST; 1158 + else if (dev->name != name) 1159 + strlcpy(dev->name, name, IFNAMSIZ); 1160 + 1161 + return 0; 1150 1162 } 1151 1163 EXPORT_SYMBOL(dev_get_valid_name); 1152 1164
+2 -13
net/core/ethtool.c
··· 770 770 return dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings); 771 771 } 772 772 773 - static void 774 - warn_incomplete_ethtool_legacy_settings_conversion(const char *details) 775 - { 776 - char name[sizeof(current->comm)]; 777 - 778 - pr_info_once("warning: `%s' uses legacy ethtool link settings API, %s\n", 779 - get_task_comm(name, current), details); 780 - } 781 - 782 773 /* Query device for its ethtool_cmd settings. 783 774 * 784 775 * Backward compatibility note: for compatibility with legacy ethtool, ··· 796 805 &link_ksettings); 797 806 if (err < 0) 798 807 return err; 799 - if (!convert_link_ksettings_to_legacy_settings(&cmd, 800 - &link_ksettings)) 801 - warn_incomplete_ethtool_legacy_settings_conversion( 802 - "link modes are only partially reported"); 808 + convert_link_ksettings_to_legacy_settings(&cmd, 809 + &link_ksettings); 803 810 804 811 /* send a sensible cmd tag back to user */ 805 812 cmd.cmd = ETHTOOL_GSET;
+2 -4
net/core/filter.c
··· 1054 1054 */ 1055 1055 goto out_err_free; 1056 1056 1057 - /* We are guaranteed to never error here with cBPF to eBPF 1058 - * transitions, since there's no issue with type compatibility 1059 - * checks on program arrays. 1060 - */ 1061 1057 fp = bpf_prog_select_runtime(fp, &err); 1058 + if (err) 1059 + goto out_err_free; 1062 1060 1063 1061 kfree(old_prog); 1064 1062 return fp;
+5 -5
net/core/rtnetlink.c
··· 1681 1681 return false; 1682 1682 } 1683 1683 1684 - static struct net *get_target_net(struct sk_buff *skb, int netnsid) 1684 + static struct net *get_target_net(struct sock *sk, int netnsid) 1685 1685 { 1686 1686 struct net *net; 1687 1687 1688 - net = get_net_ns_by_id(sock_net(skb->sk), netnsid); 1688 + net = get_net_ns_by_id(sock_net(sk), netnsid); 1689 1689 if (!net) 1690 1690 return ERR_PTR(-EINVAL); 1691 1691 1692 1692 /* For now, the caller is required to have CAP_NET_ADMIN in 1693 1693 * the user namespace owning the target net ns. 1694 1694 */ 1695 - if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) { 1695 + if (!sk_ns_capable(sk, net->user_ns, CAP_NET_ADMIN)) { 1696 1696 put_net(net); 1697 1697 return ERR_PTR(-EACCES); 1698 1698 } ··· 1733 1733 ifla_policy, NULL) >= 0) { 1734 1734 if (tb[IFLA_IF_NETNSID]) { 1735 1735 netnsid = nla_get_s32(tb[IFLA_IF_NETNSID]); 1736 - tgt_net = get_target_net(skb, netnsid); 1736 + tgt_net = get_target_net(skb->sk, netnsid); 1737 1737 if (IS_ERR(tgt_net)) { 1738 1738 tgt_net = net; 1739 1739 netnsid = -1; ··· 2883 2883 2884 2884 if (tb[IFLA_IF_NETNSID]) { 2885 2885 netnsid = nla_get_s32(tb[IFLA_IF_NETNSID]); 2886 - tgt_net = get_target_net(skb, netnsid); 2886 + tgt_net = get_target_net(NETLINK_CB(skb).sk, netnsid); 2887 2887 if (IS_ERR(tgt_net)) 2888 2888 return PTR_ERR(tgt_net); 2889 2889 }
+1 -1
net/core/sock_diag.c
··· 288 288 case SKNLGRP_INET6_UDP_DESTROY: 289 289 if (!sock_diag_handlers[AF_INET6]) 290 290 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, 291 - NETLINK_SOCK_DIAG, AF_INET); 291 + NETLINK_SOCK_DIAG, AF_INET6); 292 292 break; 293 293 } 294 294 return 0;
+6
net/core/sysctl_net_core.c
··· 325 325 .data = &bpf_jit_enable, 326 326 .maxlen = sizeof(int), 327 327 .mode = 0644, 328 + #ifndef CONFIG_BPF_JIT_ALWAYS_ON 328 329 .proc_handler = proc_dointvec 330 + #else 331 + .proc_handler = proc_dointvec_minmax, 332 + .extra1 = &one, 333 + .extra2 = &one, 334 + #endif 329 335 }, 330 336 # ifdef CONFIG_HAVE_EBPF_JIT 331 337 {
+3 -1
net/ipv4/raw.c
··· 520 520 goto out; 521 521 522 522 /* hdrincl should be READ_ONCE(inet->hdrincl) 523 - * but READ_ONCE() doesn't work with bit fields 523 + * but READ_ONCE() doesn't work with bit fields. 524 + * Doing this indirectly yields the same result. 524 525 */ 525 526 hdrincl = inet->hdrincl; 527 + hdrincl = READ_ONCE(hdrincl); 526 528 /* 527 529 * Check the flags. 528 530 */
+9
net/ipv6/exthdrs.c
··· 925 925 sr_phdr->segments[0] = **addr_p; 926 926 *addr_p = &sr_ihdr->segments[sr_ihdr->segments_left]; 927 927 928 + if (sr_ihdr->hdrlen > hops * 2) { 929 + int tlvs_offset, tlvs_length; 930 + 931 + tlvs_offset = (1 + hops * 2) << 3; 932 + tlvs_length = (sr_ihdr->hdrlen - hops * 2) << 3; 933 + memcpy((char *)sr_phdr + tlvs_offset, 934 + (char *)sr_ihdr + tlvs_offset, tlvs_length); 935 + } 936 + 928 937 #ifdef CONFIG_IPV6_SEG6_HMAC 929 938 if (sr_has_hmac(sr_phdr)) { 930 939 struct net *net = NULL;
+49 -24
net/ipv6/ip6_fib.c
··· 640 640 if (!(fn->fn_flags & RTN_RTINFO)) { 641 641 RCU_INIT_POINTER(fn->leaf, NULL); 642 642 rt6_release(leaf); 643 + /* remove null_entry in the root node */ 644 + } else if (fn->fn_flags & RTN_TL_ROOT && 645 + rcu_access_pointer(fn->leaf) == 646 + net->ipv6.ip6_null_entry) { 647 + RCU_INIT_POINTER(fn->leaf, NULL); 643 648 } 644 649 645 650 return fn; ··· 1246 1241 * If fib6_add_1 has cleared the old leaf pointer in the 1247 1242 * super-tree leaf node we have to find a new one for it. 1248 1243 */ 1249 - struct rt6_info *pn_leaf = rcu_dereference_protected(pn->leaf, 1250 - lockdep_is_held(&table->tb6_lock)); 1251 - if (pn != fn && pn_leaf == rt) { 1252 - pn_leaf = NULL; 1253 - RCU_INIT_POINTER(pn->leaf, NULL); 1254 - atomic_dec(&rt->rt6i_ref); 1255 - } 1256 - if (pn != fn && !pn_leaf && !(pn->fn_flags & RTN_RTINFO)) { 1257 - pn_leaf = fib6_find_prefix(info->nl_net, table, pn); 1258 - #if RT6_DEBUG >= 2 1259 - if (!pn_leaf) { 1260 - WARN_ON(!pn_leaf); 1261 - pn_leaf = info->nl_net->ipv6.ip6_null_entry; 1244 + if (pn != fn) { 1245 + struct rt6_info *pn_leaf = 1246 + rcu_dereference_protected(pn->leaf, 1247 + lockdep_is_held(&table->tb6_lock)); 1248 + if (pn_leaf == rt) { 1249 + pn_leaf = NULL; 1250 + RCU_INIT_POINTER(pn->leaf, NULL); 1251 + atomic_dec(&rt->rt6i_ref); 1262 1252 } 1253 + if (!pn_leaf && !(pn->fn_flags & RTN_RTINFO)) { 1254 + pn_leaf = fib6_find_prefix(info->nl_net, table, 1255 + pn); 1256 + #if RT6_DEBUG >= 2 1257 + if (!pn_leaf) { 1258 + WARN_ON(!pn_leaf); 1259 + pn_leaf = 1260 + info->nl_net->ipv6.ip6_null_entry; 1261 + } 1263 1262 #endif 1264 - atomic_inc(&pn_leaf->rt6i_ref); 1265 - rcu_assign_pointer(pn->leaf, pn_leaf); 1263 + atomic_inc(&pn_leaf->rt6i_ref); 1264 + rcu_assign_pointer(pn->leaf, pn_leaf); 1265 + } 1266 1266 } 1267 1267 #endif 1268 1268 goto failure; ··· 1275 1265 return err; 1276 1266 1277 1267 failure: 1278 - /* fn->leaf could be NULL if fn is an intermediate node and we 1279 - * failed to add the new route to it in both subtree creation 1280 - * failure and fib6_add_rt2node() failure case. 1281 - * In both cases, fib6_repair_tree() should be called to fix 1282 - * fn->leaf. 1268 + /* fn->leaf could be NULL and fib6_repair_tree() needs to be called if: 1269 + * 1. fn is an intermediate node and we failed to add the new 1270 + * route to it in both subtree creation failure and fib6_add_rt2node() 1271 + * failure case. 1272 + * 2. fn is the root node in the table and we fail to add the first 1273 + * default route to it. 1283 1274 */ 1284 - if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT))) 1275 + if (fn && 1276 + (!(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)) || 1277 + (fn->fn_flags & RTN_TL_ROOT && 1278 + !rcu_access_pointer(fn->leaf)))) 1285 1279 fib6_repair_tree(info->nl_net, table, fn); 1286 1280 /* Always release dst as dst->__refcnt is guaranteed 1287 1281 * to be taken before entering this function ··· 1540 1526 struct fib6_walker *w; 1541 1527 int iter = 0; 1542 1528 1529 + /* Set fn->leaf to null_entry for root node. */ 1530 + if (fn->fn_flags & RTN_TL_ROOT) { 1531 + rcu_assign_pointer(fn->leaf, net->ipv6.ip6_null_entry); 1532 + return fn; 1533 + } 1534 + 1543 1535 for (;;) { 1544 1536 struct fib6_node *fn_r = rcu_dereference_protected(fn->right, 1545 1537 lockdep_is_held(&table->tb6_lock)); ··· 1700 1680 } 1701 1681 read_unlock(&net->ipv6.fib6_walker_lock); 1702 1682 1703 - /* If it was last route, expunge its radix tree node */ 1683 + /* If it was last route, call fib6_repair_tree() to: 1684 + * 1. For root node, put back null_entry as how the table was created. 1685 + * 2. For other nodes, expunge its radix tree node. 1686 + */ 1704 1687 if (!rcu_access_pointer(fn->leaf)) { 1705 - fn->fn_flags &= ~RTN_RTINFO; 1706 - net->ipv6.rt6_stats->fib_route_nodes--; 1688 + if (!(fn->fn_flags & RTN_TL_ROOT)) { 1689 + fn->fn_flags &= ~RTN_RTINFO; 1690 + net->ipv6.rt6_stats->fib_route_nodes--; 1691 + } 1707 1692 fn = fib6_repair_tree(net, table, fn); 1708 1693 } 1709 1694
+3 -2
net/ipv6/ip6_output.c
··· 1735 1735 cork.base.opt = NULL; 1736 1736 v6_cork.opt = NULL; 1737 1737 err = ip6_setup_cork(sk, &cork, &v6_cork, ipc6, rt, fl6); 1738 - if (err) 1738 + if (err) { 1739 + ip6_cork_release(&cork, &v6_cork); 1739 1740 return ERR_PTR(err); 1740 - 1741 + } 1741 1742 if (ipc6->dontfrag < 0) 1742 1743 ipc6->dontfrag = inet6_sk(sk)->dontfrag; 1743 1744
+8 -7
net/ipv6/ip6_tunnel.c
··· 1074 1074 memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); 1075 1075 neigh_release(neigh); 1076 1076 } 1077 - } else if (!(t->parms.flags & 1078 - (IP6_TNL_F_USE_ORIG_TCLASS | IP6_TNL_F_USE_ORIG_FWMARK))) { 1079 - /* enable the cache only only if the routing decision does 1080 - * not depend on the current inner header value 1077 + } else if (t->parms.proto != 0 && !(t->parms.flags & 1078 + (IP6_TNL_F_USE_ORIG_TCLASS | 1079 + IP6_TNL_F_USE_ORIG_FWMARK))) { 1080 + /* enable the cache only if neither the outer protocol nor the 1081 + * routing decision depends on the current inner header value 1081 1082 */ 1082 1083 use_cache = true; 1083 1084 } ··· 1677 1676 { 1678 1677 struct ip6_tnl *tnl = netdev_priv(dev); 1679 1678 1680 - if (tnl->parms.proto == IPPROTO_IPIP) { 1681 - if (new_mtu < ETH_MIN_MTU) 1679 + if (tnl->parms.proto == IPPROTO_IPV6) { 1680 + if (new_mtu < IPV6_MIN_MTU) 1682 1681 return -EINVAL; 1683 1682 } else { 1684 - if (new_mtu < IPV6_MIN_MTU) 1683 + if (new_mtu < ETH_MIN_MTU) 1685 1684 return -EINVAL; 1686 1685 } 1687 1686 if (new_mtu > 0xFFF8 - dev->hard_header_len)
+2
net/mac80211/rx.c
··· 3632 3632 } 3633 3633 return true; 3634 3634 case NL80211_IFTYPE_MESH_POINT: 3635 + if (ether_addr_equal(sdata->vif.addr, hdr->addr2)) 3636 + return false; 3635 3637 if (multicast) 3636 3638 return true; 3637 3639 return ether_addr_equal(sdata->vif.addr, hdr->addr1);
+5 -3
net/netfilter/nf_tables_api.c
··· 2072 2072 continue; 2073 2073 2074 2074 list_for_each_entry_rcu(chain, &table->chains, list) { 2075 - if (ctx && ctx->chain[0] && 2075 + if (ctx && ctx->chain && 2076 2076 strcmp(ctx->chain, chain->name) != 0) 2077 2077 continue; 2078 2078 ··· 4665 4665 { 4666 4666 struct nft_obj_filter *filter = cb->data; 4667 4667 4668 - kfree(filter->table); 4669 - kfree(filter); 4668 + if (filter) { 4669 + kfree(filter->table); 4670 + kfree(filter); 4671 + } 4670 4672 4671 4673 return 0; 4672 4674 }
+2 -12
net/netfilter/xt_bpf.c
··· 55 55 56 56 static int __bpf_mt_check_path(const char *path, struct bpf_prog **ret) 57 57 { 58 - mm_segment_t oldfs = get_fs(); 59 - int retval, fd; 60 - 61 58 if (strnlen(path, XT_BPF_PATH_MAX) == XT_BPF_PATH_MAX) 62 59 return -EINVAL; 63 60 64 - set_fs(KERNEL_DS); 65 - fd = bpf_obj_get_user(path, 0); 66 - set_fs(oldfs); 67 - if (fd < 0) 68 - return fd; 69 - 70 - retval = __bpf_mt_check_fd(fd, ret); 71 - sys_close(fd); 72 - return retval; 61 + *ret = bpf_prog_get_type_path(path, BPF_PROG_TYPE_SOCKET_FILTER); 62 + return PTR_ERR_OR_ZERO(*ret); 73 63 } 74 64 75 65 static int bpf_mt_check(const struct xt_mtchk_param *par)
+4
net/rds/rdma.c
··· 525 525 526 526 local_vec = (struct rds_iovec __user *)(unsigned long) args->local_vec_addr; 527 527 528 + if (args->nr_local == 0) 529 + return -EINVAL; 530 + 528 531 /* figure out the number of pages in the vector */ 529 532 for (i = 0; i < args->nr_local; i++) { 530 533 if (copy_from_user(&vec, &local_vec[i], ··· 877 874 err: 878 875 if (page) 879 876 put_page(page); 877 + rm->atomic.op_active = 0; 880 878 kfree(rm->atomic.op_notifier); 881 879 882 880 return ret;
+1 -1
net/sched/act_gact.c
··· 159 159 if (action == TC_ACT_SHOT) 160 160 this_cpu_ptr(gact->common.cpu_qstats)->drops += packets; 161 161 162 - tm->lastuse = lastuse; 162 + tm->lastuse = max_t(u64, tm->lastuse, lastuse); 163 163 } 164 164 165 165 static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
+1 -1
net/sched/act_mirred.c
··· 239 239 struct tcf_t *tm = &m->tcf_tm; 240 240 241 241 _bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), bytes, packets); 242 - tm->lastuse = lastuse; 242 + tm->lastuse = max_t(u64, tm->lastuse, lastuse); 243 243 } 244 244 245 245 static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
+16 -12
net/sctp/input.c
··· 399 399 return; 400 400 } 401 401 402 - if (t->param_flags & SPP_PMTUD_ENABLE) { 403 - /* Update transports view of the MTU */ 404 - sctp_transport_update_pmtu(t, pmtu); 402 + if (!(t->param_flags & SPP_PMTUD_ENABLE)) 403 + /* We can't allow retransmitting in such case, as the 404 + * retransmission would be sized just as before, and thus we 405 + * would get another icmp, and retransmit again. 406 + */ 407 + return; 405 408 406 - /* Update association pmtu. */ 407 - sctp_assoc_sync_pmtu(asoc); 408 - } 409 - 410 - /* Retransmit with the new pmtu setting. 411 - * Normally, if PMTU discovery is disabled, an ICMP Fragmentation 412 - * Needed will never be sent, but if a message was sent before 413 - * PMTU discovery was disabled that was larger than the PMTU, it 414 - * would not be fragmented, so it must be re-transmitted fragmented. 409 + /* Update transports view of the MTU. Return if no update was needed. 410 + * If an update wasn't needed/possible, it also doesn't make sense to 411 + * try to retransmit now. 415 412 */ 413 + if (!sctp_transport_update_pmtu(t, pmtu)) 414 + return; 415 + 416 + /* Update association pmtu. */ 417 + sctp_assoc_sync_pmtu(asoc); 418 + 419 + /* Retransmit with the new pmtu setting. */ 416 420 sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD); 417 421 } 418 422
+21 -7
net/sctp/socket.c
··· 2277 2277 2278 2278 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) { 2279 2279 event = sctp_ulpevent_make_sender_dry_event(asoc, 2280 - GFP_ATOMIC); 2280 + GFP_USER | __GFP_NOWARN); 2281 2281 if (!event) 2282 2282 return -ENOMEM; 2283 2283 ··· 3498 3498 3499 3499 if (optlen < sizeof(struct sctp_hmacalgo)) 3500 3500 return -EINVAL; 3501 + optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) + 3502 + SCTP_AUTH_NUM_HMACS * sizeof(u16)); 3501 3503 3502 3504 hmacs = memdup_user(optval, optlen); 3503 3505 if (IS_ERR(hmacs)) ··· 3538 3536 3539 3537 if (optlen <= sizeof(struct sctp_authkey)) 3540 3538 return -EINVAL; 3539 + /* authkey->sca_keylength is u16, so optlen can't be bigger than 3540 + * this. 3541 + */ 3542 + optlen = min_t(unsigned int, optlen, USHRT_MAX + 3543 + sizeof(struct sctp_authkey)); 3541 3544 3542 3545 authkey = memdup_user(optval, optlen); 3543 3546 if (IS_ERR(authkey)) ··· 3900 3893 3901 3894 if (optlen < sizeof(*params)) 3902 3895 return -EINVAL; 3896 + /* srs_number_streams is u16, so optlen can't be bigger than this. */ 3897 + optlen = min_t(unsigned int, optlen, USHRT_MAX + 3898 + sizeof(__u16) * sizeof(*params)); 3903 3899 3904 3900 params = memdup_user(optval, optlen); 3905 3901 if (IS_ERR(params)) ··· 5025 5015 len = sizeof(int); 5026 5016 if (put_user(len, optlen)) 5027 5017 return -EFAULT; 5028 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int))) 5018 + if (copy_to_user(optval, &sctp_sk(sk)->autoclose, len)) 5029 5019 return -EFAULT; 5030 5020 return 0; 5031 5021 } ··· 5655 5645 err = -EFAULT; 5656 5646 goto out; 5657 5647 } 5648 + /* XXX: We should have accounted for sizeof(struct sctp_getaddrs) too, 5649 + * but we can't change it anymore. 5650 + */ 5658 5651 if (put_user(bytes_copied, optlen)) 5659 5652 err = -EFAULT; 5660 5653 out: ··· 6094 6081 params.assoc_id = 0; 6095 6082 } else if (len >= sizeof(struct sctp_assoc_value)) { 6096 6083 len = sizeof(struct sctp_assoc_value); 6097 - if (copy_from_user(&params, optval, sizeof(params))) 6084 + if (copy_from_user(&params, optval, len)) 6098 6085 return -EFAULT; 6099 6086 } else 6100 6087 return -EINVAL; ··· 6264 6251 6265 6252 if (len < sizeof(struct sctp_authkeyid)) 6266 6253 return -EINVAL; 6267 - if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) 6254 + 6255 + len = sizeof(struct sctp_authkeyid); 6256 + if (copy_from_user(&val, optval, len)) 6268 6257 return -EFAULT; 6269 6258 6270 6259 asoc = sctp_id2assoc(sk, val.scact_assoc_id); ··· 6278 6263 else 6279 6264 val.scact_keynumber = ep->active_key_id; 6280 6265 6281 - len = sizeof(struct sctp_authkeyid); 6282 6266 if (put_user(len, optlen)) 6283 6267 return -EFAULT; 6284 6268 if (copy_to_user(optval, &val, len)) ··· 6303 6289 if (len < sizeof(struct sctp_authchunks)) 6304 6290 return -EINVAL; 6305 6291 6306 - if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) 6292 + if (copy_from_user(&val, optval, sizeof(val))) 6307 6293 return -EFAULT; 6308 6294 6309 6295 to = p->gauth_chunks; ··· 6348 6334 if (len < sizeof(struct sctp_authchunks)) 6349 6335 return -EINVAL; 6350 6336 6351 - if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) 6337 + if (copy_from_user(&val, optval, sizeof(val))) 6352 6338 return -EFAULT; 6353 6339 6354 6340 to = p->gauth_chunks;
+10 -12
net/sctp/stream.c
··· 156 156 sctp_stream_outq_migrate(stream, NULL, outcnt); 157 157 sched->sched_all(stream); 158 158 159 - i = sctp_stream_alloc_out(stream, outcnt, gfp); 160 - if (i) 161 - return i; 159 + ret = sctp_stream_alloc_out(stream, outcnt, gfp); 160 + if (ret) 161 + goto out; 162 162 163 163 stream->outcnt = outcnt; 164 164 for (i = 0; i < stream->outcnt; i++) ··· 170 170 if (!incnt) 171 171 goto out; 172 172 173 - i = sctp_stream_alloc_in(stream, incnt, gfp); 174 - if (i) { 175 - ret = -ENOMEM; 176 - goto free; 173 + ret = sctp_stream_alloc_in(stream, incnt, gfp); 174 + if (ret) { 175 + sched->free(stream); 176 + kfree(stream->out); 177 + stream->out = NULL; 178 + stream->outcnt = 0; 179 + goto out; 177 180 } 178 181 179 182 stream->incnt = incnt; 180 - goto out; 181 183 182 - free: 183 - sched->free(stream); 184 - kfree(stream->out); 185 - stream->out = NULL; 186 184 out: 187 185 return ret; 188 186 }
+19 -10
net/sctp/transport.c
··· 248 248 transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; 249 249 } 250 250 251 - void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu) 251 + bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu) 252 252 { 253 253 struct dst_entry *dst = sctp_transport_dst_check(t); 254 + bool change = true; 254 255 255 256 if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { 256 - pr_warn("%s: Reported pmtu %d too low, using default minimum of %d\n", 257 - __func__, pmtu, SCTP_DEFAULT_MINSEGMENT); 258 - /* Use default minimum segment size and disable 259 - * pmtu discovery on this transport. 260 - */ 261 - t->pathmtu = SCTP_DEFAULT_MINSEGMENT; 262 - } else { 263 - t->pathmtu = pmtu; 257 + pr_warn_ratelimited("%s: Reported pmtu %d too low, using default minimum of %d\n", 258 + __func__, pmtu, SCTP_DEFAULT_MINSEGMENT); 259 + /* Use default minimum segment instead */ 260 + pmtu = SCTP_DEFAULT_MINSEGMENT; 264 261 } 262 + pmtu = SCTP_TRUNC4(pmtu); 265 263 266 264 if (dst) { 267 265 dst->ops->update_pmtu(dst, t->asoc->base.sk, NULL, pmtu); 268 266 dst = sctp_transport_dst_check(t); 269 267 } 270 268 271 - if (!dst) 269 + if (!dst) { 272 270 t->af_specific->get_dst(t, &t->saddr, &t->fl, t->asoc->base.sk); 271 + dst = t->dst; 272 + } 273 + 274 + if (dst) { 275 + /* Re-fetch, as under layers may have a higher minimum size */ 276 + pmtu = SCTP_TRUNC4(dst_mtu(dst)); 277 + change = t->pathmtu != pmtu; 278 + } 279 + t->pathmtu = pmtu; 280 + 281 + return change; 273 282 } 274 283 275 284 /* Caches the dst entry and source address for a transport's destination
+12 -1
net/socket.c
··· 436 436 { 437 437 struct file *newfile; 438 438 int fd = get_unused_fd_flags(flags); 439 - if (unlikely(fd < 0)) 439 + if (unlikely(fd < 0)) { 440 + sock_release(sock); 440 441 return fd; 442 + } 441 443 442 444 newfile = sock_alloc_file(sock, flags, NULL); 443 445 if (likely(!IS_ERR(newfile))) { ··· 2620 2618 } 2621 2619 2622 2620 core_initcall(sock_init); /* early initcall */ 2621 + 2622 + static int __init jit_init(void) 2623 + { 2624 + #ifdef CONFIG_BPF_JIT_ALWAYS_ON 2625 + bpf_jit_enable = 1; 2626 + #endif 2627 + return 0; 2628 + } 2629 + pure_initcall(jit_init); 2623 2630 2624 2631 #ifdef CONFIG_PROC_FS 2625 2632 void socket_seq_show(struct seq_file *seq)
+18 -4
net/tipc/group.c
··· 109 109 static void tipc_group_decr_active(struct tipc_group *grp, 110 110 struct tipc_member *m) 111 111 { 112 - if (m->state == MBR_ACTIVE || m->state == MBR_RECLAIMING) 112 + if (m->state == MBR_ACTIVE || m->state == MBR_RECLAIMING || 113 + m->state == MBR_REMITTED) 113 114 grp->active_cnt--; 114 115 } 115 116 ··· 563 562 int max_active = grp->max_active; 564 563 int reclaim_limit = max_active * 3 / 4; 565 564 int active_cnt = grp->active_cnt; 566 - struct tipc_member *m, *rm; 565 + struct tipc_member *m, *rm, *pm; 567 566 568 567 m = tipc_group_find_member(grp, node, port); 569 568 if (!m) ··· 606 605 pr_warn_ratelimited("Rcv unexpected msg after REMIT\n"); 607 606 tipc_group_proto_xmit(grp, m, GRP_ADV_MSG, xmitq); 608 607 } 608 + grp->active_cnt--; 609 + list_del_init(&m->list); 610 + if (list_empty(&grp->pending)) 611 + return; 612 + 613 + /* Set oldest pending member to active and advertise */ 614 + pm = list_first_entry(&grp->pending, struct tipc_member, list); 615 + pm->state = MBR_ACTIVE; 616 + list_move_tail(&pm->list, &grp->active); 617 + grp->active_cnt++; 618 + tipc_group_proto_xmit(grp, pm, GRP_ADV_MSG, xmitq); 609 619 break; 610 620 case MBR_RECLAIMING: 611 621 case MBR_DISCOVERED: ··· 754 742 if (!m || m->state != MBR_RECLAIMING) 755 743 return; 756 744 757 - list_del_init(&m->list); 758 - grp->active_cnt--; 759 745 remitted = msg_grp_remitted(hdr); 760 746 761 747 /* Messages preceding the REMIT still in receive queue */ 762 748 if (m->advertised > remitted) { 763 749 m->state = MBR_REMITTED; 764 750 in_flight = m->advertised - remitted; 751 + m->advertised = ADV_IDLE + in_flight; 752 + return; 765 753 } 766 754 /* All messages preceding the REMIT have been read */ 767 755 if (m->advertised <= remitted) { ··· 773 761 tipc_group_proto_xmit(grp, m, GRP_ADV_MSG, xmitq); 774 762 775 763 m->advertised = ADV_IDLE + in_flight; 764 + grp->active_cnt--; 765 + list_del_init(&m->list); 776 766 777 767 /* Set oldest pending member to active and advertise */ 778 768 if (list_empty(&grp->pending))
+2 -1
net/wireless/nl80211.c
··· 11361 11361 break; 11362 11362 case NL80211_NAN_FUNC_FOLLOW_UP: 11363 11363 if (!tb[NL80211_NAN_FUNC_FOLLOW_UP_ID] || 11364 - !tb[NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID]) { 11364 + !tb[NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID] || 11365 + !tb[NL80211_NAN_FUNC_FOLLOW_UP_DEST]) { 11365 11366 err = -EINVAL; 11366 11367 goto out; 11367 11368 }
+11 -1
security/apparmor/mount.c
··· 329 329 AA_BUG(!mntpath); 330 330 AA_BUG(!buffer); 331 331 332 + if (!PROFILE_MEDIATES(profile, AA_CLASS_MOUNT)) 333 + return 0; 334 + 332 335 error = aa_path_name(mntpath, path_flags(profile, mntpath), buffer, 333 336 &mntpnt, &info, profile->disconnected); 334 337 if (error) ··· 382 379 383 380 AA_BUG(!profile); 384 381 AA_BUG(devpath && !devbuffer); 382 + 383 + if (!PROFILE_MEDIATES(profile, AA_CLASS_MOUNT)) 384 + return 0; 385 385 386 386 if (devpath) { 387 387 error = aa_path_name(devpath, path_flags(profile, devpath), ··· 564 558 AA_BUG(!profile); 565 559 AA_BUG(!path); 566 560 561 + if (!PROFILE_MEDIATES(profile, AA_CLASS_MOUNT)) 562 + return 0; 563 + 567 564 error = aa_path_name(path, path_flags(profile, path), buffer, &name, 568 565 &info, profile->disconnected); 569 566 if (error) ··· 622 613 AA_BUG(!new_path); 623 614 AA_BUG(!old_path); 624 615 625 - if (profile_unconfined(profile)) 616 + if (profile_unconfined(profile) || 617 + !PROFILE_MEDIATES(profile, AA_CLASS_MOUNT)) 626 618 return aa_get_newest_label(&profile->label); 627 619 628 620 error = aa_path_name(old_path, path_flags(profile, old_path),
+27 -14
sound/core/oss/pcm_oss.c
··· 455 455 v = snd_pcm_hw_param_last(pcm, params, var, dir); 456 456 else 457 457 v = snd_pcm_hw_param_first(pcm, params, var, dir); 458 - snd_BUG_ON(v < 0); 459 458 return v; 460 459 } 461 460 ··· 1334 1335 1335 1336 if ((tmp = snd_pcm_oss_make_ready(substream)) < 0) 1336 1337 return tmp; 1337 - mutex_lock(&runtime->oss.params_lock); 1338 1338 while (bytes > 0) { 1339 + if (mutex_lock_interruptible(&runtime->oss.params_lock)) { 1340 + tmp = -ERESTARTSYS; 1341 + break; 1342 + } 1339 1343 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) { 1340 1344 tmp = bytes; 1341 1345 if (tmp + runtime->oss.buffer_used > runtime->oss.period_bytes) ··· 1382 1380 xfer += tmp; 1383 1381 if ((substream->f_flags & O_NONBLOCK) != 0 && 1384 1382 tmp != runtime->oss.period_bytes) 1385 - break; 1383 + tmp = -EAGAIN; 1386 1384 } 1387 - } 1388 - mutex_unlock(&runtime->oss.params_lock); 1389 - return xfer; 1390 - 1391 1385 err: 1392 - mutex_unlock(&runtime->oss.params_lock); 1386 + mutex_unlock(&runtime->oss.params_lock); 1387 + if (tmp < 0) 1388 + break; 1389 + if (signal_pending(current)) { 1390 + tmp = -ERESTARTSYS; 1391 + break; 1392 + } 1393 + tmp = 0; 1394 + } 1393 1395 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; 1394 1396 } 1395 1397 ··· 1441 1435 1442 1436 if ((tmp = snd_pcm_oss_make_ready(substream)) < 0) 1443 1437 return tmp; 1444 - mutex_lock(&runtime->oss.params_lock); 1445 1438 while (bytes > 0) { 1439 + if (mutex_lock_interruptible(&runtime->oss.params_lock)) { 1440 + tmp = -ERESTARTSYS; 1441 + break; 1442 + } 1446 1443 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) { 1447 1444 if (runtime->oss.buffer_used == 0) { 1448 1445 tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1); ··· 1476 1467 bytes -= tmp; 1477 1468 xfer += tmp; 1478 1469 } 1479 - } 1480 - mutex_unlock(&runtime->oss.params_lock); 1481 - return xfer; 1482 - 1483 1470 err: 1484 - mutex_unlock(&runtime->oss.params_lock); 1471 + mutex_unlock(&runtime->oss.params_lock); 1472 + if (tmp < 0) 1473 + break; 1474 + if (signal_pending(current)) { 1475 + tmp = -ERESTARTSYS; 1476 + break; 1477 + } 1478 + tmp = 0; 1479 + } 1485 1480 return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; 1486 1481 } 1487 1482
+11 -3
sound/core/oss/pcm_plugin.c
··· 592 592 snd_pcm_sframes_t frames = size; 593 593 594 594 plugin = snd_pcm_plug_first(plug); 595 - while (plugin && frames > 0) { 595 + while (plugin) { 596 + if (frames <= 0) 597 + return frames; 596 598 if ((next = plugin->next) != NULL) { 597 599 snd_pcm_sframes_t frames1 = frames; 598 - if (plugin->dst_frames) 600 + if (plugin->dst_frames) { 599 601 frames1 = plugin->dst_frames(plugin, frames); 602 + if (frames1 <= 0) 603 + return frames1; 604 + } 600 605 if ((err = next->client_channels(next, frames1, &dst_channels)) < 0) { 601 606 return err; 602 607 } 603 608 if (err != frames1) { 604 609 frames = err; 605 - if (plugin->src_frames) 610 + if (plugin->src_frames) { 606 611 frames = plugin->src_frames(plugin, frames1); 612 + if (frames <= 0) 613 + return frames; 614 + } 607 615 } 608 616 } else 609 617 dst_channels = NULL;
+2 -2
sound/core/pcm_lib.c
··· 1632 1632 return changed; 1633 1633 if (params->rmask) { 1634 1634 int err = snd_pcm_hw_refine(pcm, params); 1635 - if (snd_BUG_ON(err < 0)) 1635 + if (err < 0) 1636 1636 return err; 1637 1637 } 1638 1638 return snd_pcm_hw_param_value(params, var, dir); ··· 1678 1678 return changed; 1679 1679 if (params->rmask) { 1680 1680 int err = snd_pcm_hw_refine(pcm, params); 1681 - if (snd_BUG_ON(err < 0)) 1681 + if (err < 0) 1682 1682 return err; 1683 1683 } 1684 1684 return snd_pcm_hw_param_value(params, var, dir);
+7 -2
sound/core/pcm_native.c
··· 2580 2580 return ret < 0 ? ret : frames; 2581 2581 } 2582 2582 2583 - /* decrease the appl_ptr; returns the processed frames or a negative error */ 2583 + /* decrease the appl_ptr; returns the processed frames or zero for error */ 2584 2584 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, 2585 2585 snd_pcm_uframes_t frames, 2586 2586 snd_pcm_sframes_t avail) ··· 2597 2597 if (appl_ptr < 0) 2598 2598 appl_ptr += runtime->boundary; 2599 2599 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); 2600 - return ret < 0 ? ret : frames; 2600 + /* NOTE: we return zero for errors because PulseAudio gets depressed 2601 + * upon receiving an error from rewind ioctl and stops processing 2602 + * any longer. Returning zero means that no rewind is done, so 2603 + * it's not absolutely wrong to answer like that. 2604 + */ 2605 + return ret < 0 ? 0 : frames; 2601 2606 } 2602 2607 2603 2608 static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream,
+50 -48
sound/drivers/aloop.c
··· 39 39 #include <sound/core.h> 40 40 #include <sound/control.h> 41 41 #include <sound/pcm.h> 42 + #include <sound/pcm_params.h> 42 43 #include <sound/info.h> 43 44 #include <sound/initval.h> 44 45 ··· 306 305 return 0; 307 306 } 308 307 309 - static void params_change_substream(struct loopback_pcm *dpcm, 310 - struct snd_pcm_runtime *runtime) 311 - { 312 - struct snd_pcm_runtime *dst_runtime; 313 - 314 - if (dpcm == NULL || dpcm->substream == NULL) 315 - return; 316 - dst_runtime = dpcm->substream->runtime; 317 - if (dst_runtime == NULL) 318 - return; 319 - dst_runtime->hw = dpcm->cable->hw; 320 - } 321 - 322 308 static void params_change(struct snd_pcm_substream *substream) 323 309 { 324 310 struct snd_pcm_runtime *runtime = substream->runtime; ··· 317 329 cable->hw.rate_max = runtime->rate; 318 330 cable->hw.channels_min = runtime->channels; 319 331 cable->hw.channels_max = runtime->channels; 320 - params_change_substream(cable->streams[SNDRV_PCM_STREAM_PLAYBACK], 321 - runtime); 322 - params_change_substream(cable->streams[SNDRV_PCM_STREAM_CAPTURE], 323 - runtime); 324 332 } 325 333 326 334 static int loopback_prepare(struct snd_pcm_substream *substream) ··· 604 620 static int rule_format(struct snd_pcm_hw_params *params, 605 621 struct snd_pcm_hw_rule *rule) 606 622 { 623 + struct loopback_pcm *dpcm = rule->private; 624 + struct loopback_cable *cable = dpcm->cable; 625 + struct snd_mask m; 607 626 608 - struct snd_pcm_hardware *hw = rule->private; 609 - struct snd_mask *maskp = hw_param_mask(params, rule->var); 610 - 611 - maskp->bits[0] &= (u_int32_t)hw->formats; 612 - maskp->bits[1] &= (u_int32_t)(hw->formats >> 32); 613 - memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ 614 - if (! maskp->bits[0] && ! maskp->bits[1]) 615 - return -EINVAL; 616 - return 0; 627 + snd_mask_none(&m); 628 + mutex_lock(&dpcm->loopback->cable_lock); 629 + m.bits[0] = (u_int32_t)cable->hw.formats; 630 + m.bits[1] = (u_int32_t)(cable->hw.formats >> 32); 631 + mutex_unlock(&dpcm->loopback->cable_lock); 632 + return snd_mask_refine(hw_param_mask(params, rule->var), &m); 617 633 } 618 634 619 635 static int rule_rate(struct snd_pcm_hw_params *params, 620 636 struct snd_pcm_hw_rule *rule) 621 637 { 622 - struct snd_pcm_hardware *hw = rule->private; 638 + struct loopback_pcm *dpcm = rule->private; 639 + struct loopback_cable *cable = dpcm->cable; 623 640 struct snd_interval t; 624 641 625 - t.min = hw->rate_min; 626 - t.max = hw->rate_max; 642 + mutex_lock(&dpcm->loopback->cable_lock); 643 + t.min = cable->hw.rate_min; 644 + t.max = cable->hw.rate_max; 645 + mutex_unlock(&dpcm->loopback->cable_lock); 627 646 t.openmin = t.openmax = 0; 628 647 t.integer = 0; 629 648 return snd_interval_refine(hw_param_interval(params, rule->var), &t); ··· 635 648 static int rule_channels(struct snd_pcm_hw_params *params, 636 649 struct snd_pcm_hw_rule *rule) 637 650 { 638 - struct snd_pcm_hardware *hw = rule->private; 651 + struct loopback_pcm *dpcm = rule->private; 652 + struct loopback_cable *cable = dpcm->cable; 639 653 struct snd_interval t; 640 654 641 - t.min = hw->channels_min; 642 - t.max = hw->channels_max; 655 + mutex_lock(&dpcm->loopback->cable_lock); 656 + t.min = cable->hw.channels_min; 657 + t.max = cable->hw.channels_max; 658 + mutex_unlock(&dpcm->loopback->cable_lock); 643 659 t.openmin = t.openmax = 0; 644 660 t.integer = 0; 645 661 return snd_interval_refine(hw_param_interval(params, rule->var), &t); 662 + } 663 + 664 + static void free_cable(struct snd_pcm_substream *substream) 665 + { 666 + struct loopback *loopback = substream->private_data; 667 + int dev = get_cable_index(substream); 668 + struct loopback_cable *cable; 669 + 670 + cable = loopback->cables[substream->number][dev]; 671 + if (!cable) 672 + return; 673 + if (cable->streams[!substream->stream]) { 674 + /* other stream is still alive */ 675 + cable->streams[substream->stream] = NULL; 676 + } else { 677 + /* free the cable */ 678 + loopback->cables[substream->number][dev] = NULL; 679 + kfree(cable); 680 + } 646 681 } 647 682 648 683 static int loopback_open(struct snd_pcm_substream *substream) ··· 672 663 struct snd_pcm_runtime *runtime = substream->runtime; 673 664 struct loopback *loopback = substream->private_data; 674 665 struct loopback_pcm *dpcm; 675 - struct loopback_cable *cable; 666 + struct loopback_cable *cable = NULL; 676 667 int err = 0; 677 668 int dev = get_cable_index(substream); 678 669 ··· 690 681 if (!cable) { 691 682 cable = kzalloc(sizeof(*cable), GFP_KERNEL); 692 683 if (!cable) { 693 - kfree(dpcm); 694 684 err = -ENOMEM; 695 685 goto unlock; 696 686 } ··· 707 699 /* are cached -> they do not reflect the actual state */ 708 700 err = snd_pcm_hw_rule_add(runtime, 0, 709 701 SNDRV_PCM_HW_PARAM_FORMAT, 710 - rule_format, &runtime->hw, 702 + rule_format, dpcm, 711 703 SNDRV_PCM_HW_PARAM_FORMAT, -1); 712 704 if (err < 0) 713 705 goto unlock; 714 706 err = snd_pcm_hw_rule_add(runtime, 0, 715 707 SNDRV_PCM_HW_PARAM_RATE, 716 - rule_rate, &runtime->hw, 708 + rule_rate, dpcm, 717 709 SNDRV_PCM_HW_PARAM_RATE, -1); 718 710 if (err < 0) 719 711 goto unlock; 720 712 err = snd_pcm_hw_rule_add(runtime, 0, 721 713 SNDRV_PCM_HW_PARAM_CHANNELS, 722 - rule_channels, &runtime->hw, 714 + rule_channels, dpcm, 723 715 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 724 716 if (err < 0) 725 717 goto unlock; ··· 731 723 else 732 724 runtime->hw = cable->hw; 733 725 unlock: 726 + if (err < 0) { 727 + free_cable(substream); 728 + kfree(dpcm); 729 + } 734 730 mutex_unlock(&loopback->cable_lock); 735 731 return err; 736 732 } ··· 743 731 { 744 732 struct loopback *loopback = substream->private_data; 745 733 struct loopback_pcm *dpcm = substream->runtime->private_data; 746 - struct loopback_cable *cable; 747 - int dev = get_cable_index(substream); 748 734 749 735 loopback_timer_stop(dpcm); 750 736 mutex_lock(&loopback->cable_lock); 751 - cable = loopback->cables[substream->number][dev]; 752 - if (cable->streams[!substream->stream]) { 753 - /* other stream is still alive */ 754 - cable->streams[substream->stream] = NULL; 755 - } else { 756 - /* free the cable */ 757 - loopback->cables[substream->number][dev] = NULL; 758 - kfree(cable); 759 - } 737 + free_cable(substream); 760 738 mutex_unlock(&loopback->cable_lock); 761 739 return 0; 762 740 }
+1 -21
tools/testing/selftests/bpf/test_align.c
··· 474 474 .result = REJECT, 475 475 .matches = { 476 476 {4, "R5=pkt(id=0,off=0,r=0,imm=0)"}, 477 - /* ptr & 0x40 == either 0 or 0x40 */ 478 - {5, "R5=inv(id=0,umax_value=64,var_off=(0x0; 0x40))"}, 479 - /* ptr << 2 == unknown, (4n) */ 480 - {7, "R5=inv(id=0,smax_value=9223372036854775804,umax_value=18446744073709551612,var_off=(0x0; 0xfffffffffffffffc))"}, 481 - /* (4n) + 14 == (4n+2). We blow our bounds, because 482 - * the add could overflow. 483 - */ 484 - {8, "R5=inv(id=0,var_off=(0x2; 0xfffffffffffffffc))"}, 485 - /* Checked s>=0 */ 486 - {10, "R5=inv(id=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"}, 487 - /* packet pointer + nonnegative (4n+2) */ 488 - {12, "R6=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"}, 489 - {14, "R4=pkt(id=1,off=4,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"}, 490 - /* NET_IP_ALIGN + (4n+2) == (4n), alignment is fine. 491 - * We checked the bounds, but it might have been able 492 - * to overflow if the packet pointer started in the 493 - * upper half of the address space. 494 - * So we did not get a 'range' on R6, and the access 495 - * attempt will fail. 496 - */ 497 - {16, "R6=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"}, 477 + /* R5 bitwise operator &= on pointer prohibited */ 498 478 } 499 479 }, 500 480 {