diff options
320 files changed, 2314 insertions, 1384 deletions
diff --git a/.gitignore b/.gitignore index 705e09913dc2..1be78fd8163b 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -127,3 +127,7 @@ all.config | |||
127 | 127 | ||
128 | # Kdevelop4 | 128 | # Kdevelop4 |
129 | *.kdev4 | 129 | *.kdev4 |
130 | |||
131 | #Automatically generated by ASN.1 compiler | ||
132 | net/ipv4/netfilter/nf_nat_snmp_basic-asn1.c | ||
133 | net/ipv4/netfilter/nf_nat_snmp_basic-asn1.h | ||
diff --git a/Documentation/gpu/tve200.rst b/Documentation/gpu/tve200.rst index 69b17b324e12..152ea9398f7e 100644 --- a/Documentation/gpu/tve200.rst +++ b/Documentation/gpu/tve200.rst | |||
@@ -3,4 +3,4 @@ | |||
3 | ================================== | 3 | ================================== |
4 | 4 | ||
5 | .. kernel-doc:: drivers/gpu/drm/tve200/tve200_drv.c | 5 | .. kernel-doc:: drivers/gpu/drm/tve200/tve200_drv.c |
6 | :doc: Faraday TV Encoder 200 | 6 | :doc: Faraday TV Encoder TVE200 DRM Driver |
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801 index d47702456926..65514c251318 100644 --- a/Documentation/i2c/busses/i2c-i801 +++ b/Documentation/i2c/busses/i2c-i801 | |||
@@ -28,8 +28,10 @@ Supported adapters: | |||
28 | * Intel Wildcat Point (PCH) | 28 | * Intel Wildcat Point (PCH) |
29 | * Intel Wildcat Point-LP (PCH) | 29 | * Intel Wildcat Point-LP (PCH) |
30 | * Intel BayTrail (SOC) | 30 | * Intel BayTrail (SOC) |
31 | * Intel Braswell (SOC) | ||
31 | * Intel Sunrise Point-H (PCH) | 32 | * Intel Sunrise Point-H (PCH) |
32 | * Intel Sunrise Point-LP (PCH) | 33 | * Intel Sunrise Point-LP (PCH) |
34 | * Intel Kaby Lake-H (PCH) | ||
33 | * Intel DNV (SOC) | 35 | * Intel DNV (SOC) |
34 | * Intel Broxton (SOC) | 36 | * Intel Broxton (SOC) |
35 | * Intel Lewisburg (PCH) | 37 | * Intel Lewisburg (PCH) |
diff --git a/MAINTAINERS b/MAINTAINERS index 9a7f76eadae9..93a12af4f180 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -7909,7 +7909,6 @@ S: Maintained | |||
7909 | F: scripts/leaking_addresses.pl | 7909 | F: scripts/leaking_addresses.pl |
7910 | 7910 | ||
7911 | LED SUBSYSTEM | 7911 | LED SUBSYSTEM |
7912 | M: Richard Purdie <rpurdie@rpsys.net> | ||
7913 | M: Jacek Anaszewski <jacek.anaszewski@gmail.com> | 7912 | M: Jacek Anaszewski <jacek.anaszewski@gmail.com> |
7914 | M: Pavel Machek <pavel@ucw.cz> | 7913 | M: Pavel Machek <pavel@ucw.cz> |
7915 | L: linux-leds@vger.kernel.org | 7914 | L: linux-leds@vger.kernel.org |
diff --git a/arch/arc/include/asm/bug.h b/arch/arc/include/asm/bug.h index ea022d47896c..21ec82466d62 100644 --- a/arch/arc/include/asm/bug.h +++ b/arch/arc/include/asm/bug.h | |||
@@ -23,7 +23,8 @@ void die(const char *str, struct pt_regs *regs, unsigned long address); | |||
23 | 23 | ||
24 | #define BUG() do { \ | 24 | #define BUG() do { \ |
25 | pr_warn("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ | 25 | pr_warn("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ |
26 | dump_stack(); \ | 26 | barrier_before_unreachable(); \ |
27 | __builtin_trap(); \ | ||
27 | } while (0) | 28 | } while (0) |
28 | 29 | ||
29 | #define HAVE_ARCH_BUG | 30 | #define HAVE_ARCH_BUG |
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c index 57058ac46f49..7e5d7a083707 100644 --- a/arch/arm/mach-ux500/cpu-db8500.c +++ b/arch/arm/mach-ux500/cpu-db8500.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_address.h> | 24 | #include <linux/of_address.h> |
25 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
26 | #include <linux/perf/arm_pmu.h> | ||
27 | #include <linux/regulator/machine.h> | 26 | #include <linux/regulator/machine.h> |
28 | 27 | ||
29 | #include <asm/outercache.h> | 28 | #include <asm/outercache.h> |
@@ -112,37 +111,6 @@ static void ux500_restart(enum reboot_mode mode, const char *cmd) | |||
112 | prcmu_system_reset(0); | 111 | prcmu_system_reset(0); |
113 | } | 112 | } |
114 | 113 | ||
115 | /* | ||
116 | * The PMU IRQ lines of two cores are wired together into a single interrupt. | ||
117 | * Bounce the interrupt to the other core if it's not ours. | ||
118 | */ | ||
119 | static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler) | ||
120 | { | ||
121 | irqreturn_t ret = handler(irq, dev); | ||
122 | int other = !smp_processor_id(); | ||
123 | |||
124 | if (ret == IRQ_NONE && cpu_online(other)) | ||
125 | irq_set_affinity(irq, cpumask_of(other)); | ||
126 | |||
127 | /* | ||
128 | * We should be able to get away with the amount of IRQ_NONEs we give, | ||
129 | * while still having the spurious IRQ detection code kick in if the | ||
130 | * interrupt really starts hitting spuriously. | ||
131 | */ | ||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | static struct arm_pmu_platdata db8500_pmu_platdata = { | ||
136 | .handle_irq = db8500_pmu_handler, | ||
137 | .irq_flags = IRQF_NOBALANCING | IRQF_NO_THREAD, | ||
138 | }; | ||
139 | |||
140 | static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = { | ||
141 | /* Requires call-back bindings. */ | ||
142 | OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata), | ||
143 | {}, | ||
144 | }; | ||
145 | |||
146 | static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = { | 114 | static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = { |
147 | OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL), | 115 | OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL), |
148 | {}, | 116 | {}, |
@@ -165,9 +133,6 @@ static void __init u8500_init_machine(void) | |||
165 | if (of_machine_is_compatible("st-ericsson,u8540")) | 133 | if (of_machine_is_compatible("st-ericsson,u8540")) |
166 | of_platform_populate(NULL, u8500_local_bus_nodes, | 134 | of_platform_populate(NULL, u8500_local_bus_nodes, |
167 | u8540_auxdata_lookup, NULL); | 135 | u8540_auxdata_lookup, NULL); |
168 | else | ||
169 | of_platform_populate(NULL, u8500_local_bus_nodes, | ||
170 | u8500_auxdata_lookup, NULL); | ||
171 | } | 136 | } |
172 | 137 | ||
173 | static const char * stericsson_dt_platform_compat[] = { | 138 | static const char * stericsson_dt_platform_compat[] = { |
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index eda8c5f629fc..350c76a1d15b 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #define MPIDR_UP_BITMASK (0x1 << 30) | 21 | #define MPIDR_UP_BITMASK (0x1 << 30) |
22 | #define MPIDR_MT_BITMASK (0x1 << 24) | 22 | #define MPIDR_MT_BITMASK (0x1 << 24) |
23 | #define MPIDR_HWID_BITMASK 0xff00ffffffUL | 23 | #define MPIDR_HWID_BITMASK UL(0xff00ffffff) |
24 | 24 | ||
25 | #define MPIDR_LEVEL_BITS_SHIFT 3 | 25 | #define MPIDR_LEVEL_BITS_SHIFT 3 |
26 | #define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT) | 26 | #define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT) |
diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 472ef944e932..902f9edacbea 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h | |||
@@ -28,7 +28,7 @@ struct stackframe { | |||
28 | unsigned long fp; | 28 | unsigned long fp; |
29 | unsigned long pc; | 29 | unsigned long pc; |
30 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 30 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
31 | unsigned int graph; | 31 | int graph; |
32 | #endif | 32 | #endif |
33 | }; | 33 | }; |
34 | 34 | ||
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 543e11f0f657..e66b0fca99c2 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h | |||
@@ -72,15 +72,15 @@ static inline void set_fs(mm_segment_t fs) | |||
72 | * This is equivalent to the following test: | 72 | * This is equivalent to the following test: |
73 | * (u65)addr + (u65)size <= (u65)current->addr_limit + 1 | 73 | * (u65)addr + (u65)size <= (u65)current->addr_limit + 1 |
74 | */ | 74 | */ |
75 | static inline unsigned long __range_ok(unsigned long addr, unsigned long size) | 75 | static inline unsigned long __range_ok(const void __user *addr, unsigned long size) |
76 | { | 76 | { |
77 | unsigned long limit = current_thread_info()->addr_limit; | 77 | unsigned long ret, limit = current_thread_info()->addr_limit; |
78 | 78 | ||
79 | __chk_user_ptr(addr); | 79 | __chk_user_ptr(addr); |
80 | asm volatile( | 80 | asm volatile( |
81 | // A + B <= C + 1 for all A,B,C, in four easy steps: | 81 | // A + B <= C + 1 for all A,B,C, in four easy steps: |
82 | // 1: X = A + B; X' = X % 2^64 | 82 | // 1: X = A + B; X' = X % 2^64 |
83 | " adds %0, %0, %2\n" | 83 | " adds %0, %3, %2\n" |
84 | // 2: Set C = 0 if X > 2^64, to guarantee X' > C in step 4 | 84 | // 2: Set C = 0 if X > 2^64, to guarantee X' > C in step 4 |
85 | " csel %1, xzr, %1, hi\n" | 85 | " csel %1, xzr, %1, hi\n" |
86 | // 3: Set X' = ~0 if X >= 2^64. For X == 2^64, this decrements X' | 86 | // 3: Set X' = ~0 if X >= 2^64. For X == 2^64, this decrements X' |
@@ -92,9 +92,9 @@ static inline unsigned long __range_ok(unsigned long addr, unsigned long size) | |||
92 | // testing X' - C == 0, subject to the previous adjustments. | 92 | // testing X' - C == 0, subject to the previous adjustments. |
93 | " sbcs xzr, %0, %1\n" | 93 | " sbcs xzr, %0, %1\n" |
94 | " cset %0, ls\n" | 94 | " cset %0, ls\n" |
95 | : "+r" (addr), "+r" (limit) : "Ir" (size) : "cc"); | 95 | : "=&r" (ret), "+r" (limit) : "Ir" (size), "0" (addr) : "cc"); |
96 | 96 | ||
97 | return addr; | 97 | return ret; |
98 | } | 98 | } |
99 | 99 | ||
100 | /* | 100 | /* |
@@ -104,7 +104,7 @@ static inline unsigned long __range_ok(unsigned long addr, unsigned long size) | |||
104 | */ | 104 | */ |
105 | #define untagged_addr(addr) sign_extend64(addr, 55) | 105 | #define untagged_addr(addr) sign_extend64(addr, 55) |
106 | 106 | ||
107 | #define access_ok(type, addr, size) __range_ok((unsigned long)(addr), size) | 107 | #define access_ok(type, addr, size) __range_ok(addr, size) |
108 | #define user_addr_max get_fs | 108 | #define user_addr_max get_fs |
109 | 109 | ||
110 | #define _ASM_EXTABLE(from, to) \ | 110 | #define _ASM_EXTABLE(from, to) \ |
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index c33b5e4010ab..68450e954d47 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c | |||
@@ -370,6 +370,7 @@ static unsigned int __kprobes aarch32_check_condition(u32 opcode, u32 psr) | |||
370 | static int swp_handler(struct pt_regs *regs, u32 instr) | 370 | static int swp_handler(struct pt_regs *regs, u32 instr) |
371 | { | 371 | { |
372 | u32 destreg, data, type, address = 0; | 372 | u32 destreg, data, type, address = 0; |
373 | const void __user *user_ptr; | ||
373 | int rn, rt2, res = 0; | 374 | int rn, rt2, res = 0; |
374 | 375 | ||
375 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, regs->pc); | 376 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, regs->pc); |
@@ -401,7 +402,8 @@ static int swp_handler(struct pt_regs *regs, u32 instr) | |||
401 | aarch32_insn_extract_reg_num(instr, A32_RT2_OFFSET), data); | 402 | aarch32_insn_extract_reg_num(instr, A32_RT2_OFFSET), data); |
402 | 403 | ||
403 | /* Check access in reasonable access range for both SWP and SWPB */ | 404 | /* Check access in reasonable access range for both SWP and SWPB */ |
404 | if (!access_ok(VERIFY_WRITE, (address & ~3), 4)) { | 405 | user_ptr = (const void __user *)(unsigned long)(address & ~3); |
406 | if (!access_ok(VERIFY_WRITE, user_ptr, 4)) { | ||
405 | pr_debug("SWP{B} emulation: access to 0x%08x not allowed!\n", | 407 | pr_debug("SWP{B} emulation: access to 0x%08x not allowed!\n", |
406 | address); | 408 | address); |
407 | goto fault; | 409 | goto fault; |
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 29b1f873e337..2985a067fc13 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c | |||
@@ -199,9 +199,11 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr2[] = { | |||
199 | }; | 199 | }; |
200 | 200 | ||
201 | static const struct arm64_ftr_bits ftr_ctr[] = { | 201 | static const struct arm64_ftr_bits ftr_ctr[] = { |
202 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */ | 202 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RES1 */ |
203 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 29, 1, 1), /* DIC */ | ||
204 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 28, 1, 1), /* IDC */ | ||
203 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */ | 205 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */ |
204 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */ | 206 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 20, 4, 0), /* ERG */ |
205 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */ | 207 | ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */ |
206 | /* | 208 | /* |
207 | * Linux can handle differing I-cache policies. Userspace JITs will | 209 | * Linux can handle differing I-cache policies. Userspace JITs will |
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 75b220ba73a3..85a251b6dfa8 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c | |||
@@ -908,9 +908,9 @@ static void __armv8pmu_probe_pmu(void *info) | |||
908 | int pmuver; | 908 | int pmuver; |
909 | 909 | ||
910 | dfr0 = read_sysreg(id_aa64dfr0_el1); | 910 | dfr0 = read_sysreg(id_aa64dfr0_el1); |
911 | pmuver = cpuid_feature_extract_signed_field(dfr0, | 911 | pmuver = cpuid_feature_extract_unsigned_field(dfr0, |
912 | ID_AA64DFR0_PMUVER_SHIFT); | 912 | ID_AA64DFR0_PMUVER_SHIFT); |
913 | if (pmuver < 1) | 913 | if (pmuver == 0xf || pmuver == 0) |
914 | return; | 914 | return; |
915 | 915 | ||
916 | probe->present = true; | 916 | probe->present = true; |
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index ad8aeb098b31..c0da6efe5465 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c | |||
@@ -220,8 +220,15 @@ void __show_regs(struct pt_regs *regs) | |||
220 | 220 | ||
221 | show_regs_print_info(KERN_DEFAULT); | 221 | show_regs_print_info(KERN_DEFAULT); |
222 | print_pstate(regs); | 222 | print_pstate(regs); |
223 | printk("pc : %pS\n", (void *)regs->pc); | 223 | |
224 | printk("lr : %pS\n", (void *)lr); | 224 | if (!user_mode(regs)) { |
225 | printk("pc : %pS\n", (void *)regs->pc); | ||
226 | printk("lr : %pS\n", (void *)lr); | ||
227 | } else { | ||
228 | printk("pc : %016llx\n", regs->pc); | ||
229 | printk("lr : %016llx\n", lr); | ||
230 | } | ||
231 | |||
225 | printk("sp : %016llx\n", sp); | 232 | printk("sp : %016llx\n", sp); |
226 | 233 | ||
227 | i = top_reg; | 234 | i = top_reg; |
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 76809ccd309c..d5718a060672 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c | |||
@@ -59,6 +59,11 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) | |||
59 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 59 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
60 | if (tsk->ret_stack && | 60 | if (tsk->ret_stack && |
61 | (frame->pc == (unsigned long)return_to_handler)) { | 61 | (frame->pc == (unsigned long)return_to_handler)) { |
62 | if (WARN_ON_ONCE(frame->graph == -1)) | ||
63 | return -EINVAL; | ||
64 | if (frame->graph < -1) | ||
65 | frame->graph += FTRACE_NOTRACE_DEPTH; | ||
66 | |||
62 | /* | 67 | /* |
63 | * This is a case where function graph tracer has | 68 | * This is a case where function graph tracer has |
64 | * modified a return address (LR) in a stack frame | 69 | * modified a return address (LR) in a stack frame |
diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c index 8b8bbd3eaa52..a382b2a1b84e 100644 --- a/arch/arm64/kernel/sys_compat.c +++ b/arch/arm64/kernel/sys_compat.c | |||
@@ -57,7 +57,7 @@ do_compat_cache_op(unsigned long start, unsigned long end, int flags) | |||
57 | if (end < start || flags) | 57 | if (end < start || flags) |
58 | return -EINVAL; | 58 | return -EINVAL; |
59 | 59 | ||
60 | if (!access_ok(VERIFY_READ, start, end - start)) | 60 | if (!access_ok(VERIFY_READ, (const void __user *)start, end - start)) |
61 | return -EFAULT; | 61 | return -EFAULT; |
62 | 62 | ||
63 | return __do_compat_cache_op(start, end); | 63 | return __do_compat_cache_op(start, end); |
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index a4391280fba9..f258636273c9 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c | |||
@@ -52,7 +52,7 @@ unsigned long profile_pc(struct pt_regs *regs) | |||
52 | frame.fp = regs->regs[29]; | 52 | frame.fp = regs->regs[29]; |
53 | frame.pc = regs->pc; | 53 | frame.pc = regs->pc; |
54 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 54 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
55 | frame.graph = -1; /* no task info */ | 55 | frame.graph = current->curr_ret_stack; |
56 | #endif | 56 | #endif |
57 | do { | 57 | do { |
58 | int ret = unwind_frame(NULL, &frame); | 58 | int ret = unwind_frame(NULL, &frame); |
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index bbb0fde2780e..eb2d15147e8d 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c | |||
@@ -57,7 +57,7 @@ static const char *handler[]= { | |||
57 | "Error" | 57 | "Error" |
58 | }; | 58 | }; |
59 | 59 | ||
60 | int show_unhandled_signals = 1; | 60 | int show_unhandled_signals = 0; |
61 | 61 | ||
62 | static void dump_backtrace_entry(unsigned long where) | 62 | static void dump_backtrace_entry(unsigned long where) |
63 | { | 63 | { |
@@ -526,14 +526,6 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs) | |||
526 | } | 526 | } |
527 | #endif | 527 | #endif |
528 | 528 | ||
529 | if (show_unhandled_signals_ratelimited()) { | ||
530 | pr_info("%s[%d]: syscall %d\n", current->comm, | ||
531 | task_pid_nr(current), regs->syscallno); | ||
532 | dump_instr("", regs); | ||
533 | if (user_mode(regs)) | ||
534 | __show_regs(regs); | ||
535 | } | ||
536 | |||
537 | return sys_ni_syscall(); | 529 | return sys_ni_syscall(); |
538 | } | 530 | } |
539 | 531 | ||
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 3161b853f29e..84a019f55022 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c | |||
@@ -933,6 +933,11 @@ int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) | |||
933 | { | 933 | { |
934 | pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT | | 934 | pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT | |
935 | pgprot_val(mk_sect_prot(prot))); | 935 | pgprot_val(mk_sect_prot(prot))); |
936 | |||
937 | /* ioremap_page_range doesn't honour BBM */ | ||
938 | if (pud_present(READ_ONCE(*pudp))) | ||
939 | return 0; | ||
940 | |||
936 | BUG_ON(phys & ~PUD_MASK); | 941 | BUG_ON(phys & ~PUD_MASK); |
937 | set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot)); | 942 | set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot)); |
938 | return 1; | 943 | return 1; |
@@ -942,6 +947,11 @@ int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot) | |||
942 | { | 947 | { |
943 | pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT | | 948 | pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT | |
944 | pgprot_val(mk_sect_prot(prot))); | 949 | pgprot_val(mk_sect_prot(prot))); |
950 | |||
951 | /* ioremap_page_range doesn't honour BBM */ | ||
952 | if (pmd_present(READ_ONCE(*pmdp))) | ||
953 | return 0; | ||
954 | |||
945 | BUG_ON(phys & ~PMD_MASK); | 955 | BUG_ON(phys & ~PMD_MASK); |
946 | set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot)); | 956 | set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot)); |
947 | return 1; | 957 | return 1; |
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 1d4f1da7c58f..a93350451e8e 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c | |||
@@ -250,8 +250,9 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx) | |||
250 | off = offsetof(struct bpf_array, map.max_entries); | 250 | off = offsetof(struct bpf_array, map.max_entries); |
251 | emit_a64_mov_i64(tmp, off, ctx); | 251 | emit_a64_mov_i64(tmp, off, ctx); |
252 | emit(A64_LDR32(tmp, r2, tmp), ctx); | 252 | emit(A64_LDR32(tmp, r2, tmp), ctx); |
253 | emit(A64_MOV(0, r3, r3), ctx); | ||
253 | emit(A64_CMP(0, r3, tmp), ctx); | 254 | emit(A64_CMP(0, r3, tmp), ctx); |
254 | emit(A64_B_(A64_COND_GE, jmp_offset), ctx); | 255 | emit(A64_B_(A64_COND_CS, jmp_offset), ctx); |
255 | 256 | ||
256 | /* if (tail_call_cnt > MAX_TAIL_CALL_CNT) | 257 | /* if (tail_call_cnt > MAX_TAIL_CALL_CNT) |
257 | * goto out; | 258 | * goto out; |
@@ -259,7 +260,7 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx) | |||
259 | */ | 260 | */ |
260 | emit_a64_mov_i64(tmp, MAX_TAIL_CALL_CNT, ctx); | 261 | emit_a64_mov_i64(tmp, MAX_TAIL_CALL_CNT, ctx); |
261 | emit(A64_CMP(1, tcc, tmp), ctx); | 262 | emit(A64_CMP(1, tcc, tmp), ctx); |
262 | emit(A64_B_(A64_COND_GT, jmp_offset), ctx); | 263 | emit(A64_B_(A64_COND_HI, jmp_offset), ctx); |
263 | emit(A64_ADD_I(1, tcc, tcc, 1), ctx); | 264 | emit(A64_ADD_I(1, tcc, tcc, 1), ctx); |
264 | 265 | ||
265 | /* prog = array->ptrs[index]; | 266 | /* prog = array->ptrs[index]; |
diff --git a/arch/cris/include/arch-v10/arch/bug.h b/arch/cris/include/arch-v10/arch/bug.h index 905afeacfedf..06da9d49152a 100644 --- a/arch/cris/include/arch-v10/arch/bug.h +++ b/arch/cris/include/arch-v10/arch/bug.h | |||
@@ -44,18 +44,25 @@ struct bug_frame { | |||
44 | * not be used like this with newer versions of gcc. | 44 | * not be used like this with newer versions of gcc. |
45 | */ | 45 | */ |
46 | #define BUG() \ | 46 | #define BUG() \ |
47 | do { \ | ||
47 | __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\ | 48 | __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\ |
48 | "movu.w " __stringify(__LINE__) ",$r0\n\t"\ | 49 | "movu.w " __stringify(__LINE__) ",$r0\n\t"\ |
49 | "jump 0f\n\t" \ | 50 | "jump 0f\n\t" \ |
50 | ".section .rodata\n" \ | 51 | ".section .rodata\n" \ |
51 | "0:\t.string \"" __FILE__ "\"\n\t" \ | 52 | "0:\t.string \"" __FILE__ "\"\n\t" \ |
52 | ".previous") | 53 | ".previous"); \ |
54 | unreachable(); \ | ||
55 | } while (0) | ||
53 | #endif | 56 | #endif |
54 | 57 | ||
55 | #else | 58 | #else |
56 | 59 | ||
57 | /* This just causes an oops. */ | 60 | /* This just causes an oops. */ |
58 | #define BUG() (*(int *)0 = 0) | 61 | #define BUG() \ |
62 | do { \ | ||
63 | barrier_before_unreachable(); \ | ||
64 | __builtin_trap(); \ | ||
65 | } while (0) | ||
59 | 66 | ||
60 | #endif | 67 | #endif |
61 | 68 | ||
diff --git a/arch/ia64/include/asm/bug.h b/arch/ia64/include/asm/bug.h index bd3eeb8d1cfa..66b37a532765 100644 --- a/arch/ia64/include/asm/bug.h +++ b/arch/ia64/include/asm/bug.h | |||
@@ -4,7 +4,11 @@ | |||
4 | 4 | ||
5 | #ifdef CONFIG_BUG | 5 | #ifdef CONFIG_BUG |
6 | #define ia64_abort() __builtin_trap() | 6 | #define ia64_abort() __builtin_trap() |
7 | #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) | 7 | #define BUG() do { \ |
8 | printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ | ||
9 | barrier_before_unreachable(); \ | ||
10 | ia64_abort(); \ | ||
11 | } while (0) | ||
8 | 12 | ||
9 | /* should this BUG be made generic? */ | 13 | /* should this BUG be made generic? */ |
10 | #define HAVE_ARCH_BUG | 14 | #define HAVE_ARCH_BUG |
diff --git a/arch/m68k/include/asm/bug.h b/arch/m68k/include/asm/bug.h index b7e2bf1ba4a6..275dca1435bf 100644 --- a/arch/m68k/include/asm/bug.h +++ b/arch/m68k/include/asm/bug.h | |||
@@ -8,16 +8,19 @@ | |||
8 | #ifndef CONFIG_SUN3 | 8 | #ifndef CONFIG_SUN3 |
9 | #define BUG() do { \ | 9 | #define BUG() do { \ |
10 | pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ | 10 | pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ |
11 | barrier_before_unreachable(); \ | ||
11 | __builtin_trap(); \ | 12 | __builtin_trap(); \ |
12 | } while (0) | 13 | } while (0) |
13 | #else | 14 | #else |
14 | #define BUG() do { \ | 15 | #define BUG() do { \ |
15 | pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ | 16 | pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ |
17 | barrier_before_unreachable(); \ | ||
16 | panic("BUG!"); \ | 18 | panic("BUG!"); \ |
17 | } while (0) | 19 | } while (0) |
18 | #endif | 20 | #endif |
19 | #else | 21 | #else |
20 | #define BUG() do { \ | 22 | #define BUG() do { \ |
23 | barrier_before_unreachable(); \ | ||
21 | __builtin_trap(); \ | 24 | __builtin_trap(); \ |
22 | } while (0) | 25 | } while (0) |
23 | #endif | 26 | #endif |
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile index 1bd5c4f00d19..c22da16d67b8 100644 --- a/arch/mips/boot/Makefile +++ b/arch/mips/boot/Makefile | |||
@@ -126,6 +126,7 @@ $(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS | |||
126 | 126 | ||
127 | quiet_cmd_cpp_its_S = ITS $@ | 127 | quiet_cmd_cpp_its_S = ITS $@ |
128 | cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \ | 128 | cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \ |
129 | -D__ASSEMBLY__ \ | ||
129 | -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \ | 130 | -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \ |
130 | -DVMLINUX_BINARY="\"$(3)\"" \ | 131 | -DVMLINUX_BINARY="\"$(3)\"" \ |
131 | -DVMLINUX_COMPRESSION="\"$(2)\"" \ | 132 | -DVMLINUX_COMPRESSION="\"$(2)\"" \ |
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h index 946681db8dc3..9a0fa66b81ac 100644 --- a/arch/mips/include/asm/compat.h +++ b/arch/mips/include/asm/compat.h | |||
@@ -86,7 +86,6 @@ struct compat_flock { | |||
86 | compat_off_t l_len; | 86 | compat_off_t l_len; |
87 | s32 l_sysid; | 87 | s32 l_sysid; |
88 | compat_pid_t l_pid; | 88 | compat_pid_t l_pid; |
89 | short __unused; | ||
90 | s32 pad[4]; | 89 | s32 pad[4]; |
91 | }; | 90 | }; |
92 | 91 | ||
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index b6722c246d9c..04807c7f64cc 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig | |||
@@ -8,7 +8,6 @@ config RISCV | |||
8 | select OF | 8 | select OF |
9 | select OF_EARLY_FLATTREE | 9 | select OF_EARLY_FLATTREE |
10 | select OF_IRQ | 10 | select OF_IRQ |
11 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
12 | select ARCH_WANT_FRAME_POINTERS | 11 | select ARCH_WANT_FRAME_POINTERS |
13 | select CLONE_BACKWARDS | 12 | select CLONE_BACKWARDS |
14 | select COMMON_CLK | 13 | select COMMON_CLK |
@@ -20,7 +19,6 @@ config RISCV | |||
20 | select GENERIC_STRNLEN_USER | 19 | select GENERIC_STRNLEN_USER |
21 | select GENERIC_SMP_IDLE_THREAD | 20 | select GENERIC_SMP_IDLE_THREAD |
22 | select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A | 21 | select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A |
23 | select ARCH_WANT_OPTIONAL_GPIOLIB | ||
24 | select HAVE_MEMBLOCK | 22 | select HAVE_MEMBLOCK |
25 | select HAVE_MEMBLOCK_NODE_MAP | 23 | select HAVE_MEMBLOCK_NODE_MAP |
26 | select HAVE_DMA_API_DEBUG | 24 | select HAVE_DMA_API_DEBUG |
@@ -34,7 +32,6 @@ config RISCV | |||
34 | select HAVE_ARCH_TRACEHOOK | 32 | select HAVE_ARCH_TRACEHOOK |
35 | select MODULES_USE_ELF_RELA if MODULES | 33 | select MODULES_USE_ELF_RELA if MODULES |
36 | select THREAD_INFO_IN_TASK | 34 | select THREAD_INFO_IN_TASK |
37 | select RISCV_IRQ_INTC | ||
38 | select RISCV_TIMER | 35 | select RISCV_TIMER |
39 | 36 | ||
40 | config MMU | 37 | config MMU |
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index 87fc045be51f..56fa592cfa34 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S | |||
@@ -172,6 +172,9 @@ ENTRY(handle_exception) | |||
172 | move a1, sp /* pt_regs */ | 172 | move a1, sp /* pt_regs */ |
173 | tail do_IRQ | 173 | tail do_IRQ |
174 | 1: | 174 | 1: |
175 | /* Exceptions run with interrupts enabled */ | ||
176 | csrs sstatus, SR_SIE | ||
177 | |||
175 | /* Handle syscalls */ | 178 | /* Handle syscalls */ |
176 | li t0, EXC_SYSCALL | 179 | li t0, EXC_SYSCALL |
177 | beq s4, t0, handle_syscall | 180 | beq s4, t0, handle_syscall |
@@ -198,8 +201,6 @@ handle_syscall: | |||
198 | */ | 201 | */ |
199 | addi s2, s2, 0x4 | 202 | addi s2, s2, 0x4 |
200 | REG_S s2, PT_SEPC(sp) | 203 | REG_S s2, PT_SEPC(sp) |
201 | /* System calls run with interrupts enabled */ | ||
202 | csrs sstatus, SR_SIE | ||
203 | /* Trace syscalls, but only if requested by the user. */ | 204 | /* Trace syscalls, but only if requested by the user. */ |
204 | REG_L t0, TASK_TI_FLAGS(tp) | 205 | REG_L t0, TASK_TI_FLAGS(tp) |
205 | andi t0, t0, _TIF_SYSCALL_TRACE | 206 | andi t0, t0, _TIF_SYSCALL_TRACE |
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 226eeb190f90..6e07ed37bbff 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S | |||
@@ -64,7 +64,7 @@ ENTRY(_start) | |||
64 | /* Start the kernel */ | 64 | /* Start the kernel */ |
65 | mv a0, s0 | 65 | mv a0, s0 |
66 | mv a1, s1 | 66 | mv a1, s1 |
67 | call sbi_save | 67 | call parse_dtb |
68 | tail start_kernel | 68 | tail start_kernel |
69 | 69 | ||
70 | relocate: | 70 | relocate: |
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 09f7064e898c..c11f40c1b2a8 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c | |||
@@ -144,7 +144,7 @@ asmlinkage void __init setup_vm(void) | |||
144 | #endif | 144 | #endif |
145 | } | 145 | } |
146 | 146 | ||
147 | void __init sbi_save(unsigned int hartid, void *dtb) | 147 | void __init parse_dtb(unsigned int hartid, void *dtb) |
148 | { | 148 | { |
149 | early_init_dt_scan(__va(dtb)); | 149 | early_init_dt_scan(__va(dtb)); |
150 | } | 150 | } |
diff --git a/arch/sparc/include/asm/bug.h b/arch/sparc/include/asm/bug.h index 6f17528356b2..ea53e418f6c0 100644 --- a/arch/sparc/include/asm/bug.h +++ b/arch/sparc/include/asm/bug.h | |||
@@ -9,10 +9,14 @@ | |||
9 | void do_BUG(const char *file, int line); | 9 | void do_BUG(const char *file, int line); |
10 | #define BUG() do { \ | 10 | #define BUG() do { \ |
11 | do_BUG(__FILE__, __LINE__); \ | 11 | do_BUG(__FILE__, __LINE__); \ |
12 | barrier_before_unreachable(); \ | ||
12 | __builtin_trap(); \ | 13 | __builtin_trap(); \ |
13 | } while (0) | 14 | } while (0) |
14 | #else | 15 | #else |
15 | #define BUG() __builtin_trap() | 16 | #define BUG() do { \ |
17 | barrier_before_unreachable(); \ | ||
18 | __builtin_trap(); \ | ||
19 | } while (0) | ||
16 | #endif | 20 | #endif |
17 | 21 | ||
18 | #define HAVE_ARCH_BUG | 22 | #define HAVE_ARCH_BUG |
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 76b058533e47..81a1be326571 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h | |||
@@ -177,4 +177,41 @@ static inline void indirect_branch_prediction_barrier(void) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | #endif /* __ASSEMBLY__ */ | 179 | #endif /* __ASSEMBLY__ */ |
180 | |||
181 | /* | ||
182 | * Below is used in the eBPF JIT compiler and emits the byte sequence | ||
183 | * for the following assembly: | ||
184 | * | ||
185 | * With retpolines configured: | ||
186 | * | ||
187 | * callq do_rop | ||
188 | * spec_trap: | ||
189 | * pause | ||
190 | * lfence | ||
191 | * jmp spec_trap | ||
192 | * do_rop: | ||
193 | * mov %rax,(%rsp) | ||
194 | * retq | ||
195 | * | ||
196 | * Without retpolines configured: | ||
197 | * | ||
198 | * jmp *%rax | ||
199 | */ | ||
200 | #ifdef CONFIG_RETPOLINE | ||
201 | # define RETPOLINE_RAX_BPF_JIT_SIZE 17 | ||
202 | # define RETPOLINE_RAX_BPF_JIT() \ | ||
203 | EMIT1_off32(0xE8, 7); /* callq do_rop */ \ | ||
204 | /* spec_trap: */ \ | ||
205 | EMIT2(0xF3, 0x90); /* pause */ \ | ||
206 | EMIT3(0x0F, 0xAE, 0xE8); /* lfence */ \ | ||
207 | EMIT2(0xEB, 0xF9); /* jmp spec_trap */ \ | ||
208 | /* do_rop: */ \ | ||
209 | EMIT4(0x48, 0x89, 0x04, 0x24); /* mov %rax,(%rsp) */ \ | ||
210 | EMIT1(0xC3); /* retq */ | ||
211 | #else | ||
212 | # define RETPOLINE_RAX_BPF_JIT_SIZE 2 | ||
213 | # define RETPOLINE_RAX_BPF_JIT() \ | ||
214 | EMIT2(0xFF, 0xE0); /* jmp *%rax */ | ||
215 | #endif | ||
216 | |||
180 | #endif /* _ASM_X86_NOSPEC_BRANCH_H_ */ | 217 | #endif /* _ASM_X86_NOSPEC_BRANCH_H_ */ |
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c index 1f790cf9d38f..3b7427aa7d85 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c | |||
@@ -542,6 +542,7 @@ int arch_kexec_apply_relocations_add(const Elf64_Ehdr *ehdr, | |||
542 | goto overflow; | 542 | goto overflow; |
543 | break; | 543 | break; |
544 | case R_X86_64_PC32: | 544 | case R_X86_64_PC32: |
545 | case R_X86_64_PLT32: | ||
545 | value -= (u64)address; | 546 | value -= (u64)address; |
546 | *(u32 *)location = value; | 547 | *(u32 *)location = value; |
547 | break; | 548 | break; |
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index da0c160e5589..f58336af095c 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c | |||
@@ -191,6 +191,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
191 | goto overflow; | 191 | goto overflow; |
192 | break; | 192 | break; |
193 | case R_X86_64_PC32: | 193 | case R_X86_64_PC32: |
194 | case R_X86_64_PLT32: | ||
194 | if (*(u32 *)loc != 0) | 195 | if (*(u32 *)loc != 0) |
195 | goto invalid_relocation; | 196 | goto invalid_relocation; |
196 | val -= (u64)loc; | 197 | val -= (u64)loc; |
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 4923d92f918d..45e4eb5bcbb2 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/if_vlan.h> | 13 | #include <linux/if_vlan.h> |
14 | #include <asm/cacheflush.h> | 14 | #include <asm/cacheflush.h> |
15 | #include <asm/set_memory.h> | 15 | #include <asm/set_memory.h> |
16 | #include <asm/nospec-branch.h> | ||
16 | #include <linux/bpf.h> | 17 | #include <linux/bpf.h> |
17 | 18 | ||
18 | /* | 19 | /* |
@@ -290,7 +291,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
290 | EMIT2(0x89, 0xD2); /* mov edx, edx */ | 291 | EMIT2(0x89, 0xD2); /* mov edx, edx */ |
291 | EMIT3(0x39, 0x56, /* cmp dword ptr [rsi + 16], edx */ | 292 | EMIT3(0x39, 0x56, /* cmp dword ptr [rsi + 16], edx */ |
292 | offsetof(struct bpf_array, map.max_entries)); | 293 | offsetof(struct bpf_array, map.max_entries)); |
293 | #define OFFSET1 43 /* number of bytes to jump */ | 294 | #define OFFSET1 (41 + RETPOLINE_RAX_BPF_JIT_SIZE) /* number of bytes to jump */ |
294 | EMIT2(X86_JBE, OFFSET1); /* jbe out */ | 295 | EMIT2(X86_JBE, OFFSET1); /* jbe out */ |
295 | label1 = cnt; | 296 | label1 = cnt; |
296 | 297 | ||
@@ -299,7 +300,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
299 | */ | 300 | */ |
300 | EMIT2_off32(0x8B, 0x85, 36); /* mov eax, dword ptr [rbp + 36] */ | 301 | EMIT2_off32(0x8B, 0x85, 36); /* mov eax, dword ptr [rbp + 36] */ |
301 | EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ | 302 | EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ |
302 | #define OFFSET2 32 | 303 | #define OFFSET2 (30 + RETPOLINE_RAX_BPF_JIT_SIZE) |
303 | EMIT2(X86_JA, OFFSET2); /* ja out */ | 304 | EMIT2(X86_JA, OFFSET2); /* ja out */ |
304 | label2 = cnt; | 305 | label2 = cnt; |
305 | EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ | 306 | EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ |
@@ -313,7 +314,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
313 | * goto out; | 314 | * goto out; |
314 | */ | 315 | */ |
315 | EMIT3(0x48, 0x85, 0xC0); /* test rax,rax */ | 316 | EMIT3(0x48, 0x85, 0xC0); /* test rax,rax */ |
316 | #define OFFSET3 10 | 317 | #define OFFSET3 (8 + RETPOLINE_RAX_BPF_JIT_SIZE) |
317 | EMIT2(X86_JE, OFFSET3); /* je out */ | 318 | EMIT2(X86_JE, OFFSET3); /* je out */ |
318 | label3 = cnt; | 319 | label3 = cnt; |
319 | 320 | ||
@@ -326,7 +327,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
326 | * rdi == ctx (1st arg) | 327 | * rdi == ctx (1st arg) |
327 | * rax == prog->bpf_func + prologue_size | 328 | * rax == prog->bpf_func + prologue_size |
328 | */ | 329 | */ |
329 | EMIT2(0xFF, 0xE0); /* jmp rax */ | 330 | RETPOLINE_RAX_BPF_JIT(); |
330 | 331 | ||
331 | /* out: */ | 332 | /* out: */ |
332 | BUILD_BUG_ON(cnt - label1 != OFFSET1); | 333 | BUILD_BUG_ON(cnt - label1 != OFFSET1); |
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index 5d73c443e778..220e97841e49 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c | |||
@@ -770,9 +770,12 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym, | |||
770 | break; | 770 | break; |
771 | 771 | ||
772 | case R_X86_64_PC32: | 772 | case R_X86_64_PC32: |
773 | case R_X86_64_PLT32: | ||
773 | /* | 774 | /* |
774 | * PC relative relocations don't need to be adjusted unless | 775 | * PC relative relocations don't need to be adjusted unless |
775 | * referencing a percpu symbol. | 776 | * referencing a percpu symbol. |
777 | * | ||
778 | * NB: R_X86_64_PLT32 can be treated as R_X86_64_PC32. | ||
776 | */ | 779 | */ |
777 | if (is_percpu_sym(sym, symname)) | 780 | if (is_percpu_sym(sym, symname)) |
778 | add_reloc(&relocs32neg, offset); | 781 | add_reloc(&relocs32neg, offset); |
diff --git a/certs/blacklist_nohashes.c b/certs/blacklist_nohashes.c index 73fd99098ad7..753b703ef0ef 100644 --- a/certs/blacklist_nohashes.c +++ b/certs/blacklist_nohashes.c | |||
@@ -1,6 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include "blacklist.h" | 2 | #include "blacklist.h" |
3 | 3 | ||
4 | const char __initdata *const blacklist_hashes[] = { | 4 | const char __initconst *const blacklist_hashes[] = { |
5 | NULL | 5 | NULL |
6 | }; | 6 | }; |
diff --git a/crypto/asymmetric_keys/pkcs7_trust.c b/crypto/asymmetric_keys/pkcs7_trust.c index 1f4e25f10049..598906b1e28d 100644 --- a/crypto/asymmetric_keys/pkcs7_trust.c +++ b/crypto/asymmetric_keys/pkcs7_trust.c | |||
@@ -106,6 +106,7 @@ static int pkcs7_validate_trust_one(struct pkcs7_message *pkcs7, | |||
106 | pr_devel("sinfo %u: Direct signer is key %x\n", | 106 | pr_devel("sinfo %u: Direct signer is key %x\n", |
107 | sinfo->index, key_serial(key)); | 107 | sinfo->index, key_serial(key)); |
108 | x509 = NULL; | 108 | x509 = NULL; |
109 | sig = sinfo->sig; | ||
109 | goto matched; | 110 | goto matched; |
110 | } | 111 | } |
111 | if (PTR_ERR(key) != -ENOKEY) | 112 | if (PTR_ERR(key) != -ENOKEY) |
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c index 39e6de0c2761..97c77f66b20d 100644 --- a/crypto/asymmetric_keys/pkcs7_verify.c +++ b/crypto/asymmetric_keys/pkcs7_verify.c | |||
@@ -270,7 +270,7 @@ static int pkcs7_verify_sig_chain(struct pkcs7_message *pkcs7, | |||
270 | sinfo->index); | 270 | sinfo->index); |
271 | return 0; | 271 | return 0; |
272 | } | 272 | } |
273 | ret = public_key_verify_signature(p->pub, p->sig); | 273 | ret = public_key_verify_signature(p->pub, x509->sig); |
274 | if (ret < 0) | 274 | if (ret < 0) |
275 | return ret; | 275 | return ret; |
276 | x509->signer = p; | 276 | x509->signer = p; |
@@ -366,8 +366,7 @@ static int pkcs7_verify_one(struct pkcs7_message *pkcs7, | |||
366 | * | 366 | * |
367 | * (*) -EBADMSG if some part of the message was invalid, or: | 367 | * (*) -EBADMSG if some part of the message was invalid, or: |
368 | * | 368 | * |
369 | * (*) 0 if no signature chains were found to be blacklisted or to contain | 369 | * (*) 0 if a signature chain passed verification, or: |
370 | * unsupported crypto, or: | ||
371 | * | 370 | * |
372 | * (*) -EKEYREJECTED if a blacklisted key was encountered, or: | 371 | * (*) -EKEYREJECTED if a blacklisted key was encountered, or: |
373 | * | 372 | * |
@@ -423,8 +422,11 @@ int pkcs7_verify(struct pkcs7_message *pkcs7, | |||
423 | 422 | ||
424 | for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { | 423 | for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { |
425 | ret = pkcs7_verify_one(pkcs7, sinfo); | 424 | ret = pkcs7_verify_one(pkcs7, sinfo); |
426 | if (sinfo->blacklisted && actual_ret == -ENOPKG) | 425 | if (sinfo->blacklisted) { |
427 | actual_ret = -EKEYREJECTED; | 426 | if (actual_ret == -ENOPKG) |
427 | actual_ret = -EKEYREJECTED; | ||
428 | continue; | ||
429 | } | ||
428 | if (ret < 0) { | 430 | if (ret < 0) { |
429 | if (ret == -ENOPKG) { | 431 | if (ret == -ENOPKG) { |
430 | sinfo->unsupported_crypto = true; | 432 | sinfo->unsupported_crypto = true; |
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index de996586762a..e929fe1e4106 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c | |||
@@ -79,9 +79,11 @@ int public_key_verify_signature(const struct public_key *pkey, | |||
79 | 79 | ||
80 | BUG_ON(!pkey); | 80 | BUG_ON(!pkey); |
81 | BUG_ON(!sig); | 81 | BUG_ON(!sig); |
82 | BUG_ON(!sig->digest); | ||
83 | BUG_ON(!sig->s); | 82 | BUG_ON(!sig->s); |
84 | 83 | ||
84 | if (!sig->digest) | ||
85 | return -ENOPKG; | ||
86 | |||
85 | alg_name = sig->pkey_algo; | 87 | alg_name = sig->pkey_algo; |
86 | if (strcmp(sig->pkey_algo, "rsa") == 0) { | 88 | if (strcmp(sig->pkey_algo, "rsa") == 0) { |
87 | /* The data wangled by the RSA algorithm is typically padded | 89 | /* The data wangled by the RSA algorithm is typically padded |
diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c index 86fb68508952..7c93c7728454 100644 --- a/crypto/asymmetric_keys/restrict.c +++ b/crypto/asymmetric_keys/restrict.c | |||
@@ -67,8 +67,9 @@ __setup("ca_keys=", ca_keys_setup); | |||
67 | * | 67 | * |
68 | * Returns 0 if the new certificate was accepted, -ENOKEY if we couldn't find a | 68 | * Returns 0 if the new certificate was accepted, -ENOKEY if we couldn't find a |
69 | * matching parent certificate in the trusted list, -EKEYREJECTED if the | 69 | * matching parent certificate in the trusted list, -EKEYREJECTED if the |
70 | * signature check fails or the key is blacklisted and some other error if | 70 | * signature check fails or the key is blacklisted, -ENOPKG if the signature |
71 | * there is a matching certificate but the signature check cannot be performed. | 71 | * uses unsupported crypto, or some other error if there is a matching |
72 | * certificate but the signature check cannot be performed. | ||
72 | */ | 73 | */ |
73 | int restrict_link_by_signature(struct key *dest_keyring, | 74 | int restrict_link_by_signature(struct key *dest_keyring, |
74 | const struct key_type *type, | 75 | const struct key_type *type, |
@@ -88,6 +89,8 @@ int restrict_link_by_signature(struct key *dest_keyring, | |||
88 | return -EOPNOTSUPP; | 89 | return -EOPNOTSUPP; |
89 | 90 | ||
90 | sig = payload->data[asym_auth]; | 91 | sig = payload->data[asym_auth]; |
92 | if (!sig) | ||
93 | return -ENOPKG; | ||
91 | if (!sig->auth_ids[0] && !sig->auth_ids[1]) | 94 | if (!sig->auth_ids[0] && !sig->auth_ids[1]) |
92 | return -ENOKEY; | 95 | return -ENOKEY; |
93 | 96 | ||
@@ -139,6 +142,8 @@ static int key_or_keyring_common(struct key *dest_keyring, | |||
139 | return -EOPNOTSUPP; | 142 | return -EOPNOTSUPP; |
140 | 143 | ||
141 | sig = payload->data[asym_auth]; | 144 | sig = payload->data[asym_auth]; |
145 | if (!sig) | ||
146 | return -ENOPKG; | ||
142 | if (!sig->auth_ids[0] && !sig->auth_ids[1]) | 147 | if (!sig->auth_ids[0] && !sig->auth_ids[1]) |
143 | return -ENOKEY; | 148 | return -ENOKEY; |
144 | 149 | ||
@@ -222,9 +227,9 @@ static int key_or_keyring_common(struct key *dest_keyring, | |||
222 | * | 227 | * |
223 | * Returns 0 if the new certificate was accepted, -ENOKEY if we | 228 | * Returns 0 if the new certificate was accepted, -ENOKEY if we |
224 | * couldn't find a matching parent certificate in the trusted list, | 229 | * couldn't find a matching parent certificate in the trusted list, |
225 | * -EKEYREJECTED if the signature check fails, and some other error if | 230 | * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses |
226 | * there is a matching certificate but the signature check cannot be | 231 | * unsupported crypto, or some other error if there is a matching certificate |
227 | * performed. | 232 | * but the signature check cannot be performed. |
228 | */ | 233 | */ |
229 | int restrict_link_by_key_or_keyring(struct key *dest_keyring, | 234 | int restrict_link_by_key_or_keyring(struct key *dest_keyring, |
230 | const struct key_type *type, | 235 | const struct key_type *type, |
@@ -249,9 +254,9 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring, | |||
249 | * | 254 | * |
250 | * Returns 0 if the new certificate was accepted, -ENOKEY if we | 255 | * Returns 0 if the new certificate was accepted, -ENOKEY if we |
251 | * couldn't find a matching parent certificate in the trusted list, | 256 | * couldn't find a matching parent certificate in the trusted list, |
252 | * -EKEYREJECTED if the signature check fails, and some other error if | 257 | * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses |
253 | * there is a matching certificate but the signature check cannot be | 258 | * unsupported crypto, or some other error if there is a matching certificate |
254 | * performed. | 259 | * but the signature check cannot be performed. |
255 | */ | 260 | */ |
256 | int restrict_link_by_key_or_keyring_chain(struct key *dest_keyring, | 261 | int restrict_link_by_key_or_keyring_chain(struct key *dest_keyring, |
257 | const struct key_type *type, | 262 | const struct key_type *type, |
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 15e3d3c2260d..764b63a5aade 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c | |||
@@ -1991,8 +1991,14 @@ static void binder_send_failed_reply(struct binder_transaction *t, | |||
1991 | &target_thread->reply_error.work); | 1991 | &target_thread->reply_error.work); |
1992 | wake_up_interruptible(&target_thread->wait); | 1992 | wake_up_interruptible(&target_thread->wait); |
1993 | } else { | 1993 | } else { |
1994 | WARN(1, "Unexpected reply error: %u\n", | 1994 | /* |
1995 | target_thread->reply_error.cmd); | 1995 | * Cannot get here for normal operation, but |
1996 | * we can if multiple synchronous transactions | ||
1997 | * are sent without blocking for responses. | ||
1998 | * Just ignore the 2nd error in this case. | ||
1999 | */ | ||
2000 | pr_warn("Unexpected reply error: %u\n", | ||
2001 | target_thread->reply_error.cmd); | ||
1996 | } | 2002 | } |
1997 | binder_inner_proc_unlock(target_thread->proc); | 2003 | binder_inner_proc_unlock(target_thread->proc); |
1998 | binder_thread_dec_tmpref(target_thread); | 2004 | binder_thread_dec_tmpref(target_thread); |
@@ -2193,7 +2199,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, | |||
2193 | int debug_id = buffer->debug_id; | 2199 | int debug_id = buffer->debug_id; |
2194 | 2200 | ||
2195 | binder_debug(BINDER_DEBUG_TRANSACTION, | 2201 | binder_debug(BINDER_DEBUG_TRANSACTION, |
2196 | "%d buffer release %d, size %zd-%zd, failed at %p\n", | 2202 | "%d buffer release %d, size %zd-%zd, failed at %pK\n", |
2197 | proc->pid, buffer->debug_id, | 2203 | proc->pid, buffer->debug_id, |
2198 | buffer->data_size, buffer->offsets_size, failed_at); | 2204 | buffer->data_size, buffer->offsets_size, failed_at); |
2199 | 2205 | ||
@@ -3705,7 +3711,7 @@ static int binder_thread_write(struct binder_proc *proc, | |||
3705 | } | 3711 | } |
3706 | } | 3712 | } |
3707 | binder_debug(BINDER_DEBUG_DEAD_BINDER, | 3713 | binder_debug(BINDER_DEBUG_DEAD_BINDER, |
3708 | "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n", | 3714 | "%d:%d BC_DEAD_BINDER_DONE %016llx found %pK\n", |
3709 | proc->pid, thread->pid, (u64)cookie, | 3715 | proc->pid, thread->pid, (u64)cookie, |
3710 | death); | 3716 | death); |
3711 | if (death == NULL) { | 3717 | if (death == NULL) { |
@@ -4376,6 +4382,15 @@ static int binder_thread_release(struct binder_proc *proc, | |||
4376 | 4382 | ||
4377 | binder_inner_proc_unlock(thread->proc); | 4383 | binder_inner_proc_unlock(thread->proc); |
4378 | 4384 | ||
4385 | /* | ||
4386 | * This is needed to avoid races between wake_up_poll() above and | ||
4387 | * and ep_remove_waitqueue() called for other reasons (eg the epoll file | ||
4388 | * descriptor being closed); ep_remove_waitqueue() holds an RCU read | ||
4389 | * lock, so we can be sure it's done after calling synchronize_rcu(). | ||
4390 | */ | ||
4391 | if (thread->looper & BINDER_LOOPER_STATE_POLL) | ||
4392 | synchronize_rcu(); | ||
4393 | |||
4379 | if (send_reply) | 4394 | if (send_reply) |
4380 | binder_send_failed_reply(send_reply, BR_DEAD_REPLY); | 4395 | binder_send_failed_reply(send_reply, BR_DEAD_REPLY); |
4381 | binder_release_work(proc, &thread->todo); | 4396 | binder_release_work(proc, &thread->todo); |
@@ -4391,6 +4406,8 @@ static __poll_t binder_poll(struct file *filp, | |||
4391 | bool wait_for_proc_work; | 4406 | bool wait_for_proc_work; |
4392 | 4407 | ||
4393 | thread = binder_get_thread(proc); | 4408 | thread = binder_get_thread(proc); |
4409 | if (!thread) | ||
4410 | return POLLERR; | ||
4394 | 4411 | ||
4395 | binder_inner_proc_lock(thread->proc); | 4412 | binder_inner_proc_lock(thread->proc); |
4396 | thread->looper |= BINDER_LOOPER_STATE_POLL; | 4413 | thread->looper |= BINDER_LOOPER_STATE_POLL; |
@@ -5034,7 +5051,7 @@ static void print_binder_transaction_ilocked(struct seq_file *m, | |||
5034 | spin_lock(&t->lock); | 5051 | spin_lock(&t->lock); |
5035 | to_proc = t->to_proc; | 5052 | to_proc = t->to_proc; |
5036 | seq_printf(m, | 5053 | seq_printf(m, |
5037 | "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d", | 5054 | "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d", |
5038 | prefix, t->debug_id, t, | 5055 | prefix, t->debug_id, t, |
5039 | t->from ? t->from->proc->pid : 0, | 5056 | t->from ? t->from->proc->pid : 0, |
5040 | t->from ? t->from->pid : 0, | 5057 | t->from ? t->from->pid : 0, |
@@ -5058,7 +5075,7 @@ static void print_binder_transaction_ilocked(struct seq_file *m, | |||
5058 | } | 5075 | } |
5059 | if (buffer->target_node) | 5076 | if (buffer->target_node) |
5060 | seq_printf(m, " node %d", buffer->target_node->debug_id); | 5077 | seq_printf(m, " node %d", buffer->target_node->debug_id); |
5061 | seq_printf(m, " size %zd:%zd data %p\n", | 5078 | seq_printf(m, " size %zd:%zd data %pK\n", |
5062 | buffer->data_size, buffer->offsets_size, | 5079 | buffer->data_size, buffer->offsets_size, |
5063 | buffer->data); | 5080 | buffer->data); |
5064 | } | 5081 | } |
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 188f44b7eb27..5d64c08b7f47 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c | |||
@@ -1922,15 +1922,21 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) | |||
1922 | uint32_t aes_control; | 1922 | uint32_t aes_control; |
1923 | unsigned long flags; | 1923 | unsigned long flags; |
1924 | int err; | 1924 | int err; |
1925 | u8 *iv; | ||
1925 | 1926 | ||
1926 | aes_control = SSS_AES_KEY_CHANGE_MODE; | 1927 | aes_control = SSS_AES_KEY_CHANGE_MODE; |
1927 | if (mode & FLAGS_AES_DECRYPT) | 1928 | if (mode & FLAGS_AES_DECRYPT) |
1928 | aes_control |= SSS_AES_MODE_DECRYPT; | 1929 | aes_control |= SSS_AES_MODE_DECRYPT; |
1929 | 1930 | ||
1930 | if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) | 1931 | if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) { |
1931 | aes_control |= SSS_AES_CHAIN_MODE_CBC; | 1932 | aes_control |= SSS_AES_CHAIN_MODE_CBC; |
1932 | else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) | 1933 | iv = req->info; |
1934 | } else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) { | ||
1933 | aes_control |= SSS_AES_CHAIN_MODE_CTR; | 1935 | aes_control |= SSS_AES_CHAIN_MODE_CTR; |
1936 | iv = req->info; | ||
1937 | } else { | ||
1938 | iv = NULL; /* AES_ECB */ | ||
1939 | } | ||
1934 | 1940 | ||
1935 | if (dev->ctx->keylen == AES_KEYSIZE_192) | 1941 | if (dev->ctx->keylen == AES_KEYSIZE_192) |
1936 | aes_control |= SSS_AES_KEY_SIZE_192; | 1942 | aes_control |= SSS_AES_KEY_SIZE_192; |
@@ -1961,7 +1967,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) | |||
1961 | goto outdata_error; | 1967 | goto outdata_error; |
1962 | 1968 | ||
1963 | SSS_AES_WRITE(dev, AES_CONTROL, aes_control); | 1969 | SSS_AES_WRITE(dev, AES_CONTROL, aes_control); |
1964 | s5p_set_aes(dev, dev->ctx->aes_key, req->info, dev->ctx->keylen); | 1970 | s5p_set_aes(dev, dev->ctx->aes_key, iv, dev->ctx->keylen); |
1965 | 1971 | ||
1966 | s5p_set_dma_indata(dev, dev->sg_src); | 1972 | s5p_set_dma_indata(dev, dev->sg_src); |
1967 | s5p_set_dma_outdata(dev, dev->sg_dst); | 1973 | s5p_set_dma_outdata(dev, dev->sg_dst); |
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c index 0a44d43802fe..3ec4c715e240 100644 --- a/drivers/extcon/extcon-axp288.c +++ b/drivers/extcon/extcon-axp288.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver | 2 | * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver |
3 | * | 3 | * |
4 | * Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com> | ||
5 | * Copyright (C) 2015 Intel Corporation | 4 | * Copyright (C) 2015 Intel Corporation |
6 | * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com> | 5 | * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com> |
7 | * | 6 | * |
@@ -98,15 +97,13 @@ struct axp288_extcon_info { | |||
98 | struct device *dev; | 97 | struct device *dev; |
99 | struct regmap *regmap; | 98 | struct regmap *regmap; |
100 | struct regmap_irq_chip_data *regmap_irqc; | 99 | struct regmap_irq_chip_data *regmap_irqc; |
101 | struct delayed_work det_work; | ||
102 | int irq[EXTCON_IRQ_END]; | 100 | int irq[EXTCON_IRQ_END]; |
103 | struct extcon_dev *edev; | 101 | struct extcon_dev *edev; |
104 | unsigned int previous_cable; | 102 | unsigned int previous_cable; |
105 | bool first_detect_done; | ||
106 | }; | 103 | }; |
107 | 104 | ||
108 | /* Power up/down reason string array */ | 105 | /* Power up/down reason string array */ |
109 | static char *axp288_pwr_up_down_info[] = { | 106 | static const char * const axp288_pwr_up_down_info[] = { |
110 | "Last wake caused by user pressing the power button", | 107 | "Last wake caused by user pressing the power button", |
111 | "Last wake caused by a charger insertion", | 108 | "Last wake caused by a charger insertion", |
112 | "Last wake caused by a battery insertion", | 109 | "Last wake caused by a battery insertion", |
@@ -124,7 +121,7 @@ static char *axp288_pwr_up_down_info[] = { | |||
124 | */ | 121 | */ |
125 | static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) | 122 | static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) |
126 | { | 123 | { |
127 | char **rsi; | 124 | const char * const *rsi; |
128 | unsigned int val, i, clear_mask = 0; | 125 | unsigned int val, i, clear_mask = 0; |
129 | int ret; | 126 | int ret; |
130 | 127 | ||
@@ -140,25 +137,6 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) | |||
140 | regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); | 137 | regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); |
141 | } | 138 | } |
142 | 139 | ||
143 | static void axp288_chrg_detect_complete(struct axp288_extcon_info *info) | ||
144 | { | ||
145 | /* | ||
146 | * We depend on other drivers to do things like mux the data lines, | ||
147 | * enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has | ||
148 | * not set these things up correctly resulting in the initial charger | ||
149 | * cable type detection giving a wrong result and we end up not charging | ||
150 | * or charging at only 0.5A. | ||
151 | * | ||
152 | * So we schedule a second cable type detection after 2 seconds to | ||
153 | * give the other drivers time to load and do their thing. | ||
154 | */ | ||
155 | if (!info->first_detect_done) { | ||
156 | queue_delayed_work(system_wq, &info->det_work, | ||
157 | msecs_to_jiffies(2000)); | ||
158 | info->first_detect_done = true; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) | 140 | static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) |
163 | { | 141 | { |
164 | int ret, stat, cfg, pwr_stat; | 142 | int ret, stat, cfg, pwr_stat; |
@@ -223,8 +201,6 @@ no_vbus: | |||
223 | info->previous_cable = cable; | 201 | info->previous_cable = cable; |
224 | } | 202 | } |
225 | 203 | ||
226 | axp288_chrg_detect_complete(info); | ||
227 | |||
228 | return 0; | 204 | return 0; |
229 | 205 | ||
230 | dev_det_ret: | 206 | dev_det_ret: |
@@ -246,11 +222,8 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data) | |||
246 | return IRQ_HANDLED; | 222 | return IRQ_HANDLED; |
247 | } | 223 | } |
248 | 224 | ||
249 | static void axp288_extcon_det_work(struct work_struct *work) | 225 | static void axp288_extcon_enable(struct axp288_extcon_info *info) |
250 | { | 226 | { |
251 | struct axp288_extcon_info *info = | ||
252 | container_of(work, struct axp288_extcon_info, det_work.work); | ||
253 | |||
254 | regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, | 227 | regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, |
255 | BC_GLOBAL_RUN, 0); | 228 | BC_GLOBAL_RUN, 0); |
256 | /* Enable the charger detection logic */ | 229 | /* Enable the charger detection logic */ |
@@ -272,7 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
272 | info->regmap = axp20x->regmap; | 245 | info->regmap = axp20x->regmap; |
273 | info->regmap_irqc = axp20x->regmap_irqc; | 246 | info->regmap_irqc = axp20x->regmap_irqc; |
274 | info->previous_cable = EXTCON_NONE; | 247 | info->previous_cable = EXTCON_NONE; |
275 | INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work); | ||
276 | 248 | ||
277 | platform_set_drvdata(pdev, info); | 249 | platform_set_drvdata(pdev, info); |
278 | 250 | ||
@@ -318,7 +290,7 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
318 | } | 290 | } |
319 | 291 | ||
320 | /* Start charger cable type detection */ | 292 | /* Start charger cable type detection */ |
321 | queue_delayed_work(system_wq, &info->det_work, 0); | 293 | axp288_extcon_enable(info); |
322 | 294 | ||
323 | return 0; | 295 | return 0; |
324 | } | 296 | } |
diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c index c8691b5a9cb0..191e99f06a9a 100644 --- a/drivers/extcon/extcon-intel-int3496.c +++ b/drivers/extcon/extcon-intel-int3496.c | |||
@@ -153,8 +153,9 @@ static int int3496_probe(struct platform_device *pdev) | |||
153 | return ret; | 153 | return ret; |
154 | } | 154 | } |
155 | 155 | ||
156 | /* queue initial processing of id-pin */ | 156 | /* process id-pin so that we start with the right status */ |
157 | queue_delayed_work(system_wq, &data->work, 0); | 157 | queue_delayed_work(system_wq, &data->work, 0); |
158 | flush_delayed_work(&data->work); | ||
158 | 159 | ||
159 | platform_set_drvdata(pdev, data); | 160 | platform_set_drvdata(pdev, data); |
160 | 161 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index 8ca3783f2deb..74d2efaec52f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | |||
@@ -736,9 +736,11 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force) | |||
736 | enum drm_connector_status ret = connector_status_disconnected; | 736 | enum drm_connector_status ret = connector_status_disconnected; |
737 | int r; | 737 | int r; |
738 | 738 | ||
739 | r = pm_runtime_get_sync(connector->dev->dev); | 739 | if (!drm_kms_helper_is_poll_worker()) { |
740 | if (r < 0) | 740 | r = pm_runtime_get_sync(connector->dev->dev); |
741 | return connector_status_disconnected; | 741 | if (r < 0) |
742 | return connector_status_disconnected; | ||
743 | } | ||
742 | 744 | ||
743 | if (encoder) { | 745 | if (encoder) { |
744 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); | 746 | struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); |
@@ -757,8 +759,12 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force) | |||
757 | /* check acpi lid status ??? */ | 759 | /* check acpi lid status ??? */ |
758 | 760 | ||
759 | amdgpu_connector_update_scratch_regs(connector, ret); | 761 | amdgpu_connector_update_scratch_regs(connector, ret); |
760 | pm_runtime_mark_last_busy(connector->dev->dev); | 762 | |
761 | pm_runtime_put_autosuspend(connector->dev->dev); | 763 | if (!drm_kms_helper_is_poll_worker()) { |
764 | pm_runtime_mark_last_busy(connector->dev->dev); | ||
765 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
766 | } | ||
767 | |||
762 | return ret; | 768 | return ret; |
763 | } | 769 | } |
764 | 770 | ||
@@ -868,9 +874,11 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force) | |||
868 | enum drm_connector_status ret = connector_status_disconnected; | 874 | enum drm_connector_status ret = connector_status_disconnected; |
869 | int r; | 875 | int r; |
870 | 876 | ||
871 | r = pm_runtime_get_sync(connector->dev->dev); | 877 | if (!drm_kms_helper_is_poll_worker()) { |
872 | if (r < 0) | 878 | r = pm_runtime_get_sync(connector->dev->dev); |
873 | return connector_status_disconnected; | 879 | if (r < 0) |
880 | return connector_status_disconnected; | ||
881 | } | ||
874 | 882 | ||
875 | encoder = amdgpu_connector_best_single_encoder(connector); | 883 | encoder = amdgpu_connector_best_single_encoder(connector); |
876 | if (!encoder) | 884 | if (!encoder) |
@@ -924,8 +932,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force) | |||
924 | amdgpu_connector_update_scratch_regs(connector, ret); | 932 | amdgpu_connector_update_scratch_regs(connector, ret); |
925 | 933 | ||
926 | out: | 934 | out: |
927 | pm_runtime_mark_last_busy(connector->dev->dev); | 935 | if (!drm_kms_helper_is_poll_worker()) { |
928 | pm_runtime_put_autosuspend(connector->dev->dev); | 936 | pm_runtime_mark_last_busy(connector->dev->dev); |
937 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
938 | } | ||
929 | 939 | ||
930 | return ret; | 940 | return ret; |
931 | } | 941 | } |
@@ -988,9 +998,11 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) | |||
988 | enum drm_connector_status ret = connector_status_disconnected; | 998 | enum drm_connector_status ret = connector_status_disconnected; |
989 | bool dret = false, broken_edid = false; | 999 | bool dret = false, broken_edid = false; |
990 | 1000 | ||
991 | r = pm_runtime_get_sync(connector->dev->dev); | 1001 | if (!drm_kms_helper_is_poll_worker()) { |
992 | if (r < 0) | 1002 | r = pm_runtime_get_sync(connector->dev->dev); |
993 | return connector_status_disconnected; | 1003 | if (r < 0) |
1004 | return connector_status_disconnected; | ||
1005 | } | ||
994 | 1006 | ||
995 | if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { | 1007 | if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { |
996 | ret = connector->status; | 1008 | ret = connector->status; |
@@ -1115,8 +1127,10 @@ out: | |||
1115 | amdgpu_connector_update_scratch_regs(connector, ret); | 1127 | amdgpu_connector_update_scratch_regs(connector, ret); |
1116 | 1128 | ||
1117 | exit: | 1129 | exit: |
1118 | pm_runtime_mark_last_busy(connector->dev->dev); | 1130 | if (!drm_kms_helper_is_poll_worker()) { |
1119 | pm_runtime_put_autosuspend(connector->dev->dev); | 1131 | pm_runtime_mark_last_busy(connector->dev->dev); |
1132 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1133 | } | ||
1120 | 1134 | ||
1121 | return ret; | 1135 | return ret; |
1122 | } | 1136 | } |
@@ -1359,9 +1373,11 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force) | |||
1359 | struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector); | 1373 | struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector); |
1360 | int r; | 1374 | int r; |
1361 | 1375 | ||
1362 | r = pm_runtime_get_sync(connector->dev->dev); | 1376 | if (!drm_kms_helper_is_poll_worker()) { |
1363 | if (r < 0) | 1377 | r = pm_runtime_get_sync(connector->dev->dev); |
1364 | return connector_status_disconnected; | 1378 | if (r < 0) |
1379 | return connector_status_disconnected; | ||
1380 | } | ||
1365 | 1381 | ||
1366 | if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { | 1382 | if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { |
1367 | ret = connector->status; | 1383 | ret = connector->status; |
@@ -1429,8 +1445,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force) | |||
1429 | 1445 | ||
1430 | amdgpu_connector_update_scratch_regs(connector, ret); | 1446 | amdgpu_connector_update_scratch_regs(connector, ret); |
1431 | out: | 1447 | out: |
1432 | pm_runtime_mark_last_busy(connector->dev->dev); | 1448 | if (!drm_kms_helper_is_poll_worker()) { |
1433 | pm_runtime_put_autosuspend(connector->dev->dev); | 1449 | pm_runtime_mark_last_busy(connector->dev->dev); |
1450 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1451 | } | ||
1434 | 1452 | ||
1435 | return ret; | 1453 | return ret; |
1436 | } | 1454 | } |
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c index cd23b1b28259..c91b9b054e3f 100644 --- a/drivers/gpu/drm/cirrus/cirrus_mode.c +++ b/drivers/gpu/drm/cirrus/cirrus_mode.c | |||
@@ -294,22 +294,7 @@ static void cirrus_crtc_prepare(struct drm_crtc *crtc) | |||
294 | { | 294 | { |
295 | } | 295 | } |
296 | 296 | ||
297 | /* | 297 | static void cirrus_crtc_load_lut(struct drm_crtc *crtc) |
298 | * This is called after a mode is programmed. It should reverse anything done | ||
299 | * by the prepare function | ||
300 | */ | ||
301 | static void cirrus_crtc_commit(struct drm_crtc *crtc) | ||
302 | { | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * The core can pass us a set of gamma values to program. We actually only | ||
307 | * use this for 8-bit mode so can't perform smooth fades on deeper modes, | ||
308 | * but it's a requirement that we provide the function | ||
309 | */ | ||
310 | static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | ||
311 | u16 *blue, uint32_t size, | ||
312 | struct drm_modeset_acquire_ctx *ctx) | ||
313 | { | 298 | { |
314 | struct drm_device *dev = crtc->dev; | 299 | struct drm_device *dev = crtc->dev; |
315 | struct cirrus_device *cdev = dev->dev_private; | 300 | struct cirrus_device *cdev = dev->dev_private; |
@@ -317,7 +302,7 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | |||
317 | int i; | 302 | int i; |
318 | 303 | ||
319 | if (!crtc->enabled) | 304 | if (!crtc->enabled) |
320 | return 0; | 305 | return; |
321 | 306 | ||
322 | r = crtc->gamma_store; | 307 | r = crtc->gamma_store; |
323 | g = r + crtc->gamma_size; | 308 | g = r + crtc->gamma_size; |
@@ -330,6 +315,27 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | |||
330 | WREG8(PALETTE_DATA, *g++ >> 8); | 315 | WREG8(PALETTE_DATA, *g++ >> 8); |
331 | WREG8(PALETTE_DATA, *b++ >> 8); | 316 | WREG8(PALETTE_DATA, *b++ >> 8); |
332 | } | 317 | } |
318 | } | ||
319 | |||
320 | /* | ||
321 | * This is called after a mode is programmed. It should reverse anything done | ||
322 | * by the prepare function | ||
323 | */ | ||
324 | static void cirrus_crtc_commit(struct drm_crtc *crtc) | ||
325 | { | ||
326 | cirrus_crtc_load_lut(crtc); | ||
327 | } | ||
328 | |||
329 | /* | ||
330 | * The core can pass us a set of gamma values to program. We actually only | ||
331 | * use this for 8-bit mode so can't perform smooth fades on deeper modes, | ||
332 | * but it's a requirement that we provide the function | ||
333 | */ | ||
334 | static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | ||
335 | u16 *blue, uint32_t size, | ||
336 | struct drm_modeset_acquire_ctx *ctx) | ||
337 | { | ||
338 | cirrus_crtc_load_lut(crtc); | ||
333 | 339 | ||
334 | return 0; | 340 | return 0; |
335 | } | 341 | } |
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ab4032167094..ae3cbfe9e01c 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c | |||
@@ -1878,6 +1878,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state, | |||
1878 | new_crtc_state->event->base.completion = &commit->flip_done; | 1878 | new_crtc_state->event->base.completion = &commit->flip_done; |
1879 | new_crtc_state->event->base.completion_release = release_crtc_commit; | 1879 | new_crtc_state->event->base.completion_release = release_crtc_commit; |
1880 | drm_crtc_commit_get(commit); | 1880 | drm_crtc_commit_get(commit); |
1881 | |||
1882 | commit->abort_completion = true; | ||
1881 | } | 1883 | } |
1882 | 1884 | ||
1883 | for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i) { | 1885 | for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i) { |
@@ -3421,8 +3423,21 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); | |||
3421 | void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) | 3423 | void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) |
3422 | { | 3424 | { |
3423 | if (state->commit) { | 3425 | if (state->commit) { |
3426 | /* | ||
3427 | * In the event that a non-blocking commit returns | ||
3428 | * -ERESTARTSYS before the commit_tail work is queued, we will | ||
3429 | * have an extra reference to the commit object. Release it, if | ||
3430 | * the event has not been consumed by the worker. | ||
3431 | * | ||
3432 | * state->event may be freed, so we can't directly look at | ||
3433 | * state->event->base.completion. | ||
3434 | */ | ||
3435 | if (state->event && state->commit->abort_completion) | ||
3436 | drm_crtc_commit_put(state->commit); | ||
3437 | |||
3424 | kfree(state->commit->event); | 3438 | kfree(state->commit->event); |
3425 | state->commit->event = NULL; | 3439 | state->commit->event = NULL; |
3440 | |||
3426 | drm_crtc_commit_put(state->commit); | 3441 | drm_crtc_commit_put(state->commit); |
3427 | } | 3442 | } |
3428 | 3443 | ||
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index ddd537914575..4f751a9d71a3 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c | |||
@@ -113,6 +113,9 @@ static const struct edid_quirk { | |||
113 | /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ | 113 | /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ |
114 | { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, | 114 | { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, |
115 | 115 | ||
116 | /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ | ||
117 | { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC }, | ||
118 | |||
116 | /* Belinea 10 15 55 */ | 119 | /* Belinea 10 15 55 */ |
117 | { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, | 120 | { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, |
118 | { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, | 121 | { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, |
@@ -162,6 +165,24 @@ static const struct edid_quirk { | |||
162 | 165 | ||
163 | /* HTC Vive VR Headset */ | 166 | /* HTC Vive VR Headset */ |
164 | { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, | 167 | { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, |
168 | |||
169 | /* Oculus Rift DK1, DK2, and CV1 VR Headsets */ | ||
170 | { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP }, | ||
171 | { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP }, | ||
172 | { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP }, | ||
173 | |||
174 | /* Windows Mixed Reality Headsets */ | ||
175 | { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP }, | ||
176 | { "HPN", 0x3515, EDID_QUIRK_NON_DESKTOP }, | ||
177 | { "LEN", 0x0408, EDID_QUIRK_NON_DESKTOP }, | ||
178 | { "LEN", 0xb800, EDID_QUIRK_NON_DESKTOP }, | ||
179 | { "FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP }, | ||
180 | { "DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP }, | ||
181 | { "SEC", 0x144a, EDID_QUIRK_NON_DESKTOP }, | ||
182 | { "AUS", 0xc102, EDID_QUIRK_NON_DESKTOP }, | ||
183 | |||
184 | /* Sony PlayStation VR Headset */ | ||
185 | { "SNY", 0x0704, EDID_QUIRK_NON_DESKTOP }, | ||
165 | }; | 186 | }; |
166 | 187 | ||
167 | /* | 188 | /* |
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 186c4e90cc1c..89eef1bb4ddc 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c | |||
@@ -836,9 +836,24 @@ struct drm_mm_node *drm_mm_scan_color_evict(struct drm_mm_scan *scan) | |||
836 | if (!mm->color_adjust) | 836 | if (!mm->color_adjust) |
837 | return NULL; | 837 | return NULL; |
838 | 838 | ||
839 | hole = list_first_entry(&mm->hole_stack, typeof(*hole), hole_stack); | 839 | /* |
840 | hole_start = __drm_mm_hole_node_start(hole); | 840 | * The hole found during scanning should ideally be the first element |
841 | hole_end = hole_start + hole->hole_size; | 841 | * in the hole_stack list, but due to side-effects in the driver it |
842 | * may not be. | ||
843 | */ | ||
844 | list_for_each_entry(hole, &mm->hole_stack, hole_stack) { | ||
845 | hole_start = __drm_mm_hole_node_start(hole); | ||
846 | hole_end = hole_start + hole->hole_size; | ||
847 | |||
848 | if (hole_start <= scan->hit_start && | ||
849 | hole_end >= scan->hit_end) | ||
850 | break; | ||
851 | } | ||
852 | |||
853 | /* We should only be called after we found the hole previously */ | ||
854 | DRM_MM_BUG_ON(&hole->hole_stack == &mm->hole_stack); | ||
855 | if (unlikely(&hole->hole_stack == &mm->hole_stack)) | ||
856 | return NULL; | ||
842 | 857 | ||
843 | DRM_MM_BUG_ON(hole_start > scan->hit_start); | 858 | DRM_MM_BUG_ON(hole_start > scan->hit_start); |
844 | DRM_MM_BUG_ON(hole_end < scan->hit_end); | 859 | DRM_MM_BUG_ON(hole_end < scan->hit_end); |
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 555fbe54d6e2..00b8445ba819 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c | |||
@@ -654,6 +654,26 @@ out: | |||
654 | } | 654 | } |
655 | 655 | ||
656 | /** | 656 | /** |
657 | * drm_kms_helper_is_poll_worker - is %current task an output poll worker? | ||
658 | * | ||
659 | * Determine if %current task is an output poll worker. This can be used | ||
660 | * to select distinct code paths for output polling versus other contexts. | ||
661 | * | ||
662 | * One use case is to avoid a deadlock between the output poll worker and | ||
663 | * the autosuspend worker wherein the latter waits for polling to finish | ||
664 | * upon calling drm_kms_helper_poll_disable(), while the former waits for | ||
665 | * runtime suspend to finish upon calling pm_runtime_get_sync() in a | ||
666 | * connector ->detect hook. | ||
667 | */ | ||
668 | bool drm_kms_helper_is_poll_worker(void) | ||
669 | { | ||
670 | struct work_struct *work = current_work(); | ||
671 | |||
672 | return work && work->func == output_poll_execute; | ||
673 | } | ||
674 | EXPORT_SYMBOL(drm_kms_helper_is_poll_worker); | ||
675 | |||
676 | /** | ||
657 | * drm_kms_helper_poll_disable - disable output polling | 677 | * drm_kms_helper_poll_disable - disable output polling |
658 | * @dev: drm_device | 678 | * @dev: drm_device |
659 | * | 679 | * |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 2b8bf2dd6387..f68ef1b3a28c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c | |||
@@ -286,7 +286,6 @@ static int g2d_init_cmdlist(struct g2d_data *g2d) | |||
286 | 286 | ||
287 | node = kcalloc(G2D_CMDLIST_NUM, sizeof(*node), GFP_KERNEL); | 287 | node = kcalloc(G2D_CMDLIST_NUM, sizeof(*node), GFP_KERNEL); |
288 | if (!node) { | 288 | if (!node) { |
289 | dev_err(dev, "failed to allocate memory\n"); | ||
290 | ret = -ENOMEM; | 289 | ret = -ENOMEM; |
291 | goto err; | 290 | goto err; |
292 | } | 291 | } |
@@ -926,7 +925,7 @@ static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no) | |||
926 | struct drm_device *drm_dev = g2d->subdrv.drm_dev; | 925 | struct drm_device *drm_dev = g2d->subdrv.drm_dev; |
927 | struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node; | 926 | struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node; |
928 | struct drm_exynos_pending_g2d_event *e; | 927 | struct drm_exynos_pending_g2d_event *e; |
929 | struct timeval now; | 928 | struct timespec64 now; |
930 | 929 | ||
931 | if (list_empty(&runqueue_node->event_list)) | 930 | if (list_empty(&runqueue_node->event_list)) |
932 | return; | 931 | return; |
@@ -934,9 +933,9 @@ static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no) | |||
934 | e = list_first_entry(&runqueue_node->event_list, | 933 | e = list_first_entry(&runqueue_node->event_list, |
935 | struct drm_exynos_pending_g2d_event, base.link); | 934 | struct drm_exynos_pending_g2d_event, base.link); |
936 | 935 | ||
937 | do_gettimeofday(&now); | 936 | ktime_get_ts64(&now); |
938 | e->event.tv_sec = now.tv_sec; | 937 | e->event.tv_sec = now.tv_sec; |
939 | e->event.tv_usec = now.tv_usec; | 938 | e->event.tv_usec = now.tv_nsec / NSEC_PER_USEC; |
940 | e->event.cmdlist_no = cmdlist_no; | 939 | e->event.cmdlist_no = cmdlist_no; |
941 | 940 | ||
942 | drm_send_event(drm_dev, &e->base); | 941 | drm_send_event(drm_dev, &e->base); |
@@ -1358,10 +1357,9 @@ int exynos_g2d_exec_ioctl(struct drm_device *drm_dev, void *data, | |||
1358 | return -EFAULT; | 1357 | return -EFAULT; |
1359 | 1358 | ||
1360 | runqueue_node = kmem_cache_alloc(g2d->runqueue_slab, GFP_KERNEL); | 1359 | runqueue_node = kmem_cache_alloc(g2d->runqueue_slab, GFP_KERNEL); |
1361 | if (!runqueue_node) { | 1360 | if (!runqueue_node) |
1362 | dev_err(dev, "failed to allocate memory\n"); | ||
1363 | return -ENOMEM; | 1361 | return -ENOMEM; |
1364 | } | 1362 | |
1365 | run_cmdlist = &runqueue_node->run_cmdlist; | 1363 | run_cmdlist = &runqueue_node->run_cmdlist; |
1366 | event_list = &runqueue_node->event_list; | 1364 | event_list = &runqueue_node->event_list; |
1367 | INIT_LIST_HEAD(run_cmdlist); | 1365 | INIT_LIST_HEAD(run_cmdlist); |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h b/drivers/gpu/drm/exynos/exynos_drm_rotator.h deleted file mode 100644 index 71a0b4c0c1e8..000000000000 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
3 | * | ||
4 | * Authors: | ||
5 | * YoungJun Cho <yj44.cho@samsung.com> | ||
6 | * Eunchul Kim <chulspro.kim@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef _EXYNOS_DRM_ROTATOR_H_ | ||
15 | #define _EXYNOS_DRM_ROTATOR_H_ | ||
16 | |||
17 | /* TODO */ | ||
18 | |||
19 | #endif | ||
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index a4b75a46f946..abd84cbcf1c2 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
@@ -1068,10 +1068,13 @@ static void hdmi_audio_config(struct hdmi_context *hdata) | |||
1068 | /* Configuration I2S input ports. Configure I2S_PIN_SEL_0~4 */ | 1068 | /* Configuration I2S input ports. Configure I2S_PIN_SEL_0~4 */ |
1069 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_0, HDMI_I2S_SEL_SCLK(5) | 1069 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_0, HDMI_I2S_SEL_SCLK(5) |
1070 | | HDMI_I2S_SEL_LRCK(6)); | 1070 | | HDMI_I2S_SEL_LRCK(6)); |
1071 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_1, HDMI_I2S_SEL_SDATA1(1) | 1071 | |
1072 | | HDMI_I2S_SEL_SDATA2(4)); | 1072 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_1, HDMI_I2S_SEL_SDATA1(3) |
1073 | | HDMI_I2S_SEL_SDATA0(4)); | ||
1074 | |||
1073 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_2, HDMI_I2S_SEL_SDATA3(1) | 1075 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_2, HDMI_I2S_SEL_SDATA3(1) |
1074 | | HDMI_I2S_SEL_SDATA2(2)); | 1076 | | HDMI_I2S_SEL_SDATA2(2)); |
1077 | |||
1075 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_3, HDMI_I2S_SEL_DSD(0)); | 1078 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_3, HDMI_I2S_SEL_DSD(0)); |
1076 | 1079 | ||
1077 | /* I2S_CON_1 & 2 */ | 1080 | /* I2S_CON_1 & 2 */ |
diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h index 30496134a3d0..d7cbe53c4c01 100644 --- a/drivers/gpu/drm/exynos/regs-fimc.h +++ b/drivers/gpu/drm/exynos/regs-fimc.h | |||
@@ -569,7 +569,7 @@ | |||
569 | #define EXYNOS_CIIMGEFF_FIN_EMBOSSING (4 << 26) | 569 | #define EXYNOS_CIIMGEFF_FIN_EMBOSSING (4 << 26) |
570 | #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE (5 << 26) | 570 | #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE (5 << 26) |
571 | #define EXYNOS_CIIMGEFF_FIN_MASK (7 << 26) | 571 | #define EXYNOS_CIIMGEFF_FIN_MASK (7 << 26) |
572 | #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK ((0xff < 13) | (0xff < 0)) | 572 | #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | (0xff << 0)) |
573 | 573 | ||
574 | /* Real input DMA size register */ | 574 | /* Real input DMA size register */ |
575 | #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE (1 << 31) | 575 | #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE (1 << 31) |
diff --git a/drivers/gpu/drm/exynos/regs-hdmi.h b/drivers/gpu/drm/exynos/regs-hdmi.h index 04be0f7e8193..4420c203ac85 100644 --- a/drivers/gpu/drm/exynos/regs-hdmi.h +++ b/drivers/gpu/drm/exynos/regs-hdmi.h | |||
@@ -464,7 +464,7 @@ | |||
464 | 464 | ||
465 | /* I2S_PIN_SEL_1 */ | 465 | /* I2S_PIN_SEL_1 */ |
466 | #define HDMI_I2S_SEL_SDATA1(x) (((x) & 0x7) << 4) | 466 | #define HDMI_I2S_SEL_SDATA1(x) (((x) & 0x7) << 4) |
467 | #define HDMI_I2S_SEL_SDATA2(x) ((x) & 0x7) | 467 | #define HDMI_I2S_SEL_SDATA0(x) ((x) & 0x7) |
468 | 468 | ||
469 | /* I2S_PIN_SEL_2 */ | 469 | /* I2S_PIN_SEL_2 */ |
470 | #define HDMI_I2S_SEL_SDATA3(x) (((x) & 0x7) << 4) | 470 | #define HDMI_I2S_SEL_SDATA3(x) (((x) & 0x7) << 4) |
diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c index 5155f0179b61..05520202c967 100644 --- a/drivers/gpu/drm/meson/meson_crtc.c +++ b/drivers/gpu/drm/meson/meson_crtc.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include "meson_venc.h" | 36 | #include "meson_venc.h" |
37 | #include "meson_vpp.h" | 37 | #include "meson_vpp.h" |
38 | #include "meson_viu.h" | 38 | #include "meson_viu.h" |
39 | #include "meson_canvas.h" | ||
39 | #include "meson_registers.h" | 40 | #include "meson_registers.h" |
40 | 41 | ||
41 | /* CRTC definition */ | 42 | /* CRTC definition */ |
@@ -192,6 +193,11 @@ void meson_crtc_irq(struct meson_drm *priv) | |||
192 | } else | 193 | } else |
193 | meson_vpp_disable_interlace_vscaler_osd1(priv); | 194 | meson_vpp_disable_interlace_vscaler_osd1(priv); |
194 | 195 | ||
196 | meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, | ||
197 | priv->viu.osd1_addr, priv->viu.osd1_stride, | ||
198 | priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, | ||
199 | MESON_CANVAS_BLKMODE_LINEAR); | ||
200 | |||
195 | /* Enable OSD1 */ | 201 | /* Enable OSD1 */ |
196 | writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND, | 202 | writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND, |
197 | priv->io_base + _REG(VPP_MISC)); | 203 | priv->io_base + _REG(VPP_MISC)); |
diff --git a/drivers/gpu/drm/meson/meson_drv.h b/drivers/gpu/drm/meson/meson_drv.h index 5e8b392b9d1f..8450d6ac8c9b 100644 --- a/drivers/gpu/drm/meson/meson_drv.h +++ b/drivers/gpu/drm/meson/meson_drv.h | |||
@@ -43,6 +43,9 @@ struct meson_drm { | |||
43 | bool osd1_commit; | 43 | bool osd1_commit; |
44 | uint32_t osd1_ctrl_stat; | 44 | uint32_t osd1_ctrl_stat; |
45 | uint32_t osd1_blk0_cfg[5]; | 45 | uint32_t osd1_blk0_cfg[5]; |
46 | uint32_t osd1_addr; | ||
47 | uint32_t osd1_stride; | ||
48 | uint32_t osd1_height; | ||
46 | } viu; | 49 | } viu; |
47 | 50 | ||
48 | struct { | 51 | struct { |
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c index d0a6ac8390f3..27bd3503e1e4 100644 --- a/drivers/gpu/drm/meson/meson_plane.c +++ b/drivers/gpu/drm/meson/meson_plane.c | |||
@@ -164,10 +164,9 @@ static void meson_plane_atomic_update(struct drm_plane *plane, | |||
164 | /* Update Canvas with buffer address */ | 164 | /* Update Canvas with buffer address */ |
165 | gem = drm_fb_cma_get_gem_obj(fb, 0); | 165 | gem = drm_fb_cma_get_gem_obj(fb, 0); |
166 | 166 | ||
167 | meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, | 167 | priv->viu.osd1_addr = gem->paddr; |
168 | gem->paddr, fb->pitches[0], | 168 | priv->viu.osd1_stride = fb->pitches[0]; |
169 | fb->height, MESON_CANVAS_WRAP_NONE, | 169 | priv->viu.osd1_height = fb->height; |
170 | MESON_CANVAS_BLKMODE_LINEAR); | ||
171 | 170 | ||
172 | spin_unlock_irqrestore(&priv->drm->event_lock, flags); | 171 | spin_unlock_irqrestore(&priv->drm->event_lock, flags); |
173 | } | 172 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 69d6e61a01ec..6ed9cb053dfa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c | |||
@@ -570,9 +570,15 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) | |||
570 | nv_connector->edid = NULL; | 570 | nv_connector->edid = NULL; |
571 | } | 571 | } |
572 | 572 | ||
573 | ret = pm_runtime_get_sync(connector->dev->dev); | 573 | /* Outputs are only polled while runtime active, so acquiring a |
574 | if (ret < 0 && ret != -EACCES) | 574 | * runtime PM ref here is unnecessary (and would deadlock upon |
575 | return conn_status; | 575 | * runtime suspend because it waits for polling to finish). |
576 | */ | ||
577 | if (!drm_kms_helper_is_poll_worker()) { | ||
578 | ret = pm_runtime_get_sync(connector->dev->dev); | ||
579 | if (ret < 0 && ret != -EACCES) | ||
580 | return conn_status; | ||
581 | } | ||
576 | 582 | ||
577 | nv_encoder = nouveau_connector_ddc_detect(connector); | 583 | nv_encoder = nouveau_connector_ddc_detect(connector); |
578 | if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) { | 584 | if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) { |
@@ -647,8 +653,10 @@ detect_analog: | |||
647 | 653 | ||
648 | out: | 654 | out: |
649 | 655 | ||
650 | pm_runtime_mark_last_busy(connector->dev->dev); | 656 | if (!drm_kms_helper_is_poll_worker()) { |
651 | pm_runtime_put_autosuspend(connector->dev->dev); | 657 | pm_runtime_mark_last_busy(connector->dev->dev); |
658 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
659 | } | ||
652 | 660 | ||
653 | return conn_status; | 661 | return conn_status; |
654 | } | 662 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index 5012f5e47a1e..2e2ca3c6b47d 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c | |||
@@ -899,9 +899,11 @@ radeon_lvds_detect(struct drm_connector *connector, bool force) | |||
899 | enum drm_connector_status ret = connector_status_disconnected; | 899 | enum drm_connector_status ret = connector_status_disconnected; |
900 | int r; | 900 | int r; |
901 | 901 | ||
902 | r = pm_runtime_get_sync(connector->dev->dev); | 902 | if (!drm_kms_helper_is_poll_worker()) { |
903 | if (r < 0) | 903 | r = pm_runtime_get_sync(connector->dev->dev); |
904 | return connector_status_disconnected; | 904 | if (r < 0) |
905 | return connector_status_disconnected; | ||
906 | } | ||
905 | 907 | ||
906 | if (encoder) { | 908 | if (encoder) { |
907 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 909 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
@@ -924,8 +926,12 @@ radeon_lvds_detect(struct drm_connector *connector, bool force) | |||
924 | /* check acpi lid status ??? */ | 926 | /* check acpi lid status ??? */ |
925 | 927 | ||
926 | radeon_connector_update_scratch_regs(connector, ret); | 928 | radeon_connector_update_scratch_regs(connector, ret); |
927 | pm_runtime_mark_last_busy(connector->dev->dev); | 929 | |
928 | pm_runtime_put_autosuspend(connector->dev->dev); | 930 | if (!drm_kms_helper_is_poll_worker()) { |
931 | pm_runtime_mark_last_busy(connector->dev->dev); | ||
932 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
933 | } | ||
934 | |||
929 | return ret; | 935 | return ret; |
930 | } | 936 | } |
931 | 937 | ||
@@ -1039,9 +1045,11 @@ radeon_vga_detect(struct drm_connector *connector, bool force) | |||
1039 | enum drm_connector_status ret = connector_status_disconnected; | 1045 | enum drm_connector_status ret = connector_status_disconnected; |
1040 | int r; | 1046 | int r; |
1041 | 1047 | ||
1042 | r = pm_runtime_get_sync(connector->dev->dev); | 1048 | if (!drm_kms_helper_is_poll_worker()) { |
1043 | if (r < 0) | 1049 | r = pm_runtime_get_sync(connector->dev->dev); |
1044 | return connector_status_disconnected; | 1050 | if (r < 0) |
1051 | return connector_status_disconnected; | ||
1052 | } | ||
1045 | 1053 | ||
1046 | encoder = radeon_best_single_encoder(connector); | 1054 | encoder = radeon_best_single_encoder(connector); |
1047 | if (!encoder) | 1055 | if (!encoder) |
@@ -1108,8 +1116,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force) | |||
1108 | radeon_connector_update_scratch_regs(connector, ret); | 1116 | radeon_connector_update_scratch_regs(connector, ret); |
1109 | 1117 | ||
1110 | out: | 1118 | out: |
1111 | pm_runtime_mark_last_busy(connector->dev->dev); | 1119 | if (!drm_kms_helper_is_poll_worker()) { |
1112 | pm_runtime_put_autosuspend(connector->dev->dev); | 1120 | pm_runtime_mark_last_busy(connector->dev->dev); |
1121 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1122 | } | ||
1113 | 1123 | ||
1114 | return ret; | 1124 | return ret; |
1115 | } | 1125 | } |
@@ -1173,9 +1183,11 @@ radeon_tv_detect(struct drm_connector *connector, bool force) | |||
1173 | if (!radeon_connector->dac_load_detect) | 1183 | if (!radeon_connector->dac_load_detect) |
1174 | return ret; | 1184 | return ret; |
1175 | 1185 | ||
1176 | r = pm_runtime_get_sync(connector->dev->dev); | 1186 | if (!drm_kms_helper_is_poll_worker()) { |
1177 | if (r < 0) | 1187 | r = pm_runtime_get_sync(connector->dev->dev); |
1178 | return connector_status_disconnected; | 1188 | if (r < 0) |
1189 | return connector_status_disconnected; | ||
1190 | } | ||
1179 | 1191 | ||
1180 | encoder = radeon_best_single_encoder(connector); | 1192 | encoder = radeon_best_single_encoder(connector); |
1181 | if (!encoder) | 1193 | if (!encoder) |
@@ -1187,8 +1199,12 @@ radeon_tv_detect(struct drm_connector *connector, bool force) | |||
1187 | if (ret == connector_status_connected) | 1199 | if (ret == connector_status_connected) |
1188 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); | 1200 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); |
1189 | radeon_connector_update_scratch_regs(connector, ret); | 1201 | radeon_connector_update_scratch_regs(connector, ret); |
1190 | pm_runtime_mark_last_busy(connector->dev->dev); | 1202 | |
1191 | pm_runtime_put_autosuspend(connector->dev->dev); | 1203 | if (!drm_kms_helper_is_poll_worker()) { |
1204 | pm_runtime_mark_last_busy(connector->dev->dev); | ||
1205 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1206 | } | ||
1207 | |||
1192 | return ret; | 1208 | return ret; |
1193 | } | 1209 | } |
1194 | 1210 | ||
@@ -1251,9 +1267,11 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) | |||
1251 | enum drm_connector_status ret = connector_status_disconnected; | 1267 | enum drm_connector_status ret = connector_status_disconnected; |
1252 | bool dret = false, broken_edid = false; | 1268 | bool dret = false, broken_edid = false; |
1253 | 1269 | ||
1254 | r = pm_runtime_get_sync(connector->dev->dev); | 1270 | if (!drm_kms_helper_is_poll_worker()) { |
1255 | if (r < 0) | 1271 | r = pm_runtime_get_sync(connector->dev->dev); |
1256 | return connector_status_disconnected; | 1272 | if (r < 0) |
1273 | return connector_status_disconnected; | ||
1274 | } | ||
1257 | 1275 | ||
1258 | if (radeon_connector->detected_hpd_without_ddc) { | 1276 | if (radeon_connector->detected_hpd_without_ddc) { |
1259 | force = true; | 1277 | force = true; |
@@ -1436,8 +1454,10 @@ out: | |||
1436 | } | 1454 | } |
1437 | 1455 | ||
1438 | exit: | 1456 | exit: |
1439 | pm_runtime_mark_last_busy(connector->dev->dev); | 1457 | if (!drm_kms_helper_is_poll_worker()) { |
1440 | pm_runtime_put_autosuspend(connector->dev->dev); | 1458 | pm_runtime_mark_last_busy(connector->dev->dev); |
1459 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1460 | } | ||
1441 | 1461 | ||
1442 | return ret; | 1462 | return ret; |
1443 | } | 1463 | } |
@@ -1688,9 +1708,11 @@ radeon_dp_detect(struct drm_connector *connector, bool force) | |||
1688 | if (radeon_dig_connector->is_mst) | 1708 | if (radeon_dig_connector->is_mst) |
1689 | return connector_status_disconnected; | 1709 | return connector_status_disconnected; |
1690 | 1710 | ||
1691 | r = pm_runtime_get_sync(connector->dev->dev); | 1711 | if (!drm_kms_helper_is_poll_worker()) { |
1692 | if (r < 0) | 1712 | r = pm_runtime_get_sync(connector->dev->dev); |
1693 | return connector_status_disconnected; | 1713 | if (r < 0) |
1714 | return connector_status_disconnected; | ||
1715 | } | ||
1694 | 1716 | ||
1695 | if (!force && radeon_check_hpd_status_unchanged(connector)) { | 1717 | if (!force && radeon_check_hpd_status_unchanged(connector)) { |
1696 | ret = connector->status; | 1718 | ret = connector->status; |
@@ -1777,8 +1799,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force) | |||
1777 | } | 1799 | } |
1778 | 1800 | ||
1779 | out: | 1801 | out: |
1780 | pm_runtime_mark_last_busy(connector->dev->dev); | 1802 | if (!drm_kms_helper_is_poll_worker()) { |
1781 | pm_runtime_put_autosuspend(connector->dev->dev); | 1803 | pm_runtime_mark_last_busy(connector->dev->dev); |
1804 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
1805 | } | ||
1782 | 1806 | ||
1783 | return ret; | 1807 | return ret; |
1784 | } | 1808 | } |
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 658fa2d3e40c..48685cddbad1 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c | |||
@@ -1089,7 +1089,7 @@ static void ipu_irq_handler(struct irq_desc *desc) | |||
1089 | { | 1089 | { |
1090 | struct ipu_soc *ipu = irq_desc_get_handler_data(desc); | 1090 | struct ipu_soc *ipu = irq_desc_get_handler_data(desc); |
1091 | struct irq_chip *chip = irq_desc_get_chip(desc); | 1091 | struct irq_chip *chip = irq_desc_get_chip(desc); |
1092 | const int int_reg[] = { 0, 1, 2, 3, 10, 11, 12, 13, 14}; | 1092 | static const int int_reg[] = { 0, 1, 2, 3, 10, 11, 12, 13, 14}; |
1093 | 1093 | ||
1094 | chained_irq_enter(chip, desc); | 1094 | chained_irq_enter(chip, desc); |
1095 | 1095 | ||
@@ -1102,7 +1102,7 @@ static void ipu_err_irq_handler(struct irq_desc *desc) | |||
1102 | { | 1102 | { |
1103 | struct ipu_soc *ipu = irq_desc_get_handler_data(desc); | 1103 | struct ipu_soc *ipu = irq_desc_get_handler_data(desc); |
1104 | struct irq_chip *chip = irq_desc_get_chip(desc); | 1104 | struct irq_chip *chip = irq_desc_get_chip(desc); |
1105 | const int int_reg[] = { 4, 5, 8, 9}; | 1105 | static const int int_reg[] = { 4, 5, 8, 9}; |
1106 | 1106 | ||
1107 | chained_irq_enter(chip, desc); | 1107 | chained_irq_enter(chip, desc); |
1108 | 1108 | ||
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c index bb9c087e6c0d..9f2d9ec42add 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c | |||
@@ -788,12 +788,14 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image) | |||
788 | case V4L2_PIX_FMT_SGBRG8: | 788 | case V4L2_PIX_FMT_SGBRG8: |
789 | case V4L2_PIX_FMT_SGRBG8: | 789 | case V4L2_PIX_FMT_SGRBG8: |
790 | case V4L2_PIX_FMT_SRGGB8: | 790 | case V4L2_PIX_FMT_SRGGB8: |
791 | case V4L2_PIX_FMT_GREY: | ||
791 | offset = image->rect.left + image->rect.top * pix->bytesperline; | 792 | offset = image->rect.left + image->rect.top * pix->bytesperline; |
792 | break; | 793 | break; |
793 | case V4L2_PIX_FMT_SBGGR16: | 794 | case V4L2_PIX_FMT_SBGGR16: |
794 | case V4L2_PIX_FMT_SGBRG16: | 795 | case V4L2_PIX_FMT_SGBRG16: |
795 | case V4L2_PIX_FMT_SGRBG16: | 796 | case V4L2_PIX_FMT_SGRBG16: |
796 | case V4L2_PIX_FMT_SRGGB16: | 797 | case V4L2_PIX_FMT_SRGGB16: |
798 | case V4L2_PIX_FMT_Y16: | ||
797 | offset = image->rect.left * 2 + | 799 | offset = image->rect.left * 2 + |
798 | image->rect.top * pix->bytesperline; | 800 | image->rect.top * pix->bytesperline; |
799 | break; | 801 | break; |
diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index 24e12b87a0cb..caa05b0702e1 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c | |||
@@ -288,6 +288,7 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code) | |||
288 | case MEDIA_BUS_FMT_SGBRG10_1X10: | 288 | case MEDIA_BUS_FMT_SGBRG10_1X10: |
289 | case MEDIA_BUS_FMT_SGRBG10_1X10: | 289 | case MEDIA_BUS_FMT_SGRBG10_1X10: |
290 | case MEDIA_BUS_FMT_SRGGB10_1X10: | 290 | case MEDIA_BUS_FMT_SRGGB10_1X10: |
291 | case MEDIA_BUS_FMT_Y10_1X10: | ||
291 | cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; | 292 | cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; |
292 | cfg->mipi_dt = MIPI_DT_RAW10; | 293 | cfg->mipi_dt = MIPI_DT_RAW10; |
293 | cfg->data_width = IPU_CSI_DATA_WIDTH_10; | 294 | cfg->data_width = IPU_CSI_DATA_WIDTH_10; |
@@ -296,6 +297,7 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code) | |||
296 | case MEDIA_BUS_FMT_SGBRG12_1X12: | 297 | case MEDIA_BUS_FMT_SGBRG12_1X12: |
297 | case MEDIA_BUS_FMT_SGRBG12_1X12: | 298 | case MEDIA_BUS_FMT_SGRBG12_1X12: |
298 | case MEDIA_BUS_FMT_SRGGB12_1X12: | 299 | case MEDIA_BUS_FMT_SRGGB12_1X12: |
300 | case MEDIA_BUS_FMT_Y12_1X12: | ||
299 | cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; | 301 | cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; |
300 | cfg->mipi_dt = MIPI_DT_RAW12; | 302 | cfg->mipi_dt = MIPI_DT_RAW12; |
301 | cfg->data_width = IPU_CSI_DATA_WIDTH_12; | 303 | cfg->data_width = IPU_CSI_DATA_WIDTH_12; |
diff --git a/drivers/gpu/ipu-v3/ipu-pre.c b/drivers/gpu/ipu-v3/ipu-pre.c index f1cec3d70498..0f70e8847540 100644 --- a/drivers/gpu/ipu-v3/ipu-pre.c +++ b/drivers/gpu/ipu-v3/ipu-pre.c | |||
@@ -129,11 +129,14 @@ ipu_pre_lookup_by_phandle(struct device *dev, const char *name, int index) | |||
129 | if (pre_node == pre->dev->of_node) { | 129 | if (pre_node == pre->dev->of_node) { |
130 | mutex_unlock(&ipu_pre_list_mutex); | 130 | mutex_unlock(&ipu_pre_list_mutex); |
131 | device_link_add(dev, pre->dev, DL_FLAG_AUTOREMOVE); | 131 | device_link_add(dev, pre->dev, DL_FLAG_AUTOREMOVE); |
132 | of_node_put(pre_node); | ||
132 | return pre; | 133 | return pre; |
133 | } | 134 | } |
134 | } | 135 | } |
135 | mutex_unlock(&ipu_pre_list_mutex); | 136 | mutex_unlock(&ipu_pre_list_mutex); |
136 | 137 | ||
138 | of_node_put(pre_node); | ||
139 | |||
137 | return NULL; | 140 | return NULL; |
138 | } | 141 | } |
139 | 142 | ||
diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c index 067365c733c6..97b99500153d 100644 --- a/drivers/gpu/ipu-v3/ipu-prg.c +++ b/drivers/gpu/ipu-v3/ipu-prg.c | |||
@@ -102,11 +102,14 @@ ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id) | |||
102 | mutex_unlock(&ipu_prg_list_mutex); | 102 | mutex_unlock(&ipu_prg_list_mutex); |
103 | device_link_add(dev, prg->dev, DL_FLAG_AUTOREMOVE); | 103 | device_link_add(dev, prg->dev, DL_FLAG_AUTOREMOVE); |
104 | prg->id = ipu_id; | 104 | prg->id = ipu_id; |
105 | of_node_put(prg_node); | ||
105 | return prg; | 106 | return prg; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | mutex_unlock(&ipu_prg_list_mutex); | 109 | mutex_unlock(&ipu_prg_list_mutex); |
109 | 110 | ||
111 | of_node_put(prg_node); | ||
112 | |||
110 | return NULL; | 113 | return NULL; |
111 | } | 114 | } |
112 | 115 | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 43ddcdfbd0da..9454ac134ce2 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -645,6 +645,9 @@ | |||
645 | #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 | 645 | #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 |
646 | #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 | 646 | #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 |
647 | #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 | 647 | #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 |
648 | #define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 | ||
649 | #define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 | ||
650 | #define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 | ||
648 | #define USB_DEVICE_ID_LD_JWM 0x1080 | 651 | #define USB_DEVICE_ID_LD_JWM 0x1080 |
649 | #define USB_DEVICE_ID_LD_DMMP 0x1081 | 652 | #define USB_DEVICE_ID_LD_DMMP 0x1081 |
650 | #define USB_DEVICE_ID_LD_UMIP 0x1090 | 653 | #define USB_DEVICE_ID_LD_UMIP 0x1090 |
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 5f6035a5ce36..e92b77fa574a 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c | |||
@@ -809,6 +809,9 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
809 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, | 809 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, |
810 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, | 810 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, |
811 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, | 811 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, |
812 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, | ||
813 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, | ||
814 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, | ||
812 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, | 815 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
813 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, | 816 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
814 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, | 817 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a9805c7cb305..e2954fb86d65 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -123,8 +123,10 @@ config I2C_I801 | |||
123 | Wildcat Point (PCH) | 123 | Wildcat Point (PCH) |
124 | Wildcat Point-LP (PCH) | 124 | Wildcat Point-LP (PCH) |
125 | BayTrail (SOC) | 125 | BayTrail (SOC) |
126 | Braswell (SOC) | ||
126 | Sunrise Point-H (PCH) | 127 | Sunrise Point-H (PCH) |
127 | Sunrise Point-LP (PCH) | 128 | Sunrise Point-LP (PCH) |
129 | Kaby Lake-H (PCH) | ||
128 | DNV (SOC) | 130 | DNV (SOC) |
129 | Broxton (SOC) | 131 | Broxton (SOC) |
130 | Lewisburg (PCH) | 132 | Lewisburg (PCH) |
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index cd07a69e2e93..44deae78913e 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c | |||
@@ -50,6 +50,9 @@ | |||
50 | #define BCM2835_I2C_S_CLKT BIT(9) | 50 | #define BCM2835_I2C_S_CLKT BIT(9) |
51 | #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */ | 51 | #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */ |
52 | 52 | ||
53 | #define BCM2835_I2C_FEDL_SHIFT 16 | ||
54 | #define BCM2835_I2C_REDL_SHIFT 0 | ||
55 | |||
53 | #define BCM2835_I2C_CDIV_MIN 0x0002 | 56 | #define BCM2835_I2C_CDIV_MIN 0x0002 |
54 | #define BCM2835_I2C_CDIV_MAX 0xFFFE | 57 | #define BCM2835_I2C_CDIV_MAX 0xFFFE |
55 | 58 | ||
@@ -81,7 +84,7 @@ static inline u32 bcm2835_i2c_readl(struct bcm2835_i2c_dev *i2c_dev, u32 reg) | |||
81 | 84 | ||
82 | static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev) | 85 | static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev) |
83 | { | 86 | { |
84 | u32 divider; | 87 | u32 divider, redl, fedl; |
85 | 88 | ||
86 | divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk), | 89 | divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk), |
87 | i2c_dev->bus_clk_rate); | 90 | i2c_dev->bus_clk_rate); |
@@ -100,6 +103,22 @@ static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev) | |||
100 | 103 | ||
101 | bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider); | 104 | bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider); |
102 | 105 | ||
106 | /* | ||
107 | * Number of core clocks to wait after falling edge before | ||
108 | * outputting the next data bit. Note that both FEDL and REDL | ||
109 | * can't be greater than CDIV/2. | ||
110 | */ | ||
111 | fedl = max(divider / 16, 1u); | ||
112 | |||
113 | /* | ||
114 | * Number of core clocks to wait after rising edge before | ||
115 | * sampling the next incoming data bit. | ||
116 | */ | ||
117 | redl = max(divider / 4, 1u); | ||
118 | |||
119 | bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DEL, | ||
120 | (fedl << BCM2835_I2C_FEDL_SHIFT) | | ||
121 | (redl << BCM2835_I2C_REDL_SHIFT)); | ||
103 | return 0; | 122 | return 0; |
104 | } | 123 | } |
105 | 124 | ||
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c index ae691884d071..05732531829f 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c | |||
@@ -209,7 +209,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev) | |||
209 | i2c_dw_disable_int(dev); | 209 | i2c_dw_disable_int(dev); |
210 | 210 | ||
211 | /* Enable the adapter */ | 211 | /* Enable the adapter */ |
212 | __i2c_dw_enable(dev, true); | 212 | __i2c_dw_enable_and_wait(dev, true); |
213 | 213 | ||
214 | /* Clear and enable interrupts */ | 214 | /* Clear and enable interrupts */ |
215 | dw_readl(dev, DW_IC_CLR_INTR); | 215 | dw_readl(dev, DW_IC_CLR_INTR); |
@@ -644,7 +644,7 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) | |||
644 | gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); | 644 | gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); |
645 | if (IS_ERR(gpio)) { | 645 | if (IS_ERR(gpio)) { |
646 | r = PTR_ERR(gpio); | 646 | r = PTR_ERR(gpio); |
647 | if (r == -ENOENT) | 647 | if (r == -ENOENT || r == -ENOSYS) |
648 | return 0; | 648 | return 0; |
649 | return r; | 649 | return r; |
650 | } | 650 | } |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 8eac00efadc1..692b34125866 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -58,6 +58,7 @@ | |||
58 | * Wildcat Point (PCH) 0x8ca2 32 hard yes yes yes | 58 | * Wildcat Point (PCH) 0x8ca2 32 hard yes yes yes |
59 | * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes | 59 | * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes |
60 | * BayTrail (SOC) 0x0f12 32 hard yes yes yes | 60 | * BayTrail (SOC) 0x0f12 32 hard yes yes yes |
61 | * Braswell (SOC) 0x2292 32 hard yes yes yes | ||
61 | * Sunrise Point-H (PCH) 0xa123 32 hard yes yes yes | 62 | * Sunrise Point-H (PCH) 0xa123 32 hard yes yes yes |
62 | * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes yes | 63 | * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes yes |
63 | * DNV (SOC) 0x19df 32 hard yes yes yes | 64 | * DNV (SOC) 0x19df 32 hard yes yes yes |
diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c index 2fd8b6d00391..87197ece0f90 100644 --- a/drivers/i2c/busses/i2c-sirf.c +++ b/drivers/i2c/busses/i2c-sirf.c | |||
@@ -341,7 +341,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev) | |||
341 | platform_set_drvdata(pdev, adap); | 341 | platform_set_drvdata(pdev, adap); |
342 | init_completion(&siic->done); | 342 | init_completion(&siic->done); |
343 | 343 | ||
344 | /* Controller Initalisation */ | 344 | /* Controller initialisation */ |
345 | 345 | ||
346 | writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); | 346 | writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); |
347 | while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) | 347 | while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) |
@@ -369,7 +369,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev) | |||
369 | * but they start to affect the speed when clock is set to faster | 369 | * but they start to affect the speed when clock is set to faster |
370 | * frequencies. | 370 | * frequencies. |
371 | * Through the actual tests, use the different user_div value(which | 371 | * Through the actual tests, use the different user_div value(which |
372 | * in the divider formular 'Fio / (Fi2c * user_div)') to adapt | 372 | * in the divider formula 'Fio / (Fi2c * user_div)') to adapt |
373 | * the different ranges of i2c bus clock frequency, to make the SCL | 373 | * the different ranges of i2c bus clock frequency, to make the SCL |
374 | * more accurate. | 374 | * more accurate. |
375 | */ | 375 | */ |
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index 327a49ba1991..9515ca165dfd 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c | |||
@@ -243,7 +243,7 @@ static int aspeed_adc_probe(struct platform_device *pdev) | |||
243 | ASPEED_ADC_INIT_POLLING_TIME, | 243 | ASPEED_ADC_INIT_POLLING_TIME, |
244 | ASPEED_ADC_INIT_TIMEOUT); | 244 | ASPEED_ADC_INIT_TIMEOUT); |
245 | if (ret) | 245 | if (ret) |
246 | goto scaler_error; | 246 | goto poll_timeout_error; |
247 | } | 247 | } |
248 | 248 | ||
249 | /* Start all channels in normal mode. */ | 249 | /* Start all channels in normal mode. */ |
@@ -274,9 +274,10 @@ iio_register_error: | |||
274 | writel(ASPEED_OPERATION_MODE_POWER_DOWN, | 274 | writel(ASPEED_OPERATION_MODE_POWER_DOWN, |
275 | data->base + ASPEED_REG_ENGINE_CONTROL); | 275 | data->base + ASPEED_REG_ENGINE_CONTROL); |
276 | clk_disable_unprepare(data->clk_scaler->clk); | 276 | clk_disable_unprepare(data->clk_scaler->clk); |
277 | reset_error: | ||
278 | reset_control_assert(data->rst); | ||
279 | clk_enable_error: | 277 | clk_enable_error: |
278 | poll_timeout_error: | ||
279 | reset_control_assert(data->rst); | ||
280 | reset_error: | ||
280 | clk_hw_unregister_divider(data->clk_scaler); | 281 | clk_hw_unregister_divider(data->clk_scaler); |
281 | scaler_error: | 282 | scaler_error: |
282 | clk_hw_unregister_divider(data->clk_prescaler); | 283 | clk_hw_unregister_divider(data->clk_prescaler); |
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 7f5def465340..9a2583caedaa 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c | |||
@@ -722,8 +722,6 @@ static int stm32h7_adc_enable(struct stm32_adc *adc) | |||
722 | int ret; | 722 | int ret; |
723 | u32 val; | 723 | u32 val; |
724 | 724 | ||
725 | /* Clear ADRDY by writing one, then enable ADC */ | ||
726 | stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); | ||
727 | stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); | 725 | stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); |
728 | 726 | ||
729 | /* Poll for ADRDY to be set (after adc startup time) */ | 727 | /* Poll for ADRDY to be set (after adc startup time) */ |
@@ -731,8 +729,11 @@ static int stm32h7_adc_enable(struct stm32_adc *adc) | |||
731 | val & STM32H7_ADRDY, | 729 | val & STM32H7_ADRDY, |
732 | 100, STM32_ADC_TIMEOUT_US); | 730 | 100, STM32_ADC_TIMEOUT_US); |
733 | if (ret) { | 731 | if (ret) { |
734 | stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); | 732 | stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADDIS); |
735 | dev_err(&indio_dev->dev, "Failed to enable ADC\n"); | 733 | dev_err(&indio_dev->dev, "Failed to enable ADC\n"); |
734 | } else { | ||
735 | /* Clear ADRDY by writing one */ | ||
736 | stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); | ||
736 | } | 737 | } |
737 | 738 | ||
738 | return ret; | 739 | return ret; |
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c index 0dd5a381be64..457372f36791 100644 --- a/drivers/iio/imu/adis_trigger.c +++ b/drivers/iio/imu/adis_trigger.c | |||
@@ -46,6 +46,10 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) | |||
46 | if (adis->trig == NULL) | 46 | if (adis->trig == NULL) |
47 | return -ENOMEM; | 47 | return -ENOMEM; |
48 | 48 | ||
49 | adis->trig->dev.parent = &adis->spi->dev; | ||
50 | adis->trig->ops = &adis_trigger_ops; | ||
51 | iio_trigger_set_drvdata(adis->trig, adis); | ||
52 | |||
49 | ret = request_irq(adis->spi->irq, | 53 | ret = request_irq(adis->spi->irq, |
50 | &iio_trigger_generic_data_rdy_poll, | 54 | &iio_trigger_generic_data_rdy_poll, |
51 | IRQF_TRIGGER_RISING, | 55 | IRQF_TRIGGER_RISING, |
@@ -54,9 +58,6 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) | |||
54 | if (ret) | 58 | if (ret) |
55 | goto error_free_trig; | 59 | goto error_free_trig; |
56 | 60 | ||
57 | adis->trig->dev.parent = &adis->spi->dev; | ||
58 | adis->trig->ops = &adis_trigger_ops; | ||
59 | iio_trigger_set_drvdata(adis->trig, adis); | ||
60 | ret = iio_trigger_register(adis->trig); | 61 | ret = iio_trigger_register(adis->trig); |
61 | 62 | ||
62 | indio_dev->trig = iio_trigger_get(adis->trig); | 63 | indio_dev->trig = iio_trigger_get(adis->trig); |
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 79abf70a126d..cd5bfe39591b 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
@@ -175,7 +175,7 @@ __poll_t iio_buffer_poll(struct file *filp, | |||
175 | struct iio_dev *indio_dev = filp->private_data; | 175 | struct iio_dev *indio_dev = filp->private_data; |
176 | struct iio_buffer *rb = indio_dev->buffer; | 176 | struct iio_buffer *rb = indio_dev->buffer; |
177 | 177 | ||
178 | if (!indio_dev->info) | 178 | if (!indio_dev->info || rb == NULL) |
179 | return 0; | 179 | return 0; |
180 | 180 | ||
181 | poll_wait(filp, &rb->pollq, wait); | 181 | poll_wait(filp, &rb->pollq, wait); |
diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig index fcb1c4ba5e41..f726f9427602 100644 --- a/drivers/iio/proximity/Kconfig +++ b/drivers/iio/proximity/Kconfig | |||
@@ -68,6 +68,8 @@ config SX9500 | |||
68 | 68 | ||
69 | config SRF08 | 69 | config SRF08 |
70 | tristate "Devantech SRF02/SRF08/SRF10 ultrasonic ranger sensor" | 70 | tristate "Devantech SRF02/SRF08/SRF10 ultrasonic ranger sensor" |
71 | select IIO_BUFFER | ||
72 | select IIO_TRIGGERED_BUFFER | ||
71 | depends on I2C | 73 | depends on I2C |
72 | help | 74 | help |
73 | Say Y here to build a driver for Devantech SRF02/SRF08/SRF10 | 75 | Say Y here to build a driver for Devantech SRF02/SRF08/SRF10 |
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index c4560d84dfae..25bb178f6074 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h | |||
@@ -305,16 +305,21 @@ void nldev_exit(void); | |||
305 | static inline struct ib_qp *_ib_create_qp(struct ib_device *dev, | 305 | static inline struct ib_qp *_ib_create_qp(struct ib_device *dev, |
306 | struct ib_pd *pd, | 306 | struct ib_pd *pd, |
307 | struct ib_qp_init_attr *attr, | 307 | struct ib_qp_init_attr *attr, |
308 | struct ib_udata *udata) | 308 | struct ib_udata *udata, |
309 | struct ib_uobject *uobj) | ||
309 | { | 310 | { |
310 | struct ib_qp *qp; | 311 | struct ib_qp *qp; |
311 | 312 | ||
313 | if (!dev->create_qp) | ||
314 | return ERR_PTR(-EOPNOTSUPP); | ||
315 | |||
312 | qp = dev->create_qp(pd, attr, udata); | 316 | qp = dev->create_qp(pd, attr, udata); |
313 | if (IS_ERR(qp)) | 317 | if (IS_ERR(qp)) |
314 | return qp; | 318 | return qp; |
315 | 319 | ||
316 | qp->device = dev; | 320 | qp->device = dev; |
317 | qp->pd = pd; | 321 | qp->pd = pd; |
322 | qp->uobject = uobj; | ||
318 | /* | 323 | /* |
319 | * We don't track XRC QPs for now, because they don't have PD | 324 | * We don't track XRC QPs for now, because they don't have PD |
320 | * and more importantly they are created internaly by driver, | 325 | * and more importantly they are created internaly by driver, |
diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c index 85b5ee4defa4..d8eead5d106d 100644 --- a/drivers/infiniband/core/rdma_core.c +++ b/drivers/infiniband/core/rdma_core.c | |||
@@ -141,7 +141,12 @@ static struct ib_uobject *alloc_uobj(struct ib_ucontext *context, | |||
141 | */ | 141 | */ |
142 | uobj->context = context; | 142 | uobj->context = context; |
143 | uobj->type = type; | 143 | uobj->type = type; |
144 | atomic_set(&uobj->usecnt, 0); | 144 | /* |
145 | * Allocated objects start out as write locked to deny any other | ||
146 | * syscalls from accessing them until they are committed. See | ||
147 | * rdma_alloc_commit_uobject | ||
148 | */ | ||
149 | atomic_set(&uobj->usecnt, -1); | ||
145 | kref_init(&uobj->ref); | 150 | kref_init(&uobj->ref); |
146 | 151 | ||
147 | return uobj; | 152 | return uobj; |
@@ -196,7 +201,15 @@ static struct ib_uobject *lookup_get_idr_uobject(const struct uverbs_obj_type *t | |||
196 | goto free; | 201 | goto free; |
197 | } | 202 | } |
198 | 203 | ||
199 | uverbs_uobject_get(uobj); | 204 | /* |
205 | * The idr_find is guaranteed to return a pointer to something that | ||
206 | * isn't freed yet, or NULL, as the free after idr_remove goes through | ||
207 | * kfree_rcu(). However the object may still have been released and | ||
208 | * kfree() could be called at any time. | ||
209 | */ | ||
210 | if (!kref_get_unless_zero(&uobj->ref)) | ||
211 | uobj = ERR_PTR(-ENOENT); | ||
212 | |||
200 | free: | 213 | free: |
201 | rcu_read_unlock(); | 214 | rcu_read_unlock(); |
202 | return uobj; | 215 | return uobj; |
@@ -399,13 +412,13 @@ static int __must_check remove_commit_fd_uobject(struct ib_uobject *uobj, | |||
399 | return ret; | 412 | return ret; |
400 | } | 413 | } |
401 | 414 | ||
402 | static void lockdep_check(struct ib_uobject *uobj, bool exclusive) | 415 | static void assert_uverbs_usecnt(struct ib_uobject *uobj, bool exclusive) |
403 | { | 416 | { |
404 | #ifdef CONFIG_LOCKDEP | 417 | #ifdef CONFIG_LOCKDEP |
405 | if (exclusive) | 418 | if (exclusive) |
406 | WARN_ON(atomic_read(&uobj->usecnt) > 0); | 419 | WARN_ON(atomic_read(&uobj->usecnt) != -1); |
407 | else | 420 | else |
408 | WARN_ON(atomic_read(&uobj->usecnt) == -1); | 421 | WARN_ON(atomic_read(&uobj->usecnt) <= 0); |
409 | #endif | 422 | #endif |
410 | } | 423 | } |
411 | 424 | ||
@@ -444,7 +457,7 @@ int __must_check rdma_remove_commit_uobject(struct ib_uobject *uobj) | |||
444 | WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); | 457 | WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); |
445 | return 0; | 458 | return 0; |
446 | } | 459 | } |
447 | lockdep_check(uobj, true); | 460 | assert_uverbs_usecnt(uobj, true); |
448 | ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY); | 461 | ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY); |
449 | 462 | ||
450 | up_read(&ucontext->cleanup_rwsem); | 463 | up_read(&ucontext->cleanup_rwsem); |
@@ -474,16 +487,17 @@ int rdma_explicit_destroy(struct ib_uobject *uobject) | |||
474 | WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); | 487 | WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); |
475 | return 0; | 488 | return 0; |
476 | } | 489 | } |
477 | lockdep_check(uobject, true); | 490 | assert_uverbs_usecnt(uobject, true); |
478 | ret = uobject->type->type_class->remove_commit(uobject, | 491 | ret = uobject->type->type_class->remove_commit(uobject, |
479 | RDMA_REMOVE_DESTROY); | 492 | RDMA_REMOVE_DESTROY); |
480 | if (ret) | 493 | if (ret) |
481 | return ret; | 494 | goto out; |
482 | 495 | ||
483 | uobject->type = &null_obj_type; | 496 | uobject->type = &null_obj_type; |
484 | 497 | ||
498 | out: | ||
485 | up_read(&ucontext->cleanup_rwsem); | 499 | up_read(&ucontext->cleanup_rwsem); |
486 | return 0; | 500 | return ret; |
487 | } | 501 | } |
488 | 502 | ||
489 | static void alloc_commit_idr_uobject(struct ib_uobject *uobj) | 503 | static void alloc_commit_idr_uobject(struct ib_uobject *uobj) |
@@ -527,6 +541,10 @@ int rdma_alloc_commit_uobject(struct ib_uobject *uobj) | |||
527 | return ret; | 541 | return ret; |
528 | } | 542 | } |
529 | 543 | ||
544 | /* matches atomic_set(-1) in alloc_uobj */ | ||
545 | assert_uverbs_usecnt(uobj, true); | ||
546 | atomic_set(&uobj->usecnt, 0); | ||
547 | |||
530 | uobj->type->type_class->alloc_commit(uobj); | 548 | uobj->type->type_class->alloc_commit(uobj); |
531 | up_read(&uobj->context->cleanup_rwsem); | 549 | up_read(&uobj->context->cleanup_rwsem); |
532 | 550 | ||
@@ -561,7 +579,7 @@ static void lookup_put_fd_uobject(struct ib_uobject *uobj, bool exclusive) | |||
561 | 579 | ||
562 | void rdma_lookup_put_uobject(struct ib_uobject *uobj, bool exclusive) | 580 | void rdma_lookup_put_uobject(struct ib_uobject *uobj, bool exclusive) |
563 | { | 581 | { |
564 | lockdep_check(uobj, exclusive); | 582 | assert_uverbs_usecnt(uobj, exclusive); |
565 | uobj->type->type_class->lookup_put(uobj, exclusive); | 583 | uobj->type->type_class->lookup_put(uobj, exclusive); |
566 | /* | 584 | /* |
567 | * In order to unlock an object, either decrease its usecnt for | 585 | * In order to unlock an object, either decrease its usecnt for |
diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c index 857637bf46da..3dbc4e4cca41 100644 --- a/drivers/infiniband/core/restrack.c +++ b/drivers/infiniband/core/restrack.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <rdma/restrack.h> | 7 | #include <rdma/restrack.h> |
8 | #include <linux/mutex.h> | 8 | #include <linux/mutex.h> |
9 | #include <linux/sched/task.h> | 9 | #include <linux/sched/task.h> |
10 | #include <linux/uaccess.h> | ||
11 | #include <linux/pid_namespace.h> | 10 | #include <linux/pid_namespace.h> |
12 | 11 | ||
13 | void rdma_restrack_init(struct rdma_restrack_root *res) | 12 | void rdma_restrack_init(struct rdma_restrack_root *res) |
@@ -63,7 +62,6 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res) | |||
63 | { | 62 | { |
64 | enum rdma_restrack_type type = res->type; | 63 | enum rdma_restrack_type type = res->type; |
65 | struct ib_device *dev; | 64 | struct ib_device *dev; |
66 | struct ib_xrcd *xrcd; | ||
67 | struct ib_pd *pd; | 65 | struct ib_pd *pd; |
68 | struct ib_cq *cq; | 66 | struct ib_cq *cq; |
69 | struct ib_qp *qp; | 67 | struct ib_qp *qp; |
@@ -81,10 +79,6 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res) | |||
81 | qp = container_of(res, struct ib_qp, res); | 79 | qp = container_of(res, struct ib_qp, res); |
82 | dev = qp->device; | 80 | dev = qp->device; |
83 | break; | 81 | break; |
84 | case RDMA_RESTRACK_XRCD: | ||
85 | xrcd = container_of(res, struct ib_xrcd, res); | ||
86 | dev = xrcd->device; | ||
87 | break; | ||
88 | default: | 82 | default: |
89 | WARN_ONCE(true, "Wrong resource tracking type %u\n", type); | 83 | WARN_ONCE(true, "Wrong resource tracking type %u\n", type); |
90 | return NULL; | 84 | return NULL; |
@@ -93,6 +87,21 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res) | |||
93 | return dev; | 87 | return dev; |
94 | } | 88 | } |
95 | 89 | ||
90 | static bool res_is_user(struct rdma_restrack_entry *res) | ||
91 | { | ||
92 | switch (res->type) { | ||
93 | case RDMA_RESTRACK_PD: | ||
94 | return container_of(res, struct ib_pd, res)->uobject; | ||
95 | case RDMA_RESTRACK_CQ: | ||
96 | return container_of(res, struct ib_cq, res)->uobject; | ||
97 | case RDMA_RESTRACK_QP: | ||
98 | return container_of(res, struct ib_qp, res)->uobject; | ||
99 | default: | ||
100 | WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type); | ||
101 | return false; | ||
102 | } | ||
103 | } | ||
104 | |||
96 | void rdma_restrack_add(struct rdma_restrack_entry *res) | 105 | void rdma_restrack_add(struct rdma_restrack_entry *res) |
97 | { | 106 | { |
98 | struct ib_device *dev = res_to_dev(res); | 107 | struct ib_device *dev = res_to_dev(res); |
@@ -100,7 +109,7 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) | |||
100 | if (!dev) | 109 | if (!dev) |
101 | return; | 110 | return; |
102 | 111 | ||
103 | if (!uaccess_kernel()) { | 112 | if (res_is_user(res)) { |
104 | get_task_struct(current); | 113 | get_task_struct(current); |
105 | res->task = current; | 114 | res->task = current; |
106 | res->kern_name = NULL; | 115 | res->kern_name = NULL; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 256934d1f64f..a148de35df8d 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -562,9 +562,10 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, | |||
562 | if (f.file) | 562 | if (f.file) |
563 | fdput(f); | 563 | fdput(f); |
564 | 564 | ||
565 | mutex_unlock(&file->device->xrcd_tree_mutex); | ||
566 | |||
565 | uobj_alloc_commit(&obj->uobject); | 567 | uobj_alloc_commit(&obj->uobject); |
566 | 568 | ||
567 | mutex_unlock(&file->device->xrcd_tree_mutex); | ||
568 | return in_len; | 569 | return in_len; |
569 | 570 | ||
570 | err_copy: | 571 | err_copy: |
@@ -603,10 +604,8 @@ ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file, | |||
603 | 604 | ||
604 | uobj = uobj_get_write(uobj_get_type(xrcd), cmd.xrcd_handle, | 605 | uobj = uobj_get_write(uobj_get_type(xrcd), cmd.xrcd_handle, |
605 | file->ucontext); | 606 | file->ucontext); |
606 | if (IS_ERR(uobj)) { | 607 | if (IS_ERR(uobj)) |
607 | mutex_unlock(&file->device->xrcd_tree_mutex); | ||
608 | return PTR_ERR(uobj); | 608 | return PTR_ERR(uobj); |
609 | } | ||
610 | 609 | ||
611 | ret = uobj_remove_commit(uobj); | 610 | ret = uobj_remove_commit(uobj); |
612 | return ret ?: in_len; | 611 | return ret ?: in_len; |
@@ -979,6 +978,9 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, | |||
979 | struct ib_uverbs_ex_create_cq_resp resp; | 978 | struct ib_uverbs_ex_create_cq_resp resp; |
980 | struct ib_cq_init_attr attr = {}; | 979 | struct ib_cq_init_attr attr = {}; |
981 | 980 | ||
981 | if (!ib_dev->create_cq) | ||
982 | return ERR_PTR(-EOPNOTSUPP); | ||
983 | |||
982 | if (cmd->comp_vector >= file->device->num_comp_vectors) | 984 | if (cmd->comp_vector >= file->device->num_comp_vectors) |
983 | return ERR_PTR(-EINVAL); | 985 | return ERR_PTR(-EINVAL); |
984 | 986 | ||
@@ -1030,14 +1032,14 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, | |||
1030 | resp.response_length = offsetof(typeof(resp), response_length) + | 1032 | resp.response_length = offsetof(typeof(resp), response_length) + |
1031 | sizeof(resp.response_length); | 1033 | sizeof(resp.response_length); |
1032 | 1034 | ||
1035 | cq->res.type = RDMA_RESTRACK_CQ; | ||
1036 | rdma_restrack_add(&cq->res); | ||
1037 | |||
1033 | ret = cb(file, obj, &resp, ucore, context); | 1038 | ret = cb(file, obj, &resp, ucore, context); |
1034 | if (ret) | 1039 | if (ret) |
1035 | goto err_cb; | 1040 | goto err_cb; |
1036 | 1041 | ||
1037 | uobj_alloc_commit(&obj->uobject); | 1042 | uobj_alloc_commit(&obj->uobject); |
1038 | cq->res.type = RDMA_RESTRACK_CQ; | ||
1039 | rdma_restrack_add(&cq->res); | ||
1040 | |||
1041 | return obj; | 1043 | return obj; |
1042 | 1044 | ||
1043 | err_cb: | 1045 | err_cb: |
@@ -1518,7 +1520,8 @@ static int create_qp(struct ib_uverbs_file *file, | |||
1518 | if (cmd->qp_type == IB_QPT_XRC_TGT) | 1520 | if (cmd->qp_type == IB_QPT_XRC_TGT) |
1519 | qp = ib_create_qp(pd, &attr); | 1521 | qp = ib_create_qp(pd, &attr); |
1520 | else | 1522 | else |
1521 | qp = _ib_create_qp(device, pd, &attr, uhw); | 1523 | qp = _ib_create_qp(device, pd, &attr, uhw, |
1524 | &obj->uevent.uobject); | ||
1522 | 1525 | ||
1523 | if (IS_ERR(qp)) { | 1526 | if (IS_ERR(qp)) { |
1524 | ret = PTR_ERR(qp); | 1527 | ret = PTR_ERR(qp); |
@@ -1550,8 +1553,10 @@ static int create_qp(struct ib_uverbs_file *file, | |||
1550 | atomic_inc(&attr.srq->usecnt); | 1553 | atomic_inc(&attr.srq->usecnt); |
1551 | if (ind_tbl) | 1554 | if (ind_tbl) |
1552 | atomic_inc(&ind_tbl->usecnt); | 1555 | atomic_inc(&ind_tbl->usecnt); |
1556 | } else { | ||
1557 | /* It is done in _ib_create_qp for other QP types */ | ||
1558 | qp->uobject = &obj->uevent.uobject; | ||
1553 | } | 1559 | } |
1554 | qp->uobject = &obj->uevent.uobject; | ||
1555 | 1560 | ||
1556 | obj->uevent.uobject.object = qp; | 1561 | obj->uevent.uobject.object = qp; |
1557 | 1562 | ||
@@ -1971,8 +1976,15 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
1971 | goto release_qp; | 1976 | goto release_qp; |
1972 | } | 1977 | } |
1973 | 1978 | ||
1979 | if ((cmd->base.attr_mask & IB_QP_AV) && | ||
1980 | !rdma_is_port_valid(qp->device, cmd->base.dest.port_num)) { | ||
1981 | ret = -EINVAL; | ||
1982 | goto release_qp; | ||
1983 | } | ||
1984 | |||
1974 | if ((cmd->base.attr_mask & IB_QP_ALT_PATH) && | 1985 | if ((cmd->base.attr_mask & IB_QP_ALT_PATH) && |
1975 | !rdma_is_port_valid(qp->device, cmd->base.alt_port_num)) { | 1986 | (!rdma_is_port_valid(qp->device, cmd->base.alt_port_num) || |
1987 | !rdma_is_port_valid(qp->device, cmd->base.alt_dest.port_num))) { | ||
1976 | ret = -EINVAL; | 1988 | ret = -EINVAL; |
1977 | goto release_qp; | 1989 | goto release_qp; |
1978 | } | 1990 | } |
@@ -2941,6 +2953,11 @@ int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file, | |||
2941 | wq_init_attr.create_flags = cmd.create_flags; | 2953 | wq_init_attr.create_flags = cmd.create_flags; |
2942 | obj->uevent.events_reported = 0; | 2954 | obj->uevent.events_reported = 0; |
2943 | INIT_LIST_HEAD(&obj->uevent.event_list); | 2955 | INIT_LIST_HEAD(&obj->uevent.event_list); |
2956 | |||
2957 | if (!pd->device->create_wq) { | ||
2958 | err = -EOPNOTSUPP; | ||
2959 | goto err_put_cq; | ||
2960 | } | ||
2944 | wq = pd->device->create_wq(pd, &wq_init_attr, uhw); | 2961 | wq = pd->device->create_wq(pd, &wq_init_attr, uhw); |
2945 | if (IS_ERR(wq)) { | 2962 | if (IS_ERR(wq)) { |
2946 | err = PTR_ERR(wq); | 2963 | err = PTR_ERR(wq); |
@@ -3084,7 +3101,12 @@ int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file, | |||
3084 | wq_attr.flags = cmd.flags; | 3101 | wq_attr.flags = cmd.flags; |
3085 | wq_attr.flags_mask = cmd.flags_mask; | 3102 | wq_attr.flags_mask = cmd.flags_mask; |
3086 | } | 3103 | } |
3104 | if (!wq->device->modify_wq) { | ||
3105 | ret = -EOPNOTSUPP; | ||
3106 | goto out; | ||
3107 | } | ||
3087 | ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask, uhw); | 3108 | ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask, uhw); |
3109 | out: | ||
3088 | uobj_put_obj_read(wq); | 3110 | uobj_put_obj_read(wq); |
3089 | return ret; | 3111 | return ret; |
3090 | } | 3112 | } |
@@ -3181,6 +3203,11 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file, | |||
3181 | 3203 | ||
3182 | init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size; | 3204 | init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size; |
3183 | init_attr.ind_tbl = wqs; | 3205 | init_attr.ind_tbl = wqs; |
3206 | |||
3207 | if (!ib_dev->create_rwq_ind_table) { | ||
3208 | err = -EOPNOTSUPP; | ||
3209 | goto err_uobj; | ||
3210 | } | ||
3184 | rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr, uhw); | 3211 | rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr, uhw); |
3185 | 3212 | ||
3186 | if (IS_ERR(rwq_ind_tbl)) { | 3213 | if (IS_ERR(rwq_ind_tbl)) { |
@@ -3770,6 +3797,9 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file, | |||
3770 | struct ib_device_attr attr = {0}; | 3797 | struct ib_device_attr attr = {0}; |
3771 | int err; | 3798 | int err; |
3772 | 3799 | ||
3800 | if (!ib_dev->query_device) | ||
3801 | return -EOPNOTSUPP; | ||
3802 | |||
3773 | if (ucore->inlen < sizeof(cmd)) | 3803 | if (ucore->inlen < sizeof(cmd)) |
3774 | return -EINVAL; | 3804 | return -EINVAL; |
3775 | 3805 | ||
diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c index d96dc1d17be1..339b85145044 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c | |||
@@ -59,6 +59,9 @@ static int uverbs_process_attr(struct ib_device *ibdev, | |||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | if (test_bit(attr_id, attr_bundle_h->valid_bitmap)) | ||
63 | return -EINVAL; | ||
64 | |||
62 | spec = &attr_spec_bucket->attrs[attr_id]; | 65 | spec = &attr_spec_bucket->attrs[attr_id]; |
63 | e = &elements[attr_id]; | 66 | e = &elements[attr_id]; |
64 | e->uattr = uattr_ptr; | 67 | e->uattr = uattr_ptr; |
diff --git a/drivers/infiniband/core/uverbs_ioctl_merge.c b/drivers/infiniband/core/uverbs_ioctl_merge.c index 062485f9300d..62e1eb1d2a28 100644 --- a/drivers/infiniband/core/uverbs_ioctl_merge.c +++ b/drivers/infiniband/core/uverbs_ioctl_merge.c | |||
@@ -114,6 +114,7 @@ static size_t get_elements_above_id(const void **iters, | |||
114 | short min = SHRT_MAX; | 114 | short min = SHRT_MAX; |
115 | const void *elem; | 115 | const void *elem; |
116 | int i, j, last_stored = -1; | 116 | int i, j, last_stored = -1; |
117 | unsigned int equal_min = 0; | ||
117 | 118 | ||
118 | for_each_element(elem, i, j, elements, num_elements, num_offset, | 119 | for_each_element(elem, i, j, elements, num_elements, num_offset, |
119 | data_offset) { | 120 | data_offset) { |
@@ -136,6 +137,10 @@ static size_t get_elements_above_id(const void **iters, | |||
136 | */ | 137 | */ |
137 | iters[last_stored == i ? num_iters - 1 : num_iters++] = elem; | 138 | iters[last_stored == i ? num_iters - 1 : num_iters++] = elem; |
138 | last_stored = i; | 139 | last_stored = i; |
140 | if (min == GET_ID(id)) | ||
141 | equal_min++; | ||
142 | else | ||
143 | equal_min = 1; | ||
139 | min = GET_ID(id); | 144 | min = GET_ID(id); |
140 | } | 145 | } |
141 | 146 | ||
@@ -146,15 +151,10 @@ static size_t get_elements_above_id(const void **iters, | |||
146 | * Therefore, we need to clean the beginning of the array to make sure | 151 | * Therefore, we need to clean the beginning of the array to make sure |
147 | * all ids of final elements are equal to min. | 152 | * all ids of final elements are equal to min. |
148 | */ | 153 | */ |
149 | for (i = num_iters - 1; i >= 0 && | 154 | memmove(iters, iters + num_iters - equal_min, sizeof(*iters) * equal_min); |
150 | GET_ID(*(u16 *)(iters[i] + id_offset)) == min; i--) | ||
151 | ; | ||
152 | |||
153 | num_iters -= i + 1; | ||
154 | memmove(iters, iters + i + 1, sizeof(*iters) * num_iters); | ||
155 | 155 | ||
156 | *min_id = min; | 156 | *min_id = min; |
157 | return num_iters; | 157 | return equal_min; |
158 | } | 158 | } |
159 | 159 | ||
160 | #define find_max_element_entry_id(num_elements, elements, num_objects_fld, \ | 160 | #define find_max_element_entry_id(num_elements, elements, num_objects_fld, \ |
@@ -322,7 +322,7 @@ static struct uverbs_method_spec *build_method_with_attrs(const struct uverbs_me | |||
322 | hash = kzalloc(sizeof(*hash) + | 322 | hash = kzalloc(sizeof(*hash) + |
323 | ALIGN(sizeof(*hash->attrs) * (attr_max_bucket + 1), | 323 | ALIGN(sizeof(*hash->attrs) * (attr_max_bucket + 1), |
324 | sizeof(long)) + | 324 | sizeof(long)) + |
325 | BITS_TO_LONGS(attr_max_bucket) * sizeof(long), | 325 | BITS_TO_LONGS(attr_max_bucket + 1) * sizeof(long), |
326 | GFP_KERNEL); | 326 | GFP_KERNEL); |
327 | if (!hash) { | 327 | if (!hash) { |
328 | res = -ENOMEM; | 328 | res = -ENOMEM; |
@@ -509,7 +509,7 @@ static struct uverbs_object_spec *build_object_with_methods(const struct uverbs_ | |||
509 | * first handler which != NULL. This also defines the | 509 | * first handler which != NULL. This also defines the |
510 | * set of flags used for this handler. | 510 | * set of flags used for this handler. |
511 | */ | 511 | */ |
512 | for (i = num_object_defs - 1; | 512 | for (i = num_method_defs - 1; |
513 | i >= 0 && !method_defs[i]->handler; i--) | 513 | i >= 0 && !method_defs[i]->handler; i--) |
514 | ; | 514 | ; |
515 | hash->methods[min_id++] = method; | 515 | hash->methods[min_id++] = method; |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 395a3b091229..b1ca223aa380 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -650,12 +650,21 @@ static int verify_command_mask(struct ib_device *ib_dev, __u32 command) | |||
650 | return -1; | 650 | return -1; |
651 | } | 651 | } |
652 | 652 | ||
653 | static bool verify_command_idx(u32 command, bool extended) | ||
654 | { | ||
655 | if (extended) | ||
656 | return command < ARRAY_SIZE(uverbs_ex_cmd_table); | ||
657 | |||
658 | return command < ARRAY_SIZE(uverbs_cmd_table); | ||
659 | } | ||
660 | |||
653 | static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | 661 | static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, |
654 | size_t count, loff_t *pos) | 662 | size_t count, loff_t *pos) |
655 | { | 663 | { |
656 | struct ib_uverbs_file *file = filp->private_data; | 664 | struct ib_uverbs_file *file = filp->private_data; |
657 | struct ib_device *ib_dev; | 665 | struct ib_device *ib_dev; |
658 | struct ib_uverbs_cmd_hdr hdr; | 666 | struct ib_uverbs_cmd_hdr hdr; |
667 | bool extended_command; | ||
659 | __u32 command; | 668 | __u32 command; |
660 | __u32 flags; | 669 | __u32 flags; |
661 | int srcu_key; | 670 | int srcu_key; |
@@ -688,6 +697,15 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | |||
688 | } | 697 | } |
689 | 698 | ||
690 | command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; | 699 | command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; |
700 | flags = (hdr.command & | ||
701 | IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; | ||
702 | |||
703 | extended_command = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED; | ||
704 | if (!verify_command_idx(command, extended_command)) { | ||
705 | ret = -EINVAL; | ||
706 | goto out; | ||
707 | } | ||
708 | |||
691 | if (verify_command_mask(ib_dev, command)) { | 709 | if (verify_command_mask(ib_dev, command)) { |
692 | ret = -EOPNOTSUPP; | 710 | ret = -EOPNOTSUPP; |
693 | goto out; | 711 | goto out; |
@@ -699,12 +717,8 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | |||
699 | goto out; | 717 | goto out; |
700 | } | 718 | } |
701 | 719 | ||
702 | flags = (hdr.command & | ||
703 | IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; | ||
704 | |||
705 | if (!flags) { | 720 | if (!flags) { |
706 | if (command >= ARRAY_SIZE(uverbs_cmd_table) || | 721 | if (!uverbs_cmd_table[command]) { |
707 | !uverbs_cmd_table[command]) { | ||
708 | ret = -EINVAL; | 722 | ret = -EINVAL; |
709 | goto out; | 723 | goto out; |
710 | } | 724 | } |
@@ -725,8 +739,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | |||
725 | struct ib_udata uhw; | 739 | struct ib_udata uhw; |
726 | size_t written_count = count; | 740 | size_t written_count = count; |
727 | 741 | ||
728 | if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) || | 742 | if (!uverbs_ex_cmd_table[command]) { |
729 | !uverbs_ex_cmd_table[command]) { | ||
730 | ret = -ENOSYS; | 743 | ret = -ENOSYS; |
731 | goto out; | 744 | goto out; |
732 | } | 745 | } |
@@ -942,6 +955,7 @@ static const struct file_operations uverbs_fops = { | |||
942 | .llseek = no_llseek, | 955 | .llseek = no_llseek, |
943 | #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) | 956 | #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) |
944 | .unlocked_ioctl = ib_uverbs_ioctl, | 957 | .unlocked_ioctl = ib_uverbs_ioctl, |
958 | .compat_ioctl = ib_uverbs_ioctl, | ||
945 | #endif | 959 | #endif |
946 | }; | 960 | }; |
947 | 961 | ||
@@ -954,6 +968,7 @@ static const struct file_operations uverbs_mmap_fops = { | |||
954 | .llseek = no_llseek, | 968 | .llseek = no_llseek, |
955 | #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) | 969 | #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) |
956 | .unlocked_ioctl = ib_uverbs_ioctl, | 970 | .unlocked_ioctl = ib_uverbs_ioctl, |
971 | .compat_ioctl = ib_uverbs_ioctl, | ||
957 | #endif | 972 | #endif |
958 | }; | 973 | }; |
959 | 974 | ||
diff --git a/drivers/infiniband/core/uverbs_std_types.c b/drivers/infiniband/core/uverbs_std_types.c index cab0ac3556eb..df1360e6774f 100644 --- a/drivers/infiniband/core/uverbs_std_types.c +++ b/drivers/infiniband/core/uverbs_std_types.c | |||
@@ -234,15 +234,18 @@ static void create_udata(struct uverbs_attr_bundle *ctx, | |||
234 | uverbs_attr_get(ctx, UVERBS_UHW_OUT); | 234 | uverbs_attr_get(ctx, UVERBS_UHW_OUT); |
235 | 235 | ||
236 | if (!IS_ERR(uhw_in)) { | 236 | if (!IS_ERR(uhw_in)) { |
237 | udata->inbuf = uhw_in->ptr_attr.ptr; | ||
238 | udata->inlen = uhw_in->ptr_attr.len; | 237 | udata->inlen = uhw_in->ptr_attr.len; |
238 | if (uverbs_attr_ptr_is_inline(uhw_in)) | ||
239 | udata->inbuf = &uhw_in->uattr->data; | ||
240 | else | ||
241 | udata->inbuf = u64_to_user_ptr(uhw_in->ptr_attr.data); | ||
239 | } else { | 242 | } else { |
240 | udata->inbuf = NULL; | 243 | udata->inbuf = NULL; |
241 | udata->inlen = 0; | 244 | udata->inlen = 0; |
242 | } | 245 | } |
243 | 246 | ||
244 | if (!IS_ERR(uhw_out)) { | 247 | if (!IS_ERR(uhw_out)) { |
245 | udata->outbuf = uhw_out->ptr_attr.ptr; | 248 | udata->outbuf = u64_to_user_ptr(uhw_out->ptr_attr.data); |
246 | udata->outlen = uhw_out->ptr_attr.len; | 249 | udata->outlen = uhw_out->ptr_attr.len; |
247 | } else { | 250 | } else { |
248 | udata->outbuf = NULL; | 251 | udata->outbuf = NULL; |
@@ -323,7 +326,8 @@ static int uverbs_create_cq_handler(struct ib_device *ib_dev, | |||
323 | cq->res.type = RDMA_RESTRACK_CQ; | 326 | cq->res.type = RDMA_RESTRACK_CQ; |
324 | rdma_restrack_add(&cq->res); | 327 | rdma_restrack_add(&cq->res); |
325 | 328 | ||
326 | ret = uverbs_copy_to(attrs, CREATE_CQ_RESP_CQE, &cq->cqe); | 329 | ret = uverbs_copy_to(attrs, CREATE_CQ_RESP_CQE, &cq->cqe, |
330 | sizeof(cq->cqe)); | ||
327 | if (ret) | 331 | if (ret) |
328 | goto err_cq; | 332 | goto err_cq; |
329 | 333 | ||
@@ -375,7 +379,7 @@ static int uverbs_destroy_cq_handler(struct ib_device *ib_dev, | |||
375 | resp.comp_events_reported = obj->comp_events_reported; | 379 | resp.comp_events_reported = obj->comp_events_reported; |
376 | resp.async_events_reported = obj->async_events_reported; | 380 | resp.async_events_reported = obj->async_events_reported; |
377 | 381 | ||
378 | return uverbs_copy_to(attrs, DESTROY_CQ_RESP, &resp); | 382 | return uverbs_copy_to(attrs, DESTROY_CQ_RESP, &resp, sizeof(resp)); |
379 | } | 383 | } |
380 | 384 | ||
381 | static DECLARE_UVERBS_METHOD( | 385 | static DECLARE_UVERBS_METHOD( |
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 16ebc6372c31..93025d2009b8 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -887,7 +887,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, | |||
887 | if (qp_init_attr->cap.max_rdma_ctxs) | 887 | if (qp_init_attr->cap.max_rdma_ctxs) |
888 | rdma_rw_init_qp(device, qp_init_attr); | 888 | rdma_rw_init_qp(device, qp_init_attr); |
889 | 889 | ||
890 | qp = _ib_create_qp(device, pd, qp_init_attr, NULL); | 890 | qp = _ib_create_qp(device, pd, qp_init_attr, NULL, NULL); |
891 | if (IS_ERR(qp)) | 891 | if (IS_ERR(qp)) |
892 | return qp; | 892 | return qp; |
893 | 893 | ||
@@ -898,7 +898,6 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, | |||
898 | } | 898 | } |
899 | 899 | ||
900 | qp->real_qp = qp; | 900 | qp->real_qp = qp; |
901 | qp->uobject = NULL; | ||
902 | qp->qp_type = qp_init_attr->qp_type; | 901 | qp->qp_type = qp_init_attr->qp_type; |
903 | qp->rwq_ind_tbl = qp_init_attr->rwq_ind_tbl; | 902 | qp->rwq_ind_tbl = qp_init_attr->rwq_ind_tbl; |
904 | 903 | ||
diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index ca32057e886f..3eb7a8387116 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h | |||
@@ -120,7 +120,6 @@ struct bnxt_re_dev { | |||
120 | #define BNXT_RE_FLAG_HAVE_L2_REF 3 | 120 | #define BNXT_RE_FLAG_HAVE_L2_REF 3 |
121 | #define BNXT_RE_FLAG_RCFW_CHANNEL_EN 4 | 121 | #define BNXT_RE_FLAG_RCFW_CHANNEL_EN 4 |
122 | #define BNXT_RE_FLAG_QOS_WORK_REG 5 | 122 | #define BNXT_RE_FLAG_QOS_WORK_REG 5 |
123 | #define BNXT_RE_FLAG_TASK_IN_PROG 6 | ||
124 | #define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29 | 123 | #define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29 |
125 | struct net_device *netdev; | 124 | struct net_device *netdev; |
126 | unsigned int version, major, minor; | 125 | unsigned int version, major, minor; |
@@ -158,6 +157,7 @@ struct bnxt_re_dev { | |||
158 | atomic_t srq_count; | 157 | atomic_t srq_count; |
159 | atomic_t mr_count; | 158 | atomic_t mr_count; |
160 | atomic_t mw_count; | 159 | atomic_t mw_count; |
160 | atomic_t sched_count; | ||
161 | /* Max of 2 lossless traffic class supported per port */ | 161 | /* Max of 2 lossless traffic class supported per port */ |
162 | u16 cosq[2]; | 162 | u16 cosq[2]; |
163 | 163 | ||
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index ae9e9ff54826..643174d949a8 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c | |||
@@ -174,10 +174,8 @@ int bnxt_re_query_device(struct ib_device *ibdev, | |||
174 | ib_attr->max_pd = dev_attr->max_pd; | 174 | ib_attr->max_pd = dev_attr->max_pd; |
175 | ib_attr->max_qp_rd_atom = dev_attr->max_qp_rd_atom; | 175 | ib_attr->max_qp_rd_atom = dev_attr->max_qp_rd_atom; |
176 | ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom; | 176 | ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom; |
177 | if (dev_attr->is_atomic) { | 177 | ib_attr->atomic_cap = IB_ATOMIC_NONE; |
178 | ib_attr->atomic_cap = IB_ATOMIC_HCA; | 178 | ib_attr->masked_atomic_cap = IB_ATOMIC_NONE; |
179 | ib_attr->masked_atomic_cap = IB_ATOMIC_HCA; | ||
180 | } | ||
181 | 179 | ||
182 | ib_attr->max_ee_rd_atom = 0; | 180 | ib_attr->max_ee_rd_atom = 0; |
183 | ib_attr->max_res_rd_atom = 0; | 181 | ib_attr->max_res_rd_atom = 0; |
@@ -787,20 +785,51 @@ int bnxt_re_query_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr) | |||
787 | return 0; | 785 | return 0; |
788 | } | 786 | } |
789 | 787 | ||
788 | static unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp) | ||
789 | __acquires(&qp->scq->cq_lock) __acquires(&qp->rcq->cq_lock) | ||
790 | { | ||
791 | unsigned long flags; | ||
792 | |||
793 | spin_lock_irqsave(&qp->scq->cq_lock, flags); | ||
794 | if (qp->rcq != qp->scq) | ||
795 | spin_lock(&qp->rcq->cq_lock); | ||
796 | else | ||
797 | __acquire(&qp->rcq->cq_lock); | ||
798 | |||
799 | return flags; | ||
800 | } | ||
801 | |||
802 | static void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp, | ||
803 | unsigned long flags) | ||
804 | __releases(&qp->scq->cq_lock) __releases(&qp->rcq->cq_lock) | ||
805 | { | ||
806 | if (qp->rcq != qp->scq) | ||
807 | spin_unlock(&qp->rcq->cq_lock); | ||
808 | else | ||
809 | __release(&qp->rcq->cq_lock); | ||
810 | spin_unlock_irqrestore(&qp->scq->cq_lock, flags); | ||
811 | } | ||
812 | |||
790 | /* Queue Pairs */ | 813 | /* Queue Pairs */ |
791 | int bnxt_re_destroy_qp(struct ib_qp *ib_qp) | 814 | int bnxt_re_destroy_qp(struct ib_qp *ib_qp) |
792 | { | 815 | { |
793 | struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp); | 816 | struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp); |
794 | struct bnxt_re_dev *rdev = qp->rdev; | 817 | struct bnxt_re_dev *rdev = qp->rdev; |
795 | int rc; | 818 | int rc; |
819 | unsigned int flags; | ||
796 | 820 | ||
797 | bnxt_qplib_flush_cqn_wq(&qp->qplib_qp); | 821 | bnxt_qplib_flush_cqn_wq(&qp->qplib_qp); |
798 | bnxt_qplib_del_flush_qp(&qp->qplib_qp); | ||
799 | rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); | 822 | rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); |
800 | if (rc) { | 823 | if (rc) { |
801 | dev_err(rdev_to_dev(rdev), "Failed to destroy HW QP"); | 824 | dev_err(rdev_to_dev(rdev), "Failed to destroy HW QP"); |
802 | return rc; | 825 | return rc; |
803 | } | 826 | } |
827 | |||
828 | flags = bnxt_re_lock_cqs(qp); | ||
829 | bnxt_qplib_clean_qp(&qp->qplib_qp); | ||
830 | bnxt_re_unlock_cqs(qp, flags); | ||
831 | bnxt_qplib_free_qp_res(&rdev->qplib_res, &qp->qplib_qp); | ||
832 | |||
804 | if (ib_qp->qp_type == IB_QPT_GSI && rdev->qp1_sqp) { | 833 | if (ib_qp->qp_type == IB_QPT_GSI && rdev->qp1_sqp) { |
805 | rc = bnxt_qplib_destroy_ah(&rdev->qplib_res, | 834 | rc = bnxt_qplib_destroy_ah(&rdev->qplib_res, |
806 | &rdev->sqp_ah->qplib_ah); | 835 | &rdev->sqp_ah->qplib_ah); |
@@ -810,7 +839,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp) | |||
810 | return rc; | 839 | return rc; |
811 | } | 840 | } |
812 | 841 | ||
813 | bnxt_qplib_del_flush_qp(&qp->qplib_qp); | 842 | bnxt_qplib_clean_qp(&qp->qplib_qp); |
814 | rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, | 843 | rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, |
815 | &rdev->qp1_sqp->qplib_qp); | 844 | &rdev->qp1_sqp->qplib_qp); |
816 | if (rc) { | 845 | if (rc) { |
@@ -1069,6 +1098,7 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd, | |||
1069 | goto fail; | 1098 | goto fail; |
1070 | } | 1099 | } |
1071 | qp->qplib_qp.scq = &cq->qplib_cq; | 1100 | qp->qplib_qp.scq = &cq->qplib_cq; |
1101 | qp->scq = cq; | ||
1072 | } | 1102 | } |
1073 | 1103 | ||
1074 | if (qp_init_attr->recv_cq) { | 1104 | if (qp_init_attr->recv_cq) { |
@@ -1080,6 +1110,7 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd, | |||
1080 | goto fail; | 1110 | goto fail; |
1081 | } | 1111 | } |
1082 | qp->qplib_qp.rcq = &cq->qplib_cq; | 1112 | qp->qplib_qp.rcq = &cq->qplib_cq; |
1113 | qp->rcq = cq; | ||
1083 | } | 1114 | } |
1084 | 1115 | ||
1085 | if (qp_init_attr->srq) { | 1116 | if (qp_init_attr->srq) { |
@@ -1185,7 +1216,7 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd, | |||
1185 | rc = bnxt_qplib_create_qp(&rdev->qplib_res, &qp->qplib_qp); | 1216 | rc = bnxt_qplib_create_qp(&rdev->qplib_res, &qp->qplib_qp); |
1186 | if (rc) { | 1217 | if (rc) { |
1187 | dev_err(rdev_to_dev(rdev), "Failed to create HW QP"); | 1218 | dev_err(rdev_to_dev(rdev), "Failed to create HW QP"); |
1188 | goto fail; | 1219 | goto free_umem; |
1189 | } | 1220 | } |
1190 | } | 1221 | } |
1191 | 1222 | ||
@@ -1213,6 +1244,13 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd, | |||
1213 | return &qp->ib_qp; | 1244 | return &qp->ib_qp; |
1214 | qp_destroy: | 1245 | qp_destroy: |
1215 | bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); | 1246 | bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); |
1247 | free_umem: | ||
1248 | if (udata) { | ||
1249 | if (qp->rumem) | ||
1250 | ib_umem_release(qp->rumem); | ||
1251 | if (qp->sumem) | ||
1252 | ib_umem_release(qp->sumem); | ||
1253 | } | ||
1216 | fail: | 1254 | fail: |
1217 | kfree(qp); | 1255 | kfree(qp); |
1218 | return ERR_PTR(rc); | 1256 | return ERR_PTR(rc); |
@@ -1603,7 +1641,7 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr, | |||
1603 | dev_dbg(rdev_to_dev(rdev), | 1641 | dev_dbg(rdev_to_dev(rdev), |
1604 | "Move QP = %p out of flush list\n", | 1642 | "Move QP = %p out of flush list\n", |
1605 | qp); | 1643 | qp); |
1606 | bnxt_qplib_del_flush_qp(&qp->qplib_qp); | 1644 | bnxt_qplib_clean_qp(&qp->qplib_qp); |
1607 | } | 1645 | } |
1608 | } | 1646 | } |
1609 | if (qp_attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) { | 1647 | if (qp_attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) { |
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h index 423ebe012f95..b88a48d43a9d 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h | |||
@@ -89,6 +89,8 @@ struct bnxt_re_qp { | |||
89 | /* QP1 */ | 89 | /* QP1 */ |
90 | u32 send_psn; | 90 | u32 send_psn; |
91 | struct ib_ud_header qp1_hdr; | 91 | struct ib_ud_header qp1_hdr; |
92 | struct bnxt_re_cq *scq; | ||
93 | struct bnxt_re_cq *rcq; | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | struct bnxt_re_cq { | 96 | struct bnxt_re_cq { |
diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 508d00a5a106..33a448036c2e 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c | |||
@@ -656,7 +656,6 @@ static void bnxt_re_dev_remove(struct bnxt_re_dev *rdev) | |||
656 | mutex_unlock(&bnxt_re_dev_lock); | 656 | mutex_unlock(&bnxt_re_dev_lock); |
657 | 657 | ||
658 | synchronize_rcu(); | 658 | synchronize_rcu(); |
659 | flush_workqueue(bnxt_re_wq); | ||
660 | 659 | ||
661 | ib_dealloc_device(&rdev->ibdev); | 660 | ib_dealloc_device(&rdev->ibdev); |
662 | /* rdev is gone */ | 661 | /* rdev is gone */ |
@@ -1441,7 +1440,7 @@ static void bnxt_re_task(struct work_struct *work) | |||
1441 | break; | 1440 | break; |
1442 | } | 1441 | } |
1443 | smp_mb__before_atomic(); | 1442 | smp_mb__before_atomic(); |
1444 | clear_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags); | 1443 | atomic_dec(&rdev->sched_count); |
1445 | kfree(re_work); | 1444 | kfree(re_work); |
1446 | } | 1445 | } |
1447 | 1446 | ||
@@ -1503,7 +1502,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier, | |||
1503 | /* netdev notifier will call NETDEV_UNREGISTER again later since | 1502 | /* netdev notifier will call NETDEV_UNREGISTER again later since |
1504 | * we are still holding the reference to the netdev | 1503 | * we are still holding the reference to the netdev |
1505 | */ | 1504 | */ |
1506 | if (test_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags)) | 1505 | if (atomic_read(&rdev->sched_count) > 0) |
1507 | goto exit; | 1506 | goto exit; |
1508 | bnxt_re_ib_unreg(rdev, false); | 1507 | bnxt_re_ib_unreg(rdev, false); |
1509 | bnxt_re_remove_one(rdev); | 1508 | bnxt_re_remove_one(rdev); |
@@ -1523,7 +1522,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier, | |||
1523 | re_work->vlan_dev = (real_dev == netdev ? | 1522 | re_work->vlan_dev = (real_dev == netdev ? |
1524 | NULL : netdev); | 1523 | NULL : netdev); |
1525 | INIT_WORK(&re_work->work, bnxt_re_task); | 1524 | INIT_WORK(&re_work->work, bnxt_re_task); |
1526 | set_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags); | 1525 | atomic_inc(&rdev->sched_count); |
1527 | queue_work(bnxt_re_wq, &re_work->work); | 1526 | queue_work(bnxt_re_wq, &re_work->work); |
1528 | } | 1527 | } |
1529 | } | 1528 | } |
@@ -1578,6 +1577,11 @@ static void __exit bnxt_re_mod_exit(void) | |||
1578 | */ | 1577 | */ |
1579 | list_for_each_entry_safe_reverse(rdev, next, &to_be_deleted, list) { | 1578 | list_for_each_entry_safe_reverse(rdev, next, &to_be_deleted, list) { |
1580 | dev_info(rdev_to_dev(rdev), "Unregistering Device"); | 1579 | dev_info(rdev_to_dev(rdev), "Unregistering Device"); |
1580 | /* | ||
1581 | * Flush out any scheduled tasks before destroying the | ||
1582 | * resources | ||
1583 | */ | ||
1584 | flush_workqueue(bnxt_re_wq); | ||
1581 | bnxt_re_dev_stop(rdev); | 1585 | bnxt_re_dev_stop(rdev); |
1582 | bnxt_re_ib_unreg(rdev, true); | 1586 | bnxt_re_ib_unreg(rdev, true); |
1583 | bnxt_re_remove_one(rdev); | 1587 | bnxt_re_remove_one(rdev); |
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index 1b0e94697fe3..3ea5b9624f6b 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c | |||
@@ -173,7 +173,7 @@ static void __bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp) | |||
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp) | 176 | void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp) |
177 | { | 177 | { |
178 | unsigned long flags; | 178 | unsigned long flags; |
179 | 179 | ||
@@ -1419,7 +1419,6 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, | |||
1419 | struct bnxt_qplib_rcfw *rcfw = res->rcfw; | 1419 | struct bnxt_qplib_rcfw *rcfw = res->rcfw; |
1420 | struct cmdq_destroy_qp req; | 1420 | struct cmdq_destroy_qp req; |
1421 | struct creq_destroy_qp_resp resp; | 1421 | struct creq_destroy_qp_resp resp; |
1422 | unsigned long flags; | ||
1423 | u16 cmd_flags = 0; | 1422 | u16 cmd_flags = 0; |
1424 | int rc; | 1423 | int rc; |
1425 | 1424 | ||
@@ -1437,19 +1436,12 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, | |||
1437 | return rc; | 1436 | return rc; |
1438 | } | 1437 | } |
1439 | 1438 | ||
1440 | /* Must walk the associated CQs to nullified the QP ptr */ | 1439 | return 0; |
1441 | spin_lock_irqsave(&qp->scq->hwq.lock, flags); | 1440 | } |
1442 | |||
1443 | __clean_cq(qp->scq, (u64)(unsigned long)qp); | ||
1444 | |||
1445 | if (qp->rcq && qp->rcq != qp->scq) { | ||
1446 | spin_lock(&qp->rcq->hwq.lock); | ||
1447 | __clean_cq(qp->rcq, (u64)(unsigned long)qp); | ||
1448 | spin_unlock(&qp->rcq->hwq.lock); | ||
1449 | } | ||
1450 | |||
1451 | spin_unlock_irqrestore(&qp->scq->hwq.lock, flags); | ||
1452 | 1441 | ||
1442 | void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, | ||
1443 | struct bnxt_qplib_qp *qp) | ||
1444 | { | ||
1453 | bnxt_qplib_free_qp_hdr_buf(res, qp); | 1445 | bnxt_qplib_free_qp_hdr_buf(res, qp); |
1454 | bnxt_qplib_free_hwq(res->pdev, &qp->sq.hwq); | 1446 | bnxt_qplib_free_hwq(res->pdev, &qp->sq.hwq); |
1455 | kfree(qp->sq.swq); | 1447 | kfree(qp->sq.swq); |
@@ -1462,7 +1454,6 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, | |||
1462 | if (qp->orrq.max_elements) | 1454 | if (qp->orrq.max_elements) |
1463 | bnxt_qplib_free_hwq(res->pdev, &qp->orrq); | 1455 | bnxt_qplib_free_hwq(res->pdev, &qp->orrq); |
1464 | 1456 | ||
1465 | return 0; | ||
1466 | } | 1457 | } |
1467 | 1458 | ||
1468 | void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp, | 1459 | void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp, |
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h index 211b27a8f9e2..ca0a2ffa3509 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h | |||
@@ -478,6 +478,9 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); | |||
478 | int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); | 478 | int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); |
479 | int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); | 479 | int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); |
480 | int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); | 480 | int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); |
481 | void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp); | ||
482 | void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, | ||
483 | struct bnxt_qplib_qp *qp); | ||
481 | void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp, | 484 | void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp, |
482 | struct bnxt_qplib_sge *sge); | 485 | struct bnxt_qplib_sge *sge); |
483 | void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp, | 486 | void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp, |
@@ -500,7 +503,6 @@ void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type); | |||
500 | void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq); | 503 | void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq); |
501 | int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq); | 504 | int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq); |
502 | void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp); | 505 | void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp); |
503 | void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp); | ||
504 | void bnxt_qplib_acquire_cq_locks(struct bnxt_qplib_qp *qp, | 506 | void bnxt_qplib_acquire_cq_locks(struct bnxt_qplib_qp *qp, |
505 | unsigned long *flags); | 507 | unsigned long *flags); |
506 | void bnxt_qplib_release_cq_locks(struct bnxt_qplib_qp *qp, | 508 | void bnxt_qplib_release_cq_locks(struct bnxt_qplib_qp *qp, |
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c index c015c1861351..03057983341f 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c | |||
@@ -52,18 +52,6 @@ const struct bnxt_qplib_gid bnxt_qplib_gid_zero = {{ 0, 0, 0, 0, 0, 0, 0, 0, | |||
52 | 52 | ||
53 | /* Device */ | 53 | /* Device */ |
54 | 54 | ||
55 | static bool bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw) | ||
56 | { | ||
57 | int rc; | ||
58 | u16 pcie_ctl2; | ||
59 | |||
60 | rc = pcie_capability_read_word(rcfw->pdev, PCI_EXP_DEVCTL2, | ||
61 | &pcie_ctl2); | ||
62 | if (rc) | ||
63 | return false; | ||
64 | return !!(pcie_ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ); | ||
65 | } | ||
66 | |||
67 | static void bnxt_qplib_query_version(struct bnxt_qplib_rcfw *rcfw, | 55 | static void bnxt_qplib_query_version(struct bnxt_qplib_rcfw *rcfw, |
68 | char *fw_ver) | 56 | char *fw_ver) |
69 | { | 57 | { |
@@ -165,7 +153,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, | |||
165 | attr->tqm_alloc_reqs[i * 4 + 3] = *(++tqm_alloc); | 153 | attr->tqm_alloc_reqs[i * 4 + 3] = *(++tqm_alloc); |
166 | } | 154 | } |
167 | 155 | ||
168 | attr->is_atomic = bnxt_qplib_is_atomic_cap(rcfw); | 156 | attr->is_atomic = 0; |
169 | bail: | 157 | bail: |
170 | bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf); | 158 | bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf); |
171 | return rc; | 159 | return rc; |
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c index faa9478c14a6..f95b97646c25 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | |||
@@ -114,6 +114,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, | |||
114 | union pvrdma_cmd_resp rsp; | 114 | union pvrdma_cmd_resp rsp; |
115 | struct pvrdma_cmd_create_cq *cmd = &req.create_cq; | 115 | struct pvrdma_cmd_create_cq *cmd = &req.create_cq; |
116 | struct pvrdma_cmd_create_cq_resp *resp = &rsp.create_cq_resp; | 116 | struct pvrdma_cmd_create_cq_resp *resp = &rsp.create_cq_resp; |
117 | struct pvrdma_create_cq_resp cq_resp = {0}; | ||
117 | struct pvrdma_create_cq ucmd; | 118 | struct pvrdma_create_cq ucmd; |
118 | 119 | ||
119 | BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64); | 120 | BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64); |
@@ -197,6 +198,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, | |||
197 | 198 | ||
198 | cq->ibcq.cqe = resp->cqe; | 199 | cq->ibcq.cqe = resp->cqe; |
199 | cq->cq_handle = resp->cq_handle; | 200 | cq->cq_handle = resp->cq_handle; |
201 | cq_resp.cqn = resp->cq_handle; | ||
200 | spin_lock_irqsave(&dev->cq_tbl_lock, flags); | 202 | spin_lock_irqsave(&dev->cq_tbl_lock, flags); |
201 | dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; | 203 | dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; |
202 | spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); | 204 | spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); |
@@ -205,7 +207,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, | |||
205 | cq->uar = &(to_vucontext(context)->uar); | 207 | cq->uar = &(to_vucontext(context)->uar); |
206 | 208 | ||
207 | /* Copy udata back. */ | 209 | /* Copy udata back. */ |
208 | if (ib_copy_to_udata(udata, &cq->cq_handle, sizeof(__u32))) { | 210 | if (ib_copy_to_udata(udata, &cq_resp, sizeof(cq_resp))) { |
209 | dev_warn(&dev->pdev->dev, | 211 | dev_warn(&dev->pdev->dev, |
210 | "failed to copy back udata\n"); | 212 | "failed to copy back udata\n"); |
211 | pvrdma_destroy_cq(&cq->ibcq); | 213 | pvrdma_destroy_cq(&cq->ibcq); |
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c index 5acebb1ef631..af235967a9c2 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | |||
@@ -113,6 +113,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, | |||
113 | union pvrdma_cmd_resp rsp; | 113 | union pvrdma_cmd_resp rsp; |
114 | struct pvrdma_cmd_create_srq *cmd = &req.create_srq; | 114 | struct pvrdma_cmd_create_srq *cmd = &req.create_srq; |
115 | struct pvrdma_cmd_create_srq_resp *resp = &rsp.create_srq_resp; | 115 | struct pvrdma_cmd_create_srq_resp *resp = &rsp.create_srq_resp; |
116 | struct pvrdma_create_srq_resp srq_resp = {0}; | ||
116 | struct pvrdma_create_srq ucmd; | 117 | struct pvrdma_create_srq ucmd; |
117 | unsigned long flags; | 118 | unsigned long flags; |
118 | int ret; | 119 | int ret; |
@@ -204,12 +205,13 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, | |||
204 | } | 205 | } |
205 | 206 | ||
206 | srq->srq_handle = resp->srqn; | 207 | srq->srq_handle = resp->srqn; |
208 | srq_resp.srqn = resp->srqn; | ||
207 | spin_lock_irqsave(&dev->srq_tbl_lock, flags); | 209 | spin_lock_irqsave(&dev->srq_tbl_lock, flags); |
208 | dev->srq_tbl[srq->srq_handle % dev->dsr->caps.max_srq] = srq; | 210 | dev->srq_tbl[srq->srq_handle % dev->dsr->caps.max_srq] = srq; |
209 | spin_unlock_irqrestore(&dev->srq_tbl_lock, flags); | 211 | spin_unlock_irqrestore(&dev->srq_tbl_lock, flags); |
210 | 212 | ||
211 | /* Copy udata back. */ | 213 | /* Copy udata back. */ |
212 | if (ib_copy_to_udata(udata, &srq->srq_handle, sizeof(__u32))) { | 214 | if (ib_copy_to_udata(udata, &srq_resp, sizeof(srq_resp))) { |
213 | dev_warn(&dev->pdev->dev, "failed to copy back udata\n"); | 215 | dev_warn(&dev->pdev->dev, "failed to copy back udata\n"); |
214 | pvrdma_destroy_srq(&srq->ibsrq); | 216 | pvrdma_destroy_srq(&srq->ibsrq); |
215 | return ERR_PTR(-EINVAL); | 217 | return ERR_PTR(-EINVAL); |
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c index 16b96616ef7e..a51463cd2f37 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | |||
@@ -447,6 +447,7 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev, | |||
447 | union pvrdma_cmd_resp rsp; | 447 | union pvrdma_cmd_resp rsp; |
448 | struct pvrdma_cmd_create_pd *cmd = &req.create_pd; | 448 | struct pvrdma_cmd_create_pd *cmd = &req.create_pd; |
449 | struct pvrdma_cmd_create_pd_resp *resp = &rsp.create_pd_resp; | 449 | struct pvrdma_cmd_create_pd_resp *resp = &rsp.create_pd_resp; |
450 | struct pvrdma_alloc_pd_resp pd_resp = {0}; | ||
450 | int ret; | 451 | int ret; |
451 | void *ptr; | 452 | void *ptr; |
452 | 453 | ||
@@ -475,9 +476,10 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev, | |||
475 | pd->privileged = !context; | 476 | pd->privileged = !context; |
476 | pd->pd_handle = resp->pd_handle; | 477 | pd->pd_handle = resp->pd_handle; |
477 | pd->pdn = resp->pd_handle; | 478 | pd->pdn = resp->pd_handle; |
479 | pd_resp.pdn = resp->pd_handle; | ||
478 | 480 | ||
479 | if (context) { | 481 | if (context) { |
480 | if (ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32))) { | 482 | if (ib_copy_to_udata(udata, &pd_resp, sizeof(pd_resp))) { |
481 | dev_warn(&dev->pdev->dev, | 483 | dev_warn(&dev->pdev->dev, |
482 | "failed to copy back protection domain\n"); | 484 | "failed to copy back protection domain\n"); |
483 | pvrdma_dealloc_pd(&pd->ibpd); | 485 | pvrdma_dealloc_pd(&pd->ibpd); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c index 11f74cbe6660..ea302b054601 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c | |||
@@ -281,8 +281,6 @@ void ipoib_delete_debug_files(struct net_device *dev) | |||
281 | { | 281 | { |
282 | struct ipoib_dev_priv *priv = ipoib_priv(dev); | 282 | struct ipoib_dev_priv *priv = ipoib_priv(dev); |
283 | 283 | ||
284 | WARN_ONCE(!priv->mcg_dentry, "null mcg debug file\n"); | ||
285 | WARN_ONCE(!priv->path_dentry, "null path debug file\n"); | ||
286 | debugfs_remove(priv->mcg_dentry); | 284 | debugfs_remove(priv->mcg_dentry); |
287 | debugfs_remove(priv->path_dentry); | 285 | debugfs_remove(priv->path_dentry); |
288 | priv->mcg_dentry = priv->path_dentry = NULL; | 286 | priv->mcg_dentry = priv->path_dentry = NULL; |
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 8d12017b9893..4470630dd545 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -2687,6 +2687,8 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2687 | __FILE__, __LINE__, iocnum); | 2687 | __FILE__, __LINE__, iocnum); |
2688 | return -ENODEV; | 2688 | return -ENODEV; |
2689 | } | 2689 | } |
2690 | if (karg.hdr.id >= MPT_MAX_FC_DEVICES) | ||
2691 | return -EINVAL; | ||
2690 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", | 2692 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", |
2691 | ioc->name)); | 2693 | ioc->name)); |
2692 | 2694 | ||
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 3e5eabdae8d9..772d02922529 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -548,12 +548,6 @@ int mei_cldev_disable(struct mei_cl_device *cldev) | |||
548 | goto out; | 548 | goto out; |
549 | } | 549 | } |
550 | 550 | ||
551 | if (bus->dev_state == MEI_DEV_POWER_DOWN) { | ||
552 | dev_dbg(bus->dev, "Device is powering down, don't bother with disconnection\n"); | ||
553 | err = 0; | ||
554 | goto out; | ||
555 | } | ||
556 | |||
557 | err = mei_cl_disconnect(cl); | 551 | err = mei_cl_disconnect(cl); |
558 | if (err < 0) | 552 | if (err < 0) |
559 | dev_err(bus->dev, "Could not disconnect from the ME client\n"); | 553 | dev_err(bus->dev, "Could not disconnect from the ME client\n"); |
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index be64969d986a..7e60c1817c31 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -945,6 +945,12 @@ int mei_cl_disconnect(struct mei_cl *cl) | |||
945 | return 0; | 945 | return 0; |
946 | } | 946 | } |
947 | 947 | ||
948 | if (dev->dev_state == MEI_DEV_POWER_DOWN) { | ||
949 | cl_dbg(dev, cl, "Device is powering down, don't bother with disconnection\n"); | ||
950 | mei_cl_set_disconnected(cl); | ||
951 | return 0; | ||
952 | } | ||
953 | |||
948 | rets = pm_runtime_get(dev->dev); | 954 | rets = pm_runtime_get(dev->dev); |
949 | if (rets < 0 && rets != -EINPROGRESS) { | 955 | if (rets < 0 && rets != -EINPROGRESS) { |
950 | pm_runtime_put_noidle(dev->dev); | 956 | pm_runtime_put_noidle(dev->dev); |
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h index 0ccccbaf530d..e4b10b2d1a08 100644 --- a/drivers/misc/mei/hw-me-regs.h +++ b/drivers/misc/mei/hw-me-regs.h | |||
@@ -132,6 +132,11 @@ | |||
132 | #define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */ | 132 | #define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */ |
133 | #define MEI_DEV_ID_KBP_2 0xA2BB /* Kaby Point 2 */ | 133 | #define MEI_DEV_ID_KBP_2 0xA2BB /* Kaby Point 2 */ |
134 | 134 | ||
135 | #define MEI_DEV_ID_CNP_LP 0x9DE0 /* Cannon Point LP */ | ||
136 | #define MEI_DEV_ID_CNP_LP_4 0x9DE4 /* Cannon Point LP 4 (iTouch) */ | ||
137 | #define MEI_DEV_ID_CNP_H 0xA360 /* Cannon Point H */ | ||
138 | #define MEI_DEV_ID_CNP_H_4 0xA364 /* Cannon Point H 4 (iTouch) */ | ||
139 | |||
135 | /* | 140 | /* |
136 | * MEI HW Section | 141 | * MEI HW Section |
137 | */ | 142 | */ |
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 4a0ccda4d04b..ea4e152270a3 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
@@ -98,6 +98,11 @@ static const struct pci_device_id mei_me_pci_tbl[] = { | |||
98 | {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)}, | 98 | {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)}, |
99 | {MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)}, | 99 | {MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)}, |
100 | 100 | ||
101 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP, MEI_ME_PCH8_CFG)}, | ||
102 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP_4, MEI_ME_PCH8_CFG)}, | ||
103 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH8_CFG)}, | ||
104 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_4, MEI_ME_PCH8_CFG)}, | ||
105 | |||
101 | /* required last entry */ | 106 | /* required last entry */ |
102 | {0, } | 107 | {0, } |
103 | }; | 108 | }; |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c index 3e5833cf1fab..eb23f9ba1a9a 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c | |||
@@ -426,6 +426,8 @@ static int xgbe_pci_resume(struct pci_dev *pdev) | |||
426 | struct net_device *netdev = pdata->netdev; | 426 | struct net_device *netdev = pdata->netdev; |
427 | int ret = 0; | 427 | int ret = 0; |
428 | 428 | ||
429 | XP_IOWRITE(pdata, XP_INT_EN, 0x1fffff); | ||
430 | |||
429 | pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER; | 431 | pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER; |
430 | XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl); | 432 | XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl); |
431 | 433 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c index 22889fc158f2..87c4308b52a7 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | |||
@@ -226,6 +226,10 @@ static int aq_pci_probe(struct pci_dev *pdev, | |||
226 | goto err_ioremap; | 226 | goto err_ioremap; |
227 | 227 | ||
228 | self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL); | 228 | self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL); |
229 | if (!self->aq_hw) { | ||
230 | err = -ENOMEM; | ||
231 | goto err_ioremap; | ||
232 | } | ||
229 | self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self); | 233 | self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self); |
230 | 234 | ||
231 | for (bar = 0; bar < 4; ++bar) { | 235 | for (bar = 0; bar < 4; ++bar) { |
@@ -235,19 +239,19 @@ static int aq_pci_probe(struct pci_dev *pdev, | |||
235 | mmio_pa = pci_resource_start(pdev, bar); | 239 | mmio_pa = pci_resource_start(pdev, bar); |
236 | if (mmio_pa == 0U) { | 240 | if (mmio_pa == 0U) { |
237 | err = -EIO; | 241 | err = -EIO; |
238 | goto err_ioremap; | 242 | goto err_free_aq_hw; |
239 | } | 243 | } |
240 | 244 | ||
241 | reg_sz = pci_resource_len(pdev, bar); | 245 | reg_sz = pci_resource_len(pdev, bar); |
242 | if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) { | 246 | if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) { |
243 | err = -EIO; | 247 | err = -EIO; |
244 | goto err_ioremap; | 248 | goto err_free_aq_hw; |
245 | } | 249 | } |
246 | 250 | ||
247 | self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz); | 251 | self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz); |
248 | if (!self->aq_hw->mmio) { | 252 | if (!self->aq_hw->mmio) { |
249 | err = -EIO; | 253 | err = -EIO; |
250 | goto err_ioremap; | 254 | goto err_free_aq_hw; |
251 | } | 255 | } |
252 | break; | 256 | break; |
253 | } | 257 | } |
@@ -255,7 +259,7 @@ static int aq_pci_probe(struct pci_dev *pdev, | |||
255 | 259 | ||
256 | if (bar == 4) { | 260 | if (bar == 4) { |
257 | err = -EIO; | 261 | err = -EIO; |
258 | goto err_ioremap; | 262 | goto err_free_aq_hw; |
259 | } | 263 | } |
260 | 264 | ||
261 | numvecs = min((u8)AQ_CFG_VECS_DEF, | 265 | numvecs = min((u8)AQ_CFG_VECS_DEF, |
@@ -290,6 +294,8 @@ err_register: | |||
290 | aq_pci_free_irq_vectors(self); | 294 | aq_pci_free_irq_vectors(self); |
291 | err_hwinit: | 295 | err_hwinit: |
292 | iounmap(self->aq_hw->mmio); | 296 | iounmap(self->aq_hw->mmio); |
297 | err_free_aq_hw: | ||
298 | kfree(self->aq_hw); | ||
293 | err_ioremap: | 299 | err_ioremap: |
294 | free_netdev(ndev); | 300 | free_netdev(ndev); |
295 | err_pci_func: | 301 | err_pci_func: |
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 3bdeb295514b..f5c87bd35fa1 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -2934,29 +2934,17 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus, | |||
2934 | { | 2934 | { |
2935 | int size = lstatus & BD_LENGTH_MASK; | 2935 | int size = lstatus & BD_LENGTH_MASK; |
2936 | struct page *page = rxb->page; | 2936 | struct page *page = rxb->page; |
2937 | bool last = !!(lstatus & BD_LFLAG(RXBD_LAST)); | ||
2938 | |||
2939 | /* Remove the FCS from the packet length */ | ||
2940 | if (last) | ||
2941 | size -= ETH_FCS_LEN; | ||
2942 | 2937 | ||
2943 | if (likely(first)) { | 2938 | if (likely(first)) { |
2944 | skb_put(skb, size); | 2939 | skb_put(skb, size); |
2945 | } else { | 2940 | } else { |
2946 | /* the last fragments' length contains the full frame length */ | 2941 | /* the last fragments' length contains the full frame length */ |
2947 | if (last) | 2942 | if (lstatus & BD_LFLAG(RXBD_LAST)) |
2948 | size -= skb->len; | 2943 | size -= skb->len; |
2949 | 2944 | ||
2950 | /* Add the last fragment if it contains something other than | 2945 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, |
2951 | * the FCS, otherwise drop it and trim off any part of the FCS | 2946 | rxb->page_offset + RXBUF_ALIGNMENT, |
2952 | * that was already received. | 2947 | size, GFAR_RXB_TRUESIZE); |
2953 | */ | ||
2954 | if (size > 0) | ||
2955 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, | ||
2956 | rxb->page_offset + RXBUF_ALIGNMENT, | ||
2957 | size, GFAR_RXB_TRUESIZE); | ||
2958 | else if (size < 0) | ||
2959 | pskb_trim(skb, skb->len + size); | ||
2960 | } | 2948 | } |
2961 | 2949 | ||
2962 | /* try reuse page */ | 2950 | /* try reuse page */ |
@@ -3069,6 +3057,9 @@ static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb) | |||
3069 | if (priv->padding) | 3057 | if (priv->padding) |
3070 | skb_pull(skb, priv->padding); | 3058 | skb_pull(skb, priv->padding); |
3071 | 3059 | ||
3060 | /* Trim off the FCS */ | ||
3061 | pskb_trim(skb, skb->len - ETH_FCS_LEN); | ||
3062 | |||
3072 | if (ndev->features & NETIF_F_RXCSUM) | 3063 | if (ndev->features & NETIF_F_RXCSUM) |
3073 | gfar_rx_checksum(skb, fcb); | 3064 | gfar_rx_checksum(skb, fcb); |
3074 | 3065 | ||
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 69d6e01fb767..5a86a916492c 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c | |||
@@ -1920,6 +1920,11 @@ restart_poll: | |||
1920 | dev_kfree_skb_any(rx_buff->skb); | 1920 | dev_kfree_skb_any(rx_buff->skb); |
1921 | remove_buff_from_pool(adapter, rx_buff); | 1921 | remove_buff_from_pool(adapter, rx_buff); |
1922 | continue; | 1922 | continue; |
1923 | } else if (!rx_buff->skb) { | ||
1924 | /* free the entry */ | ||
1925 | next->rx_comp.first = 0; | ||
1926 | remove_buff_from_pool(adapter, rx_buff); | ||
1927 | continue; | ||
1923 | } | 1928 | } |
1924 | 1929 | ||
1925 | length = be32_to_cpu(next->rx_comp.len); | 1930 | length = be32_to_cpu(next->rx_comp.len); |
@@ -3786,7 +3791,6 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq, | |||
3786 | 3791 | ||
3787 | dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz, | 3792 | dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz, |
3788 | DMA_BIDIRECTIONAL); | 3793 | DMA_BIDIRECTIONAL); |
3789 | release_login_buffer(adapter); | ||
3790 | dma_unmap_single(dev, adapter->login_rsp_buf_token, | 3794 | dma_unmap_single(dev, adapter->login_rsp_buf_token, |
3791 | adapter->login_rsp_buf_sz, DMA_BIDIRECTIONAL); | 3795 | adapter->login_rsp_buf_sz, DMA_BIDIRECTIONAL); |
3792 | 3796 | ||
@@ -3817,6 +3821,7 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq, | |||
3817 | ibmvnic_remove(adapter->vdev); | 3821 | ibmvnic_remove(adapter->vdev); |
3818 | return -EIO; | 3822 | return -EIO; |
3819 | } | 3823 | } |
3824 | release_login_buffer(adapter); | ||
3820 | complete(&adapter->init_done); | 3825 | complete(&adapter->init_done); |
3821 | 3826 | ||
3822 | return 0; | 3827 | return 0; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c index 0be4575b58a2..fd509160c8f6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c | |||
@@ -96,10 +96,10 @@ static void print_lyr_2_4_hdrs(struct trace_seq *p, | |||
96 | "%pI4"); | 96 | "%pI4"); |
97 | } else if (ethertype.v == ETH_P_IPV6) { | 97 | } else if (ethertype.v == ETH_P_IPV6) { |
98 | static const struct in6_addr full_ones = { | 98 | static const struct in6_addr full_ones = { |
99 | .in6_u.u6_addr32 = {htonl(0xffffffff), | 99 | .in6_u.u6_addr32 = {__constant_htonl(0xffffffff), |
100 | htonl(0xffffffff), | 100 | __constant_htonl(0xffffffff), |
101 | htonl(0xffffffff), | 101 | __constant_htonl(0xffffffff), |
102 | htonl(0xffffffff)}, | 102 | __constant_htonl(0xffffffff)}, |
103 | }; | 103 | }; |
104 | DECLARE_MASK_VAL(struct in6_addr, src_ipv6); | 104 | DECLARE_MASK_VAL(struct in6_addr, src_ipv6); |
105 | DECLARE_MASK_VAL(struct in6_addr, dst_ipv6); | 105 | DECLARE_MASK_VAL(struct in6_addr, dst_ipv6); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 47bab842c5ee..da94c8cba5ee 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c | |||
@@ -1768,13 +1768,16 @@ static void mlx5e_build_rq_param(struct mlx5e_priv *priv, | |||
1768 | param->wq.linear = 1; | 1768 | param->wq.linear = 1; |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | static void mlx5e_build_drop_rq_param(struct mlx5e_rq_param *param) | 1771 | static void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev, |
1772 | struct mlx5e_rq_param *param) | ||
1772 | { | 1773 | { |
1773 | void *rqc = param->rqc; | 1774 | void *rqc = param->rqc; |
1774 | void *wq = MLX5_ADDR_OF(rqc, rqc, wq); | 1775 | void *wq = MLX5_ADDR_OF(rqc, rqc, wq); |
1775 | 1776 | ||
1776 | MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_LINKED_LIST); | 1777 | MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_LINKED_LIST); |
1777 | MLX5_SET(wq, wq, log_wq_stride, ilog2(sizeof(struct mlx5e_rx_wqe))); | 1778 | MLX5_SET(wq, wq, log_wq_stride, ilog2(sizeof(struct mlx5e_rx_wqe))); |
1779 | |||
1780 | param->wq.buf_numa_node = dev_to_node(&mdev->pdev->dev); | ||
1778 | } | 1781 | } |
1779 | 1782 | ||
1780 | static void mlx5e_build_sq_param_common(struct mlx5e_priv *priv, | 1783 | static void mlx5e_build_sq_param_common(struct mlx5e_priv *priv, |
@@ -2634,6 +2637,9 @@ static int mlx5e_alloc_drop_cq(struct mlx5_core_dev *mdev, | |||
2634 | struct mlx5e_cq *cq, | 2637 | struct mlx5e_cq *cq, |
2635 | struct mlx5e_cq_param *param) | 2638 | struct mlx5e_cq_param *param) |
2636 | { | 2639 | { |
2640 | param->wq.buf_numa_node = dev_to_node(&mdev->pdev->dev); | ||
2641 | param->wq.db_numa_node = dev_to_node(&mdev->pdev->dev); | ||
2642 | |||
2637 | return mlx5e_alloc_cq_common(mdev, param, cq); | 2643 | return mlx5e_alloc_cq_common(mdev, param, cq); |
2638 | } | 2644 | } |
2639 | 2645 | ||
@@ -2645,7 +2651,7 @@ static int mlx5e_open_drop_rq(struct mlx5_core_dev *mdev, | |||
2645 | struct mlx5e_cq *cq = &drop_rq->cq; | 2651 | struct mlx5e_cq *cq = &drop_rq->cq; |
2646 | int err; | 2652 | int err; |
2647 | 2653 | ||
2648 | mlx5e_build_drop_rq_param(&rq_param); | 2654 | mlx5e_build_drop_rq_param(mdev, &rq_param); |
2649 | 2655 | ||
2650 | err = mlx5e_alloc_drop_cq(mdev, cq, &cq_param); | 2656 | err = mlx5e_alloc_drop_cq(mdev, cq, &cq_param); |
2651 | if (err) | 2657 | if (err) |
@@ -2994,8 +3000,8 @@ static int mlx5e_setup_tc_block(struct net_device *dev, | |||
2994 | } | 3000 | } |
2995 | #endif | 3001 | #endif |
2996 | 3002 | ||
2997 | int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, | 3003 | static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, |
2998 | void *type_data) | 3004 | void *type_data) |
2999 | { | 3005 | { |
3000 | switch (type) { | 3006 | switch (type) { |
3001 | #ifdef CONFIG_MLX5_ESWITCH | 3007 | #ifdef CONFIG_MLX5_ESWITCH |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 80b84f6af2a1..8cce90dc461d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/tcp.h> | 36 | #include <linux/tcp.h> |
37 | #include <linux/bpf_trace.h> | 37 | #include <linux/bpf_trace.h> |
38 | #include <net/busy_poll.h> | 38 | #include <net/busy_poll.h> |
39 | #include <net/ip6_checksum.h> | ||
39 | #include "en.h" | 40 | #include "en.h" |
40 | #include "en_tc.h" | 41 | #include "en_tc.h" |
41 | #include "eswitch.h" | 42 | #include "eswitch.h" |
@@ -547,20 +548,33 @@ bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq) | |||
547 | return true; | 548 | return true; |
548 | } | 549 | } |
549 | 550 | ||
551 | static void mlx5e_lro_update_tcp_hdr(struct mlx5_cqe64 *cqe, struct tcphdr *tcp) | ||
552 | { | ||
553 | u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); | ||
554 | u8 tcp_ack = (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA) || | ||
555 | (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA); | ||
556 | |||
557 | tcp->check = 0; | ||
558 | tcp->psh = get_cqe_lro_tcppsh(cqe); | ||
559 | |||
560 | if (tcp_ack) { | ||
561 | tcp->ack = 1; | ||
562 | tcp->ack_seq = cqe->lro_ack_seq_num; | ||
563 | tcp->window = cqe->lro_tcp_win; | ||
564 | } | ||
565 | } | ||
566 | |||
550 | static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, | 567 | static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, |
551 | u32 cqe_bcnt) | 568 | u32 cqe_bcnt) |
552 | { | 569 | { |
553 | struct ethhdr *eth = (struct ethhdr *)(skb->data); | 570 | struct ethhdr *eth = (struct ethhdr *)(skb->data); |
554 | struct tcphdr *tcp; | 571 | struct tcphdr *tcp; |
555 | int network_depth = 0; | 572 | int network_depth = 0; |
573 | __wsum check; | ||
556 | __be16 proto; | 574 | __be16 proto; |
557 | u16 tot_len; | 575 | u16 tot_len; |
558 | void *ip_p; | 576 | void *ip_p; |
559 | 577 | ||
560 | u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); | ||
561 | u8 tcp_ack = (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA) || | ||
562 | (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA); | ||
563 | |||
564 | proto = __vlan_get_protocol(skb, eth->h_proto, &network_depth); | 578 | proto = __vlan_get_protocol(skb, eth->h_proto, &network_depth); |
565 | 579 | ||
566 | tot_len = cqe_bcnt - network_depth; | 580 | tot_len = cqe_bcnt - network_depth; |
@@ -577,23 +591,30 @@ static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, | |||
577 | ipv4->check = 0; | 591 | ipv4->check = 0; |
578 | ipv4->check = ip_fast_csum((unsigned char *)ipv4, | 592 | ipv4->check = ip_fast_csum((unsigned char *)ipv4, |
579 | ipv4->ihl); | 593 | ipv4->ihl); |
594 | |||
595 | mlx5e_lro_update_tcp_hdr(cqe, tcp); | ||
596 | check = csum_partial(tcp, tcp->doff * 4, | ||
597 | csum_unfold((__force __sum16)cqe->check_sum)); | ||
598 | /* Almost done, don't forget the pseudo header */ | ||
599 | tcp->check = csum_tcpudp_magic(ipv4->saddr, ipv4->daddr, | ||
600 | tot_len - sizeof(struct iphdr), | ||
601 | IPPROTO_TCP, check); | ||
580 | } else { | 602 | } else { |
603 | u16 payload_len = tot_len - sizeof(struct ipv6hdr); | ||
581 | struct ipv6hdr *ipv6 = ip_p; | 604 | struct ipv6hdr *ipv6 = ip_p; |
582 | 605 | ||
583 | tcp = ip_p + sizeof(struct ipv6hdr); | 606 | tcp = ip_p + sizeof(struct ipv6hdr); |
584 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; | 607 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; |
585 | 608 | ||
586 | ipv6->hop_limit = cqe->lro_min_ttl; | 609 | ipv6->hop_limit = cqe->lro_min_ttl; |
587 | ipv6->payload_len = cpu_to_be16(tot_len - | 610 | ipv6->payload_len = cpu_to_be16(payload_len); |
588 | sizeof(struct ipv6hdr)); | 611 | |
589 | } | 612 | mlx5e_lro_update_tcp_hdr(cqe, tcp); |
590 | 613 | check = csum_partial(tcp, tcp->doff * 4, | |
591 | tcp->psh = get_cqe_lro_tcppsh(cqe); | 614 | csum_unfold((__force __sum16)cqe->check_sum)); |
592 | 615 | /* Almost done, don't forget the pseudo header */ | |
593 | if (tcp_ack) { | 616 | tcp->check = csum_ipv6_magic(&ipv6->saddr, &ipv6->daddr, payload_len, |
594 | tcp->ack = 1; | 617 | IPPROTO_TCP, check); |
595 | tcp->ack_seq = cqe->lro_ack_seq_num; | ||
596 | tcp->window = cqe->lro_tcp_win; | ||
597 | } | 618 | } |
598 | } | 619 | } |
599 | 620 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c b/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c index 5a4608281f38..707976482c09 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c | |||
@@ -216,7 +216,8 @@ mlx5e_test_loopback_validate(struct sk_buff *skb, | |||
216 | if (iph->protocol != IPPROTO_UDP) | 216 | if (iph->protocol != IPPROTO_UDP) |
217 | goto out; | 217 | goto out; |
218 | 218 | ||
219 | udph = udp_hdr(skb); | 219 | /* Don't assume skb_transport_header() was set */ |
220 | udph = (struct udphdr *)((u8 *)iph + 4 * iph->ihl); | ||
220 | if (udph->dest != htons(9)) | 221 | if (udph->dest != htons(9)) |
221 | goto out; | 222 | goto out; |
222 | 223 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index fd98b0dc610f..fa86a1466718 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | |||
@@ -2529,7 +2529,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, | |||
2529 | if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) { | 2529 | if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) { |
2530 | attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; | 2530 | attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; |
2531 | } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) { | 2531 | } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) { |
2532 | if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q)) | 2532 | if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q) || |
2533 | tcf_vlan_push_prio(a)) | ||
2533 | return -EOPNOTSUPP; | 2534 | return -EOPNOTSUPP; |
2534 | 2535 | ||
2535 | attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH; | 2536 | attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index 569b42a01026..11b4f1089d1c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | |||
@@ -176,7 +176,7 @@ static inline u16 mlx5e_calc_min_inline(enum mlx5_inline_modes mode, | |||
176 | default: | 176 | default: |
177 | hlen = mlx5e_skb_l2_header_offset(skb); | 177 | hlen = mlx5e_skb_l2_header_offset(skb); |
178 | } | 178 | } |
179 | return min_t(u16, hlen, skb->len); | 179 | return min_t(u16, hlen, skb_headlen(skb)); |
180 | } | 180 | } |
181 | 181 | ||
182 | static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data, | 182 | static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data, |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 5ecf2cddc16d..c2b1d7d351fc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | |||
@@ -1529,6 +1529,10 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num, | |||
1529 | 1529 | ||
1530 | esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); | 1530 | esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); |
1531 | 1531 | ||
1532 | /* Create steering drop counters for ingress and egress ACLs */ | ||
1533 | if (vport_num && esw->mode == SRIOV_LEGACY) | ||
1534 | esw_vport_create_drop_counters(vport); | ||
1535 | |||
1532 | /* Restore old vport configuration */ | 1536 | /* Restore old vport configuration */ |
1533 | esw_apply_vport_conf(esw, vport); | 1537 | esw_apply_vport_conf(esw, vport); |
1534 | 1538 | ||
@@ -1545,10 +1549,6 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num, | |||
1545 | if (!vport_num) | 1549 | if (!vport_num) |
1546 | vport->info.trusted = true; | 1550 | vport->info.trusted = true; |
1547 | 1551 | ||
1548 | /* create steering drop counters for ingress and egress ACLs */ | ||
1549 | if (vport_num && esw->mode == SRIOV_LEGACY) | ||
1550 | esw_vport_create_drop_counters(vport); | ||
1551 | |||
1552 | esw_vport_change_handle_locked(vport); | 1552 | esw_vport_change_handle_locked(vport); |
1553 | 1553 | ||
1554 | esw->enabled_vports++; | 1554 | esw->enabled_vports++; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index c025c98700e4..31fc2cfac3b3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | |||
@@ -1429,7 +1429,8 @@ static bool check_conflicting_actions(u32 action1, u32 action2) | |||
1429 | 1429 | ||
1430 | if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | | 1430 | if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | |
1431 | MLX5_FLOW_CONTEXT_ACTION_ENCAP | | 1431 | MLX5_FLOW_CONTEXT_ACTION_ENCAP | |
1432 | MLX5_FLOW_CONTEXT_ACTION_DECAP)) | 1432 | MLX5_FLOW_CONTEXT_ACTION_DECAP | |
1433 | MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) | ||
1433 | return true; | 1434 | return true; |
1434 | 1435 | ||
1435 | return false; | 1436 | return false; |
@@ -1758,8 +1759,11 @@ search_again_locked: | |||
1758 | 1759 | ||
1759 | /* Collect all fgs which has a matching match_criteria */ | 1760 | /* Collect all fgs which has a matching match_criteria */ |
1760 | err = build_match_list(&match_head, ft, spec); | 1761 | err = build_match_list(&match_head, ft, spec); |
1761 | if (err) | 1762 | if (err) { |
1763 | if (take_write) | ||
1764 | up_write_ref_node(&ft->node); | ||
1762 | return ERR_PTR(err); | 1765 | return ERR_PTR(err); |
1766 | } | ||
1763 | 1767 | ||
1764 | if (!take_write) | 1768 | if (!take_write) |
1765 | up_read_ref_node(&ft->node); | 1769 | up_read_ref_node(&ft->node); |
@@ -1768,8 +1772,11 @@ search_again_locked: | |||
1768 | dest_num, version); | 1772 | dest_num, version); |
1769 | free_match_list(&match_head); | 1773 | free_match_list(&match_head); |
1770 | if (!IS_ERR(rule) || | 1774 | if (!IS_ERR(rule) || |
1771 | (PTR_ERR(rule) != -ENOENT && PTR_ERR(rule) != -EAGAIN)) | 1775 | (PTR_ERR(rule) != -ENOENT && PTR_ERR(rule) != -EAGAIN)) { |
1776 | if (take_write) | ||
1777 | up_write_ref_node(&ft->node); | ||
1772 | return rule; | 1778 | return rule; |
1779 | } | ||
1773 | 1780 | ||
1774 | if (!take_write) { | 1781 | if (!take_write) { |
1775 | nested_down_write_ref_node(&ft->node, FS_LOCK_GRANDPARENT); | 1782 | nested_down_write_ref_node(&ft->node, FS_LOCK_GRANDPARENT); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index e159243e0fcf..857035583ccd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/highmem.h> | 34 | #include <linux/highmem.h> |
35 | #include <rdma/mlx5-abi.h> | 35 | #include <rdma/mlx5-abi.h> |
36 | #include "en.h" | 36 | #include "en.h" |
37 | #include "clock.h" | ||
37 | 38 | ||
38 | enum { | 39 | enum { |
39 | MLX5_CYCLES_SHIFT = 23 | 40 | MLX5_CYCLES_SHIFT = 23 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 8cc22bf80c87..7142c90d4669 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
@@ -551,7 +551,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
551 | MLX5_SET(cmd_hca_cap, | 551 | MLX5_SET(cmd_hca_cap, |
552 | set_hca_cap, | 552 | set_hca_cap, |
553 | cache_line_128byte, | 553 | cache_line_128byte, |
554 | cache_line_size() == 128 ? 1 : 0); | 554 | cache_line_size() >= 128 ? 1 : 0); |
555 | 555 | ||
556 | if (MLX5_CAP_GEN_MAX(dev, dct)) | 556 | if (MLX5_CAP_GEN_MAX(dev, dct)) |
557 | MLX5_SET(cmd_hca_cap, set_hca_cap, dct, 1); | 557 | MLX5_SET(cmd_hca_cap, set_hca_cap, dct, 1); |
diff --git a/drivers/net/ethernet/smsc/Kconfig b/drivers/net/ethernet/smsc/Kconfig index 63aca9f847e1..4c2f612e4414 100644 --- a/drivers/net/ethernet/smsc/Kconfig +++ b/drivers/net/ethernet/smsc/Kconfig | |||
@@ -20,7 +20,7 @@ if NET_VENDOR_SMSC | |||
20 | 20 | ||
21 | config SMC9194 | 21 | config SMC9194 |
22 | tristate "SMC 9194 support" | 22 | tristate "SMC 9194 support" |
23 | depends on (ISA || MAC && BROKEN) | 23 | depends on ISA |
24 | select CRC32 | 24 | select CRC32 |
25 | ---help--- | 25 | ---help--- |
26 | This is support for the SMC9xxx based Ethernet cards. Choose this | 26 | This is support for the SMC9xxx based Ethernet cards. Choose this |
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index a0f2be81d52e..8fc02d9db3d0 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -1451,7 +1451,7 @@ destroy_macvlan_port: | |||
1451 | /* the macvlan port may be freed by macvlan_uninit when fail to register. | 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. | 1452 | * so we destroy the macvlan port only when it's valid. |
1453 | */ | 1453 | */ |
1454 | if (create && macvlan_port_get_rtnl(dev)) | 1454 | if (create && macvlan_port_get_rtnl(lowerdev)) |
1455 | macvlan_port_destroy(port->dev); | 1455 | macvlan_port_destroy(port->dev); |
1456 | return err; | 1456 | return err; |
1457 | } | 1457 | } |
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index d0a113743195..7a6a1fe79309 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c | |||
@@ -954,10 +954,11 @@ static int smsc75xx_set_features(struct net_device *netdev, | |||
954 | /* it's racing here! */ | 954 | /* it's racing here! */ |
955 | 955 | ||
956 | ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); | 956 | ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); |
957 | if (ret < 0) | 957 | if (ret < 0) { |
958 | netdev_warn(dev->net, "Error writing RFE_CTL\n"); | 958 | netdev_warn(dev->net, "Error writing RFE_CTL\n"); |
959 | 959 | return ret; | |
960 | return ret; | 960 | } |
961 | return 0; | ||
961 | } | 962 | } |
962 | 963 | ||
963 | static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm) | 964 | static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm) |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 626c27352ae2..9bb9e562b893 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -443,12 +443,8 @@ static bool __virtnet_xdp_xmit(struct virtnet_info *vi, | |||
443 | sg_init_one(sq->sg, xdp->data, xdp->data_end - xdp->data); | 443 | sg_init_one(sq->sg, xdp->data, xdp->data_end - xdp->data); |
444 | 444 | ||
445 | err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdp->data, GFP_ATOMIC); | 445 | err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdp->data, GFP_ATOMIC); |
446 | if (unlikely(err)) { | 446 | if (unlikely(err)) |
447 | struct page *page = virt_to_head_page(xdp->data); | 447 | return false; /* Caller handle free/refcnt */ |
448 | |||
449 | put_page(page); | ||
450 | return false; | ||
451 | } | ||
452 | 448 | ||
453 | return true; | 449 | return true; |
454 | } | 450 | } |
@@ -456,8 +452,18 @@ static bool __virtnet_xdp_xmit(struct virtnet_info *vi, | |||
456 | static int virtnet_xdp_xmit(struct net_device *dev, struct xdp_buff *xdp) | 452 | static int virtnet_xdp_xmit(struct net_device *dev, struct xdp_buff *xdp) |
457 | { | 453 | { |
458 | struct virtnet_info *vi = netdev_priv(dev); | 454 | struct virtnet_info *vi = netdev_priv(dev); |
459 | bool sent = __virtnet_xdp_xmit(vi, xdp); | 455 | struct receive_queue *rq = vi->rq; |
456 | struct bpf_prog *xdp_prog; | ||
457 | bool sent; | ||
460 | 458 | ||
459 | /* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this | ||
460 | * indicate XDP resources have been successfully allocated. | ||
461 | */ | ||
462 | xdp_prog = rcu_dereference(rq->xdp_prog); | ||
463 | if (!xdp_prog) | ||
464 | return -ENXIO; | ||
465 | |||
466 | sent = __virtnet_xdp_xmit(vi, xdp); | ||
461 | if (!sent) | 467 | if (!sent) |
462 | return -ENOSPC; | 468 | return -ENOSPC; |
463 | return 0; | 469 | return 0; |
@@ -546,8 +552,11 @@ static struct sk_buff *receive_small(struct net_device *dev, | |||
546 | unsigned int buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + | 552 | unsigned int buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + |
547 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | 553 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
548 | struct page *page = virt_to_head_page(buf); | 554 | struct page *page = virt_to_head_page(buf); |
549 | unsigned int delta = 0, err; | 555 | unsigned int delta = 0; |
550 | struct page *xdp_page; | 556 | struct page *xdp_page; |
557 | bool sent; | ||
558 | int err; | ||
559 | |||
551 | len -= vi->hdr_len; | 560 | len -= vi->hdr_len; |
552 | 561 | ||
553 | rcu_read_lock(); | 562 | rcu_read_lock(); |
@@ -558,7 +567,7 @@ static struct sk_buff *receive_small(struct net_device *dev, | |||
558 | void *orig_data; | 567 | void *orig_data; |
559 | u32 act; | 568 | u32 act; |
560 | 569 | ||
561 | if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags)) | 570 | if (unlikely(hdr->hdr.gso_type)) |
562 | goto err_xdp; | 571 | goto err_xdp; |
563 | 572 | ||
564 | if (unlikely(xdp_headroom < virtnet_get_headroom(vi))) { | 573 | if (unlikely(xdp_headroom < virtnet_get_headroom(vi))) { |
@@ -596,16 +605,19 @@ static struct sk_buff *receive_small(struct net_device *dev, | |||
596 | delta = orig_data - xdp.data; | 605 | delta = orig_data - xdp.data; |
597 | break; | 606 | break; |
598 | case XDP_TX: | 607 | case XDP_TX: |
599 | if (unlikely(!__virtnet_xdp_xmit(vi, &xdp))) | 608 | sent = __virtnet_xdp_xmit(vi, &xdp); |
609 | if (unlikely(!sent)) { | ||
600 | trace_xdp_exception(vi->dev, xdp_prog, act); | 610 | trace_xdp_exception(vi->dev, xdp_prog, act); |
601 | else | 611 | goto err_xdp; |
602 | *xdp_xmit = true; | 612 | } |
613 | *xdp_xmit = true; | ||
603 | rcu_read_unlock(); | 614 | rcu_read_unlock(); |
604 | goto xdp_xmit; | 615 | goto xdp_xmit; |
605 | case XDP_REDIRECT: | 616 | case XDP_REDIRECT: |
606 | err = xdp_do_redirect(dev, &xdp, xdp_prog); | 617 | err = xdp_do_redirect(dev, &xdp, xdp_prog); |
607 | if (!err) | 618 | if (err) |
608 | *xdp_xmit = true; | 619 | goto err_xdp; |
620 | *xdp_xmit = true; | ||
609 | rcu_read_unlock(); | 621 | rcu_read_unlock(); |
610 | goto xdp_xmit; | 622 | goto xdp_xmit; |
611 | default: | 623 | default: |
@@ -677,7 +689,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, | |||
677 | struct bpf_prog *xdp_prog; | 689 | struct bpf_prog *xdp_prog; |
678 | unsigned int truesize; | 690 | unsigned int truesize; |
679 | unsigned int headroom = mergeable_ctx_to_headroom(ctx); | 691 | unsigned int headroom = mergeable_ctx_to_headroom(ctx); |
680 | int err; | 692 | bool sent; |
681 | 693 | ||
682 | head_skb = NULL; | 694 | head_skb = NULL; |
683 | 695 | ||
@@ -746,20 +758,18 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, | |||
746 | } | 758 | } |
747 | break; | 759 | break; |
748 | case XDP_TX: | 760 | case XDP_TX: |
749 | if (unlikely(!__virtnet_xdp_xmit(vi, &xdp))) | 761 | sent = __virtnet_xdp_xmit(vi, &xdp); |
762 | if (unlikely(!sent)) { | ||
750 | trace_xdp_exception(vi->dev, xdp_prog, act); | 763 | trace_xdp_exception(vi->dev, xdp_prog, act); |
751 | else | 764 | if (unlikely(xdp_page != page)) |
752 | *xdp_xmit = true; | 765 | put_page(xdp_page); |
766 | goto err_xdp; | ||
767 | } | ||
768 | *xdp_xmit = true; | ||
753 | if (unlikely(xdp_page != page)) | 769 | if (unlikely(xdp_page != page)) |
754 | goto err_xdp; | 770 | goto err_xdp; |
755 | rcu_read_unlock(); | 771 | rcu_read_unlock(); |
756 | goto xdp_xmit; | 772 | goto xdp_xmit; |
757 | case XDP_REDIRECT: | ||
758 | err = xdp_do_redirect(dev, &xdp, xdp_prog); | ||
759 | if (!err) | ||
760 | *xdp_xmit = true; | ||
761 | rcu_read_unlock(); | ||
762 | goto xdp_xmit; | ||
763 | default: | 773 | default: |
764 | bpf_warn_invalid_xdp_action(act); | 774 | bpf_warn_invalid_xdp_action(act); |
765 | case XDP_ABORTED: | 775 | case XDP_ABORTED: |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index f0379223ec6d..3c64afa161bf 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -3561,7 +3561,7 @@ static int __init init_mac80211_hwsim(void) | |||
3561 | 3561 | ||
3562 | spin_lock_init(&hwsim_radio_lock); | 3562 | spin_lock_init(&hwsim_radio_lock); |
3563 | 3563 | ||
3564 | hwsim_wq = alloc_workqueue("hwsim_wq",WQ_MEM_RECLAIM,0); | 3564 | hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0); |
3565 | if (!hwsim_wq) | 3565 | if (!hwsim_wq) |
3566 | return -ENOMEM; | 3566 | return -ENOMEM; |
3567 | rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params); | 3567 | rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params); |
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 7bc5eee96b31..0c2ed11c0603 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/export.h> | 17 | #include <linux/export.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/perf/arm_pmu.h> | 19 | #include <linux/perf/arm_pmu.h> |
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
22 | #include <linux/sched/clock.h> | 21 | #include <linux/sched/clock.h> |
23 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
@@ -26,6 +25,9 @@ | |||
26 | 25 | ||
27 | #include <asm/irq_regs.h> | 26 | #include <asm/irq_regs.h> |
28 | 27 | ||
28 | static DEFINE_PER_CPU(struct arm_pmu *, cpu_armpmu); | ||
29 | static DEFINE_PER_CPU(int, cpu_irq); | ||
30 | |||
29 | static int | 31 | static int |
30 | armpmu_map_cache_event(const unsigned (*cache_map) | 32 | armpmu_map_cache_event(const unsigned (*cache_map) |
31 | [PERF_COUNT_HW_CACHE_MAX] | 33 | [PERF_COUNT_HW_CACHE_MAX] |
@@ -320,17 +322,9 @@ validate_group(struct perf_event *event) | |||
320 | return 0; | 322 | return 0; |
321 | } | 323 | } |
322 | 324 | ||
323 | static struct arm_pmu_platdata *armpmu_get_platdata(struct arm_pmu *armpmu) | ||
324 | { | ||
325 | struct platform_device *pdev = armpmu->plat_device; | ||
326 | |||
327 | return pdev ? dev_get_platdata(&pdev->dev) : NULL; | ||
328 | } | ||
329 | |||
330 | static irqreturn_t armpmu_dispatch_irq(int irq, void *dev) | 325 | static irqreturn_t armpmu_dispatch_irq(int irq, void *dev) |
331 | { | 326 | { |
332 | struct arm_pmu *armpmu; | 327 | struct arm_pmu *armpmu; |
333 | struct arm_pmu_platdata *plat; | ||
334 | int ret; | 328 | int ret; |
335 | u64 start_clock, finish_clock; | 329 | u64 start_clock, finish_clock; |
336 | 330 | ||
@@ -341,14 +335,11 @@ static irqreturn_t armpmu_dispatch_irq(int irq, void *dev) | |||
341 | * dereference. | 335 | * dereference. |
342 | */ | 336 | */ |
343 | armpmu = *(void **)dev; | 337 | armpmu = *(void **)dev; |
344 | 338 | if (WARN_ON_ONCE(!armpmu)) | |
345 | plat = armpmu_get_platdata(armpmu); | 339 | return IRQ_NONE; |
346 | 340 | ||
347 | start_clock = sched_clock(); | 341 | start_clock = sched_clock(); |
348 | if (plat && plat->handle_irq) | 342 | ret = armpmu->handle_irq(irq, armpmu); |
349 | ret = plat->handle_irq(irq, armpmu, armpmu->handle_irq); | ||
350 | else | ||
351 | ret = armpmu->handle_irq(irq, armpmu); | ||
352 | finish_clock = sched_clock(); | 343 | finish_clock = sched_clock(); |
353 | 344 | ||
354 | perf_sample_event_took(finish_clock - start_clock); | 345 | perf_sample_event_took(finish_clock - start_clock); |
@@ -531,54 +522,41 @@ int perf_num_counters(void) | |||
531 | } | 522 | } |
532 | EXPORT_SYMBOL_GPL(perf_num_counters); | 523 | EXPORT_SYMBOL_GPL(perf_num_counters); |
533 | 524 | ||
534 | void armpmu_free_irq(struct arm_pmu *armpmu, int cpu) | 525 | static int armpmu_count_irq_users(const int irq) |
535 | { | 526 | { |
536 | struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; | 527 | int cpu, count = 0; |
537 | int irq = per_cpu(hw_events->irq, cpu); | ||
538 | 528 | ||
539 | if (!cpumask_test_and_clear_cpu(cpu, &armpmu->active_irqs)) | 529 | for_each_possible_cpu(cpu) { |
540 | return; | 530 | if (per_cpu(cpu_irq, cpu) == irq) |
541 | 531 | count++; | |
542 | if (irq_is_percpu_devid(irq)) { | ||
543 | free_percpu_irq(irq, &hw_events->percpu_pmu); | ||
544 | cpumask_clear(&armpmu->active_irqs); | ||
545 | return; | ||
546 | } | 532 | } |
547 | 533 | ||
548 | free_irq(irq, per_cpu_ptr(&hw_events->percpu_pmu, cpu)); | 534 | return count; |
549 | } | 535 | } |
550 | 536 | ||
551 | void armpmu_free_irqs(struct arm_pmu *armpmu) | 537 | void armpmu_free_irq(int irq, int cpu) |
552 | { | 538 | { |
553 | int cpu; | 539 | if (per_cpu(cpu_irq, cpu) == 0) |
540 | return; | ||
541 | if (WARN_ON(irq != per_cpu(cpu_irq, cpu))) | ||
542 | return; | ||
543 | |||
544 | if (!irq_is_percpu_devid(irq)) | ||
545 | free_irq(irq, per_cpu_ptr(&cpu_armpmu, cpu)); | ||
546 | else if (armpmu_count_irq_users(irq) == 1) | ||
547 | free_percpu_irq(irq, &cpu_armpmu); | ||
554 | 548 | ||
555 | for_each_cpu(cpu, &armpmu->supported_cpus) | 549 | per_cpu(cpu_irq, cpu) = 0; |
556 | armpmu_free_irq(armpmu, cpu); | ||
557 | } | 550 | } |
558 | 551 | ||
559 | int armpmu_request_irq(struct arm_pmu *armpmu, int cpu) | 552 | int armpmu_request_irq(int irq, int cpu) |
560 | { | 553 | { |
561 | int err = 0; | 554 | int err = 0; |
562 | struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; | ||
563 | const irq_handler_t handler = armpmu_dispatch_irq; | 555 | const irq_handler_t handler = armpmu_dispatch_irq; |
564 | int irq = per_cpu(hw_events->irq, cpu); | ||
565 | if (!irq) | 556 | if (!irq) |
566 | return 0; | 557 | return 0; |
567 | 558 | ||
568 | if (irq_is_percpu_devid(irq) && cpumask_empty(&armpmu->active_irqs)) { | 559 | if (!irq_is_percpu_devid(irq)) { |
569 | err = request_percpu_irq(irq, handler, "arm-pmu", | ||
570 | &hw_events->percpu_pmu); | ||
571 | } else if (irq_is_percpu_devid(irq)) { | ||
572 | int other_cpu = cpumask_first(&armpmu->active_irqs); | ||
573 | int other_irq = per_cpu(hw_events->irq, other_cpu); | ||
574 | |||
575 | if (irq != other_irq) { | ||
576 | pr_warn("mismatched PPIs detected.\n"); | ||
577 | err = -EINVAL; | ||
578 | goto err_out; | ||
579 | } | ||
580 | } else { | ||
581 | struct arm_pmu_platdata *platdata = armpmu_get_platdata(armpmu); | ||
582 | unsigned long irq_flags; | 560 | unsigned long irq_flags; |
583 | 561 | ||
584 | err = irq_force_affinity(irq, cpumask_of(cpu)); | 562 | err = irq_force_affinity(irq, cpumask_of(cpu)); |
@@ -589,22 +567,22 @@ int armpmu_request_irq(struct arm_pmu *armpmu, int cpu) | |||
589 | goto err_out; | 567 | goto err_out; |
590 | } | 568 | } |
591 | 569 | ||
592 | if (platdata && platdata->irq_flags) { | 570 | irq_flags = IRQF_PERCPU | |
593 | irq_flags = platdata->irq_flags; | 571 | IRQF_NOBALANCING | |
594 | } else { | 572 | IRQF_NO_THREAD; |
595 | irq_flags = IRQF_PERCPU | | ||
596 | IRQF_NOBALANCING | | ||
597 | IRQF_NO_THREAD; | ||
598 | } | ||
599 | 573 | ||
574 | irq_set_status_flags(irq, IRQ_NOAUTOEN); | ||
600 | err = request_irq(irq, handler, irq_flags, "arm-pmu", | 575 | err = request_irq(irq, handler, irq_flags, "arm-pmu", |
601 | per_cpu_ptr(&hw_events->percpu_pmu, cpu)); | 576 | per_cpu_ptr(&cpu_armpmu, cpu)); |
577 | } else if (armpmu_count_irq_users(irq) == 0) { | ||
578 | err = request_percpu_irq(irq, handler, "arm-pmu", | ||
579 | &cpu_armpmu); | ||
602 | } | 580 | } |
603 | 581 | ||
604 | if (err) | 582 | if (err) |
605 | goto err_out; | 583 | goto err_out; |
606 | 584 | ||
607 | cpumask_set_cpu(cpu, &armpmu->active_irqs); | 585 | per_cpu(cpu_irq, cpu) = irq; |
608 | return 0; | 586 | return 0; |
609 | 587 | ||
610 | err_out: | 588 | err_out: |
@@ -612,19 +590,6 @@ err_out: | |||
612 | return err; | 590 | return err; |
613 | } | 591 | } |
614 | 592 | ||
615 | int armpmu_request_irqs(struct arm_pmu *armpmu) | ||
616 | { | ||
617 | int cpu, err; | ||
618 | |||
619 | for_each_cpu(cpu, &armpmu->supported_cpus) { | ||
620 | err = armpmu_request_irq(armpmu, cpu); | ||
621 | if (err) | ||
622 | break; | ||
623 | } | ||
624 | |||
625 | return err; | ||
626 | } | ||
627 | |||
628 | static int armpmu_get_cpu_irq(struct arm_pmu *pmu, int cpu) | 593 | static int armpmu_get_cpu_irq(struct arm_pmu *pmu, int cpu) |
629 | { | 594 | { |
630 | struct pmu_hw_events __percpu *hw_events = pmu->hw_events; | 595 | struct pmu_hw_events __percpu *hw_events = pmu->hw_events; |
@@ -647,12 +612,14 @@ static int arm_perf_starting_cpu(unsigned int cpu, struct hlist_node *node) | |||
647 | if (pmu->reset) | 612 | if (pmu->reset) |
648 | pmu->reset(pmu); | 613 | pmu->reset(pmu); |
649 | 614 | ||
615 | per_cpu(cpu_armpmu, cpu) = pmu; | ||
616 | |||
650 | irq = armpmu_get_cpu_irq(pmu, cpu); | 617 | irq = armpmu_get_cpu_irq(pmu, cpu); |
651 | if (irq) { | 618 | if (irq) { |
652 | if (irq_is_percpu_devid(irq)) { | 619 | if (irq_is_percpu_devid(irq)) |
653 | enable_percpu_irq(irq, IRQ_TYPE_NONE); | 620 | enable_percpu_irq(irq, IRQ_TYPE_NONE); |
654 | return 0; | 621 | else |
655 | } | 622 | enable_irq(irq); |
656 | } | 623 | } |
657 | 624 | ||
658 | return 0; | 625 | return 0; |
@@ -667,8 +634,14 @@ static int arm_perf_teardown_cpu(unsigned int cpu, struct hlist_node *node) | |||
667 | return 0; | 634 | return 0; |
668 | 635 | ||
669 | irq = armpmu_get_cpu_irq(pmu, cpu); | 636 | irq = armpmu_get_cpu_irq(pmu, cpu); |
670 | if (irq && irq_is_percpu_devid(irq)) | 637 | if (irq) { |
671 | disable_percpu_irq(irq); | 638 | if (irq_is_percpu_devid(irq)) |
639 | disable_percpu_irq(irq); | ||
640 | else | ||
641 | disable_irq(irq); | ||
642 | } | ||
643 | |||
644 | per_cpu(cpu_armpmu, cpu) = NULL; | ||
672 | 645 | ||
673 | return 0; | 646 | return 0; |
674 | } | 647 | } |
@@ -800,18 +773,18 @@ static void cpu_pmu_destroy(struct arm_pmu *cpu_pmu) | |||
800 | &cpu_pmu->node); | 773 | &cpu_pmu->node); |
801 | } | 774 | } |
802 | 775 | ||
803 | struct arm_pmu *armpmu_alloc(void) | 776 | static struct arm_pmu *__armpmu_alloc(gfp_t flags) |
804 | { | 777 | { |
805 | struct arm_pmu *pmu; | 778 | struct arm_pmu *pmu; |
806 | int cpu; | 779 | int cpu; |
807 | 780 | ||
808 | pmu = kzalloc(sizeof(*pmu), GFP_KERNEL); | 781 | pmu = kzalloc(sizeof(*pmu), flags); |
809 | if (!pmu) { | 782 | if (!pmu) { |
810 | pr_info("failed to allocate PMU device!\n"); | 783 | pr_info("failed to allocate PMU device!\n"); |
811 | goto out; | 784 | goto out; |
812 | } | 785 | } |
813 | 786 | ||
814 | pmu->hw_events = alloc_percpu(struct pmu_hw_events); | 787 | pmu->hw_events = alloc_percpu_gfp(struct pmu_hw_events, flags); |
815 | if (!pmu->hw_events) { | 788 | if (!pmu->hw_events) { |
816 | pr_info("failed to allocate per-cpu PMU data.\n"); | 789 | pr_info("failed to allocate per-cpu PMU data.\n"); |
817 | goto out_free_pmu; | 790 | goto out_free_pmu; |
@@ -857,6 +830,17 @@ out: | |||
857 | return NULL; | 830 | return NULL; |
858 | } | 831 | } |
859 | 832 | ||
833 | struct arm_pmu *armpmu_alloc(void) | ||
834 | { | ||
835 | return __armpmu_alloc(GFP_KERNEL); | ||
836 | } | ||
837 | |||
838 | struct arm_pmu *armpmu_alloc_atomic(void) | ||
839 | { | ||
840 | return __armpmu_alloc(GFP_ATOMIC); | ||
841 | } | ||
842 | |||
843 | |||
860 | void armpmu_free(struct arm_pmu *pmu) | 844 | void armpmu_free(struct arm_pmu *pmu) |
861 | { | 845 | { |
862 | free_percpu(pmu->hw_events); | 846 | free_percpu(pmu->hw_events); |
diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 705f1a390e31..0f197516d708 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include <linux/acpi.h> | 11 | #include <linux/acpi.h> |
12 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/irq.h> | ||
15 | #include <linux/irqdesc.h> | ||
14 | #include <linux/percpu.h> | 16 | #include <linux/percpu.h> |
15 | #include <linux/perf/arm_pmu.h> | 17 | #include <linux/perf/arm_pmu.h> |
16 | 18 | ||
@@ -87,7 +89,13 @@ static int arm_pmu_acpi_parse_irqs(void) | |||
87 | pr_warn("No ACPI PMU IRQ for CPU%d\n", cpu); | 89 | pr_warn("No ACPI PMU IRQ for CPU%d\n", cpu); |
88 | } | 90 | } |
89 | 91 | ||
92 | /* | ||
93 | * Log and request the IRQ so the core arm_pmu code can manage | ||
94 | * it. We'll have to sanity-check IRQs later when we associate | ||
95 | * them with their PMUs. | ||
96 | */ | ||
90 | per_cpu(pmu_irqs, cpu) = irq; | 97 | per_cpu(pmu_irqs, cpu) = irq; |
98 | armpmu_request_irq(irq, cpu); | ||
91 | } | 99 | } |
92 | 100 | ||
93 | return 0; | 101 | return 0; |
@@ -127,7 +135,7 @@ static struct arm_pmu *arm_pmu_acpi_find_alloc_pmu(void) | |||
127 | return pmu; | 135 | return pmu; |
128 | } | 136 | } |
129 | 137 | ||
130 | pmu = armpmu_alloc(); | 138 | pmu = armpmu_alloc_atomic(); |
131 | if (!pmu) { | 139 | if (!pmu) { |
132 | pr_warn("Unable to allocate PMU for CPU%d\n", | 140 | pr_warn("Unable to allocate PMU for CPU%d\n", |
133 | smp_processor_id()); | 141 | smp_processor_id()); |
@@ -140,6 +148,35 @@ static struct arm_pmu *arm_pmu_acpi_find_alloc_pmu(void) | |||
140 | } | 148 | } |
141 | 149 | ||
142 | /* | 150 | /* |
151 | * Check whether the new IRQ is compatible with those already associated with | ||
152 | * the PMU (e.g. we don't have mismatched PPIs). | ||
153 | */ | ||
154 | static bool pmu_irq_matches(struct arm_pmu *pmu, int irq) | ||
155 | { | ||
156 | struct pmu_hw_events __percpu *hw_events = pmu->hw_events; | ||
157 | int cpu; | ||
158 | |||
159 | if (!irq) | ||
160 | return true; | ||
161 | |||
162 | for_each_cpu(cpu, &pmu->supported_cpus) { | ||
163 | int other_irq = per_cpu(hw_events->irq, cpu); | ||
164 | if (!other_irq) | ||
165 | continue; | ||
166 | |||
167 | if (irq == other_irq) | ||
168 | continue; | ||
169 | if (!irq_is_percpu_devid(irq) && !irq_is_percpu_devid(other_irq)) | ||
170 | continue; | ||
171 | |||
172 | pr_warn("mismatched PPIs detected\n"); | ||
173 | return false; | ||
174 | } | ||
175 | |||
176 | return true; | ||
177 | } | ||
178 | |||
179 | /* | ||
143 | * This must run before the common arm_pmu hotplug logic, so that we can | 180 | * This must run before the common arm_pmu hotplug logic, so that we can |
144 | * associate a CPU and its interrupt before the common code tries to manage the | 181 | * associate a CPU and its interrupt before the common code tries to manage the |
145 | * affinity and so on. | 182 | * affinity and so on. |
@@ -164,19 +201,14 @@ static int arm_pmu_acpi_cpu_starting(unsigned int cpu) | |||
164 | if (!pmu) | 201 | if (!pmu) |
165 | return -ENOMEM; | 202 | return -ENOMEM; |
166 | 203 | ||
167 | cpumask_set_cpu(cpu, &pmu->supported_cpus); | ||
168 | |||
169 | per_cpu(probed_pmus, cpu) = pmu; | 204 | per_cpu(probed_pmus, cpu) = pmu; |
170 | 205 | ||
171 | /* | 206 | if (pmu_irq_matches(pmu, irq)) { |
172 | * Log and request the IRQ so the core arm_pmu code can manage it. In | 207 | hw_events = pmu->hw_events; |
173 | * some situations (e.g. mismatched PPIs), we may fail to request the | 208 | per_cpu(hw_events->irq, cpu) = irq; |
174 | * IRQ. However, it may be too late for us to do anything about it. | 209 | } |
175 | * The common ARM PMU code will log a warning in this case. | 210 | |
176 | */ | 211 | cpumask_set_cpu(cpu, &pmu->supported_cpus); |
177 | hw_events = pmu->hw_events; | ||
178 | per_cpu(hw_events->irq, cpu) = irq; | ||
179 | armpmu_request_irq(pmu, cpu); | ||
180 | 212 | ||
181 | /* | 213 | /* |
182 | * Ideally, we'd probe the PMU here when we find the first matching | 214 | * Ideally, we'd probe the PMU here when we find the first matching |
@@ -247,11 +279,6 @@ static int arm_pmu_acpi_init(void) | |||
247 | if (acpi_disabled) | 279 | if (acpi_disabled) |
248 | return 0; | 280 | return 0; |
249 | 281 | ||
250 | /* | ||
251 | * We can't request IRQs yet, since we don't know the cookie value | ||
252 | * until we know which CPUs share the same logical PMU. We'll handle | ||
253 | * that in arm_pmu_acpi_cpu_starting(). | ||
254 | */ | ||
255 | ret = arm_pmu_acpi_parse_irqs(); | 282 | ret = arm_pmu_acpi_parse_irqs(); |
256 | if (ret) | 283 | if (ret) |
257 | return ret; | 284 | return ret; |
diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c index 46501cc79fd7..7729eda5909d 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c | |||
@@ -127,13 +127,6 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) | |||
127 | pdev->dev.of_node); | 127 | pdev->dev.of_node); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* | ||
131 | * Some platforms have all PMU IRQs OR'd into a single IRQ, with a | ||
132 | * special platdata function that attempts to demux them. | ||
133 | */ | ||
134 | if (dev_get_platdata(&pdev->dev)) | ||
135 | cpumask_setall(&pmu->supported_cpus); | ||
136 | |||
137 | for (i = 0; i < num_irqs; i++) { | 130 | for (i = 0; i < num_irqs; i++) { |
138 | int cpu, irq; | 131 | int cpu, irq; |
139 | 132 | ||
@@ -164,6 +157,36 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) | |||
164 | return 0; | 157 | return 0; |
165 | } | 158 | } |
166 | 159 | ||
160 | static int armpmu_request_irqs(struct arm_pmu *armpmu) | ||
161 | { | ||
162 | struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; | ||
163 | int cpu, err; | ||
164 | |||
165 | for_each_cpu(cpu, &armpmu->supported_cpus) { | ||
166 | int irq = per_cpu(hw_events->irq, cpu); | ||
167 | if (!irq) | ||
168 | continue; | ||
169 | |||
170 | err = armpmu_request_irq(irq, cpu); | ||
171 | if (err) | ||
172 | break; | ||
173 | } | ||
174 | |||
175 | return err; | ||
176 | } | ||
177 | |||
178 | static void armpmu_free_irqs(struct arm_pmu *armpmu) | ||
179 | { | ||
180 | int cpu; | ||
181 | struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; | ||
182 | |||
183 | for_each_cpu(cpu, &armpmu->supported_cpus) { | ||
184 | int irq = per_cpu(hw_events->irq, cpu); | ||
185 | |||
186 | armpmu_free_irq(irq, cpu); | ||
187 | } | ||
188 | } | ||
189 | |||
167 | int arm_pmu_device_probe(struct platform_device *pdev, | 190 | int arm_pmu_device_probe(struct platform_device *pdev, |
168 | const struct of_device_id *of_table, | 191 | const struct of_device_id *of_table, |
169 | const struct pmu_probe_info *probe_table) | 192 | const struct pmu_probe_info *probe_table) |
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index fcfd28d2884c..de1b3fce936d 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -185,7 +185,6 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ | |||
185 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) | 185 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) |
186 | zalon7xx-objs := zalon.o ncr53c8xx.o | 186 | zalon7xx-objs := zalon.o ncr53c8xx.o |
187 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o | 187 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o |
188 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o | ||
189 | 188 | ||
190 | # Files generated that shall be removed upon make clean | 189 | # Files generated that shall be removed upon make clean |
191 | clean-files := 53c700_d.h 53c700_u.h | 190 | clean-files := 53c700_d.h 53c700_u.h |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index b3b931ab77eb..2664ea0df35f 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -1693,8 +1693,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1693 | * Map in the registers from the adapter. | 1693 | * Map in the registers from the adapter. |
1694 | */ | 1694 | */ |
1695 | aac->base_size = AAC_MIN_FOOTPRINT_SIZE; | 1695 | aac->base_size = AAC_MIN_FOOTPRINT_SIZE; |
1696 | if ((*aac_drivers[index].init)(aac)) | 1696 | if ((*aac_drivers[index].init)(aac)) { |
1697 | error = -ENODEV; | ||
1697 | goto out_unmap; | 1698 | goto out_unmap; |
1699 | } | ||
1698 | 1700 | ||
1699 | if (aac->sync_mode) { | 1701 | if (aac->sync_mode) { |
1700 | if (aac_sync_mode) | 1702 | if (aac_sync_mode) |
diff --git a/drivers/scsi/aic7xxx/aiclib.c b/drivers/scsi/aic7xxx/aiclib.c deleted file mode 100644 index 828ae3d9a510..000000000000 --- a/drivers/scsi/aic7xxx/aiclib.c +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* | ||
2 | * Implementation of Utility functions for all SCSI device types. | ||
3 | * | ||
4 | * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. | ||
5 | * Copyright (c) 1997, 1998 Kenneth D. Merry. | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions, and the following disclaimer, | ||
13 | * without modification, immediately at the beginning of the file. | ||
14 | * 2. The name of the author may not be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR | ||
21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.38 2002/09/23 04:56:35 mjacob Exp $ | ||
30 | * $Id$ | ||
31 | */ | ||
32 | |||
33 | #include "aiclib.h" | ||
34 | |||
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 8e2f767147cb..5a645b8b9af1 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c | |||
@@ -1889,6 +1889,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, | |||
1889 | /* we will not receive ABTS response for this IO */ | 1889 | /* we will not receive ABTS response for this IO */ |
1890 | BNX2FC_IO_DBG(io_req, "Timer context finished processing " | 1890 | BNX2FC_IO_DBG(io_req, "Timer context finished processing " |
1891 | "this scsi cmd\n"); | 1891 | "this scsi cmd\n"); |
1892 | return; | ||
1892 | } | 1893 | } |
1893 | 1894 | ||
1894 | /* Cancel the timeout_work, as we received IO completion */ | 1895 | /* Cancel the timeout_work, as we received IO completion */ |
diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c index be5ee2d37815..7dbbbb81a1e7 100644 --- a/drivers/scsi/csiostor/csio_lnode.c +++ b/drivers/scsi/csiostor/csio_lnode.c | |||
@@ -114,7 +114,7 @@ static enum csio_ln_ev fwevt_to_lnevt[] = { | |||
114 | static struct csio_lnode * | 114 | static struct csio_lnode * |
115 | csio_ln_lookup_by_portid(struct csio_hw *hw, uint8_t portid) | 115 | csio_ln_lookup_by_portid(struct csio_hw *hw, uint8_t portid) |
116 | { | 116 | { |
117 | struct csio_lnode *ln = hw->rln; | 117 | struct csio_lnode *ln; |
118 | struct list_head *tmp; | 118 | struct list_head *tmp; |
119 | 119 | ||
120 | /* Match siblings lnode with portid */ | 120 | /* Match siblings lnode with portid */ |
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 022e421c2185..4b44325d1a82 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
@@ -876,6 +876,11 @@ static void alua_rtpg_work(struct work_struct *work) | |||
876 | 876 | ||
877 | /** | 877 | /** |
878 | * alua_rtpg_queue() - cause RTPG to be submitted asynchronously | 878 | * alua_rtpg_queue() - cause RTPG to be submitted asynchronously |
879 | * @pg: ALUA port group associated with @sdev. | ||
880 | * @sdev: SCSI device for which to submit an RTPG. | ||
881 | * @qdata: Information about the callback to invoke after the RTPG. | ||
882 | * @force: Whether or not to submit an RTPG if a work item that will submit an | ||
883 | * RTPG already has been scheduled. | ||
879 | * | 884 | * |
880 | * Returns true if and only if alua_rtpg_work() will be called asynchronously. | 885 | * Returns true if and only if alua_rtpg_work() will be called asynchronously. |
881 | * That function is responsible for calling @qdata->fn(). | 886 | * That function is responsible for calling @qdata->fn(). |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index 9a0696f68f37..b81a53c4a9a8 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h | |||
@@ -367,7 +367,7 @@ enum ibmvfc_fcp_rsp_info_codes { | |||
367 | }; | 367 | }; |
368 | 368 | ||
369 | struct ibmvfc_fcp_rsp_info { | 369 | struct ibmvfc_fcp_rsp_info { |
370 | __be16 reserved; | 370 | u8 reserved[3]; |
371 | u8 rsp_code; | 371 | u8 rsp_code; |
372 | u8 reserved2[4]; | 372 | u8 reserved2[4]; |
373 | }__attribute__((packed, aligned (2))); | 373 | }__attribute__((packed, aligned (2))); |
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 13d6e4ec3022..59a87ca328d3 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c | |||
@@ -2410,8 +2410,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) | |||
2410 | continue; | 2410 | continue; |
2411 | } | 2411 | } |
2412 | 2412 | ||
2413 | for_each_cpu(cpu, mask) | 2413 | for_each_cpu_and(cpu, mask, cpu_online_mask) { |
2414 | if (cpu >= ioc->cpu_msix_table_sz) | ||
2415 | break; | ||
2414 | ioc->cpu_msix_table[cpu] = reply_q->msix_index; | 2416 | ioc->cpu_msix_table[cpu] = reply_q->msix_index; |
2417 | } | ||
2415 | } | 2418 | } |
2416 | return; | 2419 | return; |
2417 | } | 2420 | } |
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 029e2e69b29f..f57a94b4f0d9 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -1724,7 +1724,6 @@ static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) | |||
1724 | { | 1724 | { |
1725 | struct qedi_ctx *qedi = data; | 1725 | struct qedi_ctx *qedi = data; |
1726 | struct nvm_iscsi_initiator *initiator; | 1726 | struct nvm_iscsi_initiator *initiator; |
1727 | char *str = buf; | ||
1728 | int rc = 1; | 1727 | int rc = 1; |
1729 | u32 ipv6_en, dhcp_en, ip_len; | 1728 | u32 ipv6_en, dhcp_en, ip_len; |
1730 | struct nvm_iscsi_block *block; | 1729 | struct nvm_iscsi_block *block; |
@@ -1758,32 +1757,32 @@ static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) | |||
1758 | 1757 | ||
1759 | switch (type) { | 1758 | switch (type) { |
1760 | case ISCSI_BOOT_ETH_IP_ADDR: | 1759 | case ISCSI_BOOT_ETH_IP_ADDR: |
1761 | rc = snprintf(str, ip_len, fmt, ip); | 1760 | rc = snprintf(buf, ip_len, fmt, ip); |
1762 | break; | 1761 | break; |
1763 | case ISCSI_BOOT_ETH_SUBNET_MASK: | 1762 | case ISCSI_BOOT_ETH_SUBNET_MASK: |
1764 | rc = snprintf(str, ip_len, fmt, sub); | 1763 | rc = snprintf(buf, ip_len, fmt, sub); |
1765 | break; | 1764 | break; |
1766 | case ISCSI_BOOT_ETH_GATEWAY: | 1765 | case ISCSI_BOOT_ETH_GATEWAY: |
1767 | rc = snprintf(str, ip_len, fmt, gw); | 1766 | rc = snprintf(buf, ip_len, fmt, gw); |
1768 | break; | 1767 | break; |
1769 | case ISCSI_BOOT_ETH_FLAGS: | 1768 | case ISCSI_BOOT_ETH_FLAGS: |
1770 | rc = snprintf(str, 3, "%hhd\n", | 1769 | rc = snprintf(buf, 3, "%hhd\n", |
1771 | SYSFS_FLAG_FW_SEL_BOOT); | 1770 | SYSFS_FLAG_FW_SEL_BOOT); |
1772 | break; | 1771 | break; |
1773 | case ISCSI_BOOT_ETH_INDEX: | 1772 | case ISCSI_BOOT_ETH_INDEX: |
1774 | rc = snprintf(str, 3, "0\n"); | 1773 | rc = snprintf(buf, 3, "0\n"); |
1775 | break; | 1774 | break; |
1776 | case ISCSI_BOOT_ETH_MAC: | 1775 | case ISCSI_BOOT_ETH_MAC: |
1777 | rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); | 1776 | rc = sysfs_format_mac(buf, qedi->mac, ETH_ALEN); |
1778 | break; | 1777 | break; |
1779 | case ISCSI_BOOT_ETH_VLAN: | 1778 | case ISCSI_BOOT_ETH_VLAN: |
1780 | rc = snprintf(str, 12, "%d\n", | 1779 | rc = snprintf(buf, 12, "%d\n", |
1781 | GET_FIELD2(initiator->generic_cont0, | 1780 | GET_FIELD2(initiator->generic_cont0, |
1782 | NVM_ISCSI_CFG_INITIATOR_VLAN)); | 1781 | NVM_ISCSI_CFG_INITIATOR_VLAN)); |
1783 | break; | 1782 | break; |
1784 | case ISCSI_BOOT_ETH_ORIGIN: | 1783 | case ISCSI_BOOT_ETH_ORIGIN: |
1785 | if (dhcp_en) | 1784 | if (dhcp_en) |
1786 | rc = snprintf(str, 3, "3\n"); | 1785 | rc = snprintf(buf, 3, "3\n"); |
1787 | break; | 1786 | break; |
1788 | default: | 1787 | default: |
1789 | rc = 0; | 1788 | rc = 0; |
@@ -1819,7 +1818,6 @@ static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | |||
1819 | { | 1818 | { |
1820 | struct qedi_ctx *qedi = data; | 1819 | struct qedi_ctx *qedi = data; |
1821 | struct nvm_iscsi_initiator *initiator; | 1820 | struct nvm_iscsi_initiator *initiator; |
1822 | char *str = buf; | ||
1823 | int rc; | 1821 | int rc; |
1824 | struct nvm_iscsi_block *block; | 1822 | struct nvm_iscsi_block *block; |
1825 | 1823 | ||
@@ -1831,8 +1829,8 @@ static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | |||
1831 | 1829 | ||
1832 | switch (type) { | 1830 | switch (type) { |
1833 | case ISCSI_BOOT_INI_INITIATOR_NAME: | 1831 | case ISCSI_BOOT_INI_INITIATOR_NAME: |
1834 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | 1832 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
1835 | initiator->initiator_name.byte); | 1833 | initiator->initiator_name.byte); |
1836 | break; | 1834 | break; |
1837 | default: | 1835 | default: |
1838 | rc = 0; | 1836 | rc = 0; |
@@ -1860,7 +1858,6 @@ static ssize_t | |||
1860 | qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | 1858 | qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, |
1861 | char *buf, enum qedi_nvm_tgts idx) | 1859 | char *buf, enum qedi_nvm_tgts idx) |
1862 | { | 1860 | { |
1863 | char *str = buf; | ||
1864 | int rc = 1; | 1861 | int rc = 1; |
1865 | u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; | 1862 | u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; |
1866 | struct nvm_iscsi_block *block; | 1863 | struct nvm_iscsi_block *block; |
@@ -1899,48 +1896,48 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | |||
1899 | 1896 | ||
1900 | switch (type) { | 1897 | switch (type) { |
1901 | case ISCSI_BOOT_TGT_NAME: | 1898 | case ISCSI_BOOT_TGT_NAME: |
1902 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | 1899 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
1903 | block->target[idx].target_name.byte); | 1900 | block->target[idx].target_name.byte); |
1904 | break; | 1901 | break; |
1905 | case ISCSI_BOOT_TGT_IP_ADDR: | 1902 | case ISCSI_BOOT_TGT_IP_ADDR: |
1906 | if (ipv6_en) | 1903 | if (ipv6_en) |
1907 | rc = snprintf(str, ip_len, "%pI6\n", | 1904 | rc = snprintf(buf, ip_len, "%pI6\n", |
1908 | block->target[idx].ipv6_addr.byte); | 1905 | block->target[idx].ipv6_addr.byte); |
1909 | else | 1906 | else |
1910 | rc = snprintf(str, ip_len, "%pI4\n", | 1907 | rc = snprintf(buf, ip_len, "%pI4\n", |
1911 | block->target[idx].ipv4_addr.byte); | 1908 | block->target[idx].ipv4_addr.byte); |
1912 | break; | 1909 | break; |
1913 | case ISCSI_BOOT_TGT_PORT: | 1910 | case ISCSI_BOOT_TGT_PORT: |
1914 | rc = snprintf(str, 12, "%d\n", | 1911 | rc = snprintf(buf, 12, "%d\n", |
1915 | GET_FIELD2(block->target[idx].generic_cont0, | 1912 | GET_FIELD2(block->target[idx].generic_cont0, |
1916 | NVM_ISCSI_CFG_TARGET_TCP_PORT)); | 1913 | NVM_ISCSI_CFG_TARGET_TCP_PORT)); |
1917 | break; | 1914 | break; |
1918 | case ISCSI_BOOT_TGT_LUN: | 1915 | case ISCSI_BOOT_TGT_LUN: |
1919 | rc = snprintf(str, 22, "%.*d\n", | 1916 | rc = snprintf(buf, 22, "%.*d\n", |
1920 | block->target[idx].lun.value[1], | 1917 | block->target[idx].lun.value[1], |
1921 | block->target[idx].lun.value[0]); | 1918 | block->target[idx].lun.value[0]); |
1922 | break; | 1919 | break; |
1923 | case ISCSI_BOOT_TGT_CHAP_NAME: | 1920 | case ISCSI_BOOT_TGT_CHAP_NAME: |
1924 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | 1921 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1925 | chap_name); | 1922 | chap_name); |
1926 | break; | 1923 | break; |
1927 | case ISCSI_BOOT_TGT_CHAP_SECRET: | 1924 | case ISCSI_BOOT_TGT_CHAP_SECRET: |
1928 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | 1925 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1929 | chap_secret); | 1926 | chap_secret); |
1930 | break; | 1927 | break; |
1931 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | 1928 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: |
1932 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | 1929 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1933 | mchap_name); | 1930 | mchap_name); |
1934 | break; | 1931 | break; |
1935 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | 1932 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: |
1936 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | 1933 | rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1937 | mchap_secret); | 1934 | mchap_secret); |
1938 | break; | 1935 | break; |
1939 | case ISCSI_BOOT_TGT_FLAGS: | 1936 | case ISCSI_BOOT_TGT_FLAGS: |
1940 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); | 1937 | rc = snprintf(buf, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); |
1941 | break; | 1938 | break; |
1942 | case ISCSI_BOOT_TGT_NIC_ASSOC: | 1939 | case ISCSI_BOOT_TGT_NIC_ASSOC: |
1943 | rc = snprintf(str, 3, "0\n"); | 1940 | rc = snprintf(buf, 3, "0\n"); |
1944 | break; | 1941 | break; |
1945 | default: | 1942 | default: |
1946 | rc = 0; | 1943 | rc = 0; |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index aececf664654..2dea1129d396 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -59,8 +59,6 @@ qla2x00_sp_timeout(struct timer_list *t) | |||
59 | req->outstanding_cmds[sp->handle] = NULL; | 59 | req->outstanding_cmds[sp->handle] = NULL; |
60 | iocb = &sp->u.iocb_cmd; | 60 | iocb = &sp->u.iocb_cmd; |
61 | iocb->timeout(sp); | 61 | iocb->timeout(sp); |
62 | if (sp->type != SRB_ELS_DCMD) | ||
63 | sp->free(sp); | ||
64 | spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); | 62 | spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); |
65 | } | 63 | } |
66 | 64 | ||
@@ -102,7 +100,6 @@ qla2x00_async_iocb_timeout(void *data) | |||
102 | srb_t *sp = data; | 100 | srb_t *sp = data; |
103 | fc_port_t *fcport = sp->fcport; | 101 | fc_port_t *fcport = sp->fcport; |
104 | struct srb_iocb *lio = &sp->u.iocb_cmd; | 102 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
105 | struct event_arg ea; | ||
106 | 103 | ||
107 | if (fcport) { | 104 | if (fcport) { |
108 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, | 105 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, |
@@ -117,25 +114,13 @@ qla2x00_async_iocb_timeout(void *data) | |||
117 | 114 | ||
118 | switch (sp->type) { | 115 | switch (sp->type) { |
119 | case SRB_LOGIN_CMD: | 116 | case SRB_LOGIN_CMD: |
120 | if (!fcport) | ||
121 | break; | ||
122 | /* Retry as needed. */ | 117 | /* Retry as needed. */ |
123 | lio->u.logio.data[0] = MBS_COMMAND_ERROR; | 118 | lio->u.logio.data[0] = MBS_COMMAND_ERROR; |
124 | lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? | 119 | lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
125 | QLA_LOGIO_LOGIN_RETRIED : 0; | 120 | QLA_LOGIO_LOGIN_RETRIED : 0; |
126 | memset(&ea, 0, sizeof(ea)); | 121 | sp->done(sp, QLA_FUNCTION_TIMEOUT); |
127 | ea.event = FCME_PLOGI_DONE; | ||
128 | ea.fcport = sp->fcport; | ||
129 | ea.data[0] = lio->u.logio.data[0]; | ||
130 | ea.data[1] = lio->u.logio.data[1]; | ||
131 | ea.sp = sp; | ||
132 | qla24xx_handle_plogi_done_event(fcport->vha, &ea); | ||
133 | break; | 122 | break; |
134 | case SRB_LOGOUT_CMD: | 123 | case SRB_LOGOUT_CMD: |
135 | if (!fcport) | ||
136 | break; | ||
137 | qlt_logo_completion_handler(fcport, QLA_FUNCTION_TIMEOUT); | ||
138 | break; | ||
139 | case SRB_CT_PTHRU_CMD: | 124 | case SRB_CT_PTHRU_CMD: |
140 | case SRB_MB_IOCB: | 125 | case SRB_MB_IOCB: |
141 | case SRB_NACK_PLOGI: | 126 | case SRB_NACK_PLOGI: |
@@ -235,12 +220,10 @@ static void | |||
235 | qla2x00_async_logout_sp_done(void *ptr, int res) | 220 | qla2x00_async_logout_sp_done(void *ptr, int res) |
236 | { | 221 | { |
237 | srb_t *sp = ptr; | 222 | srb_t *sp = ptr; |
238 | struct srb_iocb *lio = &sp->u.iocb_cmd; | ||
239 | 223 | ||
240 | sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); | 224 | sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
241 | if (!test_bit(UNLOADING, &sp->vha->dpc_flags)) | 225 | sp->fcport->login_gen++; |
242 | qla2x00_post_async_logout_done_work(sp->vha, sp->fcport, | 226 | qlt_logo_completion_handler(sp->fcport, res); |
243 | lio->u.logio.data); | ||
244 | sp->free(sp); | 227 | sp->free(sp); |
245 | } | 228 | } |
246 | 229 | ||
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 1b62e943ec49..8d00d559bd26 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c | |||
@@ -3275,12 +3275,11 @@ qla24xx_abort_iocb(srb_t *sp, struct abort_entry_24xx *abt_iocb) | |||
3275 | memset(abt_iocb, 0, sizeof(struct abort_entry_24xx)); | 3275 | memset(abt_iocb, 0, sizeof(struct abort_entry_24xx)); |
3276 | abt_iocb->entry_type = ABORT_IOCB_TYPE; | 3276 | abt_iocb->entry_type = ABORT_IOCB_TYPE; |
3277 | abt_iocb->entry_count = 1; | 3277 | abt_iocb->entry_count = 1; |
3278 | abt_iocb->handle = | 3278 | abt_iocb->handle = cpu_to_le32(MAKE_HANDLE(req->id, sp->handle)); |
3279 | cpu_to_le32(MAKE_HANDLE(aio->u.abt.req_que_no, | ||
3280 | aio->u.abt.cmd_hndl)); | ||
3281 | abt_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); | 3279 | abt_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
3282 | abt_iocb->handle_to_abort = | 3280 | abt_iocb->handle_to_abort = |
3283 | cpu_to_le32(MAKE_HANDLE(req->id, aio->u.abt.cmd_hndl)); | 3281 | cpu_to_le32(MAKE_HANDLE(aio->u.abt.req_que_no, |
3282 | aio->u.abt.cmd_hndl)); | ||
3284 | abt_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; | 3283 | abt_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; |
3285 | abt_iocb->port_id[1] = sp->fcport->d_id.b.area; | 3284 | abt_iocb->port_id[1] = sp->fcport->d_id.b.area; |
3286 | abt_iocb->port_id[2] = sp->fcport->d_id.b.domain; | 3285 | abt_iocb->port_id[2] = sp->fcport->d_id.b.domain; |
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 14109d86c3f6..89f93ebd819d 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c | |||
@@ -272,7 +272,8 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) | |||
272 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 272 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
273 | 273 | ||
274 | /* Read all mbox registers? */ | 274 | /* Read all mbox registers? */ |
275 | mboxes = (1 << ha->mbx_count) - 1; | 275 | WARN_ON_ONCE(ha->mbx_count > 32); |
276 | mboxes = (1ULL << ha->mbx_count) - 1; | ||
276 | if (!ha->mcp) | 277 | if (!ha->mcp) |
277 | ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); | 278 | ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); |
278 | else | 279 | else |
@@ -2880,7 +2881,8 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) | |||
2880 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 2881 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
2881 | 2882 | ||
2882 | /* Read all mbox registers? */ | 2883 | /* Read all mbox registers? */ |
2883 | mboxes = (1 << ha->mbx_count) - 1; | 2884 | WARN_ON_ONCE(ha->mbx_count > 32); |
2885 | mboxes = (1ULL << ha->mbx_count) - 1; | ||
2884 | if (!ha->mcp) | 2886 | if (!ha->mcp) |
2885 | ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); | 2887 | ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); |
2886 | else | 2888 | else |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 12ee6e02d146..afcb5567998a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -3625,6 +3625,8 @@ qla2x00_remove_one(struct pci_dev *pdev) | |||
3625 | } | 3625 | } |
3626 | qla2x00_wait_for_hba_ready(base_vha); | 3626 | qla2x00_wait_for_hba_ready(base_vha); |
3627 | 3627 | ||
3628 | qla2x00_wait_for_sess_deletion(base_vha); | ||
3629 | |||
3628 | /* | 3630 | /* |
3629 | * if UNLOAD flag is already set, then continue unload, | 3631 | * if UNLOAD flag is already set, then continue unload, |
3630 | * where it was set first. | 3632 | * where it was set first. |
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index fc89af8fe256..896b2d8bd803 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -4871,8 +4871,6 @@ static int qlt_24xx_handle_els(struct scsi_qla_host *vha, | |||
4871 | sess); | 4871 | sess); |
4872 | qlt_send_term_imm_notif(vha, iocb, 1); | 4872 | qlt_send_term_imm_notif(vha, iocb, 1); |
4873 | res = 0; | 4873 | res = 0; |
4874 | spin_lock_irqsave(&tgt->ha->tgt.sess_lock, | ||
4875 | flags); | ||
4876 | break; | 4874 | break; |
4877 | } | 4875 | } |
4878 | 4876 | ||
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h index fc233717355f..817f312023a9 100644 --- a/drivers/scsi/qla4xxx/ql4_def.h +++ b/drivers/scsi/qla4xxx/ql4_def.h | |||
@@ -168,6 +168,8 @@ | |||
168 | #define DEV_DB_NON_PERSISTENT 0 | 168 | #define DEV_DB_NON_PERSISTENT 0 |
169 | #define DEV_DB_PERSISTENT 1 | 169 | #define DEV_DB_PERSISTENT 1 |
170 | 170 | ||
171 | #define QL4_ISP_REG_DISCONNECT 0xffffffffU | ||
172 | |||
171 | #define COPY_ISID(dst_isid, src_isid) { \ | 173 | #define COPY_ISID(dst_isid, src_isid) { \ |
172 | int i, j; \ | 174 | int i, j; \ |
173 | for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \ | 175 | for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \ |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 82e889bbe0ed..fc2c97d9a0d6 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -262,6 +262,24 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { | |||
262 | 262 | ||
263 | static struct scsi_transport_template *qla4xxx_scsi_transport; | 263 | static struct scsi_transport_template *qla4xxx_scsi_transport; |
264 | 264 | ||
265 | static int qla4xxx_isp_check_reg(struct scsi_qla_host *ha) | ||
266 | { | ||
267 | u32 reg_val = 0; | ||
268 | int rval = QLA_SUCCESS; | ||
269 | |||
270 | if (is_qla8022(ha)) | ||
271 | reg_val = readl(&ha->qla4_82xx_reg->host_status); | ||
272 | else if (is_qla8032(ha) || is_qla8042(ha)) | ||
273 | reg_val = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_ALIVE_COUNTER); | ||
274 | else | ||
275 | reg_val = readw(&ha->reg->ctrl_status); | ||
276 | |||
277 | if (reg_val == QL4_ISP_REG_DISCONNECT) | ||
278 | rval = QLA_ERROR; | ||
279 | |||
280 | return rval; | ||
281 | } | ||
282 | |||
265 | static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num, | 283 | static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num, |
266 | uint32_t iface_type, uint32_t payload_size, | 284 | uint32_t iface_type, uint32_t payload_size, |
267 | uint32_t pid, struct sockaddr *dst_addr) | 285 | uint32_t pid, struct sockaddr *dst_addr) |
@@ -9186,10 +9204,17 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd) | |||
9186 | struct srb *srb = NULL; | 9204 | struct srb *srb = NULL; |
9187 | int ret = SUCCESS; | 9205 | int ret = SUCCESS; |
9188 | int wait = 0; | 9206 | int wait = 0; |
9207 | int rval; | ||
9189 | 9208 | ||
9190 | ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", | 9209 | ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", |
9191 | ha->host_no, id, lun, cmd, cmd->cmnd[0]); | 9210 | ha->host_no, id, lun, cmd, cmd->cmnd[0]); |
9192 | 9211 | ||
9212 | rval = qla4xxx_isp_check_reg(ha); | ||
9213 | if (rval != QLA_SUCCESS) { | ||
9214 | ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); | ||
9215 | return FAILED; | ||
9216 | } | ||
9217 | |||
9193 | spin_lock_irqsave(&ha->hardware_lock, flags); | 9218 | spin_lock_irqsave(&ha->hardware_lock, flags); |
9194 | srb = (struct srb *) CMD_SP(cmd); | 9219 | srb = (struct srb *) CMD_SP(cmd); |
9195 | if (!srb) { | 9220 | if (!srb) { |
@@ -9241,6 +9266,7 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) | |||
9241 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); | 9266 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); |
9242 | struct ddb_entry *ddb_entry = cmd->device->hostdata; | 9267 | struct ddb_entry *ddb_entry = cmd->device->hostdata; |
9243 | int ret = FAILED, stat; | 9268 | int ret = FAILED, stat; |
9269 | int rval; | ||
9244 | 9270 | ||
9245 | if (!ddb_entry) | 9271 | if (!ddb_entry) |
9246 | return ret; | 9272 | return ret; |
@@ -9260,6 +9286,12 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) | |||
9260 | cmd, jiffies, cmd->request->timeout / HZ, | 9286 | cmd, jiffies, cmd->request->timeout / HZ, |
9261 | ha->dpc_flags, cmd->result, cmd->allowed)); | 9287 | ha->dpc_flags, cmd->result, cmd->allowed)); |
9262 | 9288 | ||
9289 | rval = qla4xxx_isp_check_reg(ha); | ||
9290 | if (rval != QLA_SUCCESS) { | ||
9291 | ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); | ||
9292 | return FAILED; | ||
9293 | } | ||
9294 | |||
9263 | /* FIXME: wait for hba to go online */ | 9295 | /* FIXME: wait for hba to go online */ |
9264 | stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); | 9296 | stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); |
9265 | if (stat != QLA_SUCCESS) { | 9297 | if (stat != QLA_SUCCESS) { |
@@ -9303,6 +9335,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) | |||
9303 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); | 9335 | struct scsi_qla_host *ha = to_qla_host(cmd->device->host); |
9304 | struct ddb_entry *ddb_entry = cmd->device->hostdata; | 9336 | struct ddb_entry *ddb_entry = cmd->device->hostdata; |
9305 | int stat, ret; | 9337 | int stat, ret; |
9338 | int rval; | ||
9306 | 9339 | ||
9307 | if (!ddb_entry) | 9340 | if (!ddb_entry) |
9308 | return FAILED; | 9341 | return FAILED; |
@@ -9320,6 +9353,12 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) | |||
9320 | ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, | 9353 | ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, |
9321 | ha->dpc_flags, cmd->result, cmd->allowed)); | 9354 | ha->dpc_flags, cmd->result, cmd->allowed)); |
9322 | 9355 | ||
9356 | rval = qla4xxx_isp_check_reg(ha); | ||
9357 | if (rval != QLA_SUCCESS) { | ||
9358 | ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); | ||
9359 | return FAILED; | ||
9360 | } | ||
9361 | |||
9323 | stat = qla4xxx_reset_target(ha, ddb_entry); | 9362 | stat = qla4xxx_reset_target(ha, ddb_entry); |
9324 | if (stat != QLA_SUCCESS) { | 9363 | if (stat != QLA_SUCCESS) { |
9325 | starget_printk(KERN_INFO, scsi_target(cmd->device), | 9364 | starget_printk(KERN_INFO, scsi_target(cmd->device), |
@@ -9374,9 +9413,16 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd) | |||
9374 | { | 9413 | { |
9375 | int return_status = FAILED; | 9414 | int return_status = FAILED; |
9376 | struct scsi_qla_host *ha; | 9415 | struct scsi_qla_host *ha; |
9416 | int rval; | ||
9377 | 9417 | ||
9378 | ha = to_qla_host(cmd->device->host); | 9418 | ha = to_qla_host(cmd->device->host); |
9379 | 9419 | ||
9420 | rval = qla4xxx_isp_check_reg(ha); | ||
9421 | if (rval != QLA_SUCCESS) { | ||
9422 | ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); | ||
9423 | return FAILED; | ||
9424 | } | ||
9425 | |||
9380 | if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) | 9426 | if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) |
9381 | qla4_83xx_set_idc_dontreset(ha); | 9427 | qla4_83xx_set_idc_dontreset(ha); |
9382 | 9428 | ||
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 40fc7a590e81..6be5ab32c94f 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c | |||
@@ -1657,7 +1657,7 @@ static struct scsi_host_template scsi_driver = { | |||
1657 | .eh_timed_out = storvsc_eh_timed_out, | 1657 | .eh_timed_out = storvsc_eh_timed_out, |
1658 | .slave_alloc = storvsc_device_alloc, | 1658 | .slave_alloc = storvsc_device_alloc, |
1659 | .slave_configure = storvsc_device_configure, | 1659 | .slave_configure = storvsc_device_configure, |
1660 | .cmd_per_lun = 255, | 1660 | .cmd_per_lun = 2048, |
1661 | .this_id = -1, | 1661 | .this_id = -1, |
1662 | .use_clustering = ENABLE_CLUSTERING, | 1662 | .use_clustering = ENABLE_CLUSTERING, |
1663 | /* Make sure we dont get a sg segment crosses a page boundary */ | 1663 | /* Make sure we dont get a sg segment crosses a page boundary */ |
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index ca360daa6a25..378af306fda1 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c | |||
@@ -536,7 +536,7 @@ sym_getsync(struct sym_hcb *np, u_char dt, u_char sfac, u_char *divp, u_char *fa | |||
536 | * Look for the greatest clock divisor that allows an | 536 | * Look for the greatest clock divisor that allows an |
537 | * input speed faster than the period. | 537 | * input speed faster than the period. |
538 | */ | 538 | */ |
539 | while (div-- > 0) | 539 | while (--div > 0) |
540 | if (kpc >= (div_10M[div] << 2)) break; | 540 | if (kpc >= (div_10M[div] << 2)) break; |
541 | 541 | ||
542 | /* | 542 | /* |
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a355d989b414..c7da2c185990 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c | |||
@@ -4352,6 +4352,8 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) | |||
4352 | /* REPORT SUPPORTED OPERATION CODES is not supported */ | 4352 | /* REPORT SUPPORTED OPERATION CODES is not supported */ |
4353 | sdev->no_report_opcodes = 1; | 4353 | sdev->no_report_opcodes = 1; |
4354 | 4354 | ||
4355 | /* WRITE_SAME command is not supported */ | ||
4356 | sdev->no_write_same = 1; | ||
4355 | 4357 | ||
4356 | ufshcd_set_queue_depth(sdev); | 4358 | ufshcd_set_queue_depth(sdev); |
4357 | 4359 | ||
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index bbdc53b686dd..6dbba5aff191 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c | |||
@@ -702,30 +702,32 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, | |||
702 | size_t pgstart, pgend; | 702 | size_t pgstart, pgend; |
703 | int ret = -EINVAL; | 703 | int ret = -EINVAL; |
704 | 704 | ||
705 | mutex_lock(&ashmem_mutex); | ||
706 | |||
705 | if (unlikely(!asma->file)) | 707 | if (unlikely(!asma->file)) |
706 | return -EINVAL; | 708 | goto out_unlock; |
707 | 709 | ||
708 | if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) | 710 | if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) { |
709 | return -EFAULT; | 711 | ret = -EFAULT; |
712 | goto out_unlock; | ||
713 | } | ||
710 | 714 | ||
711 | /* per custom, you can pass zero for len to mean "everything onward" */ | 715 | /* per custom, you can pass zero for len to mean "everything onward" */ |
712 | if (!pin.len) | 716 | if (!pin.len) |
713 | pin.len = PAGE_ALIGN(asma->size) - pin.offset; | 717 | pin.len = PAGE_ALIGN(asma->size) - pin.offset; |
714 | 718 | ||
715 | if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) | 719 | if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) |
716 | return -EINVAL; | 720 | goto out_unlock; |
717 | 721 | ||
718 | if (unlikely(((__u32)-1) - pin.offset < pin.len)) | 722 | if (unlikely(((__u32)-1) - pin.offset < pin.len)) |
719 | return -EINVAL; | 723 | goto out_unlock; |
720 | 724 | ||
721 | if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) | 725 | if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) |
722 | return -EINVAL; | 726 | goto out_unlock; |
723 | 727 | ||
724 | pgstart = pin.offset / PAGE_SIZE; | 728 | pgstart = pin.offset / PAGE_SIZE; |
725 | pgend = pgstart + (pin.len / PAGE_SIZE) - 1; | 729 | pgend = pgstart + (pin.len / PAGE_SIZE) - 1; |
726 | 730 | ||
727 | mutex_lock(&ashmem_mutex); | ||
728 | |||
729 | switch (cmd) { | 731 | switch (cmd) { |
730 | case ASHMEM_PIN: | 732 | case ASHMEM_PIN: |
731 | ret = ashmem_pin(asma, pgstart, pgend); | 733 | ret = ashmem_pin(asma, pgstart, pgend); |
@@ -738,6 +740,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, | |||
738 | break; | 740 | break; |
739 | } | 741 | } |
740 | 742 | ||
743 | out_unlock: | ||
741 | mutex_unlock(&ashmem_mutex); | 744 | mutex_unlock(&ashmem_mutex); |
742 | 745 | ||
743 | return ret; | 746 | return ret; |
diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 94e06925c712..49718c96bf9e 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/err.h> | 12 | #include <linux/err.h> |
13 | #include <linux/cma.h> | 13 | #include <linux/cma.h> |
14 | #include <linux/scatterlist.h> | 14 | #include <linux/scatterlist.h> |
15 | #include <linux/highmem.h> | ||
15 | 16 | ||
16 | #include "ion.h" | 17 | #include "ion.h" |
17 | 18 | ||
@@ -42,6 +43,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, | |||
42 | if (!pages) | 43 | if (!pages) |
43 | return -ENOMEM; | 44 | return -ENOMEM; |
44 | 45 | ||
46 | if (PageHighMem(pages)) { | ||
47 | unsigned long nr_clear_pages = nr_pages; | ||
48 | struct page *page = pages; | ||
49 | |||
50 | while (nr_clear_pages > 0) { | ||
51 | void *vaddr = kmap_atomic(page); | ||
52 | |||
53 | memset(vaddr, 0, PAGE_SIZE); | ||
54 | kunmap_atomic(vaddr); | ||
55 | page++; | ||
56 | nr_clear_pages--; | ||
57 | } | ||
58 | } else { | ||
59 | memset(page_address(pages), 0, size); | ||
60 | } | ||
61 | |||
45 | table = kmalloc(sizeof(*table), GFP_KERNEL); | 62 | table = kmalloc(sizeof(*table), GFP_KERNEL); |
46 | if (!table) | 63 | if (!table) |
47 | goto err; | 64 | goto err; |
diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig index 1f9100049176..b35ef7ee6901 100644 --- a/drivers/staging/fsl-mc/bus/Kconfig +++ b/drivers/staging/fsl-mc/bus/Kconfig | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | config FSL_MC_BUS | 8 | config FSL_MC_BUS |
9 | bool "QorIQ DPAA2 fsl-mc bus driver" | 9 | bool "QorIQ DPAA2 fsl-mc bus driver" |
10 | depends on OF && (ARCH_LAYERSCAPE || (COMPILE_TEST && (ARM || ARM64 || X86 || PPC))) | 10 | depends on OF && (ARCH_LAYERSCAPE || (COMPILE_TEST && (ARM || ARM64 || X86_LOCAL_APIC || PPC))) |
11 | select GENERIC_MSI_IRQ_DOMAIN | 11 | select GENERIC_MSI_IRQ_DOMAIN |
12 | help | 12 | help |
13 | Driver to enable the bus infrastructure for the QorIQ DPAA2 | 13 | Driver to enable the bus infrastructure for the QorIQ DPAA2 |
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index f01595593ce2..425e8b82533b 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c | |||
@@ -141,6 +141,8 @@ | |||
141 | #define AD7192_GPOCON_P1DAT BIT(1) /* P1 state */ | 141 | #define AD7192_GPOCON_P1DAT BIT(1) /* P1 state */ |
142 | #define AD7192_GPOCON_P0DAT BIT(0) /* P0 state */ | 142 | #define AD7192_GPOCON_P0DAT BIT(0) /* P0 state */ |
143 | 143 | ||
144 | #define AD7192_EXT_FREQ_MHZ_MIN 2457600 | ||
145 | #define AD7192_EXT_FREQ_MHZ_MAX 5120000 | ||
144 | #define AD7192_INT_FREQ_MHZ 4915200 | 146 | #define AD7192_INT_FREQ_MHZ 4915200 |
145 | 147 | ||
146 | /* NOTE: | 148 | /* NOTE: |
@@ -218,6 +220,12 @@ static int ad7192_calibrate_all(struct ad7192_state *st) | |||
218 | ARRAY_SIZE(ad7192_calib_arr)); | 220 | ARRAY_SIZE(ad7192_calib_arr)); |
219 | } | 221 | } |
220 | 222 | ||
223 | static inline bool ad7192_valid_external_frequency(u32 freq) | ||
224 | { | ||
225 | return (freq >= AD7192_EXT_FREQ_MHZ_MIN && | ||
226 | freq <= AD7192_EXT_FREQ_MHZ_MAX); | ||
227 | } | ||
228 | |||
221 | static int ad7192_setup(struct ad7192_state *st, | 229 | static int ad7192_setup(struct ad7192_state *st, |
222 | const struct ad7192_platform_data *pdata) | 230 | const struct ad7192_platform_data *pdata) |
223 | { | 231 | { |
@@ -243,17 +251,20 @@ static int ad7192_setup(struct ad7192_state *st, | |||
243 | id); | 251 | id); |
244 | 252 | ||
245 | switch (pdata->clock_source_sel) { | 253 | switch (pdata->clock_source_sel) { |
246 | case AD7192_CLK_EXT_MCLK1_2: | ||
247 | case AD7192_CLK_EXT_MCLK2: | ||
248 | st->mclk = AD7192_INT_FREQ_MHZ; | ||
249 | break; | ||
250 | case AD7192_CLK_INT: | 254 | case AD7192_CLK_INT: |
251 | case AD7192_CLK_INT_CO: | 255 | case AD7192_CLK_INT_CO: |
252 | if (pdata->ext_clk_hz) | 256 | st->mclk = AD7192_INT_FREQ_MHZ; |
253 | st->mclk = pdata->ext_clk_hz; | ||
254 | else | ||
255 | st->mclk = AD7192_INT_FREQ_MHZ; | ||
256 | break; | 257 | break; |
258 | case AD7192_CLK_EXT_MCLK1_2: | ||
259 | case AD7192_CLK_EXT_MCLK2: | ||
260 | if (ad7192_valid_external_frequency(pdata->ext_clk_hz)) { | ||
261 | st->mclk = pdata->ext_clk_hz; | ||
262 | break; | ||
263 | } | ||
264 | dev_err(&st->sd.spi->dev, "Invalid frequency setting %u\n", | ||
265 | pdata->ext_clk_hz); | ||
266 | ret = -EINVAL; | ||
267 | goto out; | ||
257 | default: | 268 | default: |
258 | ret = -EINVAL; | 269 | ret = -EINVAL; |
259 | goto out; | 270 | goto out; |
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 2b28fb9c0048..3bcf49466361 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c | |||
@@ -648,8 +648,6 @@ static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) | |||
648 | /* Ring buffer functions - here trigger setup related */ | 648 | /* Ring buffer functions - here trigger setup related */ |
649 | indio_dev->setup_ops = &ad5933_ring_setup_ops; | 649 | indio_dev->setup_ops = &ad5933_ring_setup_ops; |
650 | 650 | ||
651 | indio_dev->modes |= INDIO_BUFFER_HARDWARE; | ||
652 | |||
653 | return 0; | 651 | return 0; |
654 | } | 652 | } |
655 | 653 | ||
@@ -762,7 +760,7 @@ static int ad5933_probe(struct i2c_client *client, | |||
762 | indio_dev->dev.parent = &client->dev; | 760 | indio_dev->dev.parent = &client->dev; |
763 | indio_dev->info = &ad5933_info; | 761 | indio_dev->info = &ad5933_info; |
764 | indio_dev->name = id->name; | 762 | indio_dev->name = id->name; |
765 | indio_dev->modes = INDIO_DIRECT_MODE; | 763 | indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); |
766 | indio_dev->channels = ad5933_channels; | 764 | indio_dev->channels = ad5933_channels; |
767 | indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); | 765 | indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); |
768 | 766 | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 06b3b54a0e68..7b366a6c0b49 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -174,6 +174,7 @@ static int acm_wb_alloc(struct acm *acm) | |||
174 | wb = &acm->wb[wbn]; | 174 | wb = &acm->wb[wbn]; |
175 | if (!wb->use) { | 175 | if (!wb->use) { |
176 | wb->use = 1; | 176 | wb->use = 1; |
177 | wb->len = 0; | ||
177 | return wbn; | 178 | return wbn; |
178 | } | 179 | } |
179 | wbn = (wbn + 1) % ACM_NW; | 180 | wbn = (wbn + 1) % ACM_NW; |
@@ -805,16 +806,18 @@ static int acm_tty_write(struct tty_struct *tty, | |||
805 | static void acm_tty_flush_chars(struct tty_struct *tty) | 806 | static void acm_tty_flush_chars(struct tty_struct *tty) |
806 | { | 807 | { |
807 | struct acm *acm = tty->driver_data; | 808 | struct acm *acm = tty->driver_data; |
808 | struct acm_wb *cur = acm->putbuffer; | 809 | struct acm_wb *cur; |
809 | int err; | 810 | int err; |
810 | unsigned long flags; | 811 | unsigned long flags; |
811 | 812 | ||
813 | spin_lock_irqsave(&acm->write_lock, flags); | ||
814 | |||
815 | cur = acm->putbuffer; | ||
812 | if (!cur) /* nothing to do */ | 816 | if (!cur) /* nothing to do */ |
813 | return; | 817 | goto out; |
814 | 818 | ||
815 | acm->putbuffer = NULL; | 819 | acm->putbuffer = NULL; |
816 | err = usb_autopm_get_interface_async(acm->control); | 820 | err = usb_autopm_get_interface_async(acm->control); |
817 | spin_lock_irqsave(&acm->write_lock, flags); | ||
818 | if (err < 0) { | 821 | if (err < 0) { |
819 | cur->use = 0; | 822 | cur->use = 0; |
820 | acm->putbuffer = cur; | 823 | acm->putbuffer = cur; |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 4024926c1d68..f4a548471f0f 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -226,6 +226,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
226 | { USB_DEVICE(0x1a0a, 0x0200), .driver_info = | 226 | { USB_DEVICE(0x1a0a, 0x0200), .driver_info = |
227 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, | 227 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, |
228 | 228 | ||
229 | /* Corsair K70 RGB */ | ||
230 | { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, | ||
231 | |||
229 | /* Corsair Strafe RGB */ | 232 | /* Corsair Strafe RGB */ |
230 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, | 233 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, |
231 | 234 | ||
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index e4c3ce0de5de..5bcad1d869b5 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -1917,7 +1917,9 @@ static void dwc2_hsotg_program_zlp(struct dwc2_hsotg *hsotg, | |||
1917 | /* Not specific buffer needed for ep0 ZLP */ | 1917 | /* Not specific buffer needed for ep0 ZLP */ |
1918 | dma_addr_t dma = hs_ep->desc_list_dma; | 1918 | dma_addr_t dma = hs_ep->desc_list_dma; |
1919 | 1919 | ||
1920 | dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); | 1920 | if (!index) |
1921 | dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); | ||
1922 | |||
1921 | dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, dma, 0); | 1923 | dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, dma, 0); |
1922 | } else { | 1924 | } else { |
1923 | dwc2_writel(DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | | 1925 | dwc2_writel(DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | |
@@ -2974,9 +2976,13 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, | |||
2974 | if (ints & DXEPINT_STSPHSERCVD) { | 2976 | if (ints & DXEPINT_STSPHSERCVD) { |
2975 | dev_dbg(hsotg->dev, "%s: StsPhseRcvd\n", __func__); | 2977 | dev_dbg(hsotg->dev, "%s: StsPhseRcvd\n", __func__); |
2976 | 2978 | ||
2977 | /* Move to STATUS IN for DDMA */ | 2979 | /* Safety check EP0 state when STSPHSERCVD asserted */ |
2978 | if (using_desc_dma(hsotg)) | 2980 | if (hsotg->ep0_state == DWC2_EP0_DATA_OUT) { |
2979 | dwc2_hsotg_ep0_zlp(hsotg, true); | 2981 | /* Move to STATUS IN for DDMA */ |
2982 | if (using_desc_dma(hsotg)) | ||
2983 | dwc2_hsotg_ep0_zlp(hsotg, true); | ||
2984 | } | ||
2985 | |||
2980 | } | 2986 | } |
2981 | 2987 | ||
2982 | if (ints & DXEPINT_BACK2BACKSETUP) | 2988 | if (ints & DXEPINT_BACK2BACKSETUP) |
@@ -3375,12 +3381,6 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, | |||
3375 | dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | | 3381 | dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | |
3376 | DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0); | 3382 | DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0); |
3377 | 3383 | ||
3378 | dwc2_hsotg_enqueue_setup(hsotg); | ||
3379 | |||
3380 | dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", | ||
3381 | dwc2_readl(hsotg->regs + DIEPCTL0), | ||
3382 | dwc2_readl(hsotg->regs + DOEPCTL0)); | ||
3383 | |||
3384 | /* clear global NAKs */ | 3384 | /* clear global NAKs */ |
3385 | val = DCTL_CGOUTNAK | DCTL_CGNPINNAK; | 3385 | val = DCTL_CGOUTNAK | DCTL_CGNPINNAK; |
3386 | if (!is_usb_reset) | 3386 | if (!is_usb_reset) |
@@ -3391,6 +3391,12 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, | |||
3391 | mdelay(3); | 3391 | mdelay(3); |
3392 | 3392 | ||
3393 | hsotg->lx_state = DWC2_L0; | 3393 | hsotg->lx_state = DWC2_L0; |
3394 | |||
3395 | dwc2_hsotg_enqueue_setup(hsotg); | ||
3396 | |||
3397 | dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", | ||
3398 | dwc2_readl(hsotg->regs + DIEPCTL0), | ||
3399 | dwc2_readl(hsotg->regs + DOEPCTL0)); | ||
3394 | } | 3400 | } |
3395 | 3401 | ||
3396 | static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) | 3402 | static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index ade2ab00d37a..f1d838a4acd6 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -100,6 +100,8 @@ static void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) | |||
100 | reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); | 100 | reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); |
101 | reg |= DWC3_GCTL_PRTCAPDIR(mode); | 101 | reg |= DWC3_GCTL_PRTCAPDIR(mode); |
102 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 102 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
103 | |||
104 | dwc->current_dr_role = mode; | ||
103 | } | 105 | } |
104 | 106 | ||
105 | static void __dwc3_set_mode(struct work_struct *work) | 107 | static void __dwc3_set_mode(struct work_struct *work) |
@@ -133,8 +135,6 @@ static void __dwc3_set_mode(struct work_struct *work) | |||
133 | 135 | ||
134 | dwc3_set_prtcap(dwc, dwc->desired_dr_role); | 136 | dwc3_set_prtcap(dwc, dwc->desired_dr_role); |
135 | 137 | ||
136 | dwc->current_dr_role = dwc->desired_dr_role; | ||
137 | |||
138 | spin_unlock_irqrestore(&dwc->lock, flags); | 138 | spin_unlock_irqrestore(&dwc->lock, flags); |
139 | 139 | ||
140 | switch (dwc->desired_dr_role) { | 140 | switch (dwc->desired_dr_role) { |
@@ -219,7 +219,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) | |||
219 | * XHCI driver will reset the host block. If dwc3 was configured for | 219 | * XHCI driver will reset the host block. If dwc3 was configured for |
220 | * host-only mode, then we can return early. | 220 | * host-only mode, then we can return early. |
221 | */ | 221 | */ |
222 | if (dwc->dr_mode == USB_DR_MODE_HOST) | 222 | if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) |
223 | return 0; | 223 | return 0; |
224 | 224 | ||
225 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 225 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
@@ -234,6 +234,9 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) | |||
234 | udelay(1); | 234 | udelay(1); |
235 | } while (--retries); | 235 | } while (--retries); |
236 | 236 | ||
237 | phy_exit(dwc->usb3_generic_phy); | ||
238 | phy_exit(dwc->usb2_generic_phy); | ||
239 | |||
237 | return -ETIMEDOUT; | 240 | return -ETIMEDOUT; |
238 | } | 241 | } |
239 | 242 | ||
@@ -483,6 +486,22 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc) | |||
483 | parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); | 486 | parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); |
484 | } | 487 | } |
485 | 488 | ||
489 | static int dwc3_core_ulpi_init(struct dwc3 *dwc) | ||
490 | { | ||
491 | int intf; | ||
492 | int ret = 0; | ||
493 | |||
494 | intf = DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3); | ||
495 | |||
496 | if (intf == DWC3_GHWPARAMS3_HSPHY_IFC_ULPI || | ||
497 | (intf == DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI && | ||
498 | dwc->hsphy_interface && | ||
499 | !strncmp(dwc->hsphy_interface, "ulpi", 4))) | ||
500 | ret = dwc3_ulpi_init(dwc); | ||
501 | |||
502 | return ret; | ||
503 | } | ||
504 | |||
486 | /** | 505 | /** |
487 | * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core | 506 | * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core |
488 | * @dwc: Pointer to our controller context structure | 507 | * @dwc: Pointer to our controller context structure |
@@ -494,7 +513,6 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc) | |||
494 | static int dwc3_phy_setup(struct dwc3 *dwc) | 513 | static int dwc3_phy_setup(struct dwc3 *dwc) |
495 | { | 514 | { |
496 | u32 reg; | 515 | u32 reg; |
497 | int ret; | ||
498 | 516 | ||
499 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | 517 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
500 | 518 | ||
@@ -565,9 +583,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) | |||
565 | } | 583 | } |
566 | /* FALLTHROUGH */ | 584 | /* FALLTHROUGH */ |
567 | case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI: | 585 | case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI: |
568 | ret = dwc3_ulpi_init(dwc); | ||
569 | if (ret) | ||
570 | return ret; | ||
571 | /* FALLTHROUGH */ | 586 | /* FALLTHROUGH */ |
572 | default: | 587 | default: |
573 | break; | 588 | break; |
@@ -724,6 +739,7 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc) | |||
724 | } | 739 | } |
725 | 740 | ||
726 | static int dwc3_core_get_phy(struct dwc3 *dwc); | 741 | static int dwc3_core_get_phy(struct dwc3 *dwc); |
742 | static int dwc3_core_ulpi_init(struct dwc3 *dwc); | ||
727 | 743 | ||
728 | /** | 744 | /** |
729 | * dwc3_core_init - Low-level initialization of DWC3 Core | 745 | * dwc3_core_init - Low-level initialization of DWC3 Core |
@@ -755,17 +771,27 @@ static int dwc3_core_init(struct dwc3 *dwc) | |||
755 | dwc->maximum_speed = USB_SPEED_HIGH; | 771 | dwc->maximum_speed = USB_SPEED_HIGH; |
756 | } | 772 | } |
757 | 773 | ||
758 | ret = dwc3_core_get_phy(dwc); | 774 | ret = dwc3_phy_setup(dwc); |
759 | if (ret) | 775 | if (ret) |
760 | goto err0; | 776 | goto err0; |
761 | 777 | ||
762 | ret = dwc3_core_soft_reset(dwc); | 778 | if (!dwc->ulpi_ready) { |
763 | if (ret) | 779 | ret = dwc3_core_ulpi_init(dwc); |
764 | goto err0; | 780 | if (ret) |
781 | goto err0; | ||
782 | dwc->ulpi_ready = true; | ||
783 | } | ||
765 | 784 | ||
766 | ret = dwc3_phy_setup(dwc); | 785 | if (!dwc->phys_ready) { |
786 | ret = dwc3_core_get_phy(dwc); | ||
787 | if (ret) | ||
788 | goto err0a; | ||
789 | dwc->phys_ready = true; | ||
790 | } | ||
791 | |||
792 | ret = dwc3_core_soft_reset(dwc); | ||
767 | if (ret) | 793 | if (ret) |
768 | goto err0; | 794 | goto err0a; |
769 | 795 | ||
770 | dwc3_core_setup_global_control(dwc); | 796 | dwc3_core_setup_global_control(dwc); |
771 | dwc3_core_num_eps(dwc); | 797 | dwc3_core_num_eps(dwc); |
@@ -838,6 +864,9 @@ err1: | |||
838 | phy_exit(dwc->usb2_generic_phy); | 864 | phy_exit(dwc->usb2_generic_phy); |
839 | phy_exit(dwc->usb3_generic_phy); | 865 | phy_exit(dwc->usb3_generic_phy); |
840 | 866 | ||
867 | err0a: | ||
868 | dwc3_ulpi_exit(dwc); | ||
869 | |||
841 | err0: | 870 | err0: |
842 | return ret; | 871 | return ret; |
843 | } | 872 | } |
@@ -916,7 +945,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) | |||
916 | 945 | ||
917 | switch (dwc->dr_mode) { | 946 | switch (dwc->dr_mode) { |
918 | case USB_DR_MODE_PERIPHERAL: | 947 | case USB_DR_MODE_PERIPHERAL: |
919 | dwc->current_dr_role = DWC3_GCTL_PRTCAP_DEVICE; | ||
920 | dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); | 948 | dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); |
921 | 949 | ||
922 | if (dwc->usb2_phy) | 950 | if (dwc->usb2_phy) |
@@ -932,7 +960,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) | |||
932 | } | 960 | } |
933 | break; | 961 | break; |
934 | case USB_DR_MODE_HOST: | 962 | case USB_DR_MODE_HOST: |
935 | dwc->current_dr_role = DWC3_GCTL_PRTCAP_HOST; | ||
936 | dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); | 963 | dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); |
937 | 964 | ||
938 | if (dwc->usb2_phy) | 965 | if (dwc->usb2_phy) |
@@ -1234,7 +1261,6 @@ err4: | |||
1234 | 1261 | ||
1235 | err3: | 1262 | err3: |
1236 | dwc3_free_event_buffers(dwc); | 1263 | dwc3_free_event_buffers(dwc); |
1237 | dwc3_ulpi_exit(dwc); | ||
1238 | 1264 | ||
1239 | err2: | 1265 | err2: |
1240 | pm_runtime_allow(&pdev->dev); | 1266 | pm_runtime_allow(&pdev->dev); |
@@ -1284,7 +1310,7 @@ static int dwc3_remove(struct platform_device *pdev) | |||
1284 | } | 1310 | } |
1285 | 1311 | ||
1286 | #ifdef CONFIG_PM | 1312 | #ifdef CONFIG_PM |
1287 | static int dwc3_suspend_common(struct dwc3 *dwc) | 1313 | static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) |
1288 | { | 1314 | { |
1289 | unsigned long flags; | 1315 | unsigned long flags; |
1290 | 1316 | ||
@@ -1296,6 +1322,10 @@ static int dwc3_suspend_common(struct dwc3 *dwc) | |||
1296 | dwc3_core_exit(dwc); | 1322 | dwc3_core_exit(dwc); |
1297 | break; | 1323 | break; |
1298 | case DWC3_GCTL_PRTCAP_HOST: | 1324 | case DWC3_GCTL_PRTCAP_HOST: |
1325 | /* do nothing during host runtime_suspend */ | ||
1326 | if (!PMSG_IS_AUTO(msg)) | ||
1327 | dwc3_core_exit(dwc); | ||
1328 | break; | ||
1299 | default: | 1329 | default: |
1300 | /* do nothing */ | 1330 | /* do nothing */ |
1301 | break; | 1331 | break; |
@@ -1304,7 +1334,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc) | |||
1304 | return 0; | 1334 | return 0; |
1305 | } | 1335 | } |
1306 | 1336 | ||
1307 | static int dwc3_resume_common(struct dwc3 *dwc) | 1337 | static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) |
1308 | { | 1338 | { |
1309 | unsigned long flags; | 1339 | unsigned long flags; |
1310 | int ret; | 1340 | int ret; |
@@ -1320,6 +1350,13 @@ static int dwc3_resume_common(struct dwc3 *dwc) | |||
1320 | spin_unlock_irqrestore(&dwc->lock, flags); | 1350 | spin_unlock_irqrestore(&dwc->lock, flags); |
1321 | break; | 1351 | break; |
1322 | case DWC3_GCTL_PRTCAP_HOST: | 1352 | case DWC3_GCTL_PRTCAP_HOST: |
1353 | /* nothing to do on host runtime_resume */ | ||
1354 | if (!PMSG_IS_AUTO(msg)) { | ||
1355 | ret = dwc3_core_init(dwc); | ||
1356 | if (ret) | ||
1357 | return ret; | ||
1358 | } | ||
1359 | break; | ||
1323 | default: | 1360 | default: |
1324 | /* do nothing */ | 1361 | /* do nothing */ |
1325 | break; | 1362 | break; |
@@ -1331,12 +1368,11 @@ static int dwc3_resume_common(struct dwc3 *dwc) | |||
1331 | static int dwc3_runtime_checks(struct dwc3 *dwc) | 1368 | static int dwc3_runtime_checks(struct dwc3 *dwc) |
1332 | { | 1369 | { |
1333 | switch (dwc->current_dr_role) { | 1370 | switch (dwc->current_dr_role) { |
1334 | case USB_DR_MODE_PERIPHERAL: | 1371 | case DWC3_GCTL_PRTCAP_DEVICE: |
1335 | case USB_DR_MODE_OTG: | ||
1336 | if (dwc->connected) | 1372 | if (dwc->connected) |
1337 | return -EBUSY; | 1373 | return -EBUSY; |
1338 | break; | 1374 | break; |
1339 | case USB_DR_MODE_HOST: | 1375 | case DWC3_GCTL_PRTCAP_HOST: |
1340 | default: | 1376 | default: |
1341 | /* do nothing */ | 1377 | /* do nothing */ |
1342 | break; | 1378 | break; |
@@ -1353,7 +1389,7 @@ static int dwc3_runtime_suspend(struct device *dev) | |||
1353 | if (dwc3_runtime_checks(dwc)) | 1389 | if (dwc3_runtime_checks(dwc)) |
1354 | return -EBUSY; | 1390 | return -EBUSY; |
1355 | 1391 | ||
1356 | ret = dwc3_suspend_common(dwc); | 1392 | ret = dwc3_suspend_common(dwc, PMSG_AUTO_SUSPEND); |
1357 | if (ret) | 1393 | if (ret) |
1358 | return ret; | 1394 | return ret; |
1359 | 1395 | ||
@@ -1369,7 +1405,7 @@ static int dwc3_runtime_resume(struct device *dev) | |||
1369 | 1405 | ||
1370 | device_init_wakeup(dev, false); | 1406 | device_init_wakeup(dev, false); |
1371 | 1407 | ||
1372 | ret = dwc3_resume_common(dwc); | 1408 | ret = dwc3_resume_common(dwc, PMSG_AUTO_RESUME); |
1373 | if (ret) | 1409 | if (ret) |
1374 | return ret; | 1410 | return ret; |
1375 | 1411 | ||
@@ -1416,7 +1452,7 @@ static int dwc3_suspend(struct device *dev) | |||
1416 | struct dwc3 *dwc = dev_get_drvdata(dev); | 1452 | struct dwc3 *dwc = dev_get_drvdata(dev); |
1417 | int ret; | 1453 | int ret; |
1418 | 1454 | ||
1419 | ret = dwc3_suspend_common(dwc); | 1455 | ret = dwc3_suspend_common(dwc, PMSG_SUSPEND); |
1420 | if (ret) | 1456 | if (ret) |
1421 | return ret; | 1457 | return ret; |
1422 | 1458 | ||
@@ -1432,7 +1468,7 @@ static int dwc3_resume(struct device *dev) | |||
1432 | 1468 | ||
1433 | pinctrl_pm_select_default_state(dev); | 1469 | pinctrl_pm_select_default_state(dev); |
1434 | 1470 | ||
1435 | ret = dwc3_resume_common(dwc); | 1471 | ret = dwc3_resume_common(dwc, PMSG_RESUME); |
1436 | if (ret) | 1472 | if (ret) |
1437 | return ret; | 1473 | return ret; |
1438 | 1474 | ||
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 03c7aaaac926..860d2bc184d1 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -158,13 +158,15 @@ | |||
158 | #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) | 158 | #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) |
159 | #define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(n) (((n) >> 16) & 0xffff) | 159 | #define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(n) (((n) >> 16) & 0xffff) |
160 | 160 | ||
161 | #define DWC3_TXFIFOQ 1 | 161 | #define DWC3_TXFIFOQ 0 |
162 | #define DWC3_RXFIFOQ 3 | 162 | #define DWC3_RXFIFOQ 1 |
163 | #define DWC3_TXREQQ 5 | 163 | #define DWC3_TXREQQ 2 |
164 | #define DWC3_RXREQQ 7 | 164 | #define DWC3_RXREQQ 3 |
165 | #define DWC3_RXINFOQ 9 | 165 | #define DWC3_RXINFOQ 4 |
166 | #define DWC3_DESCFETCHQ 13 | 166 | #define DWC3_PSTATQ 5 |
167 | #define DWC3_EVENTQ 15 | 167 | #define DWC3_DESCFETCHQ 6 |
168 | #define DWC3_EVENTQ 7 | ||
169 | #define DWC3_AUXEVENTQ 8 | ||
168 | 170 | ||
169 | /* Global RX Threshold Configuration Register */ | 171 | /* Global RX Threshold Configuration Register */ |
170 | #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19) | 172 | #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19) |
@@ -795,7 +797,9 @@ struct dwc3_scratchpad_array { | |||
795 | * @usb3_phy: pointer to USB3 PHY | 797 | * @usb3_phy: pointer to USB3 PHY |
796 | * @usb2_generic_phy: pointer to USB2 PHY | 798 | * @usb2_generic_phy: pointer to USB2 PHY |
797 | * @usb3_generic_phy: pointer to USB3 PHY | 799 | * @usb3_generic_phy: pointer to USB3 PHY |
800 | * @phys_ready: flag to indicate that PHYs are ready | ||
798 | * @ulpi: pointer to ulpi interface | 801 | * @ulpi: pointer to ulpi interface |
802 | * @ulpi_ready: flag to indicate that ULPI is initialized | ||
799 | * @u2sel: parameter from Set SEL request. | 803 | * @u2sel: parameter from Set SEL request. |
800 | * @u2pel: parameter from Set SEL request. | 804 | * @u2pel: parameter from Set SEL request. |
801 | * @u1sel: parameter from Set SEL request. | 805 | * @u1sel: parameter from Set SEL request. |
@@ -893,7 +897,10 @@ struct dwc3 { | |||
893 | struct phy *usb2_generic_phy; | 897 | struct phy *usb2_generic_phy; |
894 | struct phy *usb3_generic_phy; | 898 | struct phy *usb3_generic_phy; |
895 | 899 | ||
900 | bool phys_ready; | ||
901 | |||
896 | struct ulpi *ulpi; | 902 | struct ulpi *ulpi; |
903 | bool ulpi_ready; | ||
897 | 904 | ||
898 | void __iomem *regs; | 905 | void __iomem *regs; |
899 | size_t regs_size; | 906 | size_t regs_size; |
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index 7ae0eefc7cc7..e54c3622eb28 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c | |||
@@ -143,6 +143,7 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) | |||
143 | clk_disable_unprepare(simple->clks[i]); | 143 | clk_disable_unprepare(simple->clks[i]); |
144 | clk_put(simple->clks[i]); | 144 | clk_put(simple->clks[i]); |
145 | } | 145 | } |
146 | simple->num_clocks = 0; | ||
146 | 147 | ||
147 | reset_control_assert(simple->resets); | 148 | reset_control_assert(simple->resets); |
148 | reset_control_put(simple->resets); | 149 | reset_control_put(simple->resets); |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index a4719e853b85..ed8b86517675 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -582,9 +582,25 @@ static int dwc3_omap_resume(struct device *dev) | |||
582 | return 0; | 582 | return 0; |
583 | } | 583 | } |
584 | 584 | ||
585 | static void dwc3_omap_complete(struct device *dev) | ||
586 | { | ||
587 | struct dwc3_omap *omap = dev_get_drvdata(dev); | ||
588 | |||
589 | if (extcon_get_state(omap->edev, EXTCON_USB)) | ||
590 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); | ||
591 | else | ||
592 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); | ||
593 | |||
594 | if (extcon_get_state(omap->edev, EXTCON_USB_HOST)) | ||
595 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); | ||
596 | else | ||
597 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); | ||
598 | } | ||
599 | |||
585 | static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { | 600 | static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { |
586 | 601 | ||
587 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) | 602 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) |
603 | .complete = dwc3_omap_complete, | ||
588 | }; | 604 | }; |
589 | 605 | ||
590 | #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops) | 606 | #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops) |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 9c2e4a17918e..18be31d5743a 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -854,7 +854,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
854 | trb++; | 854 | trb++; |
855 | trb->ctrl &= ~DWC3_TRB_CTRL_HWO; | 855 | trb->ctrl &= ~DWC3_TRB_CTRL_HWO; |
856 | trace_dwc3_complete_trb(ep0, trb); | 856 | trace_dwc3_complete_trb(ep0, trb); |
857 | ep0->trb_enqueue = 0; | 857 | |
858 | if (r->direction) | ||
859 | dwc->eps[1]->trb_enqueue = 0; | ||
860 | else | ||
861 | dwc->eps[0]->trb_enqueue = 0; | ||
862 | |||
858 | dwc->ep0_bounced = false; | 863 | dwc->ep0_bounced = false; |
859 | } | 864 | } |
860 | 865 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 616ef49ccb49..2bda4eb1e9ac 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -2745,6 +2745,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
2745 | break; | 2745 | break; |
2746 | } | 2746 | } |
2747 | 2747 | ||
2748 | dwc->eps[1]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket; | ||
2749 | |||
2748 | /* Enable USB2 LPM Capability */ | 2750 | /* Enable USB2 LPM Capability */ |
2749 | 2751 | ||
2750 | if ((dwc->revision > DWC3_REVISION_194A) && | 2752 | if ((dwc->revision > DWC3_REVISION_194A) && |
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 8f2cf3baa19c..c2592d883f67 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -1855,44 +1855,20 @@ static int ffs_func_eps_enable(struct ffs_function *func) | |||
1855 | 1855 | ||
1856 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | 1856 | spin_lock_irqsave(&func->ffs->eps_lock, flags); |
1857 | while(count--) { | 1857 | while(count--) { |
1858 | struct usb_endpoint_descriptor *ds; | ||
1859 | struct usb_ss_ep_comp_descriptor *comp_desc = NULL; | ||
1860 | int needs_comp_desc = false; | ||
1861 | int desc_idx; | ||
1862 | |||
1863 | if (ffs->gadget->speed == USB_SPEED_SUPER) { | ||
1864 | desc_idx = 2; | ||
1865 | needs_comp_desc = true; | ||
1866 | } else if (ffs->gadget->speed == USB_SPEED_HIGH) | ||
1867 | desc_idx = 1; | ||
1868 | else | ||
1869 | desc_idx = 0; | ||
1870 | |||
1871 | /* fall-back to lower speed if desc missing for current speed */ | ||
1872 | do { | ||
1873 | ds = ep->descs[desc_idx]; | ||
1874 | } while (!ds && --desc_idx >= 0); | ||
1875 | |||
1876 | if (!ds) { | ||
1877 | ret = -EINVAL; | ||
1878 | break; | ||
1879 | } | ||
1880 | |||
1881 | ep->ep->driver_data = ep; | 1858 | ep->ep->driver_data = ep; |
1882 | ep->ep->desc = ds; | ||
1883 | 1859 | ||
1884 | if (needs_comp_desc) { | 1860 | ret = config_ep_by_speed(func->gadget, &func->function, ep->ep); |
1885 | comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds + | 1861 | if (ret) { |
1886 | USB_DT_ENDPOINT_SIZE); | 1862 | pr_err("%s: config_ep_by_speed(%s) returned %d\n", |
1887 | ep->ep->maxburst = comp_desc->bMaxBurst + 1; | 1863 | __func__, ep->ep->name, ret); |
1888 | ep->ep->comp_desc = comp_desc; | 1864 | break; |
1889 | } | 1865 | } |
1890 | 1866 | ||
1891 | ret = usb_ep_enable(ep->ep); | 1867 | ret = usb_ep_enable(ep->ep); |
1892 | if (likely(!ret)) { | 1868 | if (likely(!ret)) { |
1893 | epfile->ep = ep; | 1869 | epfile->ep = ep; |
1894 | epfile->in = usb_endpoint_dir_in(ds); | 1870 | epfile->in = usb_endpoint_dir_in(ep->ep->desc); |
1895 | epfile->isoc = usb_endpoint_xfer_isoc(ds); | 1871 | epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc); |
1896 | } else { | 1872 | } else { |
1897 | break; | 1873 | break; |
1898 | } | 1874 | } |
@@ -2979,10 +2955,8 @@ static int _ffs_func_bind(struct usb_configuration *c, | |||
2979 | struct ffs_data *ffs = func->ffs; | 2955 | struct ffs_data *ffs = func->ffs; |
2980 | 2956 | ||
2981 | const int full = !!func->ffs->fs_descs_count; | 2957 | const int full = !!func->ffs->fs_descs_count; |
2982 | const int high = gadget_is_dualspeed(func->gadget) && | 2958 | const int high = !!func->ffs->hs_descs_count; |
2983 | func->ffs->hs_descs_count; | 2959 | const int super = !!func->ffs->ss_descs_count; |
2984 | const int super = gadget_is_superspeed(func->gadget) && | ||
2985 | func->ffs->ss_descs_count; | ||
2986 | 2960 | ||
2987 | int fs_len, hs_len, ss_len, ret, i; | 2961 | int fs_len, hs_len, ss_len, ret, i; |
2988 | struct ffs_ep *eps_ptr; | 2962 | struct ffs_ep *eps_ptr; |
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 11fe788b4308..d2dc1f00180b 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
@@ -524,6 +524,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
524 | dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); | 524 | dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); |
525 | return ret; | 525 | return ret; |
526 | } | 526 | } |
527 | iad_desc.bFirstInterface = ret; | ||
528 | |||
527 | std_ac_if_desc.bInterfaceNumber = ret; | 529 | std_ac_if_desc.bInterfaceNumber = ret; |
528 | uac2->ac_intf = ret; | 530 | uac2->ac_intf = ret; |
529 | uac2->ac_alt = 0; | 531 | uac2->ac_alt = 0; |
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig index 1e9567091d86..0875d38476ee 100644 --- a/drivers/usb/gadget/udc/Kconfig +++ b/drivers/usb/gadget/udc/Kconfig | |||
@@ -274,7 +274,6 @@ config USB_SNP_UDC_PLAT | |||
274 | tristate "Synopsys USB 2.0 Device controller" | 274 | tristate "Synopsys USB 2.0 Device controller" |
275 | depends on USB_GADGET && OF && HAS_DMA | 275 | depends on USB_GADGET && OF && HAS_DMA |
276 | depends on EXTCON || EXTCON=n | 276 | depends on EXTCON || EXTCON=n |
277 | select USB_GADGET_DUALSPEED | ||
278 | select USB_SNP_CORE | 277 | select USB_SNP_CORE |
279 | default ARCH_BCM_IPROC | 278 | default ARCH_BCM_IPROC |
280 | help | 279 | help |
diff --git a/drivers/usb/gadget/udc/bdc/bdc_pci.c b/drivers/usb/gadget/udc/bdc/bdc_pci.c index 1e940f054cb8..6dbc489513cd 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_pci.c +++ b/drivers/usb/gadget/udc/bdc/bdc_pci.c | |||
@@ -77,6 +77,7 @@ static int bdc_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) | |||
77 | if (ret) { | 77 | if (ret) { |
78 | dev_err(&pci->dev, | 78 | dev_err(&pci->dev, |
79 | "couldn't add resources to bdc device\n"); | 79 | "couldn't add resources to bdc device\n"); |
80 | platform_device_put(bdc); | ||
80 | return ret; | 81 | return ret; |
81 | } | 82 | } |
82 | 83 | ||
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 859d5b11ba4c..1f8b19d9cf97 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c | |||
@@ -180,8 +180,8 @@ EXPORT_SYMBOL_GPL(usb_ep_alloc_request); | |||
180 | void usb_ep_free_request(struct usb_ep *ep, | 180 | void usb_ep_free_request(struct usb_ep *ep, |
181 | struct usb_request *req) | 181 | struct usb_request *req) |
182 | { | 182 | { |
183 | ep->ops->free_request(ep, req); | ||
184 | trace_usb_ep_free_request(ep, req, 0); | 183 | trace_usb_ep_free_request(ep, req, 0); |
184 | ep->ops->free_request(ep, req); | ||
185 | } | 185 | } |
186 | EXPORT_SYMBOL_GPL(usb_ep_free_request); | 186 | EXPORT_SYMBOL_GPL(usb_ep_free_request); |
187 | 187 | ||
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index e5b4ee96c4bf..56b517a38865 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c | |||
@@ -1305,7 +1305,7 @@ static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) | |||
1305 | { | 1305 | { |
1306 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); | 1306 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); |
1307 | 1307 | ||
1308 | if (ep->name) | 1308 | if (ep->ep.name) |
1309 | nuke(ep, -ESHUTDOWN); | 1309 | nuke(ep, -ESHUTDOWN); |
1310 | } | 1310 | } |
1311 | 1311 | ||
@@ -1693,7 +1693,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) | |||
1693 | curr_ep = get_ep_by_pipe(udc, i); | 1693 | curr_ep = get_ep_by_pipe(udc, i); |
1694 | 1694 | ||
1695 | /* If the ep is configured */ | 1695 | /* If the ep is configured */ |
1696 | if (curr_ep->name == NULL) { | 1696 | if (!curr_ep->ep.name) { |
1697 | WARNING("Invalid EP?"); | 1697 | WARNING("Invalid EP?"); |
1698 | continue; | 1698 | continue; |
1699 | } | 1699 | } |
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 6e87af248367..409cde4e6a51 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
@@ -2410,7 +2410,7 @@ static int renesas_usb3_remove(struct platform_device *pdev) | |||
2410 | __renesas_usb3_ep_free_request(usb3->ep0_req); | 2410 | __renesas_usb3_ep_free_request(usb3->ep0_req); |
2411 | if (usb3->phy) | 2411 | if (usb3->phy) |
2412 | phy_put(usb3->phy); | 2412 | phy_put(usb3->phy); |
2413 | pm_runtime_disable(usb3_to_dev(usb3)); | 2413 | pm_runtime_disable(&pdev->dev); |
2414 | 2414 | ||
2415 | return 0; | 2415 | return 0; |
2416 | } | 2416 | } |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index facafdf8fb95..d7641cbdee43 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -774,12 +774,12 @@ static struct urb *request_single_step_set_feature_urb( | |||
774 | atomic_inc(&urb->use_count); | 774 | atomic_inc(&urb->use_count); |
775 | atomic_inc(&urb->dev->urbnum); | 775 | atomic_inc(&urb->dev->urbnum); |
776 | urb->setup_dma = dma_map_single( | 776 | urb->setup_dma = dma_map_single( |
777 | hcd->self.controller, | 777 | hcd->self.sysdev, |
778 | urb->setup_packet, | 778 | urb->setup_packet, |
779 | sizeof(struct usb_ctrlrequest), | 779 | sizeof(struct usb_ctrlrequest), |
780 | DMA_TO_DEVICE); | 780 | DMA_TO_DEVICE); |
781 | urb->transfer_dma = dma_map_single( | 781 | urb->transfer_dma = dma_map_single( |
782 | hcd->self.controller, | 782 | hcd->self.sysdev, |
783 | urb->transfer_buffer, | 783 | urb->transfer_buffer, |
784 | urb->transfer_buffer_length, | 784 | urb->transfer_buffer_length, |
785 | DMA_FROM_DEVICE); | 785 | DMA_FROM_DEVICE); |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 88158324dcae..327630405695 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -1188,10 +1188,10 @@ static int submit_single_step_set_feature( | |||
1188 | * 15 secs after the setup | 1188 | * 15 secs after the setup |
1189 | */ | 1189 | */ |
1190 | if (is_setup) { | 1190 | if (is_setup) { |
1191 | /* SETUP pid */ | 1191 | /* SETUP pid, and interrupt after SETUP completion */ |
1192 | qtd_fill(ehci, qtd, urb->setup_dma, | 1192 | qtd_fill(ehci, qtd, urb->setup_dma, |
1193 | sizeof(struct usb_ctrlrequest), | 1193 | sizeof(struct usb_ctrlrequest), |
1194 | token | (2 /* "setup" */ << 8), 8); | 1194 | QTD_IOC | token | (2 /* "setup" */ << 8), 8); |
1195 | 1195 | ||
1196 | submit_async(ehci, urb, &qtd_list, GFP_ATOMIC); | 1196 | submit_async(ehci, urb, &qtd_list, GFP_ATOMIC); |
1197 | return 0; /*Return now; we shall come back after 15 seconds*/ | 1197 | return 0; /*Return now; we shall come back after 15 seconds*/ |
@@ -1228,12 +1228,8 @@ static int submit_single_step_set_feature( | |||
1228 | qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); | 1228 | qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); |
1229 | list_add_tail(&qtd->qtd_list, head); | 1229 | list_add_tail(&qtd->qtd_list, head); |
1230 | 1230 | ||
1231 | /* dont fill any data in such packets */ | 1231 | /* Interrupt after STATUS completion */ |
1232 | qtd_fill(ehci, qtd, 0, 0, token, 0); | 1232 | qtd_fill(ehci, qtd, 0, 0, token | QTD_IOC, 0); |
1233 | |||
1234 | /* by default, enable interrupt on urb completion */ | ||
1235 | if (likely(!(urb->transfer_flags & URB_NO_INTERRUPT))) | ||
1236 | qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); | ||
1237 | 1233 | ||
1238 | submit_async(ehci, urb, &qtd_list, GFP_KERNEL); | 1234 | submit_async(ehci, urb, &qtd_list, GFP_KERNEL); |
1239 | 1235 | ||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index ee9676349333..84f88fa411cd 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -74,6 +74,7 @@ static const char hcd_name [] = "ohci_hcd"; | |||
74 | 74 | ||
75 | #define STATECHANGE_DELAY msecs_to_jiffies(300) | 75 | #define STATECHANGE_DELAY msecs_to_jiffies(300) |
76 | #define IO_WATCHDOG_DELAY msecs_to_jiffies(275) | 76 | #define IO_WATCHDOG_DELAY msecs_to_jiffies(275) |
77 | #define IO_WATCHDOG_OFF 0xffffff00 | ||
77 | 78 | ||
78 | #include "ohci.h" | 79 | #include "ohci.h" |
79 | #include "pci-quirks.h" | 80 | #include "pci-quirks.h" |
@@ -231,7 +232,7 @@ static int ohci_urb_enqueue ( | |||
231 | } | 232 | } |
232 | 233 | ||
233 | /* Start up the I/O watchdog timer, if it's not running */ | 234 | /* Start up the I/O watchdog timer, if it's not running */ |
234 | if (!timer_pending(&ohci->io_watchdog) && | 235 | if (ohci->prev_frame_no == IO_WATCHDOG_OFF && |
235 | list_empty(&ohci->eds_in_use) && | 236 | list_empty(&ohci->eds_in_use) && |
236 | !(ohci->flags & OHCI_QUIRK_QEMU)) { | 237 | !(ohci->flags & OHCI_QUIRK_QEMU)) { |
237 | ohci->prev_frame_no = ohci_frame_no(ohci); | 238 | ohci->prev_frame_no = ohci_frame_no(ohci); |
@@ -501,6 +502,7 @@ static int ohci_init (struct ohci_hcd *ohci) | |||
501 | return 0; | 502 | return 0; |
502 | 503 | ||
503 | timer_setup(&ohci->io_watchdog, io_watchdog_func, 0); | 504 | timer_setup(&ohci->io_watchdog, io_watchdog_func, 0); |
505 | ohci->prev_frame_no = IO_WATCHDOG_OFF; | ||
504 | 506 | ||
505 | ohci->hcca = dma_alloc_coherent (hcd->self.controller, | 507 | ohci->hcca = dma_alloc_coherent (hcd->self.controller, |
506 | sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); | 508 | sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); |
@@ -730,7 +732,7 @@ static void io_watchdog_func(struct timer_list *t) | |||
730 | u32 head; | 732 | u32 head; |
731 | struct ed *ed; | 733 | struct ed *ed; |
732 | struct td *td, *td_start, *td_next; | 734 | struct td *td, *td_start, *td_next; |
733 | unsigned frame_no; | 735 | unsigned frame_no, prev_frame_no = IO_WATCHDOG_OFF; |
734 | unsigned long flags; | 736 | unsigned long flags; |
735 | 737 | ||
736 | spin_lock_irqsave(&ohci->lock, flags); | 738 | spin_lock_irqsave(&ohci->lock, flags); |
@@ -835,7 +837,7 @@ static void io_watchdog_func(struct timer_list *t) | |||
835 | } | 837 | } |
836 | } | 838 | } |
837 | if (!list_empty(&ohci->eds_in_use)) { | 839 | if (!list_empty(&ohci->eds_in_use)) { |
838 | ohci->prev_frame_no = frame_no; | 840 | prev_frame_no = frame_no; |
839 | ohci->prev_wdh_cnt = ohci->wdh_cnt; | 841 | ohci->prev_wdh_cnt = ohci->wdh_cnt; |
840 | ohci->prev_donehead = ohci_readl(ohci, | 842 | ohci->prev_donehead = ohci_readl(ohci, |
841 | &ohci->regs->donehead); | 843 | &ohci->regs->donehead); |
@@ -845,6 +847,7 @@ static void io_watchdog_func(struct timer_list *t) | |||
845 | } | 847 | } |
846 | 848 | ||
847 | done: | 849 | done: |
850 | ohci->prev_frame_no = prev_frame_no; | ||
848 | spin_unlock_irqrestore(&ohci->lock, flags); | 851 | spin_unlock_irqrestore(&ohci->lock, flags); |
849 | } | 852 | } |
850 | 853 | ||
@@ -973,6 +976,7 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
973 | if (quirk_nec(ohci)) | 976 | if (quirk_nec(ohci)) |
974 | flush_work(&ohci->nec_work); | 977 | flush_work(&ohci->nec_work); |
975 | del_timer_sync(&ohci->io_watchdog); | 978 | del_timer_sync(&ohci->io_watchdog); |
979 | ohci->prev_frame_no = IO_WATCHDOG_OFF; | ||
976 | 980 | ||
977 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 981 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
978 | ohci_usb_reset(ohci); | 982 | ohci_usb_reset(ohci); |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index fb7aaa3b9d06..634f3c7bf774 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -311,8 +311,10 @@ static int ohci_bus_suspend (struct usb_hcd *hcd) | |||
311 | rc = ohci_rh_suspend (ohci, 0); | 311 | rc = ohci_rh_suspend (ohci, 0); |
312 | spin_unlock_irq (&ohci->lock); | 312 | spin_unlock_irq (&ohci->lock); |
313 | 313 | ||
314 | if (rc == 0) | 314 | if (rc == 0) { |
315 | del_timer_sync(&ohci->io_watchdog); | 315 | del_timer_sync(&ohci->io_watchdog); |
316 | ohci->prev_frame_no = IO_WATCHDOG_OFF; | ||
317 | } | ||
316 | return rc; | 318 | return rc; |
317 | } | 319 | } |
318 | 320 | ||
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index b2ec8c399363..4ccb85a67bb3 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -1019,6 +1019,8 @@ skip_ed: | |||
1019 | * have modified this list. normally it's just prepending | 1019 | * have modified this list. normally it's just prepending |
1020 | * entries (which we'd ignore), but paranoia won't hurt. | 1020 | * entries (which we'd ignore), but paranoia won't hurt. |
1021 | */ | 1021 | */ |
1022 | *last = ed->ed_next; | ||
1023 | ed->ed_next = NULL; | ||
1022 | modified = 0; | 1024 | modified = 0; |
1023 | 1025 | ||
1024 | /* unlink urbs as requested, but rescan the list after | 1026 | /* unlink urbs as requested, but rescan the list after |
@@ -1077,21 +1079,22 @@ rescan_this: | |||
1077 | goto rescan_this; | 1079 | goto rescan_this; |
1078 | 1080 | ||
1079 | /* | 1081 | /* |
1080 | * If no TDs are queued, take ED off the ed_rm_list. | 1082 | * If no TDs are queued, ED is now idle. |
1081 | * Otherwise, if the HC is running, reschedule. | 1083 | * Otherwise, if the HC is running, reschedule. |
1082 | * If not, leave it on the list for further dequeues. | 1084 | * If the HC isn't running, add ED back to the |
1085 | * start of the list for later processing. | ||
1083 | */ | 1086 | */ |
1084 | if (list_empty(&ed->td_list)) { | 1087 | if (list_empty(&ed->td_list)) { |
1085 | *last = ed->ed_next; | ||
1086 | ed->ed_next = NULL; | ||
1087 | ed->state = ED_IDLE; | 1088 | ed->state = ED_IDLE; |
1088 | list_del(&ed->in_use_list); | 1089 | list_del(&ed->in_use_list); |
1089 | } else if (ohci->rh_state == OHCI_RH_RUNNING) { | 1090 | } else if (ohci->rh_state == OHCI_RH_RUNNING) { |
1090 | *last = ed->ed_next; | ||
1091 | ed->ed_next = NULL; | ||
1092 | ed_schedule(ohci, ed); | 1091 | ed_schedule(ohci, ed); |
1093 | } else { | 1092 | } else { |
1094 | last = &ed->ed_next; | 1093 | ed->ed_next = ohci->ed_rm_list; |
1094 | ohci->ed_rm_list = ed; | ||
1095 | /* Don't loop on the same ED */ | ||
1096 | if (last == &ohci->ed_rm_list) | ||
1097 | last = &ed->ed_next; | ||
1095 | } | 1098 | } |
1096 | 1099 | ||
1097 | if (modified) | 1100 | if (modified) |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 161536717025..67ad4bb6919a 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -66,6 +66,23 @@ | |||
66 | #define AX_INDXC 0x30 | 66 | #define AX_INDXC 0x30 |
67 | #define AX_DATAC 0x34 | 67 | #define AX_DATAC 0x34 |
68 | 68 | ||
69 | #define PT_ADDR_INDX 0xE8 | ||
70 | #define PT_READ_INDX 0xE4 | ||
71 | #define PT_SIG_1_ADDR 0xA520 | ||
72 | #define PT_SIG_2_ADDR 0xA521 | ||
73 | #define PT_SIG_3_ADDR 0xA522 | ||
74 | #define PT_SIG_4_ADDR 0xA523 | ||
75 | #define PT_SIG_1_DATA 0x78 | ||
76 | #define PT_SIG_2_DATA 0x56 | ||
77 | #define PT_SIG_3_DATA 0x34 | ||
78 | #define PT_SIG_4_DATA 0x12 | ||
79 | #define PT4_P1_REG 0xB521 | ||
80 | #define PT4_P2_REG 0xB522 | ||
81 | #define PT2_P1_REG 0xD520 | ||
82 | #define PT2_P2_REG 0xD521 | ||
83 | #define PT1_P1_REG 0xD522 | ||
84 | #define PT1_P2_REG 0xD523 | ||
85 | |||
69 | #define NB_PCIE_INDX_ADDR 0xe0 | 86 | #define NB_PCIE_INDX_ADDR 0xe0 |
70 | #define NB_PCIE_INDX_DATA 0xe4 | 87 | #define NB_PCIE_INDX_DATA 0xe4 |
71 | #define PCIE_P_CNTL 0x10040 | 88 | #define PCIE_P_CNTL 0x10040 |
@@ -513,6 +530,98 @@ void usb_amd_dev_put(void) | |||
513 | EXPORT_SYMBOL_GPL(usb_amd_dev_put); | 530 | EXPORT_SYMBOL_GPL(usb_amd_dev_put); |
514 | 531 | ||
515 | /* | 532 | /* |
533 | * Check if port is disabled in BIOS on AMD Promontory host. | ||
534 | * BIOS Disabled ports may wake on connect/disconnect and need | ||
535 | * driver workaround to keep them disabled. | ||
536 | * Returns true if port is marked disabled. | ||
537 | */ | ||
538 | bool usb_amd_pt_check_port(struct device *device, int port) | ||
539 | { | ||
540 | unsigned char value, port_shift; | ||
541 | struct pci_dev *pdev; | ||
542 | u16 reg; | ||
543 | |||
544 | pdev = to_pci_dev(device); | ||
545 | pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_1_ADDR); | ||
546 | |||
547 | pci_read_config_byte(pdev, PT_READ_INDX, &value); | ||
548 | if (value != PT_SIG_1_DATA) | ||
549 | return false; | ||
550 | |||
551 | pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_2_ADDR); | ||
552 | |||
553 | pci_read_config_byte(pdev, PT_READ_INDX, &value); | ||
554 | if (value != PT_SIG_2_DATA) | ||
555 | return false; | ||
556 | |||
557 | pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_3_ADDR); | ||
558 | |||
559 | pci_read_config_byte(pdev, PT_READ_INDX, &value); | ||
560 | if (value != PT_SIG_3_DATA) | ||
561 | return false; | ||
562 | |||
563 | pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_4_ADDR); | ||
564 | |||
565 | pci_read_config_byte(pdev, PT_READ_INDX, &value); | ||
566 | if (value != PT_SIG_4_DATA) | ||
567 | return false; | ||
568 | |||
569 | /* Check disabled port setting, if bit is set port is enabled */ | ||
570 | switch (pdev->device) { | ||
571 | case 0x43b9: | ||
572 | case 0x43ba: | ||
573 | /* | ||
574 | * device is AMD_PROMONTORYA_4(0x43b9) or PROMONTORYA_3(0x43ba) | ||
575 | * PT4_P1_REG bits[7..1] represents USB2.0 ports 6 to 0 | ||
576 | * PT4_P2_REG bits[6..0] represents ports 13 to 7 | ||
577 | */ | ||
578 | if (port > 6) { | ||
579 | reg = PT4_P2_REG; | ||
580 | port_shift = port - 7; | ||
581 | } else { | ||
582 | reg = PT4_P1_REG; | ||
583 | port_shift = port + 1; | ||
584 | } | ||
585 | break; | ||
586 | case 0x43bb: | ||
587 | /* | ||
588 | * device is AMD_PROMONTORYA_2(0x43bb) | ||
589 | * PT2_P1_REG bits[7..5] represents USB2.0 ports 2 to 0 | ||
590 | * PT2_P2_REG bits[5..0] represents ports 9 to 3 | ||
591 | */ | ||
592 | if (port > 2) { | ||
593 | reg = PT2_P2_REG; | ||
594 | port_shift = port - 3; | ||
595 | } else { | ||
596 | reg = PT2_P1_REG; | ||
597 | port_shift = port + 5; | ||
598 | } | ||
599 | break; | ||
600 | case 0x43bc: | ||
601 | /* | ||
602 | * device is AMD_PROMONTORYA_1(0x43bc) | ||
603 | * PT1_P1_REG[7..4] represents USB2.0 ports 3 to 0 | ||
604 | * PT1_P2_REG[5..0] represents ports 9 to 4 | ||
605 | */ | ||
606 | if (port > 3) { | ||
607 | reg = PT1_P2_REG; | ||
608 | port_shift = port - 4; | ||
609 | } else { | ||
610 | reg = PT1_P1_REG; | ||
611 | port_shift = port + 4; | ||
612 | } | ||
613 | break; | ||
614 | default: | ||
615 | return false; | ||
616 | } | ||
617 | pci_write_config_word(pdev, PT_ADDR_INDX, reg); | ||
618 | pci_read_config_byte(pdev, PT_READ_INDX, &value); | ||
619 | |||
620 | return !(value & BIT(port_shift)); | ||
621 | } | ||
622 | EXPORT_SYMBOL_GPL(usb_amd_pt_check_port); | ||
623 | |||
624 | /* | ||
516 | * Make sure the controller is completely inactive, unable to | 625 | * Make sure the controller is completely inactive, unable to |
517 | * generate interrupts or do DMA. | 626 | * generate interrupts or do DMA. |
518 | */ | 627 | */ |
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h index b68dcb5dd0fd..4ca0d9b7e463 100644 --- a/drivers/usb/host/pci-quirks.h +++ b/drivers/usb/host/pci-quirks.h | |||
@@ -17,6 +17,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev); | |||
17 | void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); | 17 | void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); |
18 | void sb800_prefetch(struct device *dev, int on); | 18 | void sb800_prefetch(struct device *dev, int on); |
19 | bool usb_xhci_needs_pci_reset(struct pci_dev *pdev); | 19 | bool usb_xhci_needs_pci_reset(struct pci_dev *pdev); |
20 | bool usb_amd_pt_check_port(struct device *device, int port); | ||
20 | #else | 21 | #else |
21 | struct pci_dev; | 22 | struct pci_dev; |
22 | static inline void usb_amd_quirk_pll_disable(void) {} | 23 | static inline void usb_amd_quirk_pll_disable(void) {} |
@@ -25,6 +26,10 @@ static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {} | |||
25 | static inline void usb_amd_dev_put(void) {} | 26 | static inline void usb_amd_dev_put(void) {} |
26 | static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {} | 27 | static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {} |
27 | static inline void sb800_prefetch(struct device *dev, int on) {} | 28 | static inline void sb800_prefetch(struct device *dev, int on) {} |
29 | static inline bool usb_amd_pt_check_port(struct device *device, int port) | ||
30 | { | ||
31 | return false; | ||
32 | } | ||
28 | #endif /* CONFIG_USB_PCI */ | 33 | #endif /* CONFIG_USB_PCI */ |
29 | 34 | ||
30 | #endif /* __LINUX_USB_PCI_QUIRKS_H */ | 35 | #endif /* __LINUX_USB_PCI_QUIRKS_H */ |
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c index e26e685d8a57..5851052d4668 100644 --- a/drivers/usb/host/xhci-debugfs.c +++ b/drivers/usb/host/xhci-debugfs.c | |||
@@ -211,7 +211,7 @@ static void xhci_ring_dump_segment(struct seq_file *s, | |||
211 | static int xhci_ring_trb_show(struct seq_file *s, void *unused) | 211 | static int xhci_ring_trb_show(struct seq_file *s, void *unused) |
212 | { | 212 | { |
213 | int i; | 213 | int i; |
214 | struct xhci_ring *ring = s->private; | 214 | struct xhci_ring *ring = *(struct xhci_ring **)s->private; |
215 | struct xhci_segment *seg = ring->first_seg; | 215 | struct xhci_segment *seg = ring->first_seg; |
216 | 216 | ||
217 | for (i = 0; i < ring->num_segs; i++) { | 217 | for (i = 0; i < ring->num_segs; i++) { |
@@ -387,7 +387,7 @@ void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci, | |||
387 | 387 | ||
388 | snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index); | 388 | snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index); |
389 | epriv->root = xhci_debugfs_create_ring_dir(xhci, | 389 | epriv->root = xhci_debugfs_create_ring_dir(xhci, |
390 | &dev->eps[ep_index].new_ring, | 390 | &dev->eps[ep_index].ring, |
391 | epriv->name, | 391 | epriv->name, |
392 | spriv->root); | 392 | spriv->root); |
393 | spriv->eps[ep_index] = epriv; | 393 | spriv->eps[ep_index] = epriv; |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 46d5e08f05f1..72ebbc908e19 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -1224,17 +1224,17 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
1224 | temp = readl(port_array[wIndex]); | 1224 | temp = readl(port_array[wIndex]); |
1225 | break; | 1225 | break; |
1226 | } | 1226 | } |
1227 | 1227 | /* Port must be enabled */ | |
1228 | /* Software should not attempt to set | 1228 | if (!(temp & PORT_PE)) { |
1229 | * port link state above '3' (U3) and the port | 1229 | retval = -ENODEV; |
1230 | * must be enabled. | 1230 | break; |
1231 | */ | 1231 | } |
1232 | if ((temp & PORT_PE) == 0 || | 1232 | /* Can't set port link state above '3' (U3) */ |
1233 | (link_state > USB_SS_PORT_LS_U3)) { | 1233 | if (link_state > USB_SS_PORT_LS_U3) { |
1234 | xhci_warn(xhci, "Cannot set link state.\n"); | 1234 | xhci_warn(xhci, "Cannot set port %d link state %d\n", |
1235 | wIndex, link_state); | ||
1235 | goto error; | 1236 | goto error; |
1236 | } | 1237 | } |
1237 | |||
1238 | if (link_state == USB_SS_PORT_LS_U3) { | 1238 | if (link_state == USB_SS_PORT_LS_U3) { |
1239 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | 1239 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, |
1240 | wIndex + 1); | 1240 | wIndex + 1); |
@@ -1522,6 +1522,13 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
1522 | t2 |= PORT_WKOC_E | PORT_WKCONN_E; | 1522 | t2 |= PORT_WKOC_E | PORT_WKCONN_E; |
1523 | t2 &= ~PORT_WKDISC_E; | 1523 | t2 &= ~PORT_WKDISC_E; |
1524 | } | 1524 | } |
1525 | |||
1526 | if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && | ||
1527 | (hcd->speed < HCD_USB3)) { | ||
1528 | if (usb_amd_pt_check_port(hcd->self.controller, | ||
1529 | port_index)) | ||
1530 | t2 &= ~PORT_WAKE_BITS; | ||
1531 | } | ||
1525 | } else | 1532 | } else |
1526 | t2 &= ~PORT_WAKE_BITS; | 1533 | t2 &= ~PORT_WAKE_BITS; |
1527 | 1534 | ||
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 6c79037876db..5262fa571a5d 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -42,6 +42,10 @@ | |||
42 | #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 | 42 | #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 |
43 | #define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0 | 43 | #define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0 |
44 | 44 | ||
45 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9 | ||
46 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba | ||
47 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb | ||
48 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc | ||
45 | #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 | 49 | #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 |
46 | 50 | ||
47 | static const char hcd_name[] = "xhci_hcd"; | 51 | static const char hcd_name[] = "xhci_hcd"; |
@@ -125,6 +129,13 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
125 | if (pdev->vendor == PCI_VENDOR_ID_AMD) | 129 | if (pdev->vendor == PCI_VENDOR_ID_AMD) |
126 | xhci->quirks |= XHCI_TRUST_TX_LENGTH; | 130 | xhci->quirks |= XHCI_TRUST_TX_LENGTH; |
127 | 131 | ||
132 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) && | ||
133 | ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) || | ||
134 | (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) || | ||
135 | (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2) || | ||
136 | (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1))) | ||
137 | xhci->quirks |= XHCI_U2_DISABLE_WAKE; | ||
138 | |||
128 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 139 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
129 | xhci->quirks |= XHCI_LPM_SUPPORT; | 140 | xhci->quirks |= XHCI_LPM_SUPPORT; |
130 | xhci->quirks |= XHCI_INTEL_HOST; | 141 | xhci->quirks |= XHCI_INTEL_HOST; |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1eeb3396300f..25d4b748a56f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -646,8 +646,6 @@ static void xhci_stop(struct usb_hcd *hcd) | |||
646 | return; | 646 | return; |
647 | } | 647 | } |
648 | 648 | ||
649 | xhci_debugfs_exit(xhci); | ||
650 | |||
651 | xhci_dbc_exit(xhci); | 649 | xhci_dbc_exit(xhci); |
652 | 650 | ||
653 | spin_lock_irq(&xhci->lock); | 651 | spin_lock_irq(&xhci->lock); |
@@ -680,6 +678,7 @@ static void xhci_stop(struct usb_hcd *hcd) | |||
680 | 678 | ||
681 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory"); | 679 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory"); |
682 | xhci_mem_cleanup(xhci); | 680 | xhci_mem_cleanup(xhci); |
681 | xhci_debugfs_exit(xhci); | ||
683 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, | 682 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, |
684 | "xhci_stop completed - status = %x", | 683 | "xhci_stop completed - status = %x", |
685 | readl(&xhci->op_regs->status)); | 684 | readl(&xhci->op_regs->status)); |
@@ -1014,6 +1013,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
1014 | 1013 | ||
1015 | xhci_dbg(xhci, "cleaning up memory\n"); | 1014 | xhci_dbg(xhci, "cleaning up memory\n"); |
1016 | xhci_mem_cleanup(xhci); | 1015 | xhci_mem_cleanup(xhci); |
1016 | xhci_debugfs_exit(xhci); | ||
1017 | xhci_dbg(xhci, "xhci_stop completed - status = %x\n", | 1017 | xhci_dbg(xhci, "xhci_stop completed - status = %x\n", |
1018 | readl(&xhci->op_regs->status)); | 1018 | readl(&xhci->op_regs->status)); |
1019 | 1019 | ||
@@ -3544,12 +3544,10 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) | |||
3544 | virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING; | 3544 | virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING; |
3545 | del_timer_sync(&virt_dev->eps[i].stop_cmd_timer); | 3545 | del_timer_sync(&virt_dev->eps[i].stop_cmd_timer); |
3546 | } | 3546 | } |
3547 | 3547 | xhci_debugfs_remove_slot(xhci, udev->slot_id); | |
3548 | ret = xhci_disable_slot(xhci, udev->slot_id); | 3548 | ret = xhci_disable_slot(xhci, udev->slot_id); |
3549 | if (ret) { | 3549 | if (ret) |
3550 | xhci_debugfs_remove_slot(xhci, udev->slot_id); | ||
3551 | xhci_free_virt_device(xhci, udev->slot_id); | 3550 | xhci_free_virt_device(xhci, udev->slot_id); |
3552 | } | ||
3553 | } | 3551 | } |
3554 | 3552 | ||
3555 | int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) | 3553 | int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 96099a245c69..e4d7d3d06a75 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1822,7 +1822,7 @@ struct xhci_hcd { | |||
1822 | /* For controller with a broken Port Disable implementation */ | 1822 | /* For controller with a broken Port Disable implementation */ |
1823 | #define XHCI_BROKEN_PORT_PED (1 << 25) | 1823 | #define XHCI_BROKEN_PORT_PED (1 << 25) |
1824 | #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) | 1824 | #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) |
1825 | /* Reserved. It was XHCI_U2_DISABLE_WAKE */ | 1825 | #define XHCI_U2_DISABLE_WAKE (1 << 27) |
1826 | #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) | 1826 | #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) |
1827 | #define XHCI_HW_LPM_DISABLE (1 << 29) | 1827 | #define XHCI_HW_LPM_DISABLE (1 << 29) |
1828 | 1828 | ||
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 63b9e85dc0e9..236a60f53099 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -42,6 +42,9 @@ | |||
42 | #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */ | 42 | #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */ |
43 | #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */ | 43 | #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */ |
44 | #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */ | 44 | #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */ |
45 | #define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 /* USB Product ID of Power Analyser CASSY */ | ||
46 | #define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 /* USB Product ID of Converter Controller CASSY */ | ||
47 | #define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 /* USB Product ID of Machine Test CASSY */ | ||
45 | #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ | 48 | #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ |
46 | #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ | 49 | #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ |
47 | #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ | 50 | #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ |
@@ -84,6 +87,9 @@ static const struct usb_device_id ld_usb_table[] = { | |||
84 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, | 87 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, |
85 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, | 88 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, |
86 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, | 89 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, |
90 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, | ||
91 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, | ||
92 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, | ||
87 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, | 93 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
88 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, | 94 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
89 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, | 95 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 968bf1e8b0fe..eef4ad578b31 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -2708,7 +2708,8 @@ static int musb_resume(struct device *dev) | |||
2708 | if ((devctl & mask) != (musb->context.devctl & mask)) | 2708 | if ((devctl & mask) != (musb->context.devctl & mask)) |
2709 | musb->port1_status = 0; | 2709 | musb->port1_status = 0; |
2710 | 2710 | ||
2711 | musb_start(musb); | 2711 | musb_enable_interrupts(musb); |
2712 | musb_platform_enable(musb); | ||
2712 | 2713 | ||
2713 | spin_lock_irqsave(&musb->lock, flags); | 2714 | spin_lock_irqsave(&musb->lock, flags); |
2714 | error = musb_run_resume_work(musb); | 2715 | error = musb_run_resume_work(musb); |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 394b4ac86161..45ed32c2cba9 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -391,13 +391,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, | |||
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | /* | 394 | if (qh != NULL && qh->is_ready) { |
395 | * The pipe must be broken if current urb->status is set, so don't | ||
396 | * start next urb. | ||
397 | * TODO: to minimize the risk of regression, only check urb->status | ||
398 | * for RX, until we have a test case to understand the behavior of TX. | ||
399 | */ | ||
400 | if ((!status || !is_in) && qh && qh->is_ready) { | ||
401 | musb_dbg(musb, "... next ep%d %cX urb %p", | 395 | musb_dbg(musb, "... next ep%d %cX urb %p", |
402 | hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); | 396 | hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); |
403 | musb_start_urb(musb, is_in, qh); | 397 | musb_start_urb(musb, is_in, qh); |
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index da031c45395a..fbec863350f6 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c | |||
@@ -602,6 +602,9 @@ static enum usb_charger_type mxs_phy_charger_detect(struct usb_phy *phy) | |||
602 | void __iomem *base = phy->io_priv; | 602 | void __iomem *base = phy->io_priv; |
603 | enum usb_charger_type chgr_type = UNKNOWN_TYPE; | 603 | enum usb_charger_type chgr_type = UNKNOWN_TYPE; |
604 | 604 | ||
605 | if (!regmap) | ||
606 | return UNKNOWN_TYPE; | ||
607 | |||
605 | if (mxs_charger_data_contact_detect(mxs_phy)) | 608 | if (mxs_charger_data_contact_detect(mxs_phy)) |
606 | return chgr_type; | 609 | return chgr_type; |
607 | 610 | ||
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 5925d111bd47..39fa2fc1b8b7 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -982,6 +982,10 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt, | |||
982 | if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1)) | 982 | if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1)) |
983 | goto usbhsf_pio_prepare_pop; | 983 | goto usbhsf_pio_prepare_pop; |
984 | 984 | ||
985 | /* return at this time if the pipe is running */ | ||
986 | if (usbhs_pipe_is_running(pipe)) | ||
987 | return 0; | ||
988 | |||
985 | usbhs_pipe_config_change_bfre(pipe, 1); | 989 | usbhs_pipe_config_change_bfre(pipe, 1); |
986 | 990 | ||
987 | ret = usbhsf_fifo_select(pipe, fifo, 0); | 991 | ret = usbhsf_fifo_select(pipe, fifo, 0); |
@@ -1172,6 +1176,7 @@ static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt, | |||
1172 | usbhsf_fifo_clear(pipe, fifo); | 1176 | usbhsf_fifo_clear(pipe, fifo); |
1173 | pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len); | 1177 | pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len); |
1174 | 1178 | ||
1179 | usbhs_pipe_running(pipe, 0); | ||
1175 | usbhsf_dma_stop(pipe, fifo); | 1180 | usbhsf_dma_stop(pipe, fifo); |
1176 | usbhsf_dma_unmap(pkt); | 1181 | usbhsf_dma_unmap(pkt); |
1177 | usbhsf_fifo_unselect(pipe, pipe->fifo); | 1182 | usbhsf_fifo_unselect(pipe, pipe->fifo); |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 5db8ed517e0e..2d8d9150da0c 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -241,6 +241,7 @@ static void option_instat_callback(struct urb *urb); | |||
241 | #define QUECTEL_PRODUCT_EC21 0x0121 | 241 | #define QUECTEL_PRODUCT_EC21 0x0121 |
242 | #define QUECTEL_PRODUCT_EC25 0x0125 | 242 | #define QUECTEL_PRODUCT_EC25 0x0125 |
243 | #define QUECTEL_PRODUCT_BG96 0x0296 | 243 | #define QUECTEL_PRODUCT_BG96 0x0296 |
244 | #define QUECTEL_PRODUCT_EP06 0x0306 | ||
244 | 245 | ||
245 | #define CMOTECH_VENDOR_ID 0x16d8 | 246 | #define CMOTECH_VENDOR_ID 0x16d8 |
246 | #define CMOTECH_PRODUCT_6001 0x6001 | 247 | #define CMOTECH_PRODUCT_6001 0x6001 |
@@ -689,6 +690,10 @@ static const struct option_blacklist_info yuga_clm920_nc5_blacklist = { | |||
689 | .reserved = BIT(1) | BIT(4), | 690 | .reserved = BIT(1) | BIT(4), |
690 | }; | 691 | }; |
691 | 692 | ||
693 | static const struct option_blacklist_info quectel_ep06_blacklist = { | ||
694 | .reserved = BIT(4) | BIT(5), | ||
695 | }; | ||
696 | |||
692 | static const struct usb_device_id option_ids[] = { | 697 | static const struct usb_device_id option_ids[] = { |
693 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 698 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
694 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 699 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -1203,6 +1208,8 @@ static const struct usb_device_id option_ids[] = { | |||
1203 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 1208 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1204 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), | 1209 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), |
1205 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 1210 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1211 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), | ||
1212 | .driver_info = (kernel_ulong_t)&quectel_ep06_blacklist }, | ||
1206 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, | 1213 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, |
1207 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, | 1214 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, |
1208 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), | 1215 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), |
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index 49e552472c3f..dd8ef36ab10e 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c | |||
@@ -73,6 +73,7 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a | |||
73 | goto err; | 73 | goto err; |
74 | 74 | ||
75 | sdev->ud.tcp_socket = socket; | 75 | sdev->ud.tcp_socket = socket; |
76 | sdev->ud.sockfd = sockfd; | ||
76 | 77 | ||
77 | spin_unlock_irq(&sdev->ud.lock); | 78 | spin_unlock_irq(&sdev->ud.lock); |
78 | 79 | ||
@@ -172,6 +173,7 @@ static void stub_shutdown_connection(struct usbip_device *ud) | |||
172 | if (ud->tcp_socket) { | 173 | if (ud->tcp_socket) { |
173 | sockfd_put(ud->tcp_socket); | 174 | sockfd_put(ud->tcp_socket); |
174 | ud->tcp_socket = NULL; | 175 | ud->tcp_socket = NULL; |
176 | ud->sockfd = -1; | ||
175 | } | 177 | } |
176 | 178 | ||
177 | /* 3. free used data */ | 179 | /* 3. free used data */ |
@@ -266,6 +268,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev) | |||
266 | sdev->ud.status = SDEV_ST_AVAILABLE; | 268 | sdev->ud.status = SDEV_ST_AVAILABLE; |
267 | spin_lock_init(&sdev->ud.lock); | 269 | spin_lock_init(&sdev->ud.lock); |
268 | sdev->ud.tcp_socket = NULL; | 270 | sdev->ud.tcp_socket = NULL; |
271 | sdev->ud.sockfd = -1; | ||
269 | 272 | ||
270 | INIT_LIST_HEAD(&sdev->priv_init); | 273 | INIT_LIST_HEAD(&sdev->priv_init); |
271 | INIT_LIST_HEAD(&sdev->priv_tx); | 274 | INIT_LIST_HEAD(&sdev->priv_tx); |
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index c3e1008aa491..20e3d4609583 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c | |||
@@ -984,6 +984,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) | |||
984 | if (vdev->ud.tcp_socket) { | 984 | if (vdev->ud.tcp_socket) { |
985 | sockfd_put(vdev->ud.tcp_socket); | 985 | sockfd_put(vdev->ud.tcp_socket); |
986 | vdev->ud.tcp_socket = NULL; | 986 | vdev->ud.tcp_socket = NULL; |
987 | vdev->ud.sockfd = -1; | ||
987 | } | 988 | } |
988 | pr_info("release socket\n"); | 989 | pr_info("release socket\n"); |
989 | 990 | ||
@@ -1030,6 +1031,7 @@ static void vhci_device_reset(struct usbip_device *ud) | |||
1030 | if (ud->tcp_socket) { | 1031 | if (ud->tcp_socket) { |
1031 | sockfd_put(ud->tcp_socket); | 1032 | sockfd_put(ud->tcp_socket); |
1032 | ud->tcp_socket = NULL; | 1033 | ud->tcp_socket = NULL; |
1034 | ud->sockfd = -1; | ||
1033 | } | 1035 | } |
1034 | ud->status = VDEV_ST_NULL; | 1036 | ud->status = VDEV_ST_NULL; |
1035 | 1037 | ||
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c index bf13d1ec51f3..04e7b3b29bac 100644 --- a/drivers/xen/tmem.c +++ b/drivers/xen/tmem.c | |||
@@ -284,6 +284,10 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset, | |||
284 | int pool = tmem_frontswap_poolid; | 284 | int pool = tmem_frontswap_poolid; |
285 | int ret; | 285 | int ret; |
286 | 286 | ||
287 | /* THP isn't supported */ | ||
288 | if (PageTransHuge(page)) | ||
289 | return -1; | ||
290 | |||
287 | if (pool < 0) | 291 | if (pool < 0) |
288 | return -1; | 292 | return -1; |
289 | if (ind64 != ind) | 293 | if (ind64 != ind) |
diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c index 5f22e74bbade..8e568428c88b 100644 --- a/fs/efivarfs/file.c +++ b/fs/efivarfs/file.c | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/efi.h> | 10 | #include <linux/efi.h> |
11 | #include <linux/delay.h> | ||
11 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
13 | #include <linux/mount.h> | 14 | #include <linux/mount.h> |
@@ -74,6 +75,11 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, | |||
74 | ssize_t size = 0; | 75 | ssize_t size = 0; |
75 | int err; | 76 | int err; |
76 | 77 | ||
78 | while (!__ratelimit(&file->f_cred->user->ratelimit)) { | ||
79 | if (!msleep_interruptible(50)) | ||
80 | return -EINTR; | ||
81 | } | ||
82 | |||
77 | err = efivar_entry_size(var, &datasize); | 83 | err = efivar_entry_size(var, &datasize); |
78 | 84 | ||
79 | /* | 85 | /* |
diff --git a/fs/signalfd.c b/fs/signalfd.c index 9990957264e3..76bf9cc62074 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c | |||
@@ -118,13 +118,22 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, | |||
118 | err |= __put_user(kinfo->si_trapno, &uinfo->ssi_trapno); | 118 | err |= __put_user(kinfo->si_trapno, &uinfo->ssi_trapno); |
119 | #endif | 119 | #endif |
120 | #ifdef BUS_MCEERR_AO | 120 | #ifdef BUS_MCEERR_AO |
121 | /* | 121 | /* |
122 | * Other callers might not initialize the si_lsb field, | ||
123 | * so check explicitly for the right codes here. | ||
124 | */ | ||
125 | if (kinfo->si_signo == SIGBUS && | ||
126 | kinfo->si_code == BUS_MCEERR_AO) | ||
127 | err |= __put_user((short) kinfo->si_addr_lsb, | ||
128 | &uinfo->ssi_addr_lsb); | ||
129 | #endif | ||
130 | #ifdef BUS_MCEERR_AR | ||
131 | /* | ||
122 | * Other callers might not initialize the si_lsb field, | 132 | * Other callers might not initialize the si_lsb field, |
123 | * so check explicitly for the right codes here. | 133 | * so check explicitly for the right codes here. |
124 | */ | 134 | */ |
125 | if (kinfo->si_signo == SIGBUS && | 135 | if (kinfo->si_signo == SIGBUS && |
126 | (kinfo->si_code == BUS_MCEERR_AR || | 136 | kinfo->si_code == BUS_MCEERR_AR) |
127 | kinfo->si_code == BUS_MCEERR_AO)) | ||
128 | err |= __put_user((short) kinfo->si_addr_lsb, | 137 | err |= __put_user((short) kinfo->si_addr_lsb, |
129 | &uinfo->ssi_addr_lsb); | 138 | &uinfo->ssi_addr_lsb); |
130 | #endif | 139 | #endif |
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 963b755d19b0..a7613e1b0c87 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -52,6 +52,7 @@ struct bug_entry { | |||
52 | #ifndef HAVE_ARCH_BUG | 52 | #ifndef HAVE_ARCH_BUG |
53 | #define BUG() do { \ | 53 | #define BUG() do { \ |
54 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ | 54 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ |
55 | barrier_before_unreachable(); \ | ||
55 | panic("BUG!"); \ | 56 | panic("BUG!"); \ |
56 | } while (0) | 57 | } while (0) |
57 | #endif | 58 | #endif |
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 1c27526c499e..cf13842a6dbd 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h | |||
@@ -134,6 +134,15 @@ struct drm_crtc_commit { | |||
134 | * &drm_pending_vblank_event pointer to clean up private events. | 134 | * &drm_pending_vblank_event pointer to clean up private events. |
135 | */ | 135 | */ |
136 | struct drm_pending_vblank_event *event; | 136 | struct drm_pending_vblank_event *event; |
137 | |||
138 | /** | ||
139 | * @abort_completion: | ||
140 | * | ||
141 | * A flag that's set after drm_atomic_helper_setup_commit takes a second | ||
142 | * reference for the completion of $drm_crtc_state.event. It's used by | ||
143 | * the free code to remove the second reference if commit fails. | ||
144 | */ | ||
145 | bool abort_completion; | ||
137 | }; | 146 | }; |
138 | 147 | ||
139 | struct __drm_planes_state { | 148 | struct __drm_planes_state { |
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h index 76e237bd989b..6914633037a5 100644 --- a/include/drm/drm_crtc_helper.h +++ b/include/drm/drm_crtc_helper.h | |||
@@ -77,5 +77,6 @@ void drm_kms_helper_hotplug_event(struct drm_device *dev); | |||
77 | 77 | ||
78 | void drm_kms_helper_poll_disable(struct drm_device *dev); | 78 | void drm_kms_helper_poll_disable(struct drm_device *dev); |
79 | void drm_kms_helper_poll_enable(struct drm_device *dev); | 79 | void drm_kms_helper_poll_enable(struct drm_device *dev); |
80 | bool drm_kms_helper_is_poll_worker(void); | ||
80 | 81 | ||
81 | #endif | 82 | #endif |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 73bc63e0a1c4..901c1ccb3374 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -208,6 +208,15 @@ | |||
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | /* | 210 | /* |
211 | * calling noreturn functions, __builtin_unreachable() and __builtin_trap() | ||
212 | * confuse the stack allocation in gcc, leading to overly large stack | ||
213 | * frames, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 | ||
214 | * | ||
215 | * Adding an empty inline assembly before it works around the problem | ||
216 | */ | ||
217 | #define barrier_before_unreachable() asm volatile("") | ||
218 | |||
219 | /* | ||
211 | * Mark a position in code as unreachable. This can be used to | 220 | * Mark a position in code as unreachable. This can be used to |
212 | * suppress control flow warnings after asm blocks that transfer | 221 | * suppress control flow warnings after asm blocks that transfer |
213 | * control elsewhere. | 222 | * control elsewhere. |
@@ -217,7 +226,11 @@ | |||
217 | * unreleased. Really, we need to have autoconf for the kernel. | 226 | * unreleased. Really, we need to have autoconf for the kernel. |
218 | */ | 227 | */ |
219 | #define unreachable() \ | 228 | #define unreachable() \ |
220 | do { annotate_unreachable(); __builtin_unreachable(); } while (0) | 229 | do { \ |
230 | annotate_unreachable(); \ | ||
231 | barrier_before_unreachable(); \ | ||
232 | __builtin_unreachable(); \ | ||
233 | } while (0) | ||
221 | 234 | ||
222 | /* Mark a function definition as prohibited from being cloned. */ | 235 | /* Mark a function definition as prohibited from being cloned. */ |
223 | #define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) | 236 | #define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e835fc0423ec..ab4711c63601 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -86,6 +86,11 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
86 | # define barrier_data(ptr) barrier() | 86 | # define barrier_data(ptr) barrier() |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* workaround for GCC PR82365 if needed */ | ||
90 | #ifndef barrier_before_unreachable | ||
91 | # define barrier_before_unreachable() do { } while (0) | ||
92 | #endif | ||
93 | |||
89 | /* Unreachable code */ | 94 | /* Unreachable code */ |
90 | #ifdef CONFIG_STACK_VALIDATION | 95 | #ifdef CONFIG_STACK_VALIDATION |
91 | /* | 96 | /* |
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index fec5076eda91..dcde9471897d 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h | |||
@@ -4,6 +4,12 @@ | |||
4 | 4 | ||
5 | #include <generated/autoconf.h> | 5 | #include <generated/autoconf.h> |
6 | 6 | ||
7 | #ifdef CONFIG_CPU_BIG_ENDIAN | ||
8 | #define __BIG_ENDIAN 4321 | ||
9 | #else | ||
10 | #define __LITTLE_ENDIAN 1234 | ||
11 | #endif | ||
12 | |||
7 | #define __ARG_PLACEHOLDER_1 0, | 13 | #define __ARG_PLACEHOLDER_1 0, |
8 | #define __take_second_arg(__ignored, val, ...) val | 14 | #define __take_second_arg(__ignored, val, ...) val |
9 | 15 | ||
@@ -64,4 +70,7 @@ | |||
64 | */ | 70 | */ |
65 | #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) | 71 | #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) |
66 | 72 | ||
73 | /* Make sure we always have all types and struct attributes defined. */ | ||
74 | #include <linux/compiler_types.h> | ||
75 | |||
67 | #endif /* __LINUX_KCONFIG_H */ | 76 | #endif /* __LINUX_KCONFIG_H */ |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 882046863581..c46016bb25eb 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -523,9 +523,11 @@ static inline void __mod_memcg_state(struct mem_cgroup *memcg, | |||
523 | static inline void mod_memcg_state(struct mem_cgroup *memcg, | 523 | static inline void mod_memcg_state(struct mem_cgroup *memcg, |
524 | int idx, int val) | 524 | int idx, int val) |
525 | { | 525 | { |
526 | preempt_disable(); | 526 | unsigned long flags; |
527 | |||
528 | local_irq_save(flags); | ||
527 | __mod_memcg_state(memcg, idx, val); | 529 | __mod_memcg_state(memcg, idx, val); |
528 | preempt_enable(); | 530 | local_irq_restore(flags); |
529 | } | 531 | } |
530 | 532 | ||
531 | /** | 533 | /** |
@@ -606,9 +608,11 @@ static inline void __mod_lruvec_state(struct lruvec *lruvec, | |||
606 | static inline void mod_lruvec_state(struct lruvec *lruvec, | 608 | static inline void mod_lruvec_state(struct lruvec *lruvec, |
607 | enum node_stat_item idx, int val) | 609 | enum node_stat_item idx, int val) |
608 | { | 610 | { |
609 | preempt_disable(); | 611 | unsigned long flags; |
612 | |||
613 | local_irq_save(flags); | ||
610 | __mod_lruvec_state(lruvec, idx, val); | 614 | __mod_lruvec_state(lruvec, idx, val); |
611 | preempt_enable(); | 615 | local_irq_restore(flags); |
612 | } | 616 | } |
613 | 617 | ||
614 | static inline void __mod_lruvec_page_state(struct page *page, | 618 | static inline void __mod_lruvec_page_state(struct page *page, |
@@ -630,9 +634,11 @@ static inline void __mod_lruvec_page_state(struct page *page, | |||
630 | static inline void mod_lruvec_page_state(struct page *page, | 634 | static inline void mod_lruvec_page_state(struct page *page, |
631 | enum node_stat_item idx, int val) | 635 | enum node_stat_item idx, int val) |
632 | { | 636 | { |
633 | preempt_disable(); | 637 | unsigned long flags; |
638 | |||
639 | local_irq_save(flags); | ||
634 | __mod_lruvec_page_state(page, idx, val); | 640 | __mod_lruvec_page_state(page, idx, val); |
635 | preempt_enable(); | 641 | local_irq_restore(flags); |
636 | } | 642 | } |
637 | 643 | ||
638 | unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, | 644 | unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, |
@@ -659,9 +665,11 @@ static inline void __count_memcg_events(struct mem_cgroup *memcg, | |||
659 | static inline void count_memcg_events(struct mem_cgroup *memcg, | 665 | static inline void count_memcg_events(struct mem_cgroup *memcg, |
660 | int idx, unsigned long count) | 666 | int idx, unsigned long count) |
661 | { | 667 | { |
662 | preempt_disable(); | 668 | unsigned long flags; |
669 | |||
670 | local_irq_save(flags); | ||
663 | __count_memcg_events(memcg, idx, count); | 671 | __count_memcg_events(memcg, idx, count); |
664 | preempt_enable(); | 672 | local_irq_restore(flags); |
665 | } | 673 | } |
666 | 674 | ||
667 | /* idx can be of type enum memcg_event_item or vm_event_item */ | 675 | /* idx can be of type enum memcg_event_item or vm_event_item */ |
diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index af0f44effd44..40036a57d072 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h | |||
@@ -14,26 +14,10 @@ | |||
14 | 14 | ||
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/perf_event.h> | 16 | #include <linux/perf_event.h> |
17 | #include <linux/platform_device.h> | ||
17 | #include <linux/sysfs.h> | 18 | #include <linux/sysfs.h> |
18 | #include <asm/cputype.h> | 19 | #include <asm/cputype.h> |
19 | 20 | ||
20 | /* | ||
21 | * struct arm_pmu_platdata - ARM PMU platform data | ||
22 | * | ||
23 | * @handle_irq: an optional handler which will be called from the | ||
24 | * interrupt and passed the address of the low level handler, | ||
25 | * and can be used to implement any platform specific handling | ||
26 | * before or after calling it. | ||
27 | * | ||
28 | * @irq_flags: if non-zero, these flags will be passed to request_irq | ||
29 | * when requesting interrupts for this PMU device. | ||
30 | */ | ||
31 | struct arm_pmu_platdata { | ||
32 | irqreturn_t (*handle_irq)(int irq, void *dev, | ||
33 | irq_handler_t pmu_handler); | ||
34 | unsigned long irq_flags; | ||
35 | }; | ||
36 | |||
37 | #ifdef CONFIG_ARM_PMU | 21 | #ifdef CONFIG_ARM_PMU |
38 | 22 | ||
39 | /* | 23 | /* |
@@ -92,7 +76,6 @@ enum armpmu_attr_groups { | |||
92 | 76 | ||
93 | struct arm_pmu { | 77 | struct arm_pmu { |
94 | struct pmu pmu; | 78 | struct pmu pmu; |
95 | cpumask_t active_irqs; | ||
96 | cpumask_t supported_cpus; | 79 | cpumask_t supported_cpus; |
97 | char *name; | 80 | char *name; |
98 | irqreturn_t (*handle_irq)(int irq_num, void *dev); | 81 | irqreturn_t (*handle_irq)(int irq_num, void *dev); |
@@ -174,12 +157,11 @@ static inline int arm_pmu_acpi_probe(armpmu_init_fn init_fn) { return 0; } | |||
174 | 157 | ||
175 | /* Internal functions only for core arm_pmu code */ | 158 | /* Internal functions only for core arm_pmu code */ |
176 | struct arm_pmu *armpmu_alloc(void); | 159 | struct arm_pmu *armpmu_alloc(void); |
160 | struct arm_pmu *armpmu_alloc_atomic(void); | ||
177 | void armpmu_free(struct arm_pmu *pmu); | 161 | void armpmu_free(struct arm_pmu *pmu); |
178 | int armpmu_register(struct arm_pmu *pmu); | 162 | int armpmu_register(struct arm_pmu *pmu); |
179 | int armpmu_request_irqs(struct arm_pmu *armpmu); | 163 | int armpmu_request_irq(int irq, int cpu); |
180 | void armpmu_free_irqs(struct arm_pmu *armpmu); | 164 | void armpmu_free_irq(int irq, int cpu); |
181 | int armpmu_request_irq(struct arm_pmu *armpmu, int cpu); | ||
182 | void armpmu_free_irq(struct arm_pmu *armpmu, int cpu); | ||
183 | 165 | ||
184 | #define ARMV8_PMU_PDEV_NAME "armv8-pmu" | 166 | #define ARMV8_PMU_PDEV_NAME "armv8-pmu" |
185 | 167 | ||
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 1149533aa2fa..9806184bb3d5 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h | |||
@@ -36,7 +36,18 @@ static inline void mmgrab(struct mm_struct *mm) | |||
36 | atomic_inc(&mm->mm_count); | 36 | atomic_inc(&mm->mm_count); |
37 | } | 37 | } |
38 | 38 | ||
39 | extern void mmdrop(struct mm_struct *mm); | 39 | extern void __mmdrop(struct mm_struct *mm); |
40 | |||
41 | static inline void mmdrop(struct mm_struct *mm) | ||
42 | { | ||
43 | /* | ||
44 | * The implicit full barrier implied by atomic_dec_and_test() is | ||
45 | * required by the membarrier system call before returning to | ||
46 | * user-space, after storing to rq->curr. | ||
47 | */ | ||
48 | if (unlikely(atomic_dec_and_test(&mm->mm_count))) | ||
49 | __mmdrop(mm); | ||
50 | } | ||
40 | 51 | ||
41 | /** | 52 | /** |
42 | * mmget() - Pin the address space associated with a &struct mm_struct. | 53 | * mmget() - Pin the address space associated with a &struct mm_struct. |
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h index 0dcf4e480ef7..96fe289c4c6e 100644 --- a/include/linux/sched/user.h +++ b/include/linux/sched/user.h | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | #include <linux/uidgid.h> | 5 | #include <linux/uidgid.h> |
6 | #include <linux/atomic.h> | 6 | #include <linux/atomic.h> |
7 | #include <linux/ratelimit.h> | ||
7 | 8 | ||
8 | struct key; | 9 | struct key; |
9 | 10 | ||
@@ -41,6 +42,9 @@ struct user_struct { | |||
41 | defined(CONFIG_NET) | 42 | defined(CONFIG_NET) |
42 | atomic_long_t locked_vm; | 43 | atomic_long_t locked_vm; |
43 | #endif | 44 | #endif |
45 | |||
46 | /* Miscellaneous per-user rate limit */ | ||
47 | struct ratelimit_state ratelimit; | ||
44 | }; | 48 | }; |
45 | 49 | ||
46 | extern int uids_sysfs_init(void); | 50 | extern int uids_sysfs_init(void); |
diff --git a/include/linux/swap.h b/include/linux/swap.h index 7b6a59f722a3..a1a3f4ed94ce 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -337,8 +337,6 @@ extern void deactivate_file_page(struct page *page); | |||
337 | extern void mark_page_lazyfree(struct page *page); | 337 | extern void mark_page_lazyfree(struct page *page); |
338 | extern void swap_setup(void); | 338 | extern void swap_setup(void); |
339 | 339 | ||
340 | extern void add_page_to_unevictable_list(struct page *page); | ||
341 | |||
342 | extern void lru_cache_add_active_or_unevictable(struct page *page, | 340 | extern void lru_cache_add_active_or_unevictable(struct page *page, |
343 | struct vm_area_struct *vma); | 341 | struct vm_area_struct *vma); |
344 | 342 | ||
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 4a54ef96aff5..bc0cda180c8b 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
@@ -465,6 +465,7 @@ extern bool cancel_delayed_work_sync(struct delayed_work *dwork); | |||
465 | 465 | ||
466 | extern void workqueue_set_max_active(struct workqueue_struct *wq, | 466 | extern void workqueue_set_max_active(struct workqueue_struct *wq, |
467 | int max_active); | 467 | int max_active); |
468 | extern struct work_struct *current_work(void); | ||
468 | extern bool current_is_workqueue_rescuer(void); | 469 | extern bool current_is_workqueue_rescuer(void); |
469 | extern bool workqueue_congested(int cpu, struct workqueue_struct *wq); | 470 | extern bool workqueue_congested(int cpu, struct workqueue_struct *wq); |
470 | extern unsigned int work_busy(struct work_struct *work); | 471 | extern unsigned int work_busy(struct work_struct *work); |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index dc3e9d9c3527..2fd59ed3be00 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -4168,7 +4168,7 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid); | |||
4168 | * The TX headroom reserved by mac80211 for its own tx_status functions. | 4168 | * The TX headroom reserved by mac80211 for its own tx_status functions. |
4169 | * This is enough for the radiotap header. | 4169 | * This is enough for the radiotap header. |
4170 | */ | 4170 | */ |
4171 | #define IEEE80211_TX_STATUS_HEADROOM 14 | 4171 | #define IEEE80211_TX_STATUS_HEADROOM ALIGN(14, 4) |
4172 | 4172 | ||
4173 | /** | 4173 | /** |
4174 | * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames | 4174 | * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames |
diff --git a/include/net/regulatory.h b/include/net/regulatory.h index ebc5a2ed8631..f83cacce3308 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h | |||
@@ -78,7 +78,7 @@ struct regulatory_request { | |||
78 | int wiphy_idx; | 78 | int wiphy_idx; |
79 | enum nl80211_reg_initiator initiator; | 79 | enum nl80211_reg_initiator initiator; |
80 | enum nl80211_user_reg_hint_type user_reg_hint_type; | 80 | enum nl80211_user_reg_hint_type user_reg_hint_type; |
81 | char alpha2[2]; | 81 | char alpha2[3]; |
82 | enum nl80211_dfs_regions dfs_region; | 82 | enum nl80211_dfs_regions dfs_region; |
83 | bool intersect; | 83 | bool intersect; |
84 | bool processed; | 84 | bool processed; |
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h index c2d81167c858..2cdf8dcf4bdc 100644 --- a/include/rdma/restrack.h +++ b/include/rdma/restrack.h | |||
@@ -29,10 +29,6 @@ enum rdma_restrack_type { | |||
29 | */ | 29 | */ |
30 | RDMA_RESTRACK_QP, | 30 | RDMA_RESTRACK_QP, |
31 | /** | 31 | /** |
32 | * @RDMA_RESTRACK_XRCD: XRC domain (XRCD) | ||
33 | */ | ||
34 | RDMA_RESTRACK_XRCD, | ||
35 | /** | ||
36 | * @RDMA_RESTRACK_MAX: Last entry, used for array dclarations | 32 | * @RDMA_RESTRACK_MAX: Last entry, used for array dclarations |
37 | */ | 33 | */ |
38 | RDMA_RESTRACK_MAX | 34 | RDMA_RESTRACK_MAX |
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h index 6da44079aa58..38287d9d23a1 100644 --- a/include/rdma/uverbs_ioctl.h +++ b/include/rdma/uverbs_ioctl.h | |||
@@ -276,10 +276,7 @@ struct uverbs_object_tree_def { | |||
276 | */ | 276 | */ |
277 | 277 | ||
278 | struct uverbs_ptr_attr { | 278 | struct uverbs_ptr_attr { |
279 | union { | 279 | u64 data; |
280 | u64 data; | ||
281 | void __user *ptr; | ||
282 | }; | ||
283 | u16 len; | 280 | u16 len; |
284 | /* Combination of bits from enum UVERBS_ATTR_F_XXXX */ | 281 | /* Combination of bits from enum UVERBS_ATTR_F_XXXX */ |
285 | u16 flags; | 282 | u16 flags; |
@@ -351,38 +348,60 @@ static inline const struct uverbs_attr *uverbs_attr_get(const struct uverbs_attr | |||
351 | } | 348 | } |
352 | 349 | ||
353 | static inline int uverbs_copy_to(const struct uverbs_attr_bundle *attrs_bundle, | 350 | static inline int uverbs_copy_to(const struct uverbs_attr_bundle *attrs_bundle, |
354 | size_t idx, const void *from) | 351 | size_t idx, const void *from, size_t size) |
355 | { | 352 | { |
356 | const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); | 353 | const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); |
357 | u16 flags; | 354 | u16 flags; |
355 | size_t min_size; | ||
358 | 356 | ||
359 | if (IS_ERR(attr)) | 357 | if (IS_ERR(attr)) |
360 | return PTR_ERR(attr); | 358 | return PTR_ERR(attr); |
361 | 359 | ||
360 | min_size = min_t(size_t, attr->ptr_attr.len, size); | ||
361 | if (copy_to_user(u64_to_user_ptr(attr->ptr_attr.data), from, min_size)) | ||
362 | return -EFAULT; | ||
363 | |||
362 | flags = attr->ptr_attr.flags | UVERBS_ATTR_F_VALID_OUTPUT; | 364 | flags = attr->ptr_attr.flags | UVERBS_ATTR_F_VALID_OUTPUT; |
363 | return (!copy_to_user(attr->ptr_attr.ptr, from, attr->ptr_attr.len) && | 365 | if (put_user(flags, &attr->uattr->flags)) |
364 | !put_user(flags, &attr->uattr->flags)) ? 0 : -EFAULT; | 366 | return -EFAULT; |
367 | |||
368 | return 0; | ||
365 | } | 369 | } |
366 | 370 | ||
367 | static inline int _uverbs_copy_from(void *to, size_t to_size, | 371 | static inline bool uverbs_attr_ptr_is_inline(const struct uverbs_attr *attr) |
372 | { | ||
373 | return attr->ptr_attr.len <= sizeof(attr->ptr_attr.data); | ||
374 | } | ||
375 | |||
376 | static inline int _uverbs_copy_from(void *to, | ||
368 | const struct uverbs_attr_bundle *attrs_bundle, | 377 | const struct uverbs_attr_bundle *attrs_bundle, |
369 | size_t idx) | 378 | size_t idx, |
379 | size_t size) | ||
370 | { | 380 | { |
371 | const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); | 381 | const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); |
372 | 382 | ||
373 | if (IS_ERR(attr)) | 383 | if (IS_ERR(attr)) |
374 | return PTR_ERR(attr); | 384 | return PTR_ERR(attr); |
375 | 385 | ||
376 | if (to_size <= sizeof(((struct ib_uverbs_attr *)0)->data)) | 386 | /* |
387 | * Validation ensures attr->ptr_attr.len >= size. If the caller is | ||
388 | * using UVERBS_ATTR_SPEC_F_MIN_SZ then it must call copy_from with | ||
389 | * the right size. | ||
390 | */ | ||
391 | if (unlikely(size < attr->ptr_attr.len)) | ||
392 | return -EINVAL; | ||
393 | |||
394 | if (uverbs_attr_ptr_is_inline(attr)) | ||
377 | memcpy(to, &attr->ptr_attr.data, attr->ptr_attr.len); | 395 | memcpy(to, &attr->ptr_attr.data, attr->ptr_attr.len); |
378 | else if (copy_from_user(to, attr->ptr_attr.ptr, attr->ptr_attr.len)) | 396 | else if (copy_from_user(to, u64_to_user_ptr(attr->ptr_attr.data), |
397 | attr->ptr_attr.len)) | ||
379 | return -EFAULT; | 398 | return -EFAULT; |
380 | 399 | ||
381 | return 0; | 400 | return 0; |
382 | } | 401 | } |
383 | 402 | ||
384 | #define uverbs_copy_from(to, attrs_bundle, idx) \ | 403 | #define uverbs_copy_from(to, attrs_bundle, idx) \ |
385 | _uverbs_copy_from(to, sizeof(*(to)), attrs_bundle, idx) | 404 | _uverbs_copy_from(to, attrs_bundle, idx, sizeof(*to)) |
386 | 405 | ||
387 | /* ================================================= | 406 | /* ================================================= |
388 | * Definitions -> Specs infrastructure | 407 | * Definitions -> Specs infrastructure |
diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h index e46d82b91166..d5a1b8a492b9 100644 --- a/include/uapi/linux/ptrace.h +++ b/include/uapi/linux/ptrace.h | |||
@@ -69,8 +69,8 @@ struct ptrace_peeksiginfo_args { | |||
69 | #define PTRACE_SECCOMP_GET_METADATA 0x420d | 69 | #define PTRACE_SECCOMP_GET_METADATA 0x420d |
70 | 70 | ||
71 | struct seccomp_metadata { | 71 | struct seccomp_metadata { |
72 | unsigned long filter_off; /* Input: which filter */ | 72 | __u64 filter_off; /* Input: which filter */ |
73 | unsigned int flags; /* Output: filter's flags */ | 73 | __u64 flags; /* Output: filter's flags */ |
74 | }; | 74 | }; |
75 | 75 | ||
76 | /* Read signals from a shared (process wide) queue */ | 76 | /* Read signals from a shared (process wide) queue */ |
diff --git a/include/uapi/rdma/rdma_user_ioctl.h b/include/uapi/rdma/rdma_user_ioctl.h index 03557b5f9aa6..46de0885e800 100644 --- a/include/uapi/rdma/rdma_user_ioctl.h +++ b/include/uapi/rdma/rdma_user_ioctl.h | |||
@@ -65,7 +65,7 @@ struct ib_uverbs_attr { | |||
65 | __u16 len; /* only for pointers */ | 65 | __u16 len; /* only for pointers */ |
66 | __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */ | 66 | __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */ |
67 | __u16 reserved; | 67 | __u16 reserved; |
68 | __u64 data; /* ptr to command, inline data or idr/fd */ | 68 | __aligned_u64 data; /* ptr to command, inline data or idr/fd */ |
69 | }; | 69 | }; |
70 | 70 | ||
71 | struct ib_uverbs_ioctl_hdr { | 71 | struct ib_uverbs_ioctl_hdr { |
@@ -73,7 +73,7 @@ struct ib_uverbs_ioctl_hdr { | |||
73 | __u16 object_id; | 73 | __u16 object_id; |
74 | __u16 method_id; | 74 | __u16 method_id; |
75 | __u16 num_attrs; | 75 | __u16 num_attrs; |
76 | __u64 reserved; | 76 | __aligned_u64 reserved; |
77 | struct ib_uverbs_attr attrs[0]; | 77 | struct ib_uverbs_attr attrs[0]; |
78 | }; | 78 | }; |
79 | 79 | ||
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index b1f66480135b..14750e7c5ee4 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c | |||
@@ -26,8 +26,10 @@ static void bpf_array_free_percpu(struct bpf_array *array) | |||
26 | { | 26 | { |
27 | int i; | 27 | int i; |
28 | 28 | ||
29 | for (i = 0; i < array->map.max_entries; i++) | 29 | for (i = 0; i < array->map.max_entries; i++) { |
30 | free_percpu(array->pptrs[i]); | 30 | free_percpu(array->pptrs[i]); |
31 | cond_resched(); | ||
32 | } | ||
31 | } | 33 | } |
32 | 34 | ||
33 | static int bpf_array_alloc_percpu(struct bpf_array *array) | 35 | static int bpf_array_alloc_percpu(struct bpf_array *array) |
@@ -43,6 +45,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array) | |||
43 | return -ENOMEM; | 45 | return -ENOMEM; |
44 | } | 46 | } |
45 | array->pptrs[i] = ptr; | 47 | array->pptrs[i] = ptr; |
48 | cond_resched(); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | return 0; | 51 | return 0; |
@@ -73,11 +76,11 @@ static int array_map_alloc_check(union bpf_attr *attr) | |||
73 | static struct bpf_map *array_map_alloc(union bpf_attr *attr) | 76 | static struct bpf_map *array_map_alloc(union bpf_attr *attr) |
74 | { | 77 | { |
75 | bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; | 78 | bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; |
76 | int numa_node = bpf_map_attr_numa_node(attr); | 79 | int ret, numa_node = bpf_map_attr_numa_node(attr); |
77 | u32 elem_size, index_mask, max_entries; | 80 | u32 elem_size, index_mask, max_entries; |
78 | bool unpriv = !capable(CAP_SYS_ADMIN); | 81 | bool unpriv = !capable(CAP_SYS_ADMIN); |
82 | u64 cost, array_size, mask64; | ||
79 | struct bpf_array *array; | 83 | struct bpf_array *array; |
80 | u64 array_size, mask64; | ||
81 | 84 | ||
82 | elem_size = round_up(attr->value_size, 8); | 85 | elem_size = round_up(attr->value_size, 8); |
83 | 86 | ||
@@ -109,8 +112,19 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
109 | array_size += (u64) max_entries * elem_size; | 112 | array_size += (u64) max_entries * elem_size; |
110 | 113 | ||
111 | /* make sure there is no u32 overflow later in round_up() */ | 114 | /* make sure there is no u32 overflow later in round_up() */ |
112 | if (array_size >= U32_MAX - PAGE_SIZE) | 115 | cost = array_size; |
116 | if (cost >= U32_MAX - PAGE_SIZE) | ||
113 | return ERR_PTR(-ENOMEM); | 117 | return ERR_PTR(-ENOMEM); |
118 | if (percpu) { | ||
119 | cost += (u64)attr->max_entries * elem_size * num_possible_cpus(); | ||
120 | if (cost >= U32_MAX - PAGE_SIZE) | ||
121 | return ERR_PTR(-ENOMEM); | ||
122 | } | ||
123 | cost = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT; | ||
124 | |||
125 | ret = bpf_map_precharge_memlock(cost); | ||
126 | if (ret < 0) | ||
127 | return ERR_PTR(ret); | ||
114 | 128 | ||
115 | /* allocate all map elements and zero-initialize them */ | 129 | /* allocate all map elements and zero-initialize them */ |
116 | array = bpf_map_area_alloc(array_size, numa_node); | 130 | array = bpf_map_area_alloc(array_size, numa_node); |
@@ -121,20 +135,13 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
121 | 135 | ||
122 | /* copy mandatory map attributes */ | 136 | /* copy mandatory map attributes */ |
123 | bpf_map_init_from_attr(&array->map, attr); | 137 | bpf_map_init_from_attr(&array->map, attr); |
138 | array->map.pages = cost; | ||
124 | array->elem_size = elem_size; | 139 | array->elem_size = elem_size; |
125 | 140 | ||
126 | if (!percpu) | 141 | if (percpu && bpf_array_alloc_percpu(array)) { |
127 | goto out; | ||
128 | |||
129 | array_size += (u64) attr->max_entries * elem_size * num_possible_cpus(); | ||
130 | |||
131 | if (array_size >= U32_MAX - PAGE_SIZE || | ||
132 | bpf_array_alloc_percpu(array)) { | ||
133 | bpf_map_area_free(array); | 142 | bpf_map_area_free(array); |
134 | return ERR_PTR(-ENOMEM); | 143 | return ERR_PTR(-ENOMEM); |
135 | } | 144 | } |
136 | out: | ||
137 | array->map.pages = round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT; | ||
138 | 145 | ||
139 | return &array->map; | 146 | return &array->map; |
140 | } | 147 | } |
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 29ca9208dcfa..d315b393abdd 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c | |||
@@ -1590,7 +1590,7 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs, | |||
1590 | * so always copy 'cnt' prog_ids to the user. | 1590 | * so always copy 'cnt' prog_ids to the user. |
1591 | * In a rare race the user will see zero prog_ids | 1591 | * In a rare race the user will see zero prog_ids |
1592 | */ | 1592 | */ |
1593 | ids = kcalloc(cnt, sizeof(u32), GFP_USER); | 1593 | ids = kcalloc(cnt, sizeof(u32), GFP_USER | __GFP_NOWARN); |
1594 | if (!ids) | 1594 | if (!ids) |
1595 | return -ENOMEM; | 1595 | return -ENOMEM; |
1596 | rcu_read_lock(); | 1596 | rcu_read_lock(); |
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index fbfdada6caee..a4bb0b34375a 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c | |||
@@ -334,7 +334,7 @@ static int cpu_map_kthread_run(void *data) | |||
334 | static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, | 334 | static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, |
335 | int map_id) | 335 | int map_id) |
336 | { | 336 | { |
337 | gfp_t gfp = GFP_ATOMIC|__GFP_NOWARN; | 337 | gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; |
338 | struct bpf_cpu_map_entry *rcpu; | 338 | struct bpf_cpu_map_entry *rcpu; |
339 | int numa, err; | 339 | int numa, err; |
340 | 340 | ||
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c index 7b469d10d0e9..b4b5b81e7251 100644 --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c | |||
@@ -555,7 +555,10 @@ static void trie_free(struct bpf_map *map) | |||
555 | struct lpm_trie_node __rcu **slot; | 555 | struct lpm_trie_node __rcu **slot; |
556 | struct lpm_trie_node *node; | 556 | struct lpm_trie_node *node; |
557 | 557 | ||
558 | raw_spin_lock(&trie->lock); | 558 | /* Wait for outstanding programs to complete |
559 | * update/lookup/delete/get_next_key and free the trie. | ||
560 | */ | ||
561 | synchronize_rcu(); | ||
559 | 562 | ||
560 | /* Always start at the root and walk down to a node that has no | 563 | /* Always start at the root and walk down to a node that has no |
561 | * children. Then free that node, nullify its reference in the parent | 564 | * children. Then free that node, nullify its reference in the parent |
@@ -566,10 +569,9 @@ static void trie_free(struct bpf_map *map) | |||
566 | slot = &trie->root; | 569 | slot = &trie->root; |
567 | 570 | ||
568 | for (;;) { | 571 | for (;;) { |
569 | node = rcu_dereference_protected(*slot, | 572 | node = rcu_dereference_protected(*slot, 1); |
570 | lockdep_is_held(&trie->lock)); | ||
571 | if (!node) | 573 | if (!node) |
572 | goto unlock; | 574 | goto out; |
573 | 575 | ||
574 | if (rcu_access_pointer(node->child[0])) { | 576 | if (rcu_access_pointer(node->child[0])) { |
575 | slot = &node->child[0]; | 577 | slot = &node->child[0]; |
@@ -587,8 +589,8 @@ static void trie_free(struct bpf_map *map) | |||
587 | } | 589 | } |
588 | } | 590 | } |
589 | 591 | ||
590 | unlock: | 592 | out: |
591 | raw_spin_unlock(&trie->lock); | 593 | kfree(trie); |
592 | } | 594 | } |
593 | 595 | ||
594 | static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) | 596 | static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) |
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 48c33417d13c..a927e89dad6e 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c | |||
@@ -521,8 +521,8 @@ static struct smap_psock *smap_init_psock(struct sock *sock, | |||
521 | static struct bpf_map *sock_map_alloc(union bpf_attr *attr) | 521 | static struct bpf_map *sock_map_alloc(union bpf_attr *attr) |
522 | { | 522 | { |
523 | struct bpf_stab *stab; | 523 | struct bpf_stab *stab; |
524 | int err = -EINVAL; | ||
525 | u64 cost; | 524 | u64 cost; |
525 | int err; | ||
526 | 526 | ||
527 | if (!capable(CAP_NET_ADMIN)) | 527 | if (!capable(CAP_NET_ADMIN)) |
528 | return ERR_PTR(-EPERM); | 528 | return ERR_PTR(-EPERM); |
@@ -547,6 +547,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) | |||
547 | 547 | ||
548 | /* make sure page count doesn't overflow */ | 548 | /* make sure page count doesn't overflow */ |
549 | cost = (u64) stab->map.max_entries * sizeof(struct sock *); | 549 | cost = (u64) stab->map.max_entries * sizeof(struct sock *); |
550 | err = -EINVAL; | ||
550 | if (cost >= U32_MAX - PAGE_SIZE) | 551 | if (cost >= U32_MAX - PAGE_SIZE) |
551 | goto free_stab; | 552 | goto free_stab; |
552 | 553 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index be8aa5b98666..e5d9d405ae4e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -592,7 +592,7 @@ static void check_mm(struct mm_struct *mm) | |||
592 | * is dropped: either by a lazy thread or by | 592 | * is dropped: either by a lazy thread or by |
593 | * mmput. Free the page directory and the mm. | 593 | * mmput. Free the page directory and the mm. |
594 | */ | 594 | */ |
595 | static void __mmdrop(struct mm_struct *mm) | 595 | void __mmdrop(struct mm_struct *mm) |
596 | { | 596 | { |
597 | BUG_ON(mm == &init_mm); | 597 | BUG_ON(mm == &init_mm); |
598 | mm_free_pgd(mm); | 598 | mm_free_pgd(mm); |
@@ -603,18 +603,7 @@ static void __mmdrop(struct mm_struct *mm) | |||
603 | put_user_ns(mm->user_ns); | 603 | put_user_ns(mm->user_ns); |
604 | free_mm(mm); | 604 | free_mm(mm); |
605 | } | 605 | } |
606 | 606 | EXPORT_SYMBOL_GPL(__mmdrop); | |
607 | void mmdrop(struct mm_struct *mm) | ||
608 | { | ||
609 | /* | ||
610 | * The implicit full barrier implied by atomic_dec_and_test() is | ||
611 | * required by the membarrier system call before returning to | ||
612 | * user-space, after storing to rq->curr. | ||
613 | */ | ||
614 | if (unlikely(atomic_dec_and_test(&mm->mm_count))) | ||
615 | __mmdrop(mm); | ||
616 | } | ||
617 | EXPORT_SYMBOL_GPL(mmdrop); | ||
618 | 607 | ||
619 | static void mmdrop_async_fn(struct work_struct *work) | 608 | static void mmdrop_async_fn(struct work_struct *work) |
620 | { | 609 | { |
diff --git a/kernel/relay.c b/kernel/relay.c index c3029402f15c..c955b10c973c 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -163,7 +163,7 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) | |||
163 | { | 163 | { |
164 | struct rchan_buf *buf; | 164 | struct rchan_buf *buf; |
165 | 165 | ||
166 | if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) | 166 | if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *)) |
167 | return NULL; | 167 | return NULL; |
168 | 168 | ||
169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); |
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 940fa408a288..dc77548167ef 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
@@ -1076,14 +1076,16 @@ long seccomp_get_metadata(struct task_struct *task, | |||
1076 | 1076 | ||
1077 | size = min_t(unsigned long, size, sizeof(kmd)); | 1077 | size = min_t(unsigned long, size, sizeof(kmd)); |
1078 | 1078 | ||
1079 | if (copy_from_user(&kmd, data, size)) | 1079 | if (size < sizeof(kmd.filter_off)) |
1080 | return -EINVAL; | ||
1081 | |||
1082 | if (copy_from_user(&kmd.filter_off, data, sizeof(kmd.filter_off))) | ||
1080 | return -EFAULT; | 1083 | return -EFAULT; |
1081 | 1084 | ||
1082 | filter = get_nth_filter(task, kmd.filter_off); | 1085 | filter = get_nth_filter(task, kmd.filter_off); |
1083 | if (IS_ERR(filter)) | 1086 | if (IS_ERR(filter)) |
1084 | return PTR_ERR(filter); | 1087 | return PTR_ERR(filter); |
1085 | 1088 | ||
1086 | memset(&kmd, 0, sizeof(kmd)); | ||
1087 | if (filter->log) | 1089 | if (filter->log) |
1088 | kmd.flags |= SECCOMP_FILTER_FLAG_LOG; | 1090 | kmd.flags |= SECCOMP_FILTER_FLAG_LOG; |
1089 | 1091 | ||
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index fc2838ac8b78..c0a9e310d715 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
@@ -872,6 +872,8 @@ int perf_event_query_prog_array(struct perf_event *event, void __user *info) | |||
872 | return -EINVAL; | 872 | return -EINVAL; |
873 | if (copy_from_user(&query, uquery, sizeof(query))) | 873 | if (copy_from_user(&query, uquery, sizeof(query))) |
874 | return -EFAULT; | 874 | return -EFAULT; |
875 | if (query.ids_len > BPF_TRACE_MAX_PROGS) | ||
876 | return -E2BIG; | ||
875 | 877 | ||
876 | mutex_lock(&bpf_event_mutex); | 878 | mutex_lock(&bpf_event_mutex); |
877 | ret = bpf_prog_array_copy_info(event->tp_event->prog_array, | 879 | ret = bpf_prog_array_copy_info(event->tp_event->prog_array, |
diff --git a/kernel/user.c b/kernel/user.c index 9a20acce460d..36288d840675 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -101,6 +101,7 @@ struct user_struct root_user = { | |||
101 | .sigpending = ATOMIC_INIT(0), | 101 | .sigpending = ATOMIC_INIT(0), |
102 | .locked_shm = 0, | 102 | .locked_shm = 0, |
103 | .uid = GLOBAL_ROOT_UID, | 103 | .uid = GLOBAL_ROOT_UID, |
104 | .ratelimit = RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0), | ||
104 | }; | 105 | }; |
105 | 106 | ||
106 | /* | 107 | /* |
@@ -191,6 +192,8 @@ struct user_struct *alloc_uid(kuid_t uid) | |||
191 | 192 | ||
192 | new->uid = uid; | 193 | new->uid = uid; |
193 | atomic_set(&new->__count, 1); | 194 | atomic_set(&new->__count, 1); |
195 | ratelimit_state_init(&new->ratelimit, HZ, 100); | ||
196 | ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE); | ||
194 | 197 | ||
195 | /* | 198 | /* |
196 | * Before adding this, check whether we raced | 199 | * Before adding this, check whether we raced |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 017044c26233..bb9a519cbf50 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -4180,6 +4180,22 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) | |||
4180 | EXPORT_SYMBOL_GPL(workqueue_set_max_active); | 4180 | EXPORT_SYMBOL_GPL(workqueue_set_max_active); |
4181 | 4181 | ||
4182 | /** | 4182 | /** |
4183 | * current_work - retrieve %current task's work struct | ||
4184 | * | ||
4185 | * Determine if %current task is a workqueue worker and what it's working on. | ||
4186 | * Useful to find out the context that the %current task is running in. | ||
4187 | * | ||
4188 | * Return: work struct if %current task is a workqueue worker, %NULL otherwise. | ||
4189 | */ | ||
4190 | struct work_struct *current_work(void) | ||
4191 | { | ||
4192 | struct worker *worker = current_wq_worker(); | ||
4193 | |||
4194 | return worker ? worker->current_work : NULL; | ||
4195 | } | ||
4196 | EXPORT_SYMBOL(current_work); | ||
4197 | |||
4198 | /** | ||
4183 | * current_is_workqueue_rescuer - is %current workqueue rescuer? | 4199 | * current_is_workqueue_rescuer - is %current workqueue rescuer? |
4184 | * | 4200 | * |
4185 | * Determine whether %current is a workqueue rescuer. Can be used from | 4201 | * Determine whether %current is a workqueue rescuer. Can be used from |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 6088408ef26c..64155e310a9f 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -1642,6 +1642,7 @@ config DMA_API_DEBUG | |||
1642 | 1642 | ||
1643 | menuconfig RUNTIME_TESTING_MENU | 1643 | menuconfig RUNTIME_TESTING_MENU |
1644 | bool "Runtime Testing" | 1644 | bool "Runtime Testing" |
1645 | def_bool y | ||
1645 | 1646 | ||
1646 | if RUNTIME_TESTING_MENU | 1647 | if RUNTIME_TESTING_MENU |
1647 | 1648 | ||
@@ -431,7 +431,6 @@ int ida_get_new_above(struct ida *ida, int start, int *id) | |||
431 | bitmap = this_cpu_xchg(ida_bitmap, NULL); | 431 | bitmap = this_cpu_xchg(ida_bitmap, NULL); |
432 | if (!bitmap) | 432 | if (!bitmap) |
433 | return -EAGAIN; | 433 | return -EAGAIN; |
434 | memset(bitmap, 0, sizeof(*bitmap)); | ||
435 | bitmap->bitmap[0] = tmp >> RADIX_TREE_EXCEPTIONAL_SHIFT; | 434 | bitmap->bitmap[0] = tmp >> RADIX_TREE_EXCEPTIONAL_SHIFT; |
436 | rcu_assign_pointer(*slot, bitmap); | 435 | rcu_assign_pointer(*slot, bitmap); |
437 | } | 436 | } |
@@ -464,7 +463,6 @@ int ida_get_new_above(struct ida *ida, int start, int *id) | |||
464 | bitmap = this_cpu_xchg(ida_bitmap, NULL); | 463 | bitmap = this_cpu_xchg(ida_bitmap, NULL); |
465 | if (!bitmap) | 464 | if (!bitmap) |
466 | return -EAGAIN; | 465 | return -EAGAIN; |
467 | memset(bitmap, 0, sizeof(*bitmap)); | ||
468 | __set_bit(bit, bitmap->bitmap); | 466 | __set_bit(bit, bitmap->bitmap); |
469 | radix_tree_iter_replace(root, &iter, slot, bitmap); | 467 | radix_tree_iter_replace(root, &iter, slot, bitmap); |
470 | } | 468 | } |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 0a7ae3288a24..8e00138d593f 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -2125,7 +2125,7 @@ int ida_pre_get(struct ida *ida, gfp_t gfp) | |||
2125 | preempt_enable(); | 2125 | preempt_enable(); |
2126 | 2126 | ||
2127 | if (!this_cpu_read(ida_bitmap)) { | 2127 | if (!this_cpu_read(ida_bitmap)) { |
2128 | struct ida_bitmap *bitmap = kmalloc(sizeof(*bitmap), gfp); | 2128 | struct ida_bitmap *bitmap = kzalloc(sizeof(*bitmap), gfp); |
2129 | if (!bitmap) | 2129 | if (!bitmap) |
2130 | return 0; | 2130 | return 0; |
2131 | if (this_cpu_cmpxchg(ida_bitmap, NULL, bitmap)) | 2131 | if (this_cpu_cmpxchg(ida_bitmap, NULL, bitmap)) |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 77ee6ced11b1..d7a708f82559 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1849,7 +1849,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
1849 | { | 1849 | { |
1850 | const int default_width = 2 * sizeof(void *); | 1850 | const int default_width = 2 * sizeof(void *); |
1851 | 1851 | ||
1852 | if (!ptr && *fmt != 'K') { | 1852 | if (!ptr && *fmt != 'K' && *fmt != 'x') { |
1853 | /* | 1853 | /* |
1854 | * Print (null) with the same width as a pointer so it makes | 1854 | * Print (null) with the same width as a pointer so it makes |
1855 | * tabular output look nice. | 1855 | * tabular output look nice. |
diff --git a/mm/mlock.c b/mm/mlock.c index 79398200e423..74e5a6547c3d 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -64,6 +64,12 @@ void clear_page_mlock(struct page *page) | |||
64 | mod_zone_page_state(page_zone(page), NR_MLOCK, | 64 | mod_zone_page_state(page_zone(page), NR_MLOCK, |
65 | -hpage_nr_pages(page)); | 65 | -hpage_nr_pages(page)); |
66 | count_vm_event(UNEVICTABLE_PGCLEARED); | 66 | count_vm_event(UNEVICTABLE_PGCLEARED); |
67 | /* | ||
68 | * The previous TestClearPageMlocked() corresponds to the smp_mb() | ||
69 | * in __pagevec_lru_add_fn(). | ||
70 | * | ||
71 | * See __pagevec_lru_add_fn for more explanation. | ||
72 | */ | ||
67 | if (!isolate_lru_page(page)) { | 73 | if (!isolate_lru_page(page)) { |
68 | putback_lru_page(page); | 74 | putback_lru_page(page); |
69 | } else { | 75 | } else { |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 81e18ceef579..cb416723538f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/stop_machine.h> | 46 | #include <linux/stop_machine.h> |
47 | #include <linux/sort.h> | 47 | #include <linux/sort.h> |
48 | #include <linux/pfn.h> | 48 | #include <linux/pfn.h> |
49 | #include <xen/xen.h> | ||
49 | #include <linux/backing-dev.h> | 50 | #include <linux/backing-dev.h> |
50 | #include <linux/fault-inject.h> | 51 | #include <linux/fault-inject.h> |
51 | #include <linux/page-isolation.h> | 52 | #include <linux/page-isolation.h> |
@@ -347,6 +348,9 @@ static inline bool update_defer_init(pg_data_t *pgdat, | |||
347 | /* Always populate low zones for address-constrained allocations */ | 348 | /* Always populate low zones for address-constrained allocations */ |
348 | if (zone_end < pgdat_end_pfn(pgdat)) | 349 | if (zone_end < pgdat_end_pfn(pgdat)) |
349 | return true; | 350 | return true; |
351 | /* Xen PV domains need page structures early */ | ||
352 | if (xen_pv_domain()) | ||
353 | return true; | ||
350 | (*nr_initialised)++; | 354 | (*nr_initialised)++; |
351 | if ((*nr_initialised > pgdat->static_init_pgcnt) && | 355 | if ((*nr_initialised > pgdat->static_init_pgcnt) && |
352 | (pfn & (PAGES_PER_SECTION - 1)) == 0) { | 356 | (pfn & (PAGES_PER_SECTION - 1)) == 0) { |
@@ -446,30 +446,6 @@ void lru_cache_add(struct page *page) | |||
446 | } | 446 | } |
447 | 447 | ||
448 | /** | 448 | /** |
449 | * add_page_to_unevictable_list - add a page to the unevictable list | ||
450 | * @page: the page to be added to the unevictable list | ||
451 | * | ||
452 | * Add page directly to its zone's unevictable list. To avoid races with | ||
453 | * tasks that might be making the page evictable, through eg. munlock, | ||
454 | * munmap or exit, while it's not on the lru, we want to add the page | ||
455 | * while it's locked or otherwise "invisible" to other tasks. This is | ||
456 | * difficult to do when using the pagevec cache, so bypass that. | ||
457 | */ | ||
458 | void add_page_to_unevictable_list(struct page *page) | ||
459 | { | ||
460 | struct pglist_data *pgdat = page_pgdat(page); | ||
461 | struct lruvec *lruvec; | ||
462 | |||
463 | spin_lock_irq(&pgdat->lru_lock); | ||
464 | lruvec = mem_cgroup_page_lruvec(page, pgdat); | ||
465 | ClearPageActive(page); | ||
466 | SetPageUnevictable(page); | ||
467 | SetPageLRU(page); | ||
468 | add_page_to_lru_list(page, lruvec, LRU_UNEVICTABLE); | ||
469 | spin_unlock_irq(&pgdat->lru_lock); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * lru_cache_add_active_or_unevictable | 449 | * lru_cache_add_active_or_unevictable |
474 | * @page: the page to be added to LRU | 450 | * @page: the page to be added to LRU |
475 | * @vma: vma in which page is mapped for determining reclaimability | 451 | * @vma: vma in which page is mapped for determining reclaimability |
@@ -484,13 +460,9 @@ void lru_cache_add_active_or_unevictable(struct page *page, | |||
484 | { | 460 | { |
485 | VM_BUG_ON_PAGE(PageLRU(page), page); | 461 | VM_BUG_ON_PAGE(PageLRU(page), page); |
486 | 462 | ||
487 | if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) { | 463 | if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) |
488 | SetPageActive(page); | 464 | SetPageActive(page); |
489 | lru_cache_add(page); | 465 | else if (!TestSetPageMlocked(page)) { |
490 | return; | ||
491 | } | ||
492 | |||
493 | if (!TestSetPageMlocked(page)) { | ||
494 | /* | 466 | /* |
495 | * We use the irq-unsafe __mod_zone_page_stat because this | 467 | * We use the irq-unsafe __mod_zone_page_stat because this |
496 | * counter is not modified from interrupt context, and the pte | 468 | * counter is not modified from interrupt context, and the pte |
@@ -500,7 +472,7 @@ void lru_cache_add_active_or_unevictable(struct page *page, | |||
500 | hpage_nr_pages(page)); | 472 | hpage_nr_pages(page)); |
501 | count_vm_event(UNEVICTABLE_PGMLOCKED); | 473 | count_vm_event(UNEVICTABLE_PGMLOCKED); |
502 | } | 474 | } |
503 | add_page_to_unevictable_list(page); | 475 | lru_cache_add(page); |
504 | } | 476 | } |
505 | 477 | ||
506 | /* | 478 | /* |
@@ -886,15 +858,55 @@ void lru_add_page_tail(struct page *page, struct page *page_tail, | |||
886 | static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, | 858 | static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, |
887 | void *arg) | 859 | void *arg) |
888 | { | 860 | { |
889 | int file = page_is_file_cache(page); | 861 | enum lru_list lru; |
890 | int active = PageActive(page); | 862 | int was_unevictable = TestClearPageUnevictable(page); |
891 | enum lru_list lru = page_lru(page); | ||
892 | 863 | ||
893 | VM_BUG_ON_PAGE(PageLRU(page), page); | 864 | VM_BUG_ON_PAGE(PageLRU(page), page); |
894 | 865 | ||
895 | SetPageLRU(page); | 866 | SetPageLRU(page); |
867 | /* | ||
868 | * Page becomes evictable in two ways: | ||
869 | * 1) Within LRU lock [munlock_vma_pages() and __munlock_pagevec()]. | ||
870 | * 2) Before acquiring LRU lock to put the page to correct LRU and then | ||
871 | * a) do PageLRU check with lock [check_move_unevictable_pages] | ||
872 | * b) do PageLRU check before lock [clear_page_mlock] | ||
873 | * | ||
874 | * (1) & (2a) are ok as LRU lock will serialize them. For (2b), we need | ||
875 | * following strict ordering: | ||
876 | * | ||
877 | * #0: __pagevec_lru_add_fn #1: clear_page_mlock | ||
878 | * | ||
879 | * SetPageLRU() TestClearPageMlocked() | ||
880 | * smp_mb() // explicit ordering // above provides strict | ||
881 | * // ordering | ||
882 | * PageMlocked() PageLRU() | ||
883 | * | ||
884 | * | ||
885 | * if '#1' does not observe setting of PG_lru by '#0' and fails | ||
886 | * isolation, the explicit barrier will make sure that page_evictable | ||
887 | * check will put the page in correct LRU. Without smp_mb(), SetPageLRU | ||
888 | * can be reordered after PageMlocked check and can make '#1' to fail | ||
889 | * the isolation of the page whose Mlocked bit is cleared (#0 is also | ||
890 | * looking at the same page) and the evictable page will be stranded | ||
891 | * in an unevictable LRU. | ||
892 | */ | ||
893 | smp_mb(); | ||
894 | |||
895 | if (page_evictable(page)) { | ||
896 | lru = page_lru(page); | ||
897 | update_page_reclaim_stat(lruvec, page_is_file_cache(page), | ||
898 | PageActive(page)); | ||
899 | if (was_unevictable) | ||
900 | count_vm_event(UNEVICTABLE_PGRESCUED); | ||
901 | } else { | ||
902 | lru = LRU_UNEVICTABLE; | ||
903 | ClearPageActive(page); | ||
904 | SetPageUnevictable(page); | ||
905 | if (!was_unevictable) | ||
906 | count_vm_event(UNEVICTABLE_PGCULLED); | ||
907 | } | ||
908 | |||
896 | add_page_to_lru_list(page, lruvec, lru); | 909 | add_page_to_lru_list(page, lruvec, lru); |
897 | update_page_reclaim_stat(lruvec, file, active); | ||
898 | trace_mm_lru_insertion(page, lru); | 910 | trace_mm_lru_insertion(page, lru); |
899 | } | 911 | } |
900 | 912 | ||
@@ -913,7 +925,7 @@ EXPORT_SYMBOL(__pagevec_lru_add); | |||
913 | * @pvec: Where the resulting entries are placed | 925 | * @pvec: Where the resulting entries are placed |
914 | * @mapping: The address_space to search | 926 | * @mapping: The address_space to search |
915 | * @start: The starting entry index | 927 | * @start: The starting entry index |
916 | * @nr_pages: The maximum number of pages | 928 | * @nr_entries: The maximum number of pages |
917 | * @indices: The cache indices corresponding to the entries in @pvec | 929 | * @indices: The cache indices corresponding to the entries in @pvec |
918 | * | 930 | * |
919 | * pagevec_lookup_entries() will search for and return a group of up | 931 | * pagevec_lookup_entries() will search for and return a group of up |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 673942094328..ebff729cc956 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -1943,11 +1943,15 @@ void *vmalloc_exec(unsigned long size) | |||
1943 | } | 1943 | } |
1944 | 1944 | ||
1945 | #if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32) | 1945 | #if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32) |
1946 | #define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL | 1946 | #define GFP_VMALLOC32 (GFP_DMA32 | GFP_KERNEL) |
1947 | #elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA) | 1947 | #elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA) |
1948 | #define GFP_VMALLOC32 GFP_DMA | GFP_KERNEL | 1948 | #define GFP_VMALLOC32 (GFP_DMA | GFP_KERNEL) |
1949 | #else | 1949 | #else |
1950 | #define GFP_VMALLOC32 GFP_KERNEL | 1950 | /* |
1951 | * 64b systems should always have either DMA or DMA32 zones. For others | ||
1952 | * GFP_DMA32 should do the right thing and use the normal zone. | ||
1953 | */ | ||
1954 | #define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL | ||
1951 | #endif | 1955 | #endif |
1952 | 1956 | ||
1953 | /** | 1957 | /** |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 444749669187..bee53495a829 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -769,64 +769,7 @@ int remove_mapping(struct address_space *mapping, struct page *page) | |||
769 | */ | 769 | */ |
770 | void putback_lru_page(struct page *page) | 770 | void putback_lru_page(struct page *page) |
771 | { | 771 | { |
772 | bool is_unevictable; | 772 | lru_cache_add(page); |
773 | int was_unevictable = PageUnevictable(page); | ||
774 | |||
775 | VM_BUG_ON_PAGE(PageLRU(page), page); | ||
776 | |||
777 | redo: | ||
778 | ClearPageUnevictable(page); | ||
779 | |||
780 | if (page_evictable(page)) { | ||
781 | /* | ||
782 | * For evictable pages, we can use the cache. | ||
783 | * In event of a race, worst case is we end up with an | ||
784 | * unevictable page on [in]active list. | ||
785 | * We know how to handle that. | ||
786 | */ | ||
787 | is_unevictable = false; | ||
788 | lru_cache_add(page); | ||
789 | } else { | ||
790 | /* | ||
791 | * Put unevictable pages directly on zone's unevictable | ||
792 | * list. | ||
793 | */ | ||
794 | is_unevictable = true; | ||
795 | add_page_to_unevictable_list(page); | ||
796 | /* | ||
797 | * When racing with an mlock or AS_UNEVICTABLE clearing | ||
798 | * (page is unlocked) make sure that if the other thread | ||
799 | * does not observe our setting of PG_lru and fails | ||
800 | * isolation/check_move_unevictable_pages, | ||
801 | * we see PG_mlocked/AS_UNEVICTABLE cleared below and move | ||
802 | * the page back to the evictable list. | ||
803 | * | ||
804 | * The other side is TestClearPageMlocked() or shmem_lock(). | ||
805 | */ | ||
806 | smp_mb(); | ||
807 | } | ||
808 | |||
809 | /* | ||
810 | * page's status can change while we move it among lru. If an evictable | ||
811 | * page is on unevictable list, it never be freed. To avoid that, | ||
812 | * check after we added it to the list, again. | ||
813 | */ | ||
814 | if (is_unevictable && page_evictable(page)) { | ||
815 | if (!isolate_lru_page(page)) { | ||
816 | put_page(page); | ||
817 | goto redo; | ||
818 | } | ||
819 | /* This means someone else dropped this page from LRU | ||
820 | * So, it will be freed or putback to LRU again. There is | ||
821 | * nothing to do here. | ||
822 | */ | ||
823 | } | ||
824 | |||
825 | if (was_unevictable && !is_unevictable) | ||
826 | count_vm_event(UNEVICTABLE_PGRESCUED); | ||
827 | else if (!was_unevictable && is_unevictable) | ||
828 | count_vm_event(UNEVICTABLE_PGCULLED); | ||
829 | |||
830 | put_page(page); /* drop ref from isolate */ | 773 | put_page(page); /* drop ref from isolate */ |
831 | } | 774 | } |
832 | 775 | ||
diff --git a/mm/zpool.c b/mm/zpool.c index f8cb83e7699b..01a771e304fa 100644 --- a/mm/zpool.c +++ b/mm/zpool.c | |||
@@ -360,7 +360,7 @@ u64 zpool_get_total_size(struct zpool *zpool) | |||
360 | 360 | ||
361 | /** | 361 | /** |
362 | * zpool_evictable() - Test if zpool is potentially evictable | 362 | * zpool_evictable() - Test if zpool is potentially evictable |
363 | * @pool The zpool to test | 363 | * @zpool: The zpool to test |
364 | * | 364 | * |
365 | * Zpool is only potentially evictable when it's created with struct | 365 | * Zpool is only potentially evictable when it's created with struct |
366 | * zpool_ops.evict and its driver implements struct zpool_driver.shrink. | 366 | * zpool_ops.evict and its driver implements struct zpool_driver.shrink. |
diff --git a/mm/zswap.c b/mm/zswap.c index c004aa4fd3f4..61a5c41972db 100644 --- a/mm/zswap.c +++ b/mm/zswap.c | |||
@@ -1007,6 +1007,12 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, | |||
1007 | u8 *src, *dst; | 1007 | u8 *src, *dst; |
1008 | struct zswap_header zhdr = { .swpentry = swp_entry(type, offset) }; | 1008 | struct zswap_header zhdr = { .swpentry = swp_entry(type, offset) }; |
1009 | 1009 | ||
1010 | /* THP isn't supported */ | ||
1011 | if (PageTransHuge(page)) { | ||
1012 | ret = -EINVAL; | ||
1013 | goto reject; | ||
1014 | } | ||
1015 | |||
1010 | if (!zswap_enabled || !tree) { | 1016 | if (!zswap_enabled || !tree) { |
1011 | ret = -ENODEV; | 1017 | ret = -ENODEV; |
1012 | goto reject; | 1018 | goto reject; |
diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c index 279527f8b1fe..ce7152a12bd8 100644 --- a/net/bridge/netfilter/ebt_among.c +++ b/net/bridge/netfilter/ebt_among.c | |||
@@ -187,17 +187,17 @@ static int ebt_among_mt_check(const struct xt_mtchk_param *par) | |||
187 | expected_length += ebt_mac_wormhash_size(wh_src); | 187 | expected_length += ebt_mac_wormhash_size(wh_src); |
188 | 188 | ||
189 | if (em->match_size != EBT_ALIGN(expected_length)) { | 189 | if (em->match_size != EBT_ALIGN(expected_length)) { |
190 | pr_info("wrong size: %d against expected %d, rounded to %zd\n", | 190 | pr_err_ratelimited("wrong size: %d against expected %d, rounded to %zd\n", |
191 | em->match_size, expected_length, | 191 | em->match_size, expected_length, |
192 | EBT_ALIGN(expected_length)); | 192 | EBT_ALIGN(expected_length)); |
193 | return -EINVAL; | 193 | return -EINVAL; |
194 | } | 194 | } |
195 | if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) { | 195 | if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) { |
196 | pr_info("dst integrity fail: %x\n", -err); | 196 | pr_err_ratelimited("dst integrity fail: %x\n", -err); |
197 | return -EINVAL; | 197 | return -EINVAL; |
198 | } | 198 | } |
199 | if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) { | 199 | if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) { |
200 | pr_info("src integrity fail: %x\n", -err); | 200 | pr_err_ratelimited("src integrity fail: %x\n", -err); |
201 | return -EINVAL; | 201 | return -EINVAL; |
202 | } | 202 | } |
203 | return 0; | 203 | return 0; |
diff --git a/net/bridge/netfilter/ebt_limit.c b/net/bridge/netfilter/ebt_limit.c index 61a9f1be1263..165b9d678cf1 100644 --- a/net/bridge/netfilter/ebt_limit.c +++ b/net/bridge/netfilter/ebt_limit.c | |||
@@ -72,8 +72,8 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par) | |||
72 | /* Check for overflow. */ | 72 | /* Check for overflow. */ |
73 | if (info->burst == 0 || | 73 | if (info->burst == 0 || |
74 | user2credits(info->avg * info->burst) < user2credits(info->avg)) { | 74 | user2credits(info->avg * info->burst) < user2credits(info->avg)) { |
75 | pr_info("overflow, try lower: %u/%u\n", | 75 | pr_info_ratelimited("overflow, try lower: %u/%u\n", |
76 | info->avg, info->burst); | 76 | info->avg, info->burst); |
77 | return -EINVAL; | 77 | return -EINVAL; |
78 | } | 78 | } |
79 | 79 | ||
diff --git a/net/core/filter.c b/net/core/filter.c index 08ab4c65a998..0c121adbdbaa 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -3381,17 +3381,13 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock, | |||
3381 | struct sock *sk = bpf_sock->sk; | 3381 | struct sock *sk = bpf_sock->sk; |
3382 | int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; | 3382 | int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; |
3383 | 3383 | ||
3384 | if (!sk_fullsock(sk)) | 3384 | if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk)) |
3385 | return -EINVAL; | 3385 | return -EINVAL; |
3386 | 3386 | ||
3387 | #ifdef CONFIG_INET | ||
3388 | if (val) | 3387 | if (val) |
3389 | tcp_sk(sk)->bpf_sock_ops_cb_flags = val; | 3388 | tcp_sk(sk)->bpf_sock_ops_cb_flags = val; |
3390 | 3389 | ||
3391 | return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS); | 3390 | return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS); |
3392 | #else | ||
3393 | return -EINVAL; | ||
3394 | #endif | ||
3395 | } | 3391 | } |
3396 | 3392 | ||
3397 | static const struct bpf_func_proto bpf_sock_ops_cb_flags_set_proto = { | 3393 | static const struct bpf_func_proto bpf_sock_ops_cb_flags_set_proto = { |
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c index 0a3f88f08727..98fd12721221 100644 --- a/net/core/gen_estimator.c +++ b/net/core/gen_estimator.c | |||
@@ -66,6 +66,7 @@ struct net_rate_estimator { | |||
66 | static void est_fetch_counters(struct net_rate_estimator *e, | 66 | static void est_fetch_counters(struct net_rate_estimator *e, |
67 | struct gnet_stats_basic_packed *b) | 67 | struct gnet_stats_basic_packed *b) |
68 | { | 68 | { |
69 | memset(b, 0, sizeof(*b)); | ||
69 | if (e->stats_lock) | 70 | if (e->stats_lock) |
70 | spin_lock(e->stats_lock); | 71 | spin_lock(e->stats_lock); |
71 | 72 | ||
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 9dca0fb8c482..74c962b9b09c 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -1569,10 +1569,7 @@ int ip_getsockopt(struct sock *sk, int level, | |||
1569 | if (get_user(len, optlen)) | 1569 | if (get_user(len, optlen)) |
1570 | return -EFAULT; | 1570 | return -EFAULT; |
1571 | 1571 | ||
1572 | lock_sock(sk); | 1572 | err = nf_getsockopt(sk, PF_INET, optname, optval, &len); |
1573 | err = nf_getsockopt(sk, PF_INET, optname, optval, | ||
1574 | &len); | ||
1575 | release_sock(sk); | ||
1576 | if (err >= 0) | 1573 | if (err >= 0) |
1577 | err = put_user(len, optlen); | 1574 | err = put_user(len, optlen); |
1578 | return err; | 1575 | return err; |
@@ -1604,9 +1601,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, | |||
1604 | if (get_user(len, optlen)) | 1601 | if (get_user(len, optlen)) |
1605 | return -EFAULT; | 1602 | return -EFAULT; |
1606 | 1603 | ||
1607 | lock_sock(sk); | ||
1608 | err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len); | 1604 | err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len); |
1609 | release_sock(sk); | ||
1610 | if (err >= 0) | 1605 | if (err >= 0) |
1611 | err = put_user(len, optlen); | 1606 | err = put_user(len, optlen); |
1612 | return err; | 1607 | return err; |
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 4ffe302f9b82..e3e420f3ba7b 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
@@ -252,6 +252,10 @@ unsigned int arpt_do_table(struct sk_buff *skb, | |||
252 | } | 252 | } |
253 | if (table_base + v | 253 | if (table_base + v |
254 | != arpt_next_entry(e)) { | 254 | != arpt_next_entry(e)) { |
255 | if (unlikely(stackidx >= private->stacksize)) { | ||
256 | verdict = NF_DROP; | ||
257 | break; | ||
258 | } | ||
255 | jumpstack[stackidx++] = e; | 259 | jumpstack[stackidx++] = e; |
256 | } | 260 | } |
257 | 261 | ||
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 39a7cf9160e6..d4f7584d2dbe 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c | |||
@@ -330,8 +330,13 @@ ipt_do_table(struct sk_buff *skb, | |||
330 | continue; | 330 | continue; |
331 | } | 331 | } |
332 | if (table_base + v != ipt_next_entry(e) && | 332 | if (table_base + v != ipt_next_entry(e) && |
333 | !(e->ip.flags & IPT_F_GOTO)) | 333 | !(e->ip.flags & IPT_F_GOTO)) { |
334 | if (unlikely(stackidx >= private->stacksize)) { | ||
335 | verdict = NF_DROP; | ||
336 | break; | ||
337 | } | ||
334 | jumpstack[stackidx++] = e; | 338 | jumpstack[stackidx++] = e; |
339 | } | ||
335 | 340 | ||
336 | e = get_entry(table_base, v); | 341 | e = get_entry(table_base, v); |
337 | continue; | 342 | continue; |
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 3a84a60f6b39..4b02ab39ebc5 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -107,12 +107,6 @@ clusterip_config_entry_put(struct net *net, struct clusterip_config *c) | |||
107 | 107 | ||
108 | local_bh_disable(); | 108 | local_bh_disable(); |
109 | if (refcount_dec_and_lock(&c->entries, &cn->lock)) { | 109 | if (refcount_dec_and_lock(&c->entries, &cn->lock)) { |
110 | list_del_rcu(&c->list); | ||
111 | spin_unlock(&cn->lock); | ||
112 | local_bh_enable(); | ||
113 | |||
114 | unregister_netdevice_notifier(&c->notifier); | ||
115 | |||
116 | /* In case anyone still accesses the file, the open/close | 110 | /* In case anyone still accesses the file, the open/close |
117 | * functions are also incrementing the refcount on their own, | 111 | * functions are also incrementing the refcount on their own, |
118 | * so it's safe to remove the entry even if it's in use. */ | 112 | * so it's safe to remove the entry even if it's in use. */ |
@@ -120,6 +114,12 @@ clusterip_config_entry_put(struct net *net, struct clusterip_config *c) | |||
120 | if (cn->procdir) | 114 | if (cn->procdir) |
121 | proc_remove(c->pde); | 115 | proc_remove(c->pde); |
122 | #endif | 116 | #endif |
117 | list_del_rcu(&c->list); | ||
118 | spin_unlock(&cn->lock); | ||
119 | local_bh_enable(); | ||
120 | |||
121 | unregister_netdevice_notifier(&c->notifier); | ||
122 | |||
123 | return; | 123 | return; |
124 | } | 124 | } |
125 | local_bh_enable(); | 125 | local_bh_enable(); |
@@ -154,8 +154,12 @@ clusterip_config_find_get(struct net *net, __be32 clusterip, int entry) | |||
154 | #endif | 154 | #endif |
155 | if (unlikely(!refcount_inc_not_zero(&c->refcount))) | 155 | if (unlikely(!refcount_inc_not_zero(&c->refcount))) |
156 | c = NULL; | 156 | c = NULL; |
157 | else if (entry) | 157 | else if (entry) { |
158 | refcount_inc(&c->entries); | 158 | if (unlikely(!refcount_inc_not_zero(&c->entries))) { |
159 | clusterip_config_put(c); | ||
160 | c = NULL; | ||
161 | } | ||
162 | } | ||
159 | } | 163 | } |
160 | rcu_read_unlock_bh(); | 164 | rcu_read_unlock_bh(); |
161 | 165 | ||
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c index 270765236f5e..aaaf9a81fbc9 100644 --- a/net/ipv4/netfilter/ipt_ECN.c +++ b/net/ipv4/netfilter/ipt_ECN.c | |||
@@ -98,17 +98,15 @@ static int ecn_tg_check(const struct xt_tgchk_param *par) | |||
98 | const struct ipt_ECN_info *einfo = par->targinfo; | 98 | const struct ipt_ECN_info *einfo = par->targinfo; |
99 | const struct ipt_entry *e = par->entryinfo; | 99 | const struct ipt_entry *e = par->entryinfo; |
100 | 100 | ||
101 | if (einfo->operation & IPT_ECN_OP_MASK) { | 101 | if (einfo->operation & IPT_ECN_OP_MASK) |
102 | pr_info("unsupported ECN operation %x\n", einfo->operation); | ||
103 | return -EINVAL; | 102 | return -EINVAL; |
104 | } | 103 | |
105 | if (einfo->ip_ect & ~IPT_ECN_IP_MASK) { | 104 | if (einfo->ip_ect & ~IPT_ECN_IP_MASK) |
106 | pr_info("new ECT codepoint %x out of mask\n", einfo->ip_ect); | ||
107 | return -EINVAL; | 105 | return -EINVAL; |
108 | } | 106 | |
109 | if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR)) && | 107 | if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR)) && |
110 | (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) { | 108 | (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) { |
111 | pr_info("cannot use TCP operations on a non-tcp rule\n"); | 109 | pr_info_ratelimited("cannot use operation on non-tcp rule\n"); |
112 | return -EINVAL; | 110 | return -EINVAL; |
113 | } | 111 | } |
114 | return 0; | 112 | return 0; |
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index 8bd0d7b26632..e8bed3390e58 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c | |||
@@ -74,13 +74,13 @@ static int reject_tg_check(const struct xt_tgchk_param *par) | |||
74 | const struct ipt_entry *e = par->entryinfo; | 74 | const struct ipt_entry *e = par->entryinfo; |
75 | 75 | ||
76 | if (rejinfo->with == IPT_ICMP_ECHOREPLY) { | 76 | if (rejinfo->with == IPT_ICMP_ECHOREPLY) { |
77 | pr_info("ECHOREPLY no longer supported.\n"); | 77 | pr_info_ratelimited("ECHOREPLY no longer supported.\n"); |
78 | return -EINVAL; | 78 | return -EINVAL; |
79 | } else if (rejinfo->with == IPT_TCP_RESET) { | 79 | } else if (rejinfo->with == IPT_TCP_RESET) { |
80 | /* Must specify that it's a TCP packet */ | 80 | /* Must specify that it's a TCP packet */ |
81 | if (e->ip.proto != IPPROTO_TCP || | 81 | if (e->ip.proto != IPPROTO_TCP || |
82 | (e->ip.invflags & XT_INV_PROTO)) { | 82 | (e->ip.invflags & XT_INV_PROTO)) { |
83 | pr_info("TCP_RESET invalid for non-tcp\n"); | 83 | pr_info_ratelimited("TCP_RESET invalid for non-tcp\n"); |
84 | return -EINVAL; | 84 | return -EINVAL; |
85 | } | 85 | } |
86 | } | 86 | } |
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c index 37fb9552e858..fd01f13c896a 100644 --- a/net/ipv4/netfilter/ipt_rpfilter.c +++ b/net/ipv4/netfilter/ipt_rpfilter.c | |||
@@ -105,14 +105,14 @@ static int rpfilter_check(const struct xt_mtchk_param *par) | |||
105 | const struct xt_rpfilter_info *info = par->matchinfo; | 105 | const struct xt_rpfilter_info *info = par->matchinfo; |
106 | unsigned int options = ~XT_RPFILTER_OPTION_MASK; | 106 | unsigned int options = ~XT_RPFILTER_OPTION_MASK; |
107 | if (info->flags & options) { | 107 | if (info->flags & options) { |
108 | pr_info("unknown options encountered"); | 108 | pr_info_ratelimited("unknown options\n"); |
109 | return -EINVAL; | 109 | return -EINVAL; |
110 | } | 110 | } |
111 | 111 | ||
112 | if (strcmp(par->table, "mangle") != 0 && | 112 | if (strcmp(par->table, "mangle") != 0 && |
113 | strcmp(par->table, "raw") != 0) { | 113 | strcmp(par->table, "raw") != 0) { |
114 | pr_info("match only valid in the \'raw\' " | 114 | pr_info_ratelimited("only valid in \'raw\' or \'mangle\' table, not \'%s\'\n", |
115 | "or \'mangle\' tables, not \'%s\'.\n", par->table); | 115 | par->table); |
116 | return -EINVAL; | 116 | return -EINVAL; |
117 | } | 117 | } |
118 | 118 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 5ca7415cd48c..26eefa2eaa44 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1811,6 +1811,8 @@ int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4, | |||
1811 | return skb_get_hash_raw(skb) >> 1; | 1811 | return skb_get_hash_raw(skb) >> 1; |
1812 | memset(&hash_keys, 0, sizeof(hash_keys)); | 1812 | memset(&hash_keys, 0, sizeof(hash_keys)); |
1813 | skb_flow_dissect_flow_keys(skb, &keys, flag); | 1813 | skb_flow_dissect_flow_keys(skb, &keys, flag); |
1814 | |||
1815 | hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; | ||
1814 | hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src; | 1816 | hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src; |
1815 | hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst; | 1817 | hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst; |
1816 | hash_keys.ports.src = keys.ports.src; | 1818 | hash_keys.ports.src = keys.ports.src; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 8795d76f987c..49d043de3476 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -1718,7 +1718,7 @@ u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now, | |||
1718 | */ | 1718 | */ |
1719 | segs = max_t(u32, bytes / mss_now, min_tso_segs); | 1719 | segs = max_t(u32, bytes / mss_now, min_tso_segs); |
1720 | 1720 | ||
1721 | return min_t(u32, segs, sk->sk_gso_max_segs); | 1721 | return segs; |
1722 | } | 1722 | } |
1723 | EXPORT_SYMBOL(tcp_tso_autosize); | 1723 | EXPORT_SYMBOL(tcp_tso_autosize); |
1724 | 1724 | ||
@@ -1730,9 +1730,10 @@ static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now) | |||
1730 | const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; | 1730 | const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; |
1731 | u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0; | 1731 | u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0; |
1732 | 1732 | ||
1733 | return tso_segs ? : | 1733 | if (!tso_segs) |
1734 | tcp_tso_autosize(sk, mss_now, | 1734 | tso_segs = tcp_tso_autosize(sk, mss_now, |
1735 | sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs); | 1735 | sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs); |
1736 | return min_t(u32, tso_segs, sk->sk_gso_max_segs); | ||
1736 | } | 1737 | } |
1737 | 1738 | ||
1738 | /* Returns the portion of skb which can be sent right away */ | 1739 | /* Returns the portion of skb which can be sent right away */ |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index d78d41fc4b1a..24535169663d 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -1367,10 +1367,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
1367 | if (get_user(len, optlen)) | 1367 | if (get_user(len, optlen)) |
1368 | return -EFAULT; | 1368 | return -EFAULT; |
1369 | 1369 | ||
1370 | lock_sock(sk); | 1370 | err = nf_getsockopt(sk, PF_INET6, optname, optval, &len); |
1371 | err = nf_getsockopt(sk, PF_INET6, optname, optval, | ||
1372 | &len); | ||
1373 | release_sock(sk); | ||
1374 | if (err >= 0) | 1371 | if (err >= 0) |
1375 | err = put_user(len, optlen); | 1372 | err = put_user(len, optlen); |
1376 | } | 1373 | } |
@@ -1409,10 +1406,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
1409 | if (get_user(len, optlen)) | 1406 | if (get_user(len, optlen)) |
1410 | return -EFAULT; | 1407 | return -EFAULT; |
1411 | 1408 | ||
1412 | lock_sock(sk); | 1409 | err = compat_nf_getsockopt(sk, PF_INET6, optname, optval, &len); |
1413 | err = compat_nf_getsockopt(sk, PF_INET6, | ||
1414 | optname, optval, &len); | ||
1415 | release_sock(sk); | ||
1416 | if (err >= 0) | 1410 | if (err >= 0) |
1417 | err = put_user(len, optlen); | 1411 | err = put_user(len, optlen); |
1418 | } | 1412 | } |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index af4c917e0836..62358b93bbac 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -352,6 +352,10 @@ ip6t_do_table(struct sk_buff *skb, | |||
352 | } | 352 | } |
353 | if (table_base + v != ip6t_next_entry(e) && | 353 | if (table_base + v != ip6t_next_entry(e) && |
354 | !(e->ipv6.flags & IP6T_F_GOTO)) { | 354 | !(e->ipv6.flags & IP6T_F_GOTO)) { |
355 | if (unlikely(stackidx >= private->stacksize)) { | ||
356 | verdict = NF_DROP; | ||
357 | break; | ||
358 | } | ||
355 | jumpstack[stackidx++] = e; | 359 | jumpstack[stackidx++] = e; |
356 | } | 360 | } |
357 | 361 | ||
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index fa51a205918d..38dea8ff680f 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -85,14 +85,14 @@ static int reject_tg6_check(const struct xt_tgchk_param *par) | |||
85 | const struct ip6t_entry *e = par->entryinfo; | 85 | const struct ip6t_entry *e = par->entryinfo; |
86 | 86 | ||
87 | if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) { | 87 | if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) { |
88 | pr_info("ECHOREPLY is not supported.\n"); | 88 | pr_info_ratelimited("ECHOREPLY is not supported\n"); |
89 | return -EINVAL; | 89 | return -EINVAL; |
90 | } else if (rejinfo->with == IP6T_TCP_RESET) { | 90 | } else if (rejinfo->with == IP6T_TCP_RESET) { |
91 | /* Must specify that it's a TCP packet */ | 91 | /* Must specify that it's a TCP packet */ |
92 | if (!(e->ipv6.flags & IP6T_F_PROTO) || | 92 | if (!(e->ipv6.flags & IP6T_F_PROTO) || |
93 | e->ipv6.proto != IPPROTO_TCP || | 93 | e->ipv6.proto != IPPROTO_TCP || |
94 | (e->ipv6.invflags & XT_INV_PROTO)) { | 94 | (e->ipv6.invflags & XT_INV_PROTO)) { |
95 | pr_info("TCP_RESET illegal for non-tcp\n"); | 95 | pr_info_ratelimited("TCP_RESET illegal for non-tcp\n"); |
96 | return -EINVAL; | 96 | return -EINVAL; |
97 | } | 97 | } |
98 | } | 98 | } |
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c index b12e61b7b16c..94deb69bbbda 100644 --- a/net/ipv6/netfilter/ip6t_rpfilter.c +++ b/net/ipv6/netfilter/ip6t_rpfilter.c | |||
@@ -103,14 +103,14 @@ static int rpfilter_check(const struct xt_mtchk_param *par) | |||
103 | unsigned int options = ~XT_RPFILTER_OPTION_MASK; | 103 | unsigned int options = ~XT_RPFILTER_OPTION_MASK; |
104 | 104 | ||
105 | if (info->flags & options) { | 105 | if (info->flags & options) { |
106 | pr_info("unknown options encountered"); | 106 | pr_info_ratelimited("unknown options\n"); |
107 | return -EINVAL; | 107 | return -EINVAL; |
108 | } | 108 | } |
109 | 109 | ||
110 | if (strcmp(par->table, "mangle") != 0 && | 110 | if (strcmp(par->table, "mangle") != 0 && |
111 | strcmp(par->table, "raw") != 0) { | 111 | strcmp(par->table, "raw") != 0) { |
112 | pr_info("match only valid in the \'raw\' " | 112 | pr_info_ratelimited("only valid in \'raw\' or \'mangle\' table, not \'%s\'\n", |
113 | "or \'mangle\' tables, not \'%s\'.\n", par->table); | 113 | par->table); |
114 | return -EINVAL; | 114 | return -EINVAL; |
115 | } | 115 | } |
116 | 116 | ||
diff --git a/net/ipv6/netfilter/ip6t_srh.c b/net/ipv6/netfilter/ip6t_srh.c index 9642164107ce..33719d5560c8 100644 --- a/net/ipv6/netfilter/ip6t_srh.c +++ b/net/ipv6/netfilter/ip6t_srh.c | |||
@@ -122,12 +122,14 @@ static int srh_mt6_check(const struct xt_mtchk_param *par) | |||
122 | const struct ip6t_srh *srhinfo = par->matchinfo; | 122 | const struct ip6t_srh *srhinfo = par->matchinfo; |
123 | 123 | ||
124 | if (srhinfo->mt_flags & ~IP6T_SRH_MASK) { | 124 | if (srhinfo->mt_flags & ~IP6T_SRH_MASK) { |
125 | pr_err("unknown srh match flags %X\n", srhinfo->mt_flags); | 125 | pr_info_ratelimited("unknown srh match flags %X\n", |
126 | srhinfo->mt_flags); | ||
126 | return -EINVAL; | 127 | return -EINVAL; |
127 | } | 128 | } |
128 | 129 | ||
129 | if (srhinfo->mt_invflags & ~IP6T_SRH_INV_MASK) { | 130 | if (srhinfo->mt_invflags & ~IP6T_SRH_INV_MASK) { |
130 | pr_err("unknown srh invflags %X\n", srhinfo->mt_invflags); | 131 | pr_info_ratelimited("unknown srh invflags %X\n", |
132 | srhinfo->mt_invflags); | ||
131 | return -EINVAL; | 133 | return -EINVAL; |
132 | } | 134 | } |
133 | 135 | ||
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 3873d3877135..3a1775a62973 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -182,7 +182,7 @@ static void ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn) | |||
182 | #ifdef CONFIG_IPV6_SIT_6RD | 182 | #ifdef CONFIG_IPV6_SIT_6RD |
183 | struct ip_tunnel *t = netdev_priv(dev); | 183 | struct ip_tunnel *t = netdev_priv(dev); |
184 | 184 | ||
185 | if (t->dev == sitn->fb_tunnel_dev) { | 185 | if (dev == sitn->fb_tunnel_dev) { |
186 | ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0); | 186 | ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0); |
187 | t->ip6rd.relay_prefix = 0; | 187 | t->ip6rd.relay_prefix = 0; |
188 | t->ip6rd.prefixlen = 16; | 188 | t->ip6rd.prefixlen = 16; |
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index a8b1616cec41..1f3188d03840 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> | 8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> |
9 | * Copyright 2007-2010, Intel Corporation | 9 | * Copyright 2007-2010, Intel Corporation |
10 | * Copyright(c) 2015-2017 Intel Deutschland GmbH | 10 | * Copyright(c) 2015-2017 Intel Deutschland GmbH |
11 | * Copyright (C) 2018 Intel Corporation | ||
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
@@ -304,9 +305,6 @@ void ___ieee80211_start_rx_ba_session(struct sta_info *sta, | |||
304 | * driver so reject the timeout update. | 305 | * driver so reject the timeout update. |
305 | */ | 306 | */ |
306 | status = WLAN_STATUS_REQUEST_DECLINED; | 307 | status = WLAN_STATUS_REQUEST_DECLINED; |
307 | ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, | ||
308 | tid, dialog_token, status, | ||
309 | 1, buf_size, timeout); | ||
310 | goto end; | 308 | goto end; |
311 | } | 309 | } |
312 | 310 | ||
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 46028e12e216..f4195a0f0279 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -2892,7 +2892,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) | |||
2892 | } | 2892 | } |
2893 | if (beacon->probe_resp_len) { | 2893 | if (beacon->probe_resp_len) { |
2894 | new_beacon->probe_resp_len = beacon->probe_resp_len; | 2894 | new_beacon->probe_resp_len = beacon->probe_resp_len; |
2895 | beacon->probe_resp = pos; | 2895 | new_beacon->probe_resp = pos; |
2896 | memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); | 2896 | memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); |
2897 | pos += beacon->probe_resp_len; | 2897 | pos += beacon->probe_resp_len; |
2898 | } | 2898 | } |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 26900025de2f..ae9c33cd8ada 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -1467,7 +1467,7 @@ struct ieee802_11_elems { | |||
1467 | const struct ieee80211_timeout_interval_ie *timeout_int; | 1467 | const struct ieee80211_timeout_interval_ie *timeout_int; |
1468 | const u8 *opmode_notif; | 1468 | const u8 *opmode_notif; |
1469 | const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; | 1469 | const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; |
1470 | const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; | 1470 | struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; |
1471 | const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; | 1471 | const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; |
1472 | 1472 | ||
1473 | /* length of them, respectively */ | 1473 | /* length of them, respectively */ |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 73ac607beb5d..6a381cbe1e33 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -1255,13 +1255,12 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, | |||
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, | 1257 | static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, |
1258 | struct ieee80211_mgmt *mgmt, size_t len) | 1258 | struct ieee80211_mgmt *mgmt, size_t len, |
1259 | struct ieee802_11_elems *elems) | ||
1259 | { | 1260 | { |
1260 | struct ieee80211_mgmt *mgmt_fwd; | 1261 | struct ieee80211_mgmt *mgmt_fwd; |
1261 | struct sk_buff *skb; | 1262 | struct sk_buff *skb; |
1262 | struct ieee80211_local *local = sdata->local; | 1263 | struct ieee80211_local *local = sdata->local; |
1263 | u8 *pos = mgmt->u.action.u.chan_switch.variable; | ||
1264 | size_t offset_ttl; | ||
1265 | 1264 | ||
1266 | skb = dev_alloc_skb(local->tx_headroom + len); | 1265 | skb = dev_alloc_skb(local->tx_headroom + len); |
1267 | if (!skb) | 1266 | if (!skb) |
@@ -1269,13 +1268,9 @@ static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, | |||
1269 | skb_reserve(skb, local->tx_headroom); | 1268 | skb_reserve(skb, local->tx_headroom); |
1270 | mgmt_fwd = skb_put(skb, len); | 1269 | mgmt_fwd = skb_put(skb, len); |
1271 | 1270 | ||
1272 | /* offset_ttl is based on whether the secondary channel | 1271 | elems->mesh_chansw_params_ie->mesh_ttl--; |
1273 | * offset is available or not. Subtract 1 from the mesh TTL | 1272 | elems->mesh_chansw_params_ie->mesh_flags &= |
1274 | * and disable the initiator flag before forwarding. | 1273 | ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; |
1275 | */ | ||
1276 | offset_ttl = (len < 42) ? 7 : 10; | ||
1277 | *(pos + offset_ttl) -= 1; | ||
1278 | *(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; | ||
1279 | 1274 | ||
1280 | memcpy(mgmt_fwd, mgmt, len); | 1275 | memcpy(mgmt_fwd, mgmt, len); |
1281 | eth_broadcast_addr(mgmt_fwd->da); | 1276 | eth_broadcast_addr(mgmt_fwd->da); |
@@ -1323,7 +1318,7 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata, | |||
1323 | 1318 | ||
1324 | /* forward or re-broadcast the CSA frame */ | 1319 | /* forward or re-broadcast the CSA frame */ |
1325 | if (fwd_csa) { | 1320 | if (fwd_csa) { |
1326 | if (mesh_fwd_csa_frame(sdata, mgmt, len) < 0) | 1321 | if (mesh_fwd_csa_frame(sdata, mgmt, len, &elems) < 0) |
1327 | mcsa_dbg(sdata, "Failed to forward the CSA frame"); | 1322 | mcsa_dbg(sdata, "Failed to forward the CSA frame"); |
1328 | } | 1323 | } |
1329 | } | 1324 | } |
diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c index ee0181778a42..029334835747 100644 --- a/net/mac80211/spectmgmt.c +++ b/net/mac80211/spectmgmt.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> | 8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> |
9 | * Copyright 2007-2008, Intel Corporation | 9 | * Copyright 2007-2008, Intel Corporation |
10 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | 10 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> |
11 | * Copyright (C) 2018 Intel Corporation | ||
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
@@ -27,7 +28,7 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, | |||
27 | u32 sta_flags, u8 *bssid, | 28 | u32 sta_flags, u8 *bssid, |
28 | struct ieee80211_csa_ie *csa_ie) | 29 | struct ieee80211_csa_ie *csa_ie) |
29 | { | 30 | { |
30 | enum nl80211_band new_band; | 31 | enum nl80211_band new_band = current_band; |
31 | int new_freq; | 32 | int new_freq; |
32 | u8 new_chan_no; | 33 | u8 new_chan_no; |
33 | struct ieee80211_channel *new_chan; | 34 | struct ieee80211_channel *new_chan; |
@@ -55,15 +56,13 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, | |||
55 | elems->ext_chansw_ie->new_operating_class, | 56 | elems->ext_chansw_ie->new_operating_class, |
56 | &new_band)) { | 57 | &new_band)) { |
57 | sdata_info(sdata, | 58 | sdata_info(sdata, |
58 | "cannot understand ECSA IE operating class %d, disconnecting\n", | 59 | "cannot understand ECSA IE operating class, %d, ignoring\n", |
59 | elems->ext_chansw_ie->new_operating_class); | 60 | elems->ext_chansw_ie->new_operating_class); |
60 | return -EINVAL; | ||
61 | } | 61 | } |
62 | new_chan_no = elems->ext_chansw_ie->new_ch_num; | 62 | new_chan_no = elems->ext_chansw_ie->new_ch_num; |
63 | csa_ie->count = elems->ext_chansw_ie->count; | 63 | csa_ie->count = elems->ext_chansw_ie->count; |
64 | csa_ie->mode = elems->ext_chansw_ie->mode; | 64 | csa_ie->mode = elems->ext_chansw_ie->mode; |
65 | } else if (elems->ch_switch_ie) { | 65 | } else if (elems->ch_switch_ie) { |
66 | new_band = current_band; | ||
67 | new_chan_no = elems->ch_switch_ie->new_ch_num; | 66 | new_chan_no = elems->ch_switch_ie->new_ch_num; |
68 | csa_ie->count = elems->ch_switch_ie->count; | 67 | csa_ie->count = elems->ch_switch_ie->count; |
69 | csa_ie->mode = elems->ch_switch_ie->mode; | 68 | csa_ie->mode = elems->ch_switch_ie->mode; |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 0bc40c719a55..655c3d8b0d80 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -314,7 +314,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
314 | 314 | ||
315 | if (ieee80211_hw_check(hw, USES_RSS)) { | 315 | if (ieee80211_hw_check(hw, USES_RSS)) { |
316 | sta->pcpu_rx_stats = | 316 | sta->pcpu_rx_stats = |
317 | alloc_percpu(struct ieee80211_sta_rx_stats); | 317 | alloc_percpu_gfp(struct ieee80211_sta_rx_stats, gfp); |
318 | if (!sta->pcpu_rx_stats) | 318 | if (!sta->pcpu_rx_stats) |
319 | goto free; | 319 | goto free; |
320 | } | 320 | } |
@@ -433,6 +433,7 @@ free_txq: | |||
433 | if (sta->sta.txq[0]) | 433 | if (sta->sta.txq[0]) |
434 | kfree(to_txq_info(sta->sta.txq[0])); | 434 | kfree(to_txq_info(sta->sta.txq[0])); |
435 | free: | 435 | free: |
436 | free_percpu(sta->pcpu_rx_stats); | ||
436 | #ifdef CONFIG_MAC80211_MESH | 437 | #ifdef CONFIG_MAC80211_MESH |
437 | kfree(sta->mesh); | 438 | kfree(sta->mesh); |
438 | #endif | 439 | #endif |
diff --git a/net/netfilter/nf_nat_proto_common.c b/net/netfilter/nf_nat_proto_common.c index fbce552a796e..7d7466dbf663 100644 --- a/net/netfilter/nf_nat_proto_common.c +++ b/net/netfilter/nf_nat_proto_common.c | |||
@@ -41,7 +41,7 @@ void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto, | |||
41 | const struct nf_conn *ct, | 41 | const struct nf_conn *ct, |
42 | u16 *rover) | 42 | u16 *rover) |
43 | { | 43 | { |
44 | unsigned int range_size, min, i; | 44 | unsigned int range_size, min, max, i; |
45 | __be16 *portptr; | 45 | __be16 *portptr; |
46 | u_int16_t off; | 46 | u_int16_t off; |
47 | 47 | ||
@@ -71,7 +71,10 @@ void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto, | |||
71 | } | 71 | } |
72 | } else { | 72 | } else { |
73 | min = ntohs(range->min_proto.all); | 73 | min = ntohs(range->min_proto.all); |
74 | range_size = ntohs(range->max_proto.all) - min + 1; | 74 | max = ntohs(range->max_proto.all); |
75 | if (unlikely(max < min)) | ||
76 | swap(max, min); | ||
77 | range_size = max - min + 1; | ||
75 | } | 78 | } |
76 | 79 | ||
77 | if (range->flags & NF_NAT_RANGE_PROTO_RANDOM) { | 80 | if (range->flags & NF_NAT_RANGE_PROTO_RANDOM) { |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index a6a435d7c8f4..d9deebe599ec 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -434,36 +434,35 @@ int xt_check_match(struct xt_mtchk_param *par, | |||
434 | * ebt_among is exempt from centralized matchsize checking | 434 | * ebt_among is exempt from centralized matchsize checking |
435 | * because it uses a dynamic-size data set. | 435 | * because it uses a dynamic-size data set. |
436 | */ | 436 | */ |
437 | pr_err("%s_tables: %s.%u match: invalid size " | 437 | pr_err_ratelimited("%s_tables: %s.%u match: invalid size %u (kernel) != (user) %u\n", |
438 | "%u (kernel) != (user) %u\n", | 438 | xt_prefix[par->family], par->match->name, |
439 | xt_prefix[par->family], par->match->name, | 439 | par->match->revision, |
440 | par->match->revision, | 440 | XT_ALIGN(par->match->matchsize), size); |
441 | XT_ALIGN(par->match->matchsize), size); | ||
442 | return -EINVAL; | 441 | return -EINVAL; |
443 | } | 442 | } |
444 | if (par->match->table != NULL && | 443 | if (par->match->table != NULL && |
445 | strcmp(par->match->table, par->table) != 0) { | 444 | strcmp(par->match->table, par->table) != 0) { |
446 | pr_err("%s_tables: %s match: only valid in %s table, not %s\n", | 445 | pr_info_ratelimited("%s_tables: %s match: only valid in %s table, not %s\n", |
447 | xt_prefix[par->family], par->match->name, | 446 | xt_prefix[par->family], par->match->name, |
448 | par->match->table, par->table); | 447 | par->match->table, par->table); |
449 | return -EINVAL; | 448 | return -EINVAL; |
450 | } | 449 | } |
451 | if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { | 450 | if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { |
452 | char used[64], allow[64]; | 451 | char used[64], allow[64]; |
453 | 452 | ||
454 | pr_err("%s_tables: %s match: used from hooks %s, but only " | 453 | pr_info_ratelimited("%s_tables: %s match: used from hooks %s, but only valid from %s\n", |
455 | "valid from %s\n", | 454 | xt_prefix[par->family], par->match->name, |
456 | xt_prefix[par->family], par->match->name, | 455 | textify_hooks(used, sizeof(used), |
457 | textify_hooks(used, sizeof(used), par->hook_mask, | 456 | par->hook_mask, par->family), |
458 | par->family), | 457 | textify_hooks(allow, sizeof(allow), |
459 | textify_hooks(allow, sizeof(allow), par->match->hooks, | 458 | par->match->hooks, |
460 | par->family)); | 459 | par->family)); |
461 | return -EINVAL; | 460 | return -EINVAL; |
462 | } | 461 | } |
463 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { | 462 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { |
464 | pr_err("%s_tables: %s match: only valid for protocol %u\n", | 463 | pr_info_ratelimited("%s_tables: %s match: only valid for protocol %u\n", |
465 | xt_prefix[par->family], par->match->name, | 464 | xt_prefix[par->family], par->match->name, |
466 | par->match->proto); | 465 | par->match->proto); |
467 | return -EINVAL; | 466 | return -EINVAL; |
468 | } | 467 | } |
469 | if (par->match->checkentry != NULL) { | 468 | if (par->match->checkentry != NULL) { |
@@ -814,36 +813,35 @@ int xt_check_target(struct xt_tgchk_param *par, | |||
814 | int ret; | 813 | int ret; |
815 | 814 | ||
816 | if (XT_ALIGN(par->target->targetsize) != size) { | 815 | if (XT_ALIGN(par->target->targetsize) != size) { |
817 | pr_err("%s_tables: %s.%u target: invalid size " | 816 | pr_err_ratelimited("%s_tables: %s.%u target: invalid size %u (kernel) != (user) %u\n", |
818 | "%u (kernel) != (user) %u\n", | 817 | xt_prefix[par->family], par->target->name, |
819 | xt_prefix[par->family], par->target->name, | 818 | par->target->revision, |
820 | par->target->revision, | 819 | XT_ALIGN(par->target->targetsize), size); |
821 | XT_ALIGN(par->target->targetsize), size); | ||
822 | return -EINVAL; | 820 | return -EINVAL; |
823 | } | 821 | } |
824 | if (par->target->table != NULL && | 822 | if (par->target->table != NULL && |
825 | strcmp(par->target->table, par->table) != 0) { | 823 | strcmp(par->target->table, par->table) != 0) { |
826 | pr_err("%s_tables: %s target: only valid in %s table, not %s\n", | 824 | pr_info_ratelimited("%s_tables: %s target: only valid in %s table, not %s\n", |
827 | xt_prefix[par->family], par->target->name, | 825 | xt_prefix[par->family], par->target->name, |
828 | par->target->table, par->table); | 826 | par->target->table, par->table); |
829 | return -EINVAL; | 827 | return -EINVAL; |
830 | } | 828 | } |
831 | if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { | 829 | if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { |
832 | char used[64], allow[64]; | 830 | char used[64], allow[64]; |
833 | 831 | ||
834 | pr_err("%s_tables: %s target: used from hooks %s, but only " | 832 | pr_info_ratelimited("%s_tables: %s target: used from hooks %s, but only usable from %s\n", |
835 | "usable from %s\n", | 833 | xt_prefix[par->family], par->target->name, |
836 | xt_prefix[par->family], par->target->name, | 834 | textify_hooks(used, sizeof(used), |
837 | textify_hooks(used, sizeof(used), par->hook_mask, | 835 | par->hook_mask, par->family), |
838 | par->family), | 836 | textify_hooks(allow, sizeof(allow), |
839 | textify_hooks(allow, sizeof(allow), par->target->hooks, | 837 | par->target->hooks, |
840 | par->family)); | 838 | par->family)); |
841 | return -EINVAL; | 839 | return -EINVAL; |
842 | } | 840 | } |
843 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { | 841 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { |
844 | pr_err("%s_tables: %s target: only valid for protocol %u\n", | 842 | pr_info_ratelimited("%s_tables: %s target: only valid for protocol %u\n", |
845 | xt_prefix[par->family], par->target->name, | 843 | xt_prefix[par->family], par->target->name, |
846 | par->target->proto); | 844 | par->target->proto); |
847 | return -EINVAL; | 845 | return -EINVAL; |
848 | } | 846 | } |
849 | if (par->target->checkentry != NULL) { | 847 | if (par->target->checkentry != NULL) { |
@@ -1004,10 +1002,6 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) | |||
1004 | if (sz < sizeof(*info)) | 1002 | if (sz < sizeof(*info)) |
1005 | return NULL; | 1003 | return NULL; |
1006 | 1004 | ||
1007 | /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ | ||
1008 | if ((size >> PAGE_SHIFT) + 2 > totalram_pages) | ||
1009 | return NULL; | ||
1010 | |||
1011 | /* __GFP_NORETRY is not fully supported by kvmalloc but it should | 1005 | /* __GFP_NORETRY is not fully supported by kvmalloc but it should |
1012 | * work reasonably well if sz is too large and bail out rather | 1006 | * work reasonably well if sz is too large and bail out rather |
1013 | * than shoot all processes down before realizing there is nothing | 1007 | * than shoot all processes down before realizing there is nothing |
diff --git a/net/netfilter/xt_AUDIT.c b/net/netfilter/xt_AUDIT.c index c502419d6306..f368ee6741db 100644 --- a/net/netfilter/xt_AUDIT.c +++ b/net/netfilter/xt_AUDIT.c | |||
@@ -120,8 +120,8 @@ static int audit_tg_check(const struct xt_tgchk_param *par) | |||
120 | const struct xt_audit_info *info = par->targinfo; | 120 | const struct xt_audit_info *info = par->targinfo; |
121 | 121 | ||
122 | if (info->type > XT_AUDIT_TYPE_MAX) { | 122 | if (info->type > XT_AUDIT_TYPE_MAX) { |
123 | pr_info("Audit type out of range (valid range: 0..%hhu)\n", | 123 | pr_info_ratelimited("Audit type out of range (valid range: 0..%hhu)\n", |
124 | XT_AUDIT_TYPE_MAX); | 124 | XT_AUDIT_TYPE_MAX); |
125 | return -ERANGE; | 125 | return -ERANGE; |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/net/netfilter/xt_CHECKSUM.c b/net/netfilter/xt_CHECKSUM.c index 0f642ef8cd26..9f4151ec3e06 100644 --- a/net/netfilter/xt_CHECKSUM.c +++ b/net/netfilter/xt_CHECKSUM.c | |||
@@ -36,13 +36,13 @@ static int checksum_tg_check(const struct xt_tgchk_param *par) | |||
36 | const struct xt_CHECKSUM_info *einfo = par->targinfo; | 36 | const struct xt_CHECKSUM_info *einfo = par->targinfo; |
37 | 37 | ||
38 | if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { | 38 | if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { |
39 | pr_info("unsupported CHECKSUM operation %x\n", einfo->operation); | 39 | pr_info_ratelimited("unsupported CHECKSUM operation %x\n", |
40 | einfo->operation); | ||
40 | return -EINVAL; | 41 | return -EINVAL; |
41 | } | 42 | } |
42 | if (!einfo->operation) { | 43 | if (!einfo->operation) |
43 | pr_info("no CHECKSUM operation enabled\n"); | ||
44 | return -EINVAL; | 44 | return -EINVAL; |
45 | } | 45 | |
46 | return 0; | 46 | return 0; |
47 | } | 47 | } |
48 | 48 | ||
diff --git a/net/netfilter/xt_CONNSECMARK.c b/net/netfilter/xt_CONNSECMARK.c index da56c06a443c..f3f1caac949b 100644 --- a/net/netfilter/xt_CONNSECMARK.c +++ b/net/netfilter/xt_CONNSECMARK.c | |||
@@ -91,8 +91,8 @@ static int connsecmark_tg_check(const struct xt_tgchk_param *par) | |||
91 | 91 | ||
92 | if (strcmp(par->table, "mangle") != 0 && | 92 | if (strcmp(par->table, "mangle") != 0 && |
93 | strcmp(par->table, "security") != 0) { | 93 | strcmp(par->table, "security") != 0) { |
94 | pr_info("target only valid in the \'mangle\' " | 94 | pr_info_ratelimited("only valid in \'mangle\' or \'security\' table, not \'%s\'\n", |
95 | "or \'security\' tables, not \'%s\'.\n", par->table); | 95 | par->table); |
96 | return -EINVAL; | 96 | return -EINVAL; |
97 | } | 97 | } |
98 | 98 | ||
@@ -102,14 +102,14 @@ static int connsecmark_tg_check(const struct xt_tgchk_param *par) | |||
102 | break; | 102 | break; |
103 | 103 | ||
104 | default: | 104 | default: |
105 | pr_info("invalid mode: %hu\n", info->mode); | 105 | pr_info_ratelimited("invalid mode: %hu\n", info->mode); |
106 | return -EINVAL; | 106 | return -EINVAL; |
107 | } | 107 | } |
108 | 108 | ||
109 | ret = nf_ct_netns_get(par->net, par->family); | 109 | ret = nf_ct_netns_get(par->net, par->family); |
110 | if (ret < 0) | 110 | if (ret < 0) |
111 | pr_info("cannot load conntrack support for proto=%u\n", | 111 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
112 | par->family); | 112 | par->family); |
113 | return ret; | 113 | return ret; |
114 | } | 114 | } |
115 | 115 | ||
diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c index 5a152e2acfd5..8790190c6feb 100644 --- a/net/netfilter/xt_CT.c +++ b/net/netfilter/xt_CT.c | |||
@@ -82,15 +82,14 @@ xt_ct_set_helper(struct nf_conn *ct, const char *helper_name, | |||
82 | 82 | ||
83 | proto = xt_ct_find_proto(par); | 83 | proto = xt_ct_find_proto(par); |
84 | if (!proto) { | 84 | if (!proto) { |
85 | pr_info("You must specify a L4 protocol, and not use " | 85 | pr_info_ratelimited("You must specify a L4 protocol and not use inversions on it\n"); |
86 | "inversions on it.\n"); | ||
87 | return -ENOENT; | 86 | return -ENOENT; |
88 | } | 87 | } |
89 | 88 | ||
90 | helper = nf_conntrack_helper_try_module_get(helper_name, par->family, | 89 | helper = nf_conntrack_helper_try_module_get(helper_name, par->family, |
91 | proto); | 90 | proto); |
92 | if (helper == NULL) { | 91 | if (helper == NULL) { |
93 | pr_info("No such helper \"%s\"\n", helper_name); | 92 | pr_info_ratelimited("No such helper \"%s\"\n", helper_name); |
94 | return -ENOENT; | 93 | return -ENOENT; |
95 | } | 94 | } |
96 | 95 | ||
@@ -124,6 +123,7 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par, | |||
124 | const struct nf_conntrack_l4proto *l4proto; | 123 | const struct nf_conntrack_l4proto *l4proto; |
125 | struct ctnl_timeout *timeout; | 124 | struct ctnl_timeout *timeout; |
126 | struct nf_conn_timeout *timeout_ext; | 125 | struct nf_conn_timeout *timeout_ext; |
126 | const char *errmsg = NULL; | ||
127 | int ret = 0; | 127 | int ret = 0; |
128 | u8 proto; | 128 | u8 proto; |
129 | 129 | ||
@@ -131,29 +131,29 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par, | |||
131 | timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook); | 131 | timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook); |
132 | if (timeout_find_get == NULL) { | 132 | if (timeout_find_get == NULL) { |
133 | ret = -ENOENT; | 133 | ret = -ENOENT; |
134 | pr_info("Timeout policy base is empty\n"); | 134 | errmsg = "Timeout policy base is empty"; |
135 | goto out; | 135 | goto out; |
136 | } | 136 | } |
137 | 137 | ||
138 | proto = xt_ct_find_proto(par); | 138 | proto = xt_ct_find_proto(par); |
139 | if (!proto) { | 139 | if (!proto) { |
140 | ret = -EINVAL; | 140 | ret = -EINVAL; |
141 | pr_info("You must specify a L4 protocol, and not use " | 141 | errmsg = "You must specify a L4 protocol and not use inversions on it"; |
142 | "inversions on it.\n"); | ||
143 | goto out; | 142 | goto out; |
144 | } | 143 | } |
145 | 144 | ||
146 | timeout = timeout_find_get(par->net, timeout_name); | 145 | timeout = timeout_find_get(par->net, timeout_name); |
147 | if (timeout == NULL) { | 146 | if (timeout == NULL) { |
148 | ret = -ENOENT; | 147 | ret = -ENOENT; |
149 | pr_info("No such timeout policy \"%s\"\n", timeout_name); | 148 | pr_info_ratelimited("No such timeout policy \"%s\"\n", |
149 | timeout_name); | ||
150 | goto out; | 150 | goto out; |
151 | } | 151 | } |
152 | 152 | ||
153 | if (timeout->l3num != par->family) { | 153 | if (timeout->l3num != par->family) { |
154 | ret = -EINVAL; | 154 | ret = -EINVAL; |
155 | pr_info("Timeout policy `%s' can only be used by L3 protocol " | 155 | pr_info_ratelimited("Timeout policy `%s' can only be used by L%d protocol number %d\n", |
156 | "number %d\n", timeout_name, timeout->l3num); | 156 | timeout_name, 3, timeout->l3num); |
157 | goto err_put_timeout; | 157 | goto err_put_timeout; |
158 | } | 158 | } |
159 | /* Make sure the timeout policy matches any existing protocol tracker, | 159 | /* Make sure the timeout policy matches any existing protocol tracker, |
@@ -162,9 +162,8 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par, | |||
162 | l4proto = __nf_ct_l4proto_find(par->family, proto); | 162 | l4proto = __nf_ct_l4proto_find(par->family, proto); |
163 | if (timeout->l4proto->l4proto != l4proto->l4proto) { | 163 | if (timeout->l4proto->l4proto != l4proto->l4proto) { |
164 | ret = -EINVAL; | 164 | ret = -EINVAL; |
165 | pr_info("Timeout policy `%s' can only be used by L4 protocol " | 165 | pr_info_ratelimited("Timeout policy `%s' can only be used by L%d protocol number %d\n", |
166 | "number %d\n", | 166 | timeout_name, 4, timeout->l4proto->l4proto); |
167 | timeout_name, timeout->l4proto->l4proto); | ||
168 | goto err_put_timeout; | 167 | goto err_put_timeout; |
169 | } | 168 | } |
170 | timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC); | 169 | timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC); |
@@ -180,6 +179,8 @@ err_put_timeout: | |||
180 | __xt_ct_tg_timeout_put(timeout); | 179 | __xt_ct_tg_timeout_put(timeout); |
181 | out: | 180 | out: |
182 | rcu_read_unlock(); | 181 | rcu_read_unlock(); |
182 | if (errmsg) | ||
183 | pr_info_ratelimited("%s\n", errmsg); | ||
183 | return ret; | 184 | return ret; |
184 | #else | 185 | #else |
185 | return -EOPNOTSUPP; | 186 | return -EOPNOTSUPP; |
diff --git a/net/netfilter/xt_DSCP.c b/net/netfilter/xt_DSCP.c index 3f83d38c4e5b..098ed851b7a7 100644 --- a/net/netfilter/xt_DSCP.c +++ b/net/netfilter/xt_DSCP.c | |||
@@ -66,10 +66,8 @@ static int dscp_tg_check(const struct xt_tgchk_param *par) | |||
66 | { | 66 | { |
67 | const struct xt_DSCP_info *info = par->targinfo; | 67 | const struct xt_DSCP_info *info = par->targinfo; |
68 | 68 | ||
69 | if (info->dscp > XT_DSCP_MAX) { | 69 | if (info->dscp > XT_DSCP_MAX) |
70 | pr_info("dscp %x out of range\n", info->dscp); | ||
71 | return -EDOM; | 70 | return -EDOM; |
72 | } | ||
73 | return 0; | 71 | return 0; |
74 | } | 72 | } |
75 | 73 | ||
diff --git a/net/netfilter/xt_HL.c b/net/netfilter/xt_HL.c index 1535e87ed9bd..4653b071bed4 100644 --- a/net/netfilter/xt_HL.c +++ b/net/netfilter/xt_HL.c | |||
@@ -105,10 +105,8 @@ static int ttl_tg_check(const struct xt_tgchk_param *par) | |||
105 | { | 105 | { |
106 | const struct ipt_TTL_info *info = par->targinfo; | 106 | const struct ipt_TTL_info *info = par->targinfo; |
107 | 107 | ||
108 | if (info->mode > IPT_TTL_MAXMODE) { | 108 | if (info->mode > IPT_TTL_MAXMODE) |
109 | pr_info("TTL: invalid or unknown mode %u\n", info->mode); | ||
110 | return -EINVAL; | 109 | return -EINVAL; |
111 | } | ||
112 | if (info->mode != IPT_TTL_SET && info->ttl == 0) | 110 | if (info->mode != IPT_TTL_SET && info->ttl == 0) |
113 | return -EINVAL; | 111 | return -EINVAL; |
114 | return 0; | 112 | return 0; |
@@ -118,15 +116,10 @@ static int hl_tg6_check(const struct xt_tgchk_param *par) | |||
118 | { | 116 | { |
119 | const struct ip6t_HL_info *info = par->targinfo; | 117 | const struct ip6t_HL_info *info = par->targinfo; |
120 | 118 | ||
121 | if (info->mode > IP6T_HL_MAXMODE) { | 119 | if (info->mode > IP6T_HL_MAXMODE) |
122 | pr_info("invalid or unknown mode %u\n", info->mode); | ||
123 | return -EINVAL; | 120 | return -EINVAL; |
124 | } | 121 | if (info->mode != IP6T_HL_SET && info->hop_limit == 0) |
125 | if (info->mode != IP6T_HL_SET && info->hop_limit == 0) { | ||
126 | pr_info("increment/decrement does not " | ||
127 | "make sense with value 0\n"); | ||
128 | return -EINVAL; | 122 | return -EINVAL; |
129 | } | ||
130 | return 0; | 123 | return 0; |
131 | } | 124 | } |
132 | 125 | ||
diff --git a/net/netfilter/xt_HMARK.c b/net/netfilter/xt_HMARK.c index 60e6dbe12460..9c75f419cd80 100644 --- a/net/netfilter/xt_HMARK.c +++ b/net/netfilter/xt_HMARK.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * the Free Software Foundation. | 9 | * the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/skbuff.h> | 15 | #include <linux/skbuff.h> |
14 | #include <linux/icmp.h> | 16 | #include <linux/icmp.h> |
@@ -312,29 +314,30 @@ hmark_tg_v4(struct sk_buff *skb, const struct xt_action_param *par) | |||
312 | static int hmark_tg_check(const struct xt_tgchk_param *par) | 314 | static int hmark_tg_check(const struct xt_tgchk_param *par) |
313 | { | 315 | { |
314 | const struct xt_hmark_info *info = par->targinfo; | 316 | const struct xt_hmark_info *info = par->targinfo; |
317 | const char *errmsg = "proto mask must be zero with L3 mode"; | ||
315 | 318 | ||
316 | if (!info->hmodulus) { | 319 | if (!info->hmodulus) |
317 | pr_info("xt_HMARK: hash modulus can't be zero\n"); | ||
318 | return -EINVAL; | 320 | return -EINVAL; |
319 | } | 321 | |
320 | if (info->proto_mask && | 322 | if (info->proto_mask && |
321 | (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3))) { | 323 | (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3))) |
322 | pr_info("xt_HMARK: proto mask must be zero with L3 mode\n"); | 324 | goto err; |
323 | return -EINVAL; | 325 | |
324 | } | ||
325 | if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI_MASK) && | 326 | if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI_MASK) && |
326 | (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT_MASK) | | 327 | (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT_MASK) | |
327 | XT_HMARK_FLAG(XT_HMARK_DPORT_MASK)))) { | 328 | XT_HMARK_FLAG(XT_HMARK_DPORT_MASK)))) |
328 | pr_info("xt_HMARK: spi-mask and port-mask can't be combined\n"); | ||
329 | return -EINVAL; | 329 | return -EINVAL; |
330 | } | 330 | |
331 | if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI) && | 331 | if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI) && |
332 | (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT) | | 332 | (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT) | |
333 | XT_HMARK_FLAG(XT_HMARK_DPORT)))) { | 333 | XT_HMARK_FLAG(XT_HMARK_DPORT)))) { |
334 | pr_info("xt_HMARK: spi-set and port-set can't be combined\n"); | 334 | errmsg = "spi-set and port-set can't be combined"; |
335 | return -EINVAL; | 335 | goto err; |
336 | } | 336 | } |
337 | return 0; | 337 | return 0; |
338 | err: | ||
339 | pr_info_ratelimited("%s\n", errmsg); | ||
340 | return -EINVAL; | ||
338 | } | 341 | } |
339 | 342 | ||
340 | static struct xt_target hmark_tg_reg[] __read_mostly = { | 343 | static struct xt_target hmark_tg_reg[] __read_mostly = { |
diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c index 6c2482b709b1..1ac6600bfafd 100644 --- a/net/netfilter/xt_IDLETIMER.c +++ b/net/netfilter/xt_IDLETIMER.c | |||
@@ -146,11 +146,11 @@ static int idletimer_tg_create(struct idletimer_tg_info *info) | |||
146 | timer_setup(&info->timer->timer, idletimer_tg_expired, 0); | 146 | timer_setup(&info->timer->timer, idletimer_tg_expired, 0); |
147 | info->timer->refcnt = 1; | 147 | info->timer->refcnt = 1; |
148 | 148 | ||
149 | INIT_WORK(&info->timer->work, idletimer_tg_work); | ||
150 | |||
149 | mod_timer(&info->timer->timer, | 151 | mod_timer(&info->timer->timer, |
150 | msecs_to_jiffies(info->timeout * 1000) + jiffies); | 152 | msecs_to_jiffies(info->timeout * 1000) + jiffies); |
151 | 153 | ||
152 | INIT_WORK(&info->timer->work, idletimer_tg_work); | ||
153 | |||
154 | return 0; | 154 | return 0; |
155 | 155 | ||
156 | out_free_attr: | 156 | out_free_attr: |
@@ -191,7 +191,10 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par) | |||
191 | pr_debug("timeout value is zero\n"); | 191 | pr_debug("timeout value is zero\n"); |
192 | return -EINVAL; | 192 | return -EINVAL; |
193 | } | 193 | } |
194 | 194 | if (info->timeout >= INT_MAX / 1000) { | |
195 | pr_debug("timeout value is too big\n"); | ||
196 | return -EINVAL; | ||
197 | } | ||
195 | if (info->label[0] == '\0' || | 198 | if (info->label[0] == '\0' || |
196 | strnlen(info->label, | 199 | strnlen(info->label, |
197 | MAX_IDLETIMER_LABEL_SIZE) == MAX_IDLETIMER_LABEL_SIZE) { | 200 | MAX_IDLETIMER_LABEL_SIZE) == MAX_IDLETIMER_LABEL_SIZE) { |
diff --git a/net/netfilter/xt_LED.c b/net/netfilter/xt_LED.c index 1dcad893df78..19846445504d 100644 --- a/net/netfilter/xt_LED.c +++ b/net/netfilter/xt_LED.c | |||
@@ -111,10 +111,8 @@ static int led_tg_check(const struct xt_tgchk_param *par) | |||
111 | struct xt_led_info_internal *ledinternal; | 111 | struct xt_led_info_internal *ledinternal; |
112 | int err; | 112 | int err; |
113 | 113 | ||
114 | if (ledinfo->id[0] == '\0') { | 114 | if (ledinfo->id[0] == '\0') |
115 | pr_info("No 'id' parameter given.\n"); | ||
116 | return -EINVAL; | 115 | return -EINVAL; |
117 | } | ||
118 | 116 | ||
119 | mutex_lock(&xt_led_mutex); | 117 | mutex_lock(&xt_led_mutex); |
120 | 118 | ||
@@ -138,13 +136,14 @@ static int led_tg_check(const struct xt_tgchk_param *par) | |||
138 | 136 | ||
139 | err = led_trigger_register(&ledinternal->netfilter_led_trigger); | 137 | err = led_trigger_register(&ledinternal->netfilter_led_trigger); |
140 | if (err) { | 138 | if (err) { |
141 | pr_err("Trigger name is already in use.\n"); | 139 | pr_info_ratelimited("Trigger name is already in use.\n"); |
142 | goto exit_alloc; | 140 | goto exit_alloc; |
143 | } | 141 | } |
144 | 142 | ||
145 | /* See if we need to set up a timer */ | 143 | /* Since the letinternal timer can be shared between multiple targets, |
146 | if (ledinfo->delay > 0) | 144 | * always set it up, even if the current target does not need it |
147 | timer_setup(&ledinternal->timer, led_timeout_callback, 0); | 145 | */ |
146 | timer_setup(&ledinternal->timer, led_timeout_callback, 0); | ||
148 | 147 | ||
149 | list_add_tail(&ledinternal->list, &xt_led_triggers); | 148 | list_add_tail(&ledinternal->list, &xt_led_triggers); |
150 | 149 | ||
@@ -181,8 +180,7 @@ static void led_tg_destroy(const struct xt_tgdtor_param *par) | |||
181 | 180 | ||
182 | list_del(&ledinternal->list); | 181 | list_del(&ledinternal->list); |
183 | 182 | ||
184 | if (ledinfo->delay > 0) | 183 | del_timer_sync(&ledinternal->timer); |
185 | del_timer_sync(&ledinternal->timer); | ||
186 | 184 | ||
187 | led_trigger_unregister(&ledinternal->netfilter_led_trigger); | 185 | led_trigger_unregister(&ledinternal->netfilter_led_trigger); |
188 | 186 | ||
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c index a360b99a958a..a9aca80a32ae 100644 --- a/net/netfilter/xt_NFQUEUE.c +++ b/net/netfilter/xt_NFQUEUE.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
12 | |||
11 | #include <linux/module.h> | 13 | #include <linux/module.h> |
12 | #include <linux/skbuff.h> | 14 | #include <linux/skbuff.h> |
13 | 15 | ||
@@ -67,13 +69,13 @@ static int nfqueue_tg_check(const struct xt_tgchk_param *par) | |||
67 | init_hashrandom(&jhash_initval); | 69 | init_hashrandom(&jhash_initval); |
68 | 70 | ||
69 | if (info->queues_total == 0) { | 71 | if (info->queues_total == 0) { |
70 | pr_err("NFQUEUE: number of total queues is 0\n"); | 72 | pr_info_ratelimited("number of total queues is 0\n"); |
71 | return -EINVAL; | 73 | return -EINVAL; |
72 | } | 74 | } |
73 | maxid = info->queues_total - 1 + info->queuenum; | 75 | maxid = info->queues_total - 1 + info->queuenum; |
74 | if (maxid > 0xffff) { | 76 | if (maxid > 0xffff) { |
75 | pr_err("NFQUEUE: number of queues (%u) out of range (got %u)\n", | 77 | pr_info_ratelimited("number of queues (%u) out of range (got %u)\n", |
76 | info->queues_total, maxid); | 78 | info->queues_total, maxid); |
77 | return -ERANGE; | 79 | return -ERANGE; |
78 | } | 80 | } |
79 | if (par->target->revision == 2 && info->flags > 1) | 81 | if (par->target->revision == 2 && info->flags > 1) |
diff --git a/net/netfilter/xt_SECMARK.c b/net/netfilter/xt_SECMARK.c index 9faf5e050b79..4ad5fe27e08b 100644 --- a/net/netfilter/xt_SECMARK.c +++ b/net/netfilter/xt_SECMARK.c | |||
@@ -60,18 +60,20 @@ static int checkentry_lsm(struct xt_secmark_target_info *info) | |||
60 | &info->secid); | 60 | &info->secid); |
61 | if (err) { | 61 | if (err) { |
62 | if (err == -EINVAL) | 62 | if (err == -EINVAL) |
63 | pr_info("invalid security context \'%s\'\n", info->secctx); | 63 | pr_info_ratelimited("invalid security context \'%s\'\n", |
64 | info->secctx); | ||
64 | return err; | 65 | return err; |
65 | } | 66 | } |
66 | 67 | ||
67 | if (!info->secid) { | 68 | if (!info->secid) { |
68 | pr_info("unable to map security context \'%s\'\n", info->secctx); | 69 | pr_info_ratelimited("unable to map security context \'%s\'\n", |
70 | info->secctx); | ||
69 | return -ENOENT; | 71 | return -ENOENT; |
70 | } | 72 | } |
71 | 73 | ||
72 | err = security_secmark_relabel_packet(info->secid); | 74 | err = security_secmark_relabel_packet(info->secid); |
73 | if (err) { | 75 | if (err) { |
74 | pr_info("unable to obtain relabeling permission\n"); | 76 | pr_info_ratelimited("unable to obtain relabeling permission\n"); |
75 | return err; | 77 | return err; |
76 | } | 78 | } |
77 | 79 | ||
@@ -86,14 +88,14 @@ static int secmark_tg_check(const struct xt_tgchk_param *par) | |||
86 | 88 | ||
87 | if (strcmp(par->table, "mangle") != 0 && | 89 | if (strcmp(par->table, "mangle") != 0 && |
88 | strcmp(par->table, "security") != 0) { | 90 | strcmp(par->table, "security") != 0) { |
89 | pr_info("target only valid in the \'mangle\' " | 91 | pr_info_ratelimited("only valid in \'mangle\' or \'security\' table, not \'%s\'\n", |
90 | "or \'security\' tables, not \'%s\'.\n", par->table); | 92 | par->table); |
91 | return -EINVAL; | 93 | return -EINVAL; |
92 | } | 94 | } |
93 | 95 | ||
94 | if (mode && mode != info->mode) { | 96 | if (mode && mode != info->mode) { |
95 | pr_info("mode already set to %hu cannot mix with " | 97 | pr_info_ratelimited("mode already set to %hu cannot mix with rules for mode %hu\n", |
96 | "rules for mode %hu\n", mode, info->mode); | 98 | mode, info->mode); |
97 | return -EINVAL; | 99 | return -EINVAL; |
98 | } | 100 | } |
99 | 101 | ||
@@ -101,7 +103,7 @@ static int secmark_tg_check(const struct xt_tgchk_param *par) | |||
101 | case SECMARK_MODE_SEL: | 103 | case SECMARK_MODE_SEL: |
102 | break; | 104 | break; |
103 | default: | 105 | default: |
104 | pr_info("invalid mode: %hu\n", info->mode); | 106 | pr_info_ratelimited("invalid mode: %hu\n", info->mode); |
105 | return -EINVAL; | 107 | return -EINVAL; |
106 | } | 108 | } |
107 | 109 | ||
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c index 99bb8e410f22..98efb202f8b4 100644 --- a/net/netfilter/xt_TCPMSS.c +++ b/net/netfilter/xt_TCPMSS.c | |||
@@ -273,8 +273,7 @@ static int tcpmss_tg4_check(const struct xt_tgchk_param *par) | |||
273 | (par->hook_mask & ~((1 << NF_INET_FORWARD) | | 273 | (par->hook_mask & ~((1 << NF_INET_FORWARD) | |
274 | (1 << NF_INET_LOCAL_OUT) | | 274 | (1 << NF_INET_LOCAL_OUT) | |
275 | (1 << NF_INET_POST_ROUTING))) != 0) { | 275 | (1 << NF_INET_POST_ROUTING))) != 0) { |
276 | pr_info("path-MTU clamping only supported in " | 276 | pr_info_ratelimited("path-MTU clamping only supported in FORWARD, OUTPUT and POSTROUTING hooks\n"); |
277 | "FORWARD, OUTPUT and POSTROUTING hooks\n"); | ||
278 | return -EINVAL; | 277 | return -EINVAL; |
279 | } | 278 | } |
280 | if (par->nft_compat) | 279 | if (par->nft_compat) |
@@ -283,7 +282,7 @@ static int tcpmss_tg4_check(const struct xt_tgchk_param *par) | |||
283 | xt_ematch_foreach(ematch, e) | 282 | xt_ematch_foreach(ematch, e) |
284 | if (find_syn_match(ematch)) | 283 | if (find_syn_match(ematch)) |
285 | return 0; | 284 | return 0; |
286 | pr_info("Only works on TCP SYN packets\n"); | 285 | pr_info_ratelimited("Only works on TCP SYN packets\n"); |
287 | return -EINVAL; | 286 | return -EINVAL; |
288 | } | 287 | } |
289 | 288 | ||
@@ -298,8 +297,7 @@ static int tcpmss_tg6_check(const struct xt_tgchk_param *par) | |||
298 | (par->hook_mask & ~((1 << NF_INET_FORWARD) | | 297 | (par->hook_mask & ~((1 << NF_INET_FORWARD) | |
299 | (1 << NF_INET_LOCAL_OUT) | | 298 | (1 << NF_INET_LOCAL_OUT) | |
300 | (1 << NF_INET_POST_ROUTING))) != 0) { | 299 | (1 << NF_INET_POST_ROUTING))) != 0) { |
301 | pr_info("path-MTU clamping only supported in " | 300 | pr_info_ratelimited("path-MTU clamping only supported in FORWARD, OUTPUT and POSTROUTING hooks\n"); |
302 | "FORWARD, OUTPUT and POSTROUTING hooks\n"); | ||
303 | return -EINVAL; | 301 | return -EINVAL; |
304 | } | 302 | } |
305 | if (par->nft_compat) | 303 | if (par->nft_compat) |
@@ -308,7 +306,7 @@ static int tcpmss_tg6_check(const struct xt_tgchk_param *par) | |||
308 | xt_ematch_foreach(ematch, e) | 306 | xt_ematch_foreach(ematch, e) |
309 | if (find_syn_match(ematch)) | 307 | if (find_syn_match(ematch)) |
310 | return 0; | 308 | return 0; |
311 | pr_info("Only works on TCP SYN packets\n"); | 309 | pr_info_ratelimited("Only works on TCP SYN packets\n"); |
312 | return -EINVAL; | 310 | return -EINVAL; |
313 | } | 311 | } |
314 | #endif | 312 | #endif |
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c index 17d7705e3bd4..8c89323c06af 100644 --- a/net/netfilter/xt_TPROXY.c +++ b/net/netfilter/xt_TPROXY.c | |||
@@ -540,8 +540,7 @@ static int tproxy_tg6_check(const struct xt_tgchk_param *par) | |||
540 | !(i->invflags & IP6T_INV_PROTO)) | 540 | !(i->invflags & IP6T_INV_PROTO)) |
541 | return 0; | 541 | return 0; |
542 | 542 | ||
543 | pr_info("Can be used only in combination with " | 543 | pr_info_ratelimited("Can be used only with -p tcp or -p udp\n"); |
544 | "either -p tcp or -p udp\n"); | ||
545 | return -EINVAL; | 544 | return -EINVAL; |
546 | } | 545 | } |
547 | #endif | 546 | #endif |
@@ -559,8 +558,7 @@ static int tproxy_tg4_check(const struct xt_tgchk_param *par) | |||
559 | && !(i->invflags & IPT_INV_PROTO)) | 558 | && !(i->invflags & IPT_INV_PROTO)) |
560 | return 0; | 559 | return 0; |
561 | 560 | ||
562 | pr_info("Can be used only in combination with " | 561 | pr_info_ratelimited("Can be used only with -p tcp or -p udp\n"); |
563 | "either -p tcp or -p udp\n"); | ||
564 | return -EINVAL; | 562 | return -EINVAL; |
565 | } | 563 | } |
566 | 564 | ||
diff --git a/net/netfilter/xt_addrtype.c b/net/netfilter/xt_addrtype.c index 911a7c0da504..89e281b3bfc2 100644 --- a/net/netfilter/xt_addrtype.c +++ b/net/netfilter/xt_addrtype.c | |||
@@ -164,48 +164,47 @@ addrtype_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) | |||
164 | 164 | ||
165 | static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) | 165 | static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) |
166 | { | 166 | { |
167 | const char *errmsg = "both incoming and outgoing interface limitation cannot be selected"; | ||
167 | struct xt_addrtype_info_v1 *info = par->matchinfo; | 168 | struct xt_addrtype_info_v1 *info = par->matchinfo; |
168 | 169 | ||
169 | if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN && | 170 | if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN && |
170 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) { | 171 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) |
171 | pr_info("both incoming and outgoing " | 172 | goto err; |
172 | "interface limitation cannot be selected\n"); | ||
173 | return -EINVAL; | ||
174 | } | ||
175 | 173 | ||
176 | if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | | 174 | if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | |
177 | (1 << NF_INET_LOCAL_IN)) && | 175 | (1 << NF_INET_LOCAL_IN)) && |
178 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) { | 176 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) { |
179 | pr_info("output interface limitation " | 177 | errmsg = "output interface limitation not valid in PREROUTING and INPUT"; |
180 | "not valid in PREROUTING and INPUT\n"); | 178 | goto err; |
181 | return -EINVAL; | ||
182 | } | 179 | } |
183 | 180 | ||
184 | if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | | 181 | if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | |
185 | (1 << NF_INET_LOCAL_OUT)) && | 182 | (1 << NF_INET_LOCAL_OUT)) && |
186 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN) { | 183 | info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN) { |
187 | pr_info("input interface limitation " | 184 | errmsg = "input interface limitation not valid in POSTROUTING and OUTPUT"; |
188 | "not valid in POSTROUTING and OUTPUT\n"); | 185 | goto err; |
189 | return -EINVAL; | ||
190 | } | 186 | } |
191 | 187 | ||
192 | #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) | 188 | #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) |
193 | if (par->family == NFPROTO_IPV6) { | 189 | if (par->family == NFPROTO_IPV6) { |
194 | if ((info->source | info->dest) & XT_ADDRTYPE_BLACKHOLE) { | 190 | if ((info->source | info->dest) & XT_ADDRTYPE_BLACKHOLE) { |
195 | pr_err("ipv6 BLACKHOLE matching not supported\n"); | 191 | errmsg = "ipv6 BLACKHOLE matching not supported"; |
196 | return -EINVAL; | 192 | goto err; |
197 | } | 193 | } |
198 | if ((info->source | info->dest) >= XT_ADDRTYPE_PROHIBIT) { | 194 | if ((info->source | info->dest) >= XT_ADDRTYPE_PROHIBIT) { |
199 | pr_err("ipv6 PROHIBIT (THROW, NAT ..) matching not supported\n"); | 195 | errmsg = "ipv6 PROHIBIT (THROW, NAT ..) matching not supported"; |
200 | return -EINVAL; | 196 | goto err; |
201 | } | 197 | } |
202 | if ((info->source | info->dest) & XT_ADDRTYPE_BROADCAST) { | 198 | if ((info->source | info->dest) & XT_ADDRTYPE_BROADCAST) { |
203 | pr_err("ipv6 does not support BROADCAST matching\n"); | 199 | errmsg = "ipv6 does not support BROADCAST matching"; |
204 | return -EINVAL; | 200 | goto err; |
205 | } | 201 | } |
206 | } | 202 | } |
207 | #endif | 203 | #endif |
208 | return 0; | 204 | return 0; |
205 | err: | ||
206 | pr_info_ratelimited("%s\n", errmsg); | ||
207 | return -EINVAL; | ||
209 | } | 208 | } |
210 | 209 | ||
211 | static struct xt_match addrtype_mt_reg[] __read_mostly = { | 210 | static struct xt_match addrtype_mt_reg[] __read_mostly = { |
diff --git a/net/netfilter/xt_bpf.c b/net/netfilter/xt_bpf.c index 06b090d8e901..a2cf8a6236d6 100644 --- a/net/netfilter/xt_bpf.c +++ b/net/netfilter/xt_bpf.c | |||
@@ -7,6 +7,8 @@ | |||
7 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | |||
10 | #include <linux/module.h> | 12 | #include <linux/module.h> |
11 | #include <linux/syscalls.h> | 13 | #include <linux/syscalls.h> |
12 | #include <linux/skbuff.h> | 14 | #include <linux/skbuff.h> |
@@ -34,7 +36,7 @@ static int __bpf_mt_check_bytecode(struct sock_filter *insns, __u16 len, | |||
34 | program.filter = insns; | 36 | program.filter = insns; |
35 | 37 | ||
36 | if (bpf_prog_create(ret, &program)) { | 38 | if (bpf_prog_create(ret, &program)) { |
37 | pr_info("bpf: check failed: parse error\n"); | 39 | pr_info_ratelimited("check failed: parse error\n"); |
38 | return -EINVAL; | 40 | return -EINVAL; |
39 | } | 41 | } |
40 | 42 | ||
diff --git a/net/netfilter/xt_cgroup.c b/net/netfilter/xt_cgroup.c index 891f4e7e8ea7..7df2dece57d3 100644 --- a/net/netfilter/xt_cgroup.c +++ b/net/netfilter/xt_cgroup.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
16 | |||
15 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
16 | #include <linux/module.h> | 18 | #include <linux/module.h> |
17 | #include <linux/netfilter/x_tables.h> | 19 | #include <linux/netfilter/x_tables.h> |
@@ -48,7 +50,7 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par) | |||
48 | } | 50 | } |
49 | 51 | ||
50 | if (info->has_path && info->has_classid) { | 52 | if (info->has_path && info->has_classid) { |
51 | pr_info("xt_cgroup: both path and classid specified\n"); | 53 | pr_info_ratelimited("path and classid specified\n"); |
52 | return -EINVAL; | 54 | return -EINVAL; |
53 | } | 55 | } |
54 | 56 | ||
@@ -56,8 +58,8 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par) | |||
56 | if (info->has_path) { | 58 | if (info->has_path) { |
57 | cgrp = cgroup_get_from_path(info->path); | 59 | cgrp = cgroup_get_from_path(info->path); |
58 | if (IS_ERR(cgrp)) { | 60 | if (IS_ERR(cgrp)) { |
59 | pr_info("xt_cgroup: invalid path, errno=%ld\n", | 61 | pr_info_ratelimited("invalid path, errno=%ld\n", |
60 | PTR_ERR(cgrp)); | 62 | PTR_ERR(cgrp)); |
61 | return -EINVAL; | 63 | return -EINVAL; |
62 | } | 64 | } |
63 | info->priv = cgrp; | 65 | info->priv = cgrp; |
diff --git a/net/netfilter/xt_cluster.c b/net/netfilter/xt_cluster.c index 57ef175dfbfa..0068688995c8 100644 --- a/net/netfilter/xt_cluster.c +++ b/net/netfilter/xt_cluster.c | |||
@@ -135,14 +135,12 @@ static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) | |||
135 | struct xt_cluster_match_info *info = par->matchinfo; | 135 | struct xt_cluster_match_info *info = par->matchinfo; |
136 | 136 | ||
137 | if (info->total_nodes > XT_CLUSTER_NODES_MAX) { | 137 | if (info->total_nodes > XT_CLUSTER_NODES_MAX) { |
138 | pr_info("you have exceeded the maximum " | 138 | pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n", |
139 | "number of cluster nodes (%u > %u)\n", | 139 | info->total_nodes, XT_CLUSTER_NODES_MAX); |
140 | info->total_nodes, XT_CLUSTER_NODES_MAX); | ||
141 | return -EINVAL; | 140 | return -EINVAL; |
142 | } | 141 | } |
143 | if (info->node_mask >= (1ULL << info->total_nodes)) { | 142 | if (info->node_mask >= (1ULL << info->total_nodes)) { |
144 | pr_info("this node mask cannot be " | 143 | pr_info_ratelimited("node mask cannot exceed total number of nodes\n"); |
145 | "higher than the total number of nodes\n"); | ||
146 | return -EDOM; | 144 | return -EDOM; |
147 | } | 145 | } |
148 | return 0; | 146 | return 0; |
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c index cad0b7b5eb35..93cb018c3055 100644 --- a/net/netfilter/xt_connbytes.c +++ b/net/netfilter/xt_connbytes.c | |||
@@ -112,8 +112,8 @@ static int connbytes_mt_check(const struct xt_mtchk_param *par) | |||
112 | 112 | ||
113 | ret = nf_ct_netns_get(par->net, par->family); | 113 | ret = nf_ct_netns_get(par->net, par->family); |
114 | if (ret < 0) | 114 | if (ret < 0) |
115 | pr_info("cannot load conntrack support for proto=%u\n", | 115 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
116 | par->family); | 116 | par->family); |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * This filter cannot function correctly unless connection tracking | 119 | * This filter cannot function correctly unless connection tracking |
diff --git a/net/netfilter/xt_connlabel.c b/net/netfilter/xt_connlabel.c index 23372879e6e3..4fa4efd24353 100644 --- a/net/netfilter/xt_connlabel.c +++ b/net/netfilter/xt_connlabel.c | |||
@@ -57,14 +57,15 @@ static int connlabel_mt_check(const struct xt_mtchk_param *par) | |||
57 | int ret; | 57 | int ret; |
58 | 58 | ||
59 | if (info->options & ~options) { | 59 | if (info->options & ~options) { |
60 | pr_err("Unknown options in mask %x\n", info->options); | 60 | pr_info_ratelimited("Unknown options in mask %x\n", |
61 | info->options); | ||
61 | return -EINVAL; | 62 | return -EINVAL; |
62 | } | 63 | } |
63 | 64 | ||
64 | ret = nf_ct_netns_get(par->net, par->family); | 65 | ret = nf_ct_netns_get(par->net, par->family); |
65 | if (ret < 0) { | 66 | if (ret < 0) { |
66 | pr_info("cannot load conntrack support for proto=%u\n", | 67 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
67 | par->family); | 68 | par->family); |
68 | return ret; | 69 | return ret; |
69 | } | 70 | } |
70 | 71 | ||
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c index ec377cc6a369..809639ce6f5a 100644 --- a/net/netfilter/xt_connmark.c +++ b/net/netfilter/xt_connmark.c | |||
@@ -79,8 +79,8 @@ static int connmark_tg_check(const struct xt_tgchk_param *par) | |||
79 | 79 | ||
80 | ret = nf_ct_netns_get(par->net, par->family); | 80 | ret = nf_ct_netns_get(par->net, par->family); |
81 | if (ret < 0) | 81 | if (ret < 0) |
82 | pr_info("cannot load conntrack support for proto=%u\n", | 82 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
83 | par->family); | 83 | par->family); |
84 | return ret; | 84 | return ret; |
85 | } | 85 | } |
86 | 86 | ||
@@ -109,8 +109,8 @@ static int connmark_mt_check(const struct xt_mtchk_param *par) | |||
109 | 109 | ||
110 | ret = nf_ct_netns_get(par->net, par->family); | 110 | ret = nf_ct_netns_get(par->net, par->family); |
111 | if (ret < 0) | 111 | if (ret < 0) |
112 | pr_info("cannot load conntrack support for proto=%u\n", | 112 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
113 | par->family); | 113 | par->family); |
114 | return ret; | 114 | return ret; |
115 | } | 115 | } |
116 | 116 | ||
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c index 39cf1d019240..df80fe7d391c 100644 --- a/net/netfilter/xt_conntrack.c +++ b/net/netfilter/xt_conntrack.c | |||
@@ -272,8 +272,8 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par) | |||
272 | 272 | ||
273 | ret = nf_ct_netns_get(par->net, par->family); | 273 | ret = nf_ct_netns_get(par->net, par->family); |
274 | if (ret < 0) | 274 | if (ret < 0) |
275 | pr_info("cannot load conntrack support for proto=%u\n", | 275 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
276 | par->family); | 276 | par->family); |
277 | return ret; | 277 | return ret; |
278 | } | 278 | } |
279 | 279 | ||
diff --git a/net/netfilter/xt_dscp.c b/net/netfilter/xt_dscp.c index 236ac8008909..a4c2b862f820 100644 --- a/net/netfilter/xt_dscp.c +++ b/net/netfilter/xt_dscp.c | |||
@@ -46,10 +46,8 @@ static int dscp_mt_check(const struct xt_mtchk_param *par) | |||
46 | { | 46 | { |
47 | const struct xt_dscp_info *info = par->matchinfo; | 47 | const struct xt_dscp_info *info = par->matchinfo; |
48 | 48 | ||
49 | if (info->dscp > XT_DSCP_MAX) { | 49 | if (info->dscp > XT_DSCP_MAX) |
50 | pr_info("dscp %x out of range\n", info->dscp); | ||
51 | return -EDOM; | 50 | return -EDOM; |
52 | } | ||
53 | 51 | ||
54 | return 0; | 52 | return 0; |
55 | } | 53 | } |
diff --git a/net/netfilter/xt_ecn.c b/net/netfilter/xt_ecn.c index 3c831a8efebc..c7ad4afa5fb8 100644 --- a/net/netfilter/xt_ecn.c +++ b/net/netfilter/xt_ecn.c | |||
@@ -97,7 +97,7 @@ static int ecn_mt_check4(const struct xt_mtchk_param *par) | |||
97 | 97 | ||
98 | if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && | 98 | if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && |
99 | (ip->proto != IPPROTO_TCP || ip->invflags & IPT_INV_PROTO)) { | 99 | (ip->proto != IPPROTO_TCP || ip->invflags & IPT_INV_PROTO)) { |
100 | pr_info("cannot match TCP bits in rule for non-tcp packets\n"); | 100 | pr_info_ratelimited("cannot match TCP bits for non-tcp packets\n"); |
101 | return -EINVAL; | 101 | return -EINVAL; |
102 | } | 102 | } |
103 | 103 | ||
@@ -139,7 +139,7 @@ static int ecn_mt_check6(const struct xt_mtchk_param *par) | |||
139 | 139 | ||
140 | if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && | 140 | if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && |
141 | (ip->proto != IPPROTO_TCP || ip->invflags & IP6T_INV_PROTO)) { | 141 | (ip->proto != IPPROTO_TCP || ip->invflags & IP6T_INV_PROTO)) { |
142 | pr_info("cannot match TCP bits in rule for non-tcp packets\n"); | 142 | pr_info_ratelimited("cannot match TCP bits for non-tcp packets\n"); |
143 | return -EINVAL; | 143 | return -EINVAL; |
144 | } | 144 | } |
145 | 145 | ||
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index ca6847403ca2..66f5aca62a08 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
@@ -523,7 +523,8 @@ static u64 user2rate(u64 user) | |||
523 | if (user != 0) { | 523 | if (user != 0) { |
524 | return div64_u64(XT_HASHLIMIT_SCALE_v2, user); | 524 | return div64_u64(XT_HASHLIMIT_SCALE_v2, user); |
525 | } else { | 525 | } else { |
526 | pr_warn("invalid rate from userspace: %llu\n", user); | 526 | pr_info_ratelimited("invalid rate from userspace: %llu\n", |
527 | user); | ||
527 | return 0; | 528 | return 0; |
528 | } | 529 | } |
529 | } | 530 | } |
@@ -774,7 +775,7 @@ hashlimit_mt_common(const struct sk_buff *skb, struct xt_action_param *par, | |||
774 | if (!dh->rateinfo.prev_window && | 775 | if (!dh->rateinfo.prev_window && |
775 | (dh->rateinfo.current_rate <= dh->rateinfo.burst)) { | 776 | (dh->rateinfo.current_rate <= dh->rateinfo.burst)) { |
776 | spin_unlock(&dh->lock); | 777 | spin_unlock(&dh->lock); |
777 | rcu_read_unlock_bh(); | 778 | local_bh_enable(); |
778 | return !(cfg->mode & XT_HASHLIMIT_INVERT); | 779 | return !(cfg->mode & XT_HASHLIMIT_INVERT); |
779 | } else { | 780 | } else { |
780 | goto overlimit; | 781 | goto overlimit; |
@@ -865,33 +866,34 @@ static int hashlimit_mt_check_common(const struct xt_mtchk_param *par, | |||
865 | } | 866 | } |
866 | 867 | ||
867 | if (cfg->mode & ~XT_HASHLIMIT_ALL) { | 868 | if (cfg->mode & ~XT_HASHLIMIT_ALL) { |
868 | pr_info("Unknown mode mask %X, kernel too old?\n", | 869 | pr_info_ratelimited("Unknown mode mask %X, kernel too old?\n", |
869 | cfg->mode); | 870 | cfg->mode); |
870 | return -EINVAL; | 871 | return -EINVAL; |
871 | } | 872 | } |
872 | 873 | ||
873 | /* Check for overflow. */ | 874 | /* Check for overflow. */ |
874 | if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) { | 875 | if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) { |
875 | if (cfg->avg == 0 || cfg->avg > U32_MAX) { | 876 | if (cfg->avg == 0 || cfg->avg > U32_MAX) { |
876 | pr_info("hashlimit invalid rate\n"); | 877 | pr_info_ratelimited("invalid rate\n"); |
877 | return -ERANGE; | 878 | return -ERANGE; |
878 | } | 879 | } |
879 | 880 | ||
880 | if (cfg->interval == 0) { | 881 | if (cfg->interval == 0) { |
881 | pr_info("hashlimit invalid interval\n"); | 882 | pr_info_ratelimited("invalid interval\n"); |
882 | return -EINVAL; | 883 | return -EINVAL; |
883 | } | 884 | } |
884 | } else if (cfg->mode & XT_HASHLIMIT_BYTES) { | 885 | } else if (cfg->mode & XT_HASHLIMIT_BYTES) { |
885 | if (user2credits_byte(cfg->avg) == 0) { | 886 | if (user2credits_byte(cfg->avg) == 0) { |
886 | pr_info("overflow, rate too high: %llu\n", cfg->avg); | 887 | pr_info_ratelimited("overflow, rate too high: %llu\n", |
888 | cfg->avg); | ||
887 | return -EINVAL; | 889 | return -EINVAL; |
888 | } | 890 | } |
889 | } else if (cfg->burst == 0 || | 891 | } else if (cfg->burst == 0 || |
890 | user2credits(cfg->avg * cfg->burst, revision) < | 892 | user2credits(cfg->avg * cfg->burst, revision) < |
891 | user2credits(cfg->avg, revision)) { | 893 | user2credits(cfg->avg, revision)) { |
892 | pr_info("overflow, try lower: %llu/%llu\n", | 894 | pr_info_ratelimited("overflow, try lower: %llu/%llu\n", |
893 | cfg->avg, cfg->burst); | 895 | cfg->avg, cfg->burst); |
894 | return -ERANGE; | 896 | return -ERANGE; |
895 | } | 897 | } |
896 | 898 | ||
897 | mutex_lock(&hashlimit_mutex); | 899 | mutex_lock(&hashlimit_mutex); |
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c index 38a78151c0e9..fd077aeaaed9 100644 --- a/net/netfilter/xt_helper.c +++ b/net/netfilter/xt_helper.c | |||
@@ -61,8 +61,8 @@ static int helper_mt_check(const struct xt_mtchk_param *par) | |||
61 | 61 | ||
62 | ret = nf_ct_netns_get(par->net, par->family); | 62 | ret = nf_ct_netns_get(par->net, par->family); |
63 | if (ret < 0) { | 63 | if (ret < 0) { |
64 | pr_info("cannot load conntrack support for proto=%u\n", | 64 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
65 | par->family); | 65 | par->family); |
66 | return ret; | 66 | return ret; |
67 | } | 67 | } |
68 | info->name[sizeof(info->name) - 1] = '\0'; | 68 | info->name[sizeof(info->name) - 1] = '\0'; |
diff --git a/net/netfilter/xt_ipcomp.c b/net/netfilter/xt_ipcomp.c index 7ca64a50db04..57f1df575701 100644 --- a/net/netfilter/xt_ipcomp.c +++ b/net/netfilter/xt_ipcomp.c | |||
@@ -72,7 +72,7 @@ static int comp_mt_check(const struct xt_mtchk_param *par) | |||
72 | 72 | ||
73 | /* Must specify no unknown invflags */ | 73 | /* Must specify no unknown invflags */ |
74 | if (compinfo->invflags & ~XT_IPCOMP_INV_MASK) { | 74 | if (compinfo->invflags & ~XT_IPCOMP_INV_MASK) { |
75 | pr_err("unknown flags %X\n", compinfo->invflags); | 75 | pr_info_ratelimited("unknown flags %X\n", compinfo->invflags); |
76 | return -EINVAL; | 76 | return -EINVAL; |
77 | } | 77 | } |
78 | return 0; | 78 | return 0; |
diff --git a/net/netfilter/xt_ipvs.c b/net/netfilter/xt_ipvs.c index 42540d26c2b8..1d950a6100af 100644 --- a/net/netfilter/xt_ipvs.c +++ b/net/netfilter/xt_ipvs.c | |||
@@ -158,7 +158,8 @@ static int ipvs_mt_check(const struct xt_mtchk_param *par) | |||
158 | && par->family != NFPROTO_IPV6 | 158 | && par->family != NFPROTO_IPV6 |
159 | #endif | 159 | #endif |
160 | ) { | 160 | ) { |
161 | pr_info("protocol family %u not supported\n", par->family); | 161 | pr_info_ratelimited("protocol family %u not supported\n", |
162 | par->family); | ||
162 | return -EINVAL; | 163 | return -EINVAL; |
163 | } | 164 | } |
164 | 165 | ||
diff --git a/net/netfilter/xt_l2tp.c b/net/netfilter/xt_l2tp.c index 8aee572771f2..c43482bf48e6 100644 --- a/net/netfilter/xt_l2tp.c +++ b/net/netfilter/xt_l2tp.c | |||
@@ -216,7 +216,7 @@ static int l2tp_mt_check(const struct xt_mtchk_param *par) | |||
216 | /* Check for invalid flags */ | 216 | /* Check for invalid flags */ |
217 | if (info->flags & ~(XT_L2TP_TID | XT_L2TP_SID | XT_L2TP_VERSION | | 217 | if (info->flags & ~(XT_L2TP_TID | XT_L2TP_SID | XT_L2TP_VERSION | |
218 | XT_L2TP_TYPE)) { | 218 | XT_L2TP_TYPE)) { |
219 | pr_info("unknown flags: %x\n", info->flags); | 219 | pr_info_ratelimited("unknown flags: %x\n", info->flags); |
220 | return -EINVAL; | 220 | return -EINVAL; |
221 | } | 221 | } |
222 | 222 | ||
@@ -225,7 +225,8 @@ static int l2tp_mt_check(const struct xt_mtchk_param *par) | |||
225 | (!(info->flags & XT_L2TP_SID)) && | 225 | (!(info->flags & XT_L2TP_SID)) && |
226 | ((!(info->flags & XT_L2TP_TYPE)) || | 226 | ((!(info->flags & XT_L2TP_TYPE)) || |
227 | (info->type != XT_L2TP_TYPE_CONTROL))) { | 227 | (info->type != XT_L2TP_TYPE_CONTROL))) { |
228 | pr_info("invalid flags combination: %x\n", info->flags); | 228 | pr_info_ratelimited("invalid flags combination: %x\n", |
229 | info->flags); | ||
229 | return -EINVAL; | 230 | return -EINVAL; |
230 | } | 231 | } |
231 | 232 | ||
@@ -234,19 +235,22 @@ static int l2tp_mt_check(const struct xt_mtchk_param *par) | |||
234 | */ | 235 | */ |
235 | if (info->flags & XT_L2TP_VERSION) { | 236 | if (info->flags & XT_L2TP_VERSION) { |
236 | if ((info->version < 2) || (info->version > 3)) { | 237 | if ((info->version < 2) || (info->version > 3)) { |
237 | pr_info("wrong L2TP version: %u\n", info->version); | 238 | pr_info_ratelimited("wrong L2TP version: %u\n", |
239 | info->version); | ||
238 | return -EINVAL; | 240 | return -EINVAL; |
239 | } | 241 | } |
240 | 242 | ||
241 | if (info->version == 2) { | 243 | if (info->version == 2) { |
242 | if ((info->flags & XT_L2TP_TID) && | 244 | if ((info->flags & XT_L2TP_TID) && |
243 | (info->tid > 0xffff)) { | 245 | (info->tid > 0xffff)) { |
244 | pr_info("v2 tid > 0xffff: %u\n", info->tid); | 246 | pr_info_ratelimited("v2 tid > 0xffff: %u\n", |
247 | info->tid); | ||
245 | return -EINVAL; | 248 | return -EINVAL; |
246 | } | 249 | } |
247 | if ((info->flags & XT_L2TP_SID) && | 250 | if ((info->flags & XT_L2TP_SID) && |
248 | (info->sid > 0xffff)) { | 251 | (info->sid > 0xffff)) { |
249 | pr_info("v2 sid > 0xffff: %u\n", info->sid); | 252 | pr_info_ratelimited("v2 sid > 0xffff: %u\n", |
253 | info->sid); | ||
250 | return -EINVAL; | 254 | return -EINVAL; |
251 | } | 255 | } |
252 | } | 256 | } |
@@ -268,13 +272,13 @@ static int l2tp_mt_check4(const struct xt_mtchk_param *par) | |||
268 | 272 | ||
269 | if ((ip->proto != IPPROTO_UDP) && | 273 | if ((ip->proto != IPPROTO_UDP) && |
270 | (ip->proto != IPPROTO_L2TP)) { | 274 | (ip->proto != IPPROTO_L2TP)) { |
271 | pr_info("missing protocol rule (udp|l2tpip)\n"); | 275 | pr_info_ratelimited("missing protocol rule (udp|l2tpip)\n"); |
272 | return -EINVAL; | 276 | return -EINVAL; |
273 | } | 277 | } |
274 | 278 | ||
275 | if ((ip->proto == IPPROTO_L2TP) && | 279 | if ((ip->proto == IPPROTO_L2TP) && |
276 | (info->version == 2)) { | 280 | (info->version == 2)) { |
277 | pr_info("v2 doesn't support IP mode\n"); | 281 | pr_info_ratelimited("v2 doesn't support IP mode\n"); |
278 | return -EINVAL; | 282 | return -EINVAL; |
279 | } | 283 | } |
280 | 284 | ||
@@ -295,13 +299,13 @@ static int l2tp_mt_check6(const struct xt_mtchk_param *par) | |||
295 | 299 | ||
296 | if ((ip->proto != IPPROTO_UDP) && | 300 | if ((ip->proto != IPPROTO_UDP) && |
297 | (ip->proto != IPPROTO_L2TP)) { | 301 | (ip->proto != IPPROTO_L2TP)) { |
298 | pr_info("missing protocol rule (udp|l2tpip)\n"); | 302 | pr_info_ratelimited("missing protocol rule (udp|l2tpip)\n"); |
299 | return -EINVAL; | 303 | return -EINVAL; |
300 | } | 304 | } |
301 | 305 | ||
302 | if ((ip->proto == IPPROTO_L2TP) && | 306 | if ((ip->proto == IPPROTO_L2TP) && |
303 | (info->version == 2)) { | 307 | (info->version == 2)) { |
304 | pr_info("v2 doesn't support IP mode\n"); | 308 | pr_info_ratelimited("v2 doesn't support IP mode\n"); |
305 | return -EINVAL; | 309 | return -EINVAL; |
306 | } | 310 | } |
307 | 311 | ||
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c index 61403b77361c..55d18cd67635 100644 --- a/net/netfilter/xt_limit.c +++ b/net/netfilter/xt_limit.c | |||
@@ -106,8 +106,8 @@ static int limit_mt_check(const struct xt_mtchk_param *par) | |||
106 | /* Check for overflow. */ | 106 | /* Check for overflow. */ |
107 | if (r->burst == 0 | 107 | if (r->burst == 0 |
108 | || user2credits(r->avg * r->burst) < user2credits(r->avg)) { | 108 | || user2credits(r->avg * r->burst) < user2credits(r->avg)) { |
109 | pr_info("Overflow, try lower: %u/%u\n", | 109 | pr_info_ratelimited("Overflow, try lower: %u/%u\n", |
110 | r->avg, r->burst); | 110 | r->avg, r->burst); |
111 | return -ERANGE; | 111 | return -ERANGE; |
112 | } | 112 | } |
113 | 113 | ||
diff --git a/net/netfilter/xt_nat.c b/net/netfilter/xt_nat.c index 0fd14d1eb09d..bdb689cdc829 100644 --- a/net/netfilter/xt_nat.c +++ b/net/netfilter/xt_nat.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
12 | |||
11 | #include <linux/module.h> | 13 | #include <linux/module.h> |
12 | #include <linux/skbuff.h> | 14 | #include <linux/skbuff.h> |
13 | #include <linux/netfilter.h> | 15 | #include <linux/netfilter.h> |
@@ -19,8 +21,7 @@ static int xt_nat_checkentry_v0(const struct xt_tgchk_param *par) | |||
19 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; | 21 | const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; |
20 | 22 | ||
21 | if (mr->rangesize != 1) { | 23 | if (mr->rangesize != 1) { |
22 | pr_info("%s: multiple ranges no longer supported\n", | 24 | pr_info_ratelimited("multiple ranges no longer supported\n"); |
23 | par->target->name); | ||
24 | return -EINVAL; | 25 | return -EINVAL; |
25 | } | 26 | } |
26 | return nf_ct_netns_get(par->net, par->family); | 27 | return nf_ct_netns_get(par->net, par->family); |
diff --git a/net/netfilter/xt_nfacct.c b/net/netfilter/xt_nfacct.c index 6f92d25590a8..c8674deed4eb 100644 --- a/net/netfilter/xt_nfacct.c +++ b/net/netfilter/xt_nfacct.c | |||
@@ -6,6 +6,8 @@ | |||
6 | * it under the terms of the GNU General Public License version 2 (or any | 6 | * it under the terms of the GNU General Public License version 2 (or any |
7 | * later at your option) as published by the Free Software Foundation. | 7 | * later at your option) as published by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
10 | |||
9 | #include <linux/module.h> | 11 | #include <linux/module.h> |
10 | #include <linux/skbuff.h> | 12 | #include <linux/skbuff.h> |
11 | 13 | ||
@@ -39,8 +41,8 @@ nfacct_mt_checkentry(const struct xt_mtchk_param *par) | |||
39 | 41 | ||
40 | nfacct = nfnl_acct_find_get(par->net, info->name); | 42 | nfacct = nfnl_acct_find_get(par->net, info->name); |
41 | if (nfacct == NULL) { | 43 | if (nfacct == NULL) { |
42 | pr_info("xt_nfacct: accounting object with name `%s' " | 44 | pr_info_ratelimited("accounting object `%s' does not exists\n", |
43 | "does not exists\n", info->name); | 45 | info->name); |
44 | return -ENOENT; | 46 | return -ENOENT; |
45 | } | 47 | } |
46 | info->nfacct = nfacct; | 48 | info->nfacct = nfacct; |
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c index bb33598e4530..9d6d67b953ac 100644 --- a/net/netfilter/xt_physdev.c +++ b/net/netfilter/xt_physdev.c | |||
@@ -107,9 +107,7 @@ static int physdev_mt_check(const struct xt_mtchk_param *par) | |||
107 | info->invert & XT_PHYSDEV_OP_BRIDGED) && | 107 | info->invert & XT_PHYSDEV_OP_BRIDGED) && |
108 | par->hook_mask & ((1 << NF_INET_LOCAL_OUT) | | 108 | par->hook_mask & ((1 << NF_INET_LOCAL_OUT) | |
109 | (1 << NF_INET_FORWARD) | (1 << NF_INET_POST_ROUTING))) { | 109 | (1 << NF_INET_FORWARD) | (1 << NF_INET_POST_ROUTING))) { |
110 | pr_info("using --physdev-out and --physdev-is-out are only " | 110 | pr_info_ratelimited("--physdev-out and --physdev-is-out only supported in the FORWARD and POSTROUTING chains with bridged traffic\n"); |
111 | "supported in the FORWARD and POSTROUTING chains with " | ||
112 | "bridged traffic.\n"); | ||
113 | if (par->hook_mask & (1 << NF_INET_LOCAL_OUT)) | 111 | if (par->hook_mask & (1 << NF_INET_LOCAL_OUT)) |
114 | return -EINVAL; | 112 | return -EINVAL; |
115 | } | 113 | } |
diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c index 5639fb03bdd9..13f8ccf946d6 100644 --- a/net/netfilter/xt_policy.c +++ b/net/netfilter/xt_policy.c | |||
@@ -132,26 +132,29 @@ policy_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
132 | static int policy_mt_check(const struct xt_mtchk_param *par) | 132 | static int policy_mt_check(const struct xt_mtchk_param *par) |
133 | { | 133 | { |
134 | const struct xt_policy_info *info = par->matchinfo; | 134 | const struct xt_policy_info *info = par->matchinfo; |
135 | const char *errmsg = "neither incoming nor outgoing policy selected"; | ||
136 | |||
137 | if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) | ||
138 | goto err; | ||
135 | 139 | ||
136 | if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) { | ||
137 | pr_info("neither incoming nor outgoing policy selected\n"); | ||
138 | return -EINVAL; | ||
139 | } | ||
140 | if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | | 140 | if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | |
141 | (1 << NF_INET_LOCAL_IN)) && info->flags & XT_POLICY_MATCH_OUT) { | 141 | (1 << NF_INET_LOCAL_IN)) && info->flags & XT_POLICY_MATCH_OUT) { |
142 | pr_info("output policy not valid in PREROUTING and INPUT\n"); | 142 | errmsg = "output policy not valid in PREROUTING and INPUT"; |
143 | return -EINVAL; | 143 | goto err; |
144 | } | 144 | } |
145 | if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | | 145 | if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | |
146 | (1 << NF_INET_LOCAL_OUT)) && info->flags & XT_POLICY_MATCH_IN) { | 146 | (1 << NF_INET_LOCAL_OUT)) && info->flags & XT_POLICY_MATCH_IN) { |
147 | pr_info("input policy not valid in POSTROUTING and OUTPUT\n"); | 147 | errmsg = "input policy not valid in POSTROUTING and OUTPUT"; |
148 | return -EINVAL; | 148 | goto err; |
149 | } | 149 | } |
150 | if (info->len > XT_POLICY_MAX_ELEM) { | 150 | if (info->len > XT_POLICY_MAX_ELEM) { |
151 | pr_info("too many policy elements\n"); | 151 | errmsg = "too many policy elements"; |
152 | return -EINVAL; | 152 | goto err; |
153 | } | 153 | } |
154 | return 0; | 154 | return 0; |
155 | err: | ||
156 | pr_info_ratelimited("%s\n", errmsg); | ||
157 | return -EINVAL; | ||
155 | } | 158 | } |
156 | 159 | ||
157 | static struct xt_match policy_mt_reg[] __read_mostly = { | 160 | static struct xt_match policy_mt_reg[] __read_mostly = { |
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c index 245fa350a7a8..6d232d18faff 100644 --- a/net/netfilter/xt_recent.c +++ b/net/netfilter/xt_recent.c | |||
@@ -342,8 +342,8 @@ static int recent_mt_check(const struct xt_mtchk_param *par, | |||
342 | net_get_random_once(&hash_rnd, sizeof(hash_rnd)); | 342 | net_get_random_once(&hash_rnd, sizeof(hash_rnd)); |
343 | 343 | ||
344 | if (info->check_set & ~XT_RECENT_VALID_FLAGS) { | 344 | if (info->check_set & ~XT_RECENT_VALID_FLAGS) { |
345 | pr_info("Unsupported user space flags (%08x)\n", | 345 | pr_info_ratelimited("Unsupported userspace flags (%08x)\n", |
346 | info->check_set); | 346 | info->check_set); |
347 | return -EINVAL; | 347 | return -EINVAL; |
348 | } | 348 | } |
349 | if (hweight8(info->check_set & | 349 | if (hweight8(info->check_set & |
@@ -357,8 +357,8 @@ static int recent_mt_check(const struct xt_mtchk_param *par, | |||
357 | if ((info->check_set & XT_RECENT_REAP) && !info->seconds) | 357 | if ((info->check_set & XT_RECENT_REAP) && !info->seconds) |
358 | return -EINVAL; | 358 | return -EINVAL; |
359 | if (info->hit_count >= XT_RECENT_MAX_NSTAMPS) { | 359 | if (info->hit_count >= XT_RECENT_MAX_NSTAMPS) { |
360 | pr_info("hitcount (%u) is larger than allowed maximum (%u)\n", | 360 | pr_info_ratelimited("hitcount (%u) is larger than allowed maximum (%u)\n", |
361 | info->hit_count, XT_RECENT_MAX_NSTAMPS - 1); | 361 | info->hit_count, XT_RECENT_MAX_NSTAMPS - 1); |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | } | 363 | } |
364 | if (info->name[0] == '\0' || | 364 | if (info->name[0] == '\0' || |
@@ -587,7 +587,7 @@ recent_mt_proc_write(struct file *file, const char __user *input, | |||
587 | add = true; | 587 | add = true; |
588 | break; | 588 | break; |
589 | default: | 589 | default: |
590 | pr_info("Need \"+ip\", \"-ip\" or \"/\"\n"); | 590 | pr_info_ratelimited("Need \"+ip\", \"-ip\" or \"/\"\n"); |
591 | return -EINVAL; | 591 | return -EINVAL; |
592 | } | 592 | } |
593 | 593 | ||
@@ -601,10 +601,8 @@ recent_mt_proc_write(struct file *file, const char __user *input, | |||
601 | succ = in4_pton(c, size, (void *)&addr, '\n', NULL); | 601 | succ = in4_pton(c, size, (void *)&addr, '\n', NULL); |
602 | } | 602 | } |
603 | 603 | ||
604 | if (!succ) { | 604 | if (!succ) |
605 | pr_info("illegal address written to procfs\n"); | ||
606 | return -EINVAL; | 605 | return -EINVAL; |
607 | } | ||
608 | 606 | ||
609 | spin_lock_bh(&recent_lock); | 607 | spin_lock_bh(&recent_lock); |
610 | e = recent_entry_lookup(t, &addr, family, 0); | 608 | e = recent_entry_lookup(t, &addr, family, 0); |
diff --git a/net/netfilter/xt_set.c b/net/netfilter/xt_set.c index 16b6b11ee83f..6f4c5217d835 100644 --- a/net/netfilter/xt_set.c +++ b/net/netfilter/xt_set.c | |||
@@ -92,12 +92,12 @@ set_match_v0_checkentry(const struct xt_mtchk_param *par) | |||
92 | index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); | 92 | index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); |
93 | 93 | ||
94 | if (index == IPSET_INVALID_ID) { | 94 | if (index == IPSET_INVALID_ID) { |
95 | pr_warn("Cannot find set identified by id %u to match\n", | 95 | pr_info_ratelimited("Cannot find set identified by id %u to match\n", |
96 | info->match_set.index); | 96 | info->match_set.index); |
97 | return -ENOENT; | 97 | return -ENOENT; |
98 | } | 98 | } |
99 | if (info->match_set.u.flags[IPSET_DIM_MAX - 1] != 0) { | 99 | if (info->match_set.u.flags[IPSET_DIM_MAX - 1] != 0) { |
100 | pr_warn("Protocol error: set match dimension is over the limit!\n"); | 100 | pr_info_ratelimited("set match dimension is over the limit!\n"); |
101 | ip_set_nfnl_put(par->net, info->match_set.index); | 101 | ip_set_nfnl_put(par->net, info->match_set.index); |
102 | return -ERANGE; | 102 | return -ERANGE; |
103 | } | 103 | } |
@@ -143,12 +143,12 @@ set_match_v1_checkentry(const struct xt_mtchk_param *par) | |||
143 | index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); | 143 | index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); |
144 | 144 | ||
145 | if (index == IPSET_INVALID_ID) { | 145 | if (index == IPSET_INVALID_ID) { |
146 | pr_warn("Cannot find set identified by id %u to match\n", | 146 | pr_info_ratelimited("Cannot find set identified by id %u to match\n", |
147 | info->match_set.index); | 147 | info->match_set.index); |
148 | return -ENOENT; | 148 | return -ENOENT; |
149 | } | 149 | } |
150 | if (info->match_set.dim > IPSET_DIM_MAX) { | 150 | if (info->match_set.dim > IPSET_DIM_MAX) { |
151 | pr_warn("Protocol error: set match dimension is over the limit!\n"); | 151 | pr_info_ratelimited("set match dimension is over the limit!\n"); |
152 | ip_set_nfnl_put(par->net, info->match_set.index); | 152 | ip_set_nfnl_put(par->net, info->match_set.index); |
153 | return -ERANGE; | 153 | return -ERANGE; |
154 | } | 154 | } |
@@ -241,8 +241,8 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par) | |||
241 | if (info->add_set.index != IPSET_INVALID_ID) { | 241 | if (info->add_set.index != IPSET_INVALID_ID) { |
242 | index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); | 242 | index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); |
243 | if (index == IPSET_INVALID_ID) { | 243 | if (index == IPSET_INVALID_ID) { |
244 | pr_warn("Cannot find add_set index %u as target\n", | 244 | pr_info_ratelimited("Cannot find add_set index %u as target\n", |
245 | info->add_set.index); | 245 | info->add_set.index); |
246 | return -ENOENT; | 246 | return -ENOENT; |
247 | } | 247 | } |
248 | } | 248 | } |
@@ -250,8 +250,8 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par) | |||
250 | if (info->del_set.index != IPSET_INVALID_ID) { | 250 | if (info->del_set.index != IPSET_INVALID_ID) { |
251 | index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); | 251 | index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); |
252 | if (index == IPSET_INVALID_ID) { | 252 | if (index == IPSET_INVALID_ID) { |
253 | pr_warn("Cannot find del_set index %u as target\n", | 253 | pr_info_ratelimited("Cannot find del_set index %u as target\n", |
254 | info->del_set.index); | 254 | info->del_set.index); |
255 | if (info->add_set.index != IPSET_INVALID_ID) | 255 | if (info->add_set.index != IPSET_INVALID_ID) |
256 | ip_set_nfnl_put(par->net, info->add_set.index); | 256 | ip_set_nfnl_put(par->net, info->add_set.index); |
257 | return -ENOENT; | 257 | return -ENOENT; |
@@ -259,7 +259,7 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par) | |||
259 | } | 259 | } |
260 | if (info->add_set.u.flags[IPSET_DIM_MAX - 1] != 0 || | 260 | if (info->add_set.u.flags[IPSET_DIM_MAX - 1] != 0 || |
261 | info->del_set.u.flags[IPSET_DIM_MAX - 1] != 0) { | 261 | info->del_set.u.flags[IPSET_DIM_MAX - 1] != 0) { |
262 | pr_warn("Protocol error: SET target dimension is over the limit!\n"); | 262 | pr_info_ratelimited("SET target dimension over the limit!\n"); |
263 | if (info->add_set.index != IPSET_INVALID_ID) | 263 | if (info->add_set.index != IPSET_INVALID_ID) |
264 | ip_set_nfnl_put(par->net, info->add_set.index); | 264 | ip_set_nfnl_put(par->net, info->add_set.index); |
265 | if (info->del_set.index != IPSET_INVALID_ID) | 265 | if (info->del_set.index != IPSET_INVALID_ID) |
@@ -316,8 +316,8 @@ set_target_v1_checkentry(const struct xt_tgchk_param *par) | |||
316 | if (info->add_set.index != IPSET_INVALID_ID) { | 316 | if (info->add_set.index != IPSET_INVALID_ID) { |
317 | index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); | 317 | index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); |
318 | if (index == IPSET_INVALID_ID) { | 318 | if (index == IPSET_INVALID_ID) { |
319 | pr_warn("Cannot find add_set index %u as target\n", | 319 | pr_info_ratelimited("Cannot find add_set index %u as target\n", |
320 | info->add_set.index); | 320 | info->add_set.index); |
321 | return -ENOENT; | 321 | return -ENOENT; |
322 | } | 322 | } |
323 | } | 323 | } |
@@ -325,8 +325,8 @@ set_target_v1_checkentry(const struct xt_tgchk_param *par) | |||
325 | if (info->del_set.index != IPSET_INVALID_ID) { | 325 | if (info->del_set.index != IPSET_INVALID_ID) { |
326 | index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); | 326 | index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); |
327 | if (index == IPSET_INVALID_ID) { | 327 | if (index == IPSET_INVALID_ID) { |
328 | pr_warn("Cannot find del_set index %u as target\n", | 328 | pr_info_ratelimited("Cannot find del_set index %u as target\n", |
329 | info->del_set.index); | 329 | info->del_set.index); |
330 | if (info->add_set.index != IPSET_INVALID_ID) | 330 | if (info->add_set.index != IPSET_INVALID_ID) |
331 | ip_set_nfnl_put(par->net, info->add_set.index); | 331 | ip_set_nfnl_put(par->net, info->add_set.index); |
332 | return -ENOENT; | 332 | return -ENOENT; |
@@ -334,7 +334,7 @@ set_target_v1_checkentry(const struct xt_tgchk_param *par) | |||
334 | } | 334 | } |
335 | if (info->add_set.dim > IPSET_DIM_MAX || | 335 | if (info->add_set.dim > IPSET_DIM_MAX || |
336 | info->del_set.dim > IPSET_DIM_MAX) { | 336 | info->del_set.dim > IPSET_DIM_MAX) { |
337 | pr_warn("Protocol error: SET target dimension is over the limit!\n"); | 337 | pr_info_ratelimited("SET target dimension over the limit!\n"); |
338 | if (info->add_set.index != IPSET_INVALID_ID) | 338 | if (info->add_set.index != IPSET_INVALID_ID) |
339 | ip_set_nfnl_put(par->net, info->add_set.index); | 339 | ip_set_nfnl_put(par->net, info->add_set.index); |
340 | if (info->del_set.index != IPSET_INVALID_ID) | 340 | if (info->del_set.index != IPSET_INVALID_ID) |
@@ -444,8 +444,8 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par) | |||
444 | index = ip_set_nfnl_get_byindex(par->net, | 444 | index = ip_set_nfnl_get_byindex(par->net, |
445 | info->add_set.index); | 445 | info->add_set.index); |
446 | if (index == IPSET_INVALID_ID) { | 446 | if (index == IPSET_INVALID_ID) { |
447 | pr_warn("Cannot find add_set index %u as target\n", | 447 | pr_info_ratelimited("Cannot find add_set index %u as target\n", |
448 | info->add_set.index); | 448 | info->add_set.index); |
449 | return -ENOENT; | 449 | return -ENOENT; |
450 | } | 450 | } |
451 | } | 451 | } |
@@ -454,8 +454,8 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par) | |||
454 | index = ip_set_nfnl_get_byindex(par->net, | 454 | index = ip_set_nfnl_get_byindex(par->net, |
455 | info->del_set.index); | 455 | info->del_set.index); |
456 | if (index == IPSET_INVALID_ID) { | 456 | if (index == IPSET_INVALID_ID) { |
457 | pr_warn("Cannot find del_set index %u as target\n", | 457 | pr_info_ratelimited("Cannot find del_set index %u as target\n", |
458 | info->del_set.index); | 458 | info->del_set.index); |
459 | if (info->add_set.index != IPSET_INVALID_ID) | 459 | if (info->add_set.index != IPSET_INVALID_ID) |
460 | ip_set_nfnl_put(par->net, | 460 | ip_set_nfnl_put(par->net, |
461 | info->add_set.index); | 461 | info->add_set.index); |
@@ -465,7 +465,7 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par) | |||
465 | 465 | ||
466 | if (info->map_set.index != IPSET_INVALID_ID) { | 466 | if (info->map_set.index != IPSET_INVALID_ID) { |
467 | if (strncmp(par->table, "mangle", 7)) { | 467 | if (strncmp(par->table, "mangle", 7)) { |
468 | pr_warn("--map-set only usable from mangle table\n"); | 468 | pr_info_ratelimited("--map-set only usable from mangle table\n"); |
469 | return -EINVAL; | 469 | return -EINVAL; |
470 | } | 470 | } |
471 | if (((info->flags & IPSET_FLAG_MAP_SKBPRIO) | | 471 | if (((info->flags & IPSET_FLAG_MAP_SKBPRIO) | |
@@ -473,14 +473,14 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par) | |||
473 | !(par->hook_mask & (1 << NF_INET_FORWARD | | 473 | !(par->hook_mask & (1 << NF_INET_FORWARD | |
474 | 1 << NF_INET_LOCAL_OUT | | 474 | 1 << NF_INET_LOCAL_OUT | |
475 | 1 << NF_INET_POST_ROUTING))) { | 475 | 1 << NF_INET_POST_ROUTING))) { |
476 | pr_warn("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n"); | 476 | pr_info_ratelimited("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n"); |
477 | return -EINVAL; | 477 | return -EINVAL; |
478 | } | 478 | } |
479 | index = ip_set_nfnl_get_byindex(par->net, | 479 | index = ip_set_nfnl_get_byindex(par->net, |
480 | info->map_set.index); | 480 | info->map_set.index); |
481 | if (index == IPSET_INVALID_ID) { | 481 | if (index == IPSET_INVALID_ID) { |
482 | pr_warn("Cannot find map_set index %u as target\n", | 482 | pr_info_ratelimited("Cannot find map_set index %u as target\n", |
483 | info->map_set.index); | 483 | info->map_set.index); |
484 | if (info->add_set.index != IPSET_INVALID_ID) | 484 | if (info->add_set.index != IPSET_INVALID_ID) |
485 | ip_set_nfnl_put(par->net, | 485 | ip_set_nfnl_put(par->net, |
486 | info->add_set.index); | 486 | info->add_set.index); |
@@ -494,7 +494,7 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par) | |||
494 | if (info->add_set.dim > IPSET_DIM_MAX || | 494 | if (info->add_set.dim > IPSET_DIM_MAX || |
495 | info->del_set.dim > IPSET_DIM_MAX || | 495 | info->del_set.dim > IPSET_DIM_MAX || |
496 | info->map_set.dim > IPSET_DIM_MAX) { | 496 | info->map_set.dim > IPSET_DIM_MAX) { |
497 | pr_warn("Protocol error: SET target dimension is over the limit!\n"); | 497 | pr_info_ratelimited("SET target dimension over the limit!\n"); |
498 | if (info->add_set.index != IPSET_INVALID_ID) | 498 | if (info->add_set.index != IPSET_INVALID_ID) |
499 | ip_set_nfnl_put(par->net, info->add_set.index); | 499 | ip_set_nfnl_put(par->net, info->add_set.index); |
500 | if (info->del_set.index != IPSET_INVALID_ID) | 500 | if (info->del_set.index != IPSET_INVALID_ID) |
diff --git a/net/netfilter/xt_socket.c b/net/netfilter/xt_socket.c index 575d2153e3b8..2ac7f674d19b 100644 --- a/net/netfilter/xt_socket.c +++ b/net/netfilter/xt_socket.c | |||
@@ -171,7 +171,8 @@ static int socket_mt_v1_check(const struct xt_mtchk_param *par) | |||
171 | return err; | 171 | return err; |
172 | 172 | ||
173 | if (info->flags & ~XT_SOCKET_FLAGS_V1) { | 173 | if (info->flags & ~XT_SOCKET_FLAGS_V1) { |
174 | pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V1); | 174 | pr_info_ratelimited("unknown flags 0x%x\n", |
175 | info->flags & ~XT_SOCKET_FLAGS_V1); | ||
175 | return -EINVAL; | 176 | return -EINVAL; |
176 | } | 177 | } |
177 | return 0; | 178 | return 0; |
@@ -187,7 +188,8 @@ static int socket_mt_v2_check(const struct xt_mtchk_param *par) | |||
187 | return err; | 188 | return err; |
188 | 189 | ||
189 | if (info->flags & ~XT_SOCKET_FLAGS_V2) { | 190 | if (info->flags & ~XT_SOCKET_FLAGS_V2) { |
190 | pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V2); | 191 | pr_info_ratelimited("unknown flags 0x%x\n", |
192 | info->flags & ~XT_SOCKET_FLAGS_V2); | ||
191 | return -EINVAL; | 193 | return -EINVAL; |
192 | } | 194 | } |
193 | return 0; | 195 | return 0; |
@@ -203,8 +205,8 @@ static int socket_mt_v3_check(const struct xt_mtchk_param *par) | |||
203 | if (err) | 205 | if (err) |
204 | return err; | 206 | return err; |
205 | if (info->flags & ~XT_SOCKET_FLAGS_V3) { | 207 | if (info->flags & ~XT_SOCKET_FLAGS_V3) { |
206 | pr_info("unknown flags 0x%x\n", | 208 | pr_info_ratelimited("unknown flags 0x%x\n", |
207 | info->flags & ~XT_SOCKET_FLAGS_V3); | 209 | info->flags & ~XT_SOCKET_FLAGS_V3); |
208 | return -EINVAL; | 210 | return -EINVAL; |
209 | } | 211 | } |
210 | return 0; | 212 | return 0; |
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c index 5fbd79194d21..0b41c0befe3c 100644 --- a/net/netfilter/xt_state.c +++ b/net/netfilter/xt_state.c | |||
@@ -44,8 +44,8 @@ static int state_mt_check(const struct xt_mtchk_param *par) | |||
44 | 44 | ||
45 | ret = nf_ct_netns_get(par->net, par->family); | 45 | ret = nf_ct_netns_get(par->net, par->family); |
46 | if (ret < 0) | 46 | if (ret < 0) |
47 | pr_info("cannot load conntrack support for proto=%u\n", | 47 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", |
48 | par->family); | 48 | par->family); |
49 | return ret; | 49 | return ret; |
50 | } | 50 | } |
51 | 51 | ||
diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c index 1b01eec1fbda..0160f505e337 100644 --- a/net/netfilter/xt_time.c +++ b/net/netfilter/xt_time.c | |||
@@ -235,13 +235,13 @@ static int time_mt_check(const struct xt_mtchk_param *par) | |||
235 | 235 | ||
236 | if (info->daytime_start > XT_TIME_MAX_DAYTIME || | 236 | if (info->daytime_start > XT_TIME_MAX_DAYTIME || |
237 | info->daytime_stop > XT_TIME_MAX_DAYTIME) { | 237 | info->daytime_stop > XT_TIME_MAX_DAYTIME) { |
238 | pr_info("invalid argument - start or " | 238 | pr_info_ratelimited("invalid argument - start or stop time greater than 23:59:59\n"); |
239 | "stop time greater than 23:59:59\n"); | ||
240 | return -EDOM; | 239 | return -EDOM; |
241 | } | 240 | } |
242 | 241 | ||
243 | if (info->flags & ~XT_TIME_ALL_FLAGS) { | 242 | if (info->flags & ~XT_TIME_ALL_FLAGS) { |
244 | pr_info("unknown flags 0x%x\n", info->flags & ~XT_TIME_ALL_FLAGS); | 243 | pr_info_ratelimited("unknown flags 0x%x\n", |
244 | info->flags & ~XT_TIME_ALL_FLAGS); | ||
245 | return -EINVAL; | 245 | return -EINVAL; |
246 | } | 246 | } |
247 | 247 | ||
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 63cb55d3c2fd..5d10dcfe6411 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -2308,7 +2308,7 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | |||
2308 | if (cb->start) { | 2308 | if (cb->start) { |
2309 | ret = cb->start(cb); | 2309 | ret = cb->start(cb); |
2310 | if (ret) | 2310 | if (ret) |
2311 | goto error_unlock; | 2311 | goto error_put; |
2312 | } | 2312 | } |
2313 | 2313 | ||
2314 | nlk->cb_running = true; | 2314 | nlk->cb_running = true; |
@@ -2328,6 +2328,8 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | |||
2328 | */ | 2328 | */ |
2329 | return -EINTR; | 2329 | return -EINTR; |
2330 | 2330 | ||
2331 | error_put: | ||
2332 | module_put(control->module); | ||
2331 | error_unlock: | 2333 | error_unlock: |
2332 | sock_put(sk); | 2334 | sock_put(sk); |
2333 | mutex_unlock(nlk->cb_mutex); | 2335 | mutex_unlock(nlk->cb_mutex); |
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c index 42410e910aff..cf73dc006c3b 100644 --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c | |||
@@ -445,7 +445,7 @@ send_fragmentable: | |||
445 | (char *)&opt, sizeof(opt)); | 445 | (char *)&opt, sizeof(opt)); |
446 | if (ret == 0) { | 446 | if (ret == 0) { |
447 | ret = kernel_sendmsg(conn->params.local->socket, &msg, | 447 | ret = kernel_sendmsg(conn->params.local->socket, &msg, |
448 | iov, 1, iov[0].iov_len); | 448 | iov, 2, len); |
449 | 449 | ||
450 | opt = IPV6_PMTUDISC_DO; | 450 | opt = IPV6_PMTUDISC_DO; |
451 | kernel_setsockopt(conn->params.local->socket, | 451 | kernel_setsockopt(conn->params.local->socket, |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 3e14d38e5d42..9d1a8bbf8152 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -1397,13 +1397,18 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) | |||
1397 | nla_get_u32(tca[TCA_CHAIN]) != chain->index) | 1397 | nla_get_u32(tca[TCA_CHAIN]) != chain->index) |
1398 | continue; | 1398 | continue; |
1399 | if (!tcf_chain_dump(chain, q, parent, skb, cb, | 1399 | if (!tcf_chain_dump(chain, q, parent, skb, cb, |
1400 | index_start, &index)) | 1400 | index_start, &index)) { |
1401 | err = -EMSGSIZE; | ||
1401 | break; | 1402 | break; |
1403 | } | ||
1402 | } | 1404 | } |
1403 | 1405 | ||
1404 | cb->args[0] = index; | 1406 | cb->args[0] = index; |
1405 | 1407 | ||
1406 | out: | 1408 | out: |
1409 | /* If we did no progress, the error (EMSGSIZE) is real */ | ||
1410 | if (skb->len == 0 && err) | ||
1411 | return err; | ||
1407 | return skb->len; | 1412 | return skb->len; |
1408 | } | 1413 | } |
1409 | 1414 | ||
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 51aa55618ef7..b12da6ef3c12 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c | |||
@@ -170,9 +170,28 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | |||
170 | enum nl80211_bss_scan_width scan_width; | 170 | enum nl80211_bss_scan_width scan_width; |
171 | struct ieee80211_supported_band *sband = | 171 | struct ieee80211_supported_band *sband = |
172 | rdev->wiphy.bands[setup->chandef.chan->band]; | 172 | rdev->wiphy.bands[setup->chandef.chan->band]; |
173 | scan_width = cfg80211_chandef_to_scan_width(&setup->chandef); | 173 | |
174 | setup->basic_rates = ieee80211_mandatory_rates(sband, | 174 | if (setup->chandef.chan->band == NL80211_BAND_2GHZ) { |
175 | scan_width); | 175 | int i; |
176 | |||
177 | /* | ||
178 | * Older versions selected the mandatory rates for | ||
179 | * 2.4 GHz as well, but were broken in that only | ||
180 | * 1 Mbps was regarded as a mandatory rate. Keep | ||
181 | * using just 1 Mbps as the default basic rate for | ||
182 | * mesh to be interoperable with older versions. | ||
183 | */ | ||
184 | for (i = 0; i < sband->n_bitrates; i++) { | ||
185 | if (sband->bitrates[i].bitrate == 10) { | ||
186 | setup->basic_rates = BIT(i); | ||
187 | break; | ||
188 | } | ||
189 | } | ||
190 | } else { | ||
191 | scan_width = cfg80211_chandef_to_scan_width(&setup->chandef); | ||
192 | setup->basic_rates = ieee80211_mandatory_rates(sband, | ||
193 | scan_width); | ||
194 | } | ||
176 | } | 195 | } |
177 | 196 | ||
178 | err = cfg80211_chandef_dfs_required(&rdev->wiphy, | 197 | err = cfg80211_chandef_dfs_required(&rdev->wiphy, |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index fdb3646274a5..701cfd7acc1b 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -1032,6 +1032,8 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
1032 | wdev->current_bss = NULL; | 1032 | wdev->current_bss = NULL; |
1033 | wdev->ssid_len = 0; | 1033 | wdev->ssid_len = 0; |
1034 | wdev->conn_owner_nlportid = 0; | 1034 | wdev->conn_owner_nlportid = 0; |
1035 | kzfree(wdev->connect_keys); | ||
1036 | wdev->connect_keys = NULL; | ||
1035 | 1037 | ||
1036 | nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); | 1038 | nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); |
1037 | 1039 | ||
diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index 6f9e4ce568cd..9bb0a7f2863e 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/cred.h> | 18 | #include <linux/cred.h> |
19 | #include <linux/key-type.h> | 19 | #include <linux/key-type.h> |
20 | #include <linux/digsig.h> | 20 | #include <linux/digsig.h> |
21 | #include <linux/vmalloc.h> | ||
21 | #include <crypto/public_key.h> | 22 | #include <crypto/public_key.h> |
22 | #include <keys/system_keyring.h> | 23 | #include <keys/system_keyring.h> |
23 | 24 | ||
diff --git a/security/keys/big_key.c b/security/keys/big_key.c index 929e14978c42..fa728f662a6f 100644 --- a/security/keys/big_key.c +++ b/security/keys/big_key.c | |||
@@ -22,6 +22,13 @@ | |||
22 | #include <keys/big_key-type.h> | 22 | #include <keys/big_key-type.h> |
23 | #include <crypto/aead.h> | 23 | #include <crypto/aead.h> |
24 | 24 | ||
25 | struct big_key_buf { | ||
26 | unsigned int nr_pages; | ||
27 | void *virt; | ||
28 | struct scatterlist *sg; | ||
29 | struct page *pages[]; | ||
30 | }; | ||
31 | |||
25 | /* | 32 | /* |
26 | * Layout of key payload words. | 33 | * Layout of key payload words. |
27 | */ | 34 | */ |
@@ -91,10 +98,9 @@ static DEFINE_MUTEX(big_key_aead_lock); | |||
91 | /* | 98 | /* |
92 | * Encrypt/decrypt big_key data | 99 | * Encrypt/decrypt big_key data |
93 | */ | 100 | */ |
94 | static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key) | 101 | static int big_key_crypt(enum big_key_op op, struct big_key_buf *buf, size_t datalen, u8 *key) |
95 | { | 102 | { |
96 | int ret; | 103 | int ret; |
97 | struct scatterlist sgio; | ||
98 | struct aead_request *aead_req; | 104 | struct aead_request *aead_req; |
99 | /* We always use a zero nonce. The reason we can get away with this is | 105 | /* We always use a zero nonce. The reason we can get away with this is |
100 | * because we're using a different randomly generated key for every | 106 | * because we're using a different randomly generated key for every |
@@ -109,8 +115,7 @@ static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key) | |||
109 | return -ENOMEM; | 115 | return -ENOMEM; |
110 | 116 | ||
111 | memset(zero_nonce, 0, sizeof(zero_nonce)); | 117 | memset(zero_nonce, 0, sizeof(zero_nonce)); |
112 | sg_init_one(&sgio, data, datalen + (op == BIG_KEY_ENC ? ENC_AUTHTAG_SIZE : 0)); | 118 | aead_request_set_crypt(aead_req, buf->sg, buf->sg, datalen, zero_nonce); |
113 | aead_request_set_crypt(aead_req, &sgio, &sgio, datalen, zero_nonce); | ||
114 | aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); | 119 | aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); |
115 | aead_request_set_ad(aead_req, 0); | 120 | aead_request_set_ad(aead_req, 0); |
116 | 121 | ||
@@ -130,21 +135,81 @@ error: | |||
130 | } | 135 | } |
131 | 136 | ||
132 | /* | 137 | /* |
138 | * Free up the buffer. | ||
139 | */ | ||
140 | static void big_key_free_buffer(struct big_key_buf *buf) | ||
141 | { | ||
142 | unsigned int i; | ||
143 | |||
144 | if (buf->virt) { | ||
145 | memset(buf->virt, 0, buf->nr_pages * PAGE_SIZE); | ||
146 | vunmap(buf->virt); | ||
147 | } | ||
148 | |||
149 | for (i = 0; i < buf->nr_pages; i++) | ||
150 | if (buf->pages[i]) | ||
151 | __free_page(buf->pages[i]); | ||
152 | |||
153 | kfree(buf); | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * Allocate a buffer consisting of a set of pages with a virtual mapping | ||
158 | * applied over them. | ||
159 | */ | ||
160 | static void *big_key_alloc_buffer(size_t len) | ||
161 | { | ||
162 | struct big_key_buf *buf; | ||
163 | unsigned int npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
164 | unsigned int i, l; | ||
165 | |||
166 | buf = kzalloc(sizeof(struct big_key_buf) + | ||
167 | sizeof(struct page) * npg + | ||
168 | sizeof(struct scatterlist) * npg, | ||
169 | GFP_KERNEL); | ||
170 | if (!buf) | ||
171 | return NULL; | ||
172 | |||
173 | buf->nr_pages = npg; | ||
174 | buf->sg = (void *)(buf->pages + npg); | ||
175 | sg_init_table(buf->sg, npg); | ||
176 | |||
177 | for (i = 0; i < buf->nr_pages; i++) { | ||
178 | buf->pages[i] = alloc_page(GFP_KERNEL); | ||
179 | if (!buf->pages[i]) | ||
180 | goto nomem; | ||
181 | |||
182 | l = min_t(size_t, len, PAGE_SIZE); | ||
183 | sg_set_page(&buf->sg[i], buf->pages[i], l, 0); | ||
184 | len -= l; | ||
185 | } | ||
186 | |||
187 | buf->virt = vmap(buf->pages, buf->nr_pages, VM_MAP, PAGE_KERNEL); | ||
188 | if (!buf->virt) | ||
189 | goto nomem; | ||
190 | |||
191 | return buf; | ||
192 | |||
193 | nomem: | ||
194 | big_key_free_buffer(buf); | ||
195 | return NULL; | ||
196 | } | ||
197 | |||
198 | /* | ||
133 | * Preparse a big key | 199 | * Preparse a big key |
134 | */ | 200 | */ |
135 | int big_key_preparse(struct key_preparsed_payload *prep) | 201 | int big_key_preparse(struct key_preparsed_payload *prep) |
136 | { | 202 | { |
203 | struct big_key_buf *buf; | ||
137 | struct path *path = (struct path *)&prep->payload.data[big_key_path]; | 204 | struct path *path = (struct path *)&prep->payload.data[big_key_path]; |
138 | struct file *file; | 205 | struct file *file; |
139 | u8 *enckey; | 206 | u8 *enckey; |
140 | u8 *data = NULL; | ||
141 | ssize_t written; | 207 | ssize_t written; |
142 | size_t datalen = prep->datalen; | 208 | size_t datalen = prep->datalen, enclen = datalen + ENC_AUTHTAG_SIZE; |
143 | int ret; | 209 | int ret; |
144 | 210 | ||
145 | ret = -EINVAL; | ||
146 | if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data) | 211 | if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data) |
147 | goto error; | 212 | return -EINVAL; |
148 | 213 | ||
149 | /* Set an arbitrary quota */ | 214 | /* Set an arbitrary quota */ |
150 | prep->quotalen = 16; | 215 | prep->quotalen = 16; |
@@ -157,13 +222,12 @@ int big_key_preparse(struct key_preparsed_payload *prep) | |||
157 | * | 222 | * |
158 | * File content is stored encrypted with randomly generated key. | 223 | * File content is stored encrypted with randomly generated key. |
159 | */ | 224 | */ |
160 | size_t enclen = datalen + ENC_AUTHTAG_SIZE; | ||
161 | loff_t pos = 0; | 225 | loff_t pos = 0; |
162 | 226 | ||
163 | data = kmalloc(enclen, GFP_KERNEL); | 227 | buf = big_key_alloc_buffer(enclen); |
164 | if (!data) | 228 | if (!buf) |
165 | return -ENOMEM; | 229 | return -ENOMEM; |
166 | memcpy(data, prep->data, datalen); | 230 | memcpy(buf->virt, prep->data, datalen); |
167 | 231 | ||
168 | /* generate random key */ | 232 | /* generate random key */ |
169 | enckey = kmalloc(ENC_KEY_SIZE, GFP_KERNEL); | 233 | enckey = kmalloc(ENC_KEY_SIZE, GFP_KERNEL); |
@@ -176,7 +240,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) | |||
176 | goto err_enckey; | 240 | goto err_enckey; |
177 | 241 | ||
178 | /* encrypt aligned data */ | 242 | /* encrypt aligned data */ |
179 | ret = big_key_crypt(BIG_KEY_ENC, data, datalen, enckey); | 243 | ret = big_key_crypt(BIG_KEY_ENC, buf, datalen, enckey); |
180 | if (ret) | 244 | if (ret) |
181 | goto err_enckey; | 245 | goto err_enckey; |
182 | 246 | ||
@@ -187,7 +251,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) | |||
187 | goto err_enckey; | 251 | goto err_enckey; |
188 | } | 252 | } |
189 | 253 | ||
190 | written = kernel_write(file, data, enclen, &pos); | 254 | written = kernel_write(file, buf->virt, enclen, &pos); |
191 | if (written != enclen) { | 255 | if (written != enclen) { |
192 | ret = written; | 256 | ret = written; |
193 | if (written >= 0) | 257 | if (written >= 0) |
@@ -202,7 +266,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) | |||
202 | *path = file->f_path; | 266 | *path = file->f_path; |
203 | path_get(path); | 267 | path_get(path); |
204 | fput(file); | 268 | fput(file); |
205 | kzfree(data); | 269 | big_key_free_buffer(buf); |
206 | } else { | 270 | } else { |
207 | /* Just store the data in a buffer */ | 271 | /* Just store the data in a buffer */ |
208 | void *data = kmalloc(datalen, GFP_KERNEL); | 272 | void *data = kmalloc(datalen, GFP_KERNEL); |
@@ -220,7 +284,7 @@ err_fput: | |||
220 | err_enckey: | 284 | err_enckey: |
221 | kzfree(enckey); | 285 | kzfree(enckey); |
222 | error: | 286 | error: |
223 | kzfree(data); | 287 | big_key_free_buffer(buf); |
224 | return ret; | 288 | return ret; |
225 | } | 289 | } |
226 | 290 | ||
@@ -298,15 +362,15 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) | |||
298 | return datalen; | 362 | return datalen; |
299 | 363 | ||
300 | if (datalen > BIG_KEY_FILE_THRESHOLD) { | 364 | if (datalen > BIG_KEY_FILE_THRESHOLD) { |
365 | struct big_key_buf *buf; | ||
301 | struct path *path = (struct path *)&key->payload.data[big_key_path]; | 366 | struct path *path = (struct path *)&key->payload.data[big_key_path]; |
302 | struct file *file; | 367 | struct file *file; |
303 | u8 *data; | ||
304 | u8 *enckey = (u8 *)key->payload.data[big_key_data]; | 368 | u8 *enckey = (u8 *)key->payload.data[big_key_data]; |
305 | size_t enclen = datalen + ENC_AUTHTAG_SIZE; | 369 | size_t enclen = datalen + ENC_AUTHTAG_SIZE; |
306 | loff_t pos = 0; | 370 | loff_t pos = 0; |
307 | 371 | ||
308 | data = kmalloc(enclen, GFP_KERNEL); | 372 | buf = big_key_alloc_buffer(enclen); |
309 | if (!data) | 373 | if (!buf) |
310 | return -ENOMEM; | 374 | return -ENOMEM; |
311 | 375 | ||
312 | file = dentry_open(path, O_RDONLY, current_cred()); | 376 | file = dentry_open(path, O_RDONLY, current_cred()); |
@@ -316,26 +380,26 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) | |||
316 | } | 380 | } |
317 | 381 | ||
318 | /* read file to kernel and decrypt */ | 382 | /* read file to kernel and decrypt */ |
319 | ret = kernel_read(file, data, enclen, &pos); | 383 | ret = kernel_read(file, buf->virt, enclen, &pos); |
320 | if (ret >= 0 && ret != enclen) { | 384 | if (ret >= 0 && ret != enclen) { |
321 | ret = -EIO; | 385 | ret = -EIO; |
322 | goto err_fput; | 386 | goto err_fput; |
323 | } | 387 | } |
324 | 388 | ||
325 | ret = big_key_crypt(BIG_KEY_DEC, data, enclen, enckey); | 389 | ret = big_key_crypt(BIG_KEY_DEC, buf, enclen, enckey); |
326 | if (ret) | 390 | if (ret) |
327 | goto err_fput; | 391 | goto err_fput; |
328 | 392 | ||
329 | ret = datalen; | 393 | ret = datalen; |
330 | 394 | ||
331 | /* copy decrypted data to user */ | 395 | /* copy decrypted data to user */ |
332 | if (copy_to_user(buffer, data, datalen) != 0) | 396 | if (copy_to_user(buffer, buf->virt, datalen) != 0) |
333 | ret = -EFAULT; | 397 | ret = -EFAULT; |
334 | 398 | ||
335 | err_fput: | 399 | err_fput: |
336 | fput(file); | 400 | fput(file); |
337 | error: | 401 | error: |
338 | kzfree(data); | 402 | big_key_free_buffer(buf); |
339 | } else { | 403 | } else { |
340 | ret = datalen; | 404 | ret = datalen; |
341 | if (copy_to_user(buffer, key->payload.data[big_key_data], | 405 | if (copy_to_user(buffer, key->payload.data[big_key_data], |
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 3a0396d87c42..185acfa229b5 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c | |||
@@ -244,7 +244,7 @@ static int do_batch(int argc, char **argv) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | if (errno && errno != ENOENT) { | 246 | if (errno && errno != ENOENT) { |
247 | perror("reading batch file failed"); | 247 | p_err("reading batch file failed: %s", strerror(errno)); |
248 | err = -1; | 248 | err = -1; |
249 | } else { | 249 | } else { |
250 | p_info("processed %d lines", lines); | 250 | p_info("processed %d lines", lines); |
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index e8e2baaf93c2..e549e329be82 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -774,6 +774,9 @@ static int do_dump(int argc, char **argv) | |||
774 | n < 0 ? strerror(errno) : "short write"); | 774 | n < 0 ? strerror(errno) : "short write"); |
775 | goto err_free; | 775 | goto err_free; |
776 | } | 776 | } |
777 | |||
778 | if (json_output) | ||
779 | jsonw_null(json_wtr); | ||
777 | } else { | 780 | } else { |
778 | if (member_len == &info.jited_prog_len) { | 781 | if (member_len == &info.jited_prog_len) { |
779 | const char *name = NULL; | 782 | const char *name = NULL; |
diff --git a/tools/cgroup/Makefile b/tools/cgroup/Makefile index 860fa151640a..ffca068e4a76 100644 --- a/tools/cgroup/Makefile +++ b/tools/cgroup/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for cgroup tools | 2 | # Makefile for cgroup tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | CFLAGS = -Wall -Wextra | 4 | CFLAGS = -Wall -Wextra |
6 | 5 | ||
7 | all: cgroup_event_listener | 6 | all: cgroup_event_listener |
diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile index 805a2c0cf4cd..240eda014b37 100644 --- a/tools/gpio/Makefile +++ b/tools/gpio/Makefile | |||
@@ -12,8 +12,6 @@ endif | |||
12 | # (this improves performance and avoids hard-to-debug behaviour); | 12 | # (this improves performance and avoids hard-to-debug behaviour); |
13 | MAKEFLAGS += -r | 13 | MAKEFLAGS += -r |
14 | 14 | ||
15 | CC = $(CROSS_COMPILE)gcc | ||
16 | LD = $(CROSS_COMPILE)ld | ||
17 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
18 | 16 | ||
19 | ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon | 17 | ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon |
diff --git a/tools/hv/Makefile b/tools/hv/Makefile index 1139d71fa0cf..5db5e62cebda 100644 --- a/tools/hv/Makefile +++ b/tools/hv/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for Hyper-V tools | 2 | # Makefile for Hyper-V tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | WARNINGS = -Wall -Wextra | 4 | WARNINGS = -Wall -Wextra |
6 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) | 5 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) |
7 | 6 | ||
diff --git a/tools/iio/Makefile b/tools/iio/Makefile index a08e7a47d6a3..332ed2f6c2c2 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile | |||
@@ -12,8 +12,6 @@ endif | |||
12 | # (this improves performance and avoids hard-to-debug behaviour); | 12 | # (this improves performance and avoids hard-to-debug behaviour); |
13 | MAKEFLAGS += -r | 13 | MAKEFLAGS += -r |
14 | 14 | ||
15 | CC = $(CROSS_COMPILE)gcc | ||
16 | LD = $(CROSS_COMPILE)ld | ||
17 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
18 | 16 | ||
19 | ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer | 17 | ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer |
diff --git a/tools/laptop/freefall/Makefile b/tools/laptop/freefall/Makefile index 5f758c489a20..b572d94255f6 100644 --- a/tools/laptop/freefall/Makefile +++ b/tools/laptop/freefall/Makefile | |||
@@ -2,7 +2,6 @@ | |||
2 | PREFIX ?= /usr | 2 | PREFIX ?= /usr |
3 | SBINDIR ?= sbin | 3 | SBINDIR ?= sbin |
4 | INSTALL ?= install | 4 | INSTALL ?= install |
5 | CC = $(CROSS_COMPILE)gcc | ||
6 | 5 | ||
7 | TARGET = freefall | 6 | TARGET = freefall |
8 | 7 | ||
diff --git a/tools/leds/Makefile b/tools/leds/Makefile index c379af003807..7b6bed13daaa 100644 --- a/tools/leds/Makefile +++ b/tools/leds/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for LEDs tools | 2 | # Makefile for LEDs tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | CFLAGS = -Wall -Wextra -g -I../../include/uapi | 4 | CFLAGS = -Wall -Wextra -g -I../../include/uapi |
6 | 5 | ||
7 | all: uledmon led_hw_brightness_mon | 6 | all: uledmon led_hw_brightness_mon |
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 97073d649c1a..5bbbf285af74 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1060,11 +1060,12 @@ bpf_program__reloc_text(struct bpf_program *prog, struct bpf_object *obj, | |||
1060 | prog->insns = new_insn; | 1060 | prog->insns = new_insn; |
1061 | prog->main_prog_cnt = prog->insns_cnt; | 1061 | prog->main_prog_cnt = prog->insns_cnt; |
1062 | prog->insns_cnt = new_cnt; | 1062 | prog->insns_cnt = new_cnt; |
1063 | pr_debug("added %zd insn from %s to prog %s\n", | ||
1064 | text->insns_cnt, text->section_name, | ||
1065 | prog->section_name); | ||
1063 | } | 1066 | } |
1064 | insn = &prog->insns[relo->insn_idx]; | 1067 | insn = &prog->insns[relo->insn_idx]; |
1065 | insn->imm += prog->main_prog_cnt - relo->insn_idx; | 1068 | insn->imm += prog->main_prog_cnt - relo->insn_idx; |
1066 | pr_debug("added %zd insn from %s to prog %s\n", | ||
1067 | text->insns_cnt, text->section_name, prog->section_name); | ||
1068 | return 0; | 1069 | return 0; |
1069 | } | 1070 | } |
1070 | 1071 | ||
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9b0351d3ce34..012328038594 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -146,12 +146,6 @@ define allow-override | |||
146 | $(eval $(1) = $(2))) | 146 | $(eval $(1) = $(2))) |
147 | endef | 147 | endef |
148 | 148 | ||
149 | # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix. | ||
150 | $(call allow-override,CC,$(CROSS_COMPILE)gcc) | ||
151 | $(call allow-override,AR,$(CROSS_COMPILE)ar) | ||
152 | $(call allow-override,LD,$(CROSS_COMPILE)ld) | ||
153 | $(call allow-override,CXX,$(CROSS_COMPILE)g++) | ||
154 | |||
155 | LD += $(EXTRA_LDFLAGS) | 149 | LD += $(EXTRA_LDFLAGS) |
156 | 150 | ||
157 | HOSTCC ?= gcc | 151 | HOSTCC ?= gcc |
diff --git a/tools/power/acpi/Makefile.config b/tools/power/acpi/Makefile.config index a1883bbb0144..2cccbba64418 100644 --- a/tools/power/acpi/Makefile.config +++ b/tools/power/acpi/Makefile.config | |||
@@ -56,9 +56,6 @@ INSTALL_SCRIPT = ${INSTALL_PROGRAM} | |||
56 | # to compile vs uClibc, that can be done here as well. | 56 | # to compile vs uClibc, that can be done here as well. |
57 | CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- | 57 | CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- |
58 | CROSS_COMPILE ?= $(CROSS) | 58 | CROSS_COMPILE ?= $(CROSS) |
59 | CC = $(CROSS_COMPILE)gcc | ||
60 | LD = $(CROSS_COMPILE)gcc | ||
61 | STRIP = $(CROSS_COMPILE)strip | ||
62 | HOSTCC = gcc | 59 | HOSTCC = gcc |
63 | 60 | ||
64 | # check if compiler option is supported | 61 | # check if compiler option is supported |
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index fcb3ed0be5f8..dd614463d4d6 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include | |||
@@ -42,6 +42,24 @@ EXTRA_WARNINGS += -Wformat | |||
42 | 42 | ||
43 | CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) | 43 | CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) |
44 | 44 | ||
45 | # Makefiles suck: This macro sets a default value of $(2) for the | ||
46 | # variable named by $(1), unless the variable has been set by | ||
47 | # environment or command line. This is necessary for CC and AR | ||
48 | # because make sets default values, so the simpler ?= approach | ||
49 | # won't work as expected. | ||
50 | define allow-override | ||
51 | $(if $(or $(findstring environment,$(origin $(1))),\ | ||
52 | $(findstring command line,$(origin $(1)))),,\ | ||
53 | $(eval $(1) = $(2))) | ||
54 | endef | ||
55 | |||
56 | # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. | ||
57 | $(call allow-override,CC,$(CROSS_COMPILE)gcc) | ||
58 | $(call allow-override,AR,$(CROSS_COMPILE)ar) | ||
59 | $(call allow-override,LD,$(CROSS_COMPILE)ld) | ||
60 | $(call allow-override,CXX,$(CROSS_COMPILE)g++) | ||
61 | $(call allow-override,STRIP,$(CROSS_COMPILE)strip) | ||
62 | |||
45 | ifeq ($(CC_NO_CLANG), 1) | 63 | ifeq ($(CC_NO_CLANG), 1) |
46 | EXTRA_WARNINGS += -Wstrict-aliasing=3 | 64 | EXTRA_WARNINGS += -Wstrict-aliasing=3 |
47 | endif | 65 | endif |
diff --git a/tools/spi/Makefile b/tools/spi/Makefile index 90615e10c79a..815d15589177 100644 --- a/tools/spi/Makefile +++ b/tools/spi/Makefile | |||
@@ -11,8 +11,6 @@ endif | |||
11 | # (this improves performance and avoids hard-to-debug behaviour); | 11 | # (this improves performance and avoids hard-to-debug behaviour); |
12 | MAKEFLAGS += -r | 12 | MAKEFLAGS += -r |
13 | 13 | ||
14 | CC = $(CROSS_COMPILE)gcc | ||
15 | LD = $(CROSS_COMPILE)ld | ||
16 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 14 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
17 | 15 | ||
18 | ALL_TARGETS := spidev_test spidev_fdx | 16 | ALL_TARGETS := spidev_test spidev_fdx |
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore index cc15af2e54fe..9cf83f895d98 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore | |||
@@ -11,3 +11,4 @@ test_progs | |||
11 | test_tcpbpf_user | 11 | test_tcpbpf_user |
12 | test_verifier_log | 12 | test_verifier_log |
13 | feature | 13 | feature |
14 | test_libbpf_open | ||
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 436c4c72414f..9e03a4c356a4 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c | |||
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data) | |||
126 | fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, | 126 | fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, |
127 | 2, map_flags); | 127 | 2, map_flags); |
128 | if (fd < 0) { | 128 | if (fd < 0) { |
129 | if (errno == ENOMEM) | ||
130 | return; | ||
129 | printf("Failed to create hashmap key=%d value=%d '%s'\n", | 131 | printf("Failed to create hashmap key=%d value=%d '%s'\n", |
130 | i, j, strerror(errno)); | 132 | i, j, strerror(errno)); |
131 | exit(1); | 133 | exit(1); |
diff --git a/tools/testing/selftests/bpf/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/test_tcpbpf_kern.c index 57119ad57a3f..3e645ee41ed5 100644 --- a/tools/testing/selftests/bpf/test_tcpbpf_kern.c +++ b/tools/testing/selftests/bpf/test_tcpbpf_kern.c | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <linux/if_ether.h> | 5 | #include <linux/if_ether.h> |
6 | #include <linux/if_packet.h> | 6 | #include <linux/if_packet.h> |
7 | #include <linux/ip.h> | 7 | #include <linux/ip.h> |
8 | #include <linux/in6.h> | ||
9 | #include <linux/types.h> | 8 | #include <linux/types.h> |
10 | #include <linux/socket.h> | 9 | #include <linux/socket.h> |
11 | #include <linux/tcp.h> | 10 | #include <linux/tcp.h> |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index c0f16e93f9bd..c73592fa3d41 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -2587,6 +2587,32 @@ static struct bpf_test tests[] = { | |||
2587 | .result = ACCEPT, | 2587 | .result = ACCEPT, |
2588 | }, | 2588 | }, |
2589 | { | 2589 | { |
2590 | "runtime/jit: pass negative index to tail_call", | ||
2591 | .insns = { | ||
2592 | BPF_MOV64_IMM(BPF_REG_3, -1), | ||
2593 | BPF_LD_MAP_FD(BPF_REG_2, 0), | ||
2594 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
2595 | BPF_FUNC_tail_call), | ||
2596 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
2597 | BPF_EXIT_INSN(), | ||
2598 | }, | ||
2599 | .fixup_prog = { 1 }, | ||
2600 | .result = ACCEPT, | ||
2601 | }, | ||
2602 | { | ||
2603 | "runtime/jit: pass > 32bit index to tail_call", | ||
2604 | .insns = { | ||
2605 | BPF_LD_IMM64(BPF_REG_3, 0x100000000ULL), | ||
2606 | BPF_LD_MAP_FD(BPF_REG_2, 0), | ||
2607 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
2608 | BPF_FUNC_tail_call), | ||
2609 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
2610 | BPF_EXIT_INSN(), | ||
2611 | }, | ||
2612 | .fixup_prog = { 2 }, | ||
2613 | .result = ACCEPT, | ||
2614 | }, | ||
2615 | { | ||
2590 | "stack pointer arithmetic", | 2616 | "stack pointer arithmetic", |
2591 | .insns = { | 2617 | .insns = { |
2592 | BPF_MOV64_IMM(BPF_REG_1, 4), | 2618 | BPF_MOV64_IMM(BPF_REG_1, 4), |
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index a5276a91dfbf..0862e6f47a38 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile | |||
@@ -5,6 +5,7 @@ CFLAGS += -I../../../../include/ | |||
5 | CFLAGS += -I../../../../usr/include/ | 5 | CFLAGS += -I../../../../usr/include/ |
6 | 6 | ||
7 | TEST_PROGS := run_tests.sh | 7 | TEST_PROGS := run_tests.sh |
8 | TEST_FILES := run_fuse_test.sh | ||
8 | TEST_GEN_FILES := memfd_test fuse_mnt fuse_test | 9 | TEST_GEN_FILES := memfd_test fuse_mnt fuse_test |
9 | 10 | ||
10 | fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) | 11 | fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) |
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 0b457e8e0f0c..5df609950a66 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
@@ -141,6 +141,15 @@ struct seccomp_data { | |||
141 | #define SECCOMP_FILTER_FLAG_LOG 2 | 141 | #define SECCOMP_FILTER_FLAG_LOG 2 |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | #ifndef PTRACE_SECCOMP_GET_METADATA | ||
145 | #define PTRACE_SECCOMP_GET_METADATA 0x420d | ||
146 | |||
147 | struct seccomp_metadata { | ||
148 | __u64 filter_off; /* Input: which filter */ | ||
149 | __u64 flags; /* Output: filter's flags */ | ||
150 | }; | ||
151 | #endif | ||
152 | |||
144 | #ifndef seccomp | 153 | #ifndef seccomp |
145 | int seccomp(unsigned int op, unsigned int flags, void *args) | 154 | int seccomp(unsigned int op, unsigned int flags, void *args) |
146 | { | 155 | { |
@@ -2845,6 +2854,58 @@ TEST(get_action_avail) | |||
2845 | EXPECT_EQ(errno, EOPNOTSUPP); | 2854 | EXPECT_EQ(errno, EOPNOTSUPP); |
2846 | } | 2855 | } |
2847 | 2856 | ||
2857 | TEST(get_metadata) | ||
2858 | { | ||
2859 | pid_t pid; | ||
2860 | int pipefd[2]; | ||
2861 | char buf; | ||
2862 | struct seccomp_metadata md; | ||
2863 | |||
2864 | ASSERT_EQ(0, pipe(pipefd)); | ||
2865 | |||
2866 | pid = fork(); | ||
2867 | ASSERT_GE(pid, 0); | ||
2868 | if (pid == 0) { | ||
2869 | struct sock_filter filter[] = { | ||
2870 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | ||
2871 | }; | ||
2872 | struct sock_fprog prog = { | ||
2873 | .len = (unsigned short)ARRAY_SIZE(filter), | ||
2874 | .filter = filter, | ||
2875 | }; | ||
2876 | |||
2877 | /* one with log, one without */ | ||
2878 | ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, | ||
2879 | SECCOMP_FILTER_FLAG_LOG, &prog)); | ||
2880 | ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); | ||
2881 | |||
2882 | ASSERT_EQ(0, close(pipefd[0])); | ||
2883 | ASSERT_EQ(1, write(pipefd[1], "1", 1)); | ||
2884 | ASSERT_EQ(0, close(pipefd[1])); | ||
2885 | |||
2886 | while (1) | ||
2887 | sleep(100); | ||
2888 | } | ||
2889 | |||
2890 | ASSERT_EQ(0, close(pipefd[1])); | ||
2891 | ASSERT_EQ(1, read(pipefd[0], &buf, 1)); | ||
2892 | |||
2893 | ASSERT_EQ(0, ptrace(PTRACE_ATTACH, pid)); | ||
2894 | ASSERT_EQ(pid, waitpid(pid, NULL, 0)); | ||
2895 | |||
2896 | md.filter_off = 0; | ||
2897 | ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); | ||
2898 | EXPECT_EQ(md.flags, SECCOMP_FILTER_FLAG_LOG); | ||
2899 | EXPECT_EQ(md.filter_off, 0); | ||
2900 | |||
2901 | md.filter_off = 1; | ||
2902 | ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); | ||
2903 | EXPECT_EQ(md.flags, 0); | ||
2904 | EXPECT_EQ(md.filter_off, 1); | ||
2905 | |||
2906 | ASSERT_EQ(0, kill(pid, SIGKILL)); | ||
2907 | } | ||
2908 | |||
2848 | /* | 2909 | /* |
2849 | * TODO: | 2910 | * TODO: |
2850 | * - add microbenchmarks | 2911 | * - add microbenchmarks |
diff --git a/tools/usb/Makefile b/tools/usb/Makefile index 4e6506078494..01d758d73b6d 100644 --- a/tools/usb/Makefile +++ b/tools/usb/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for USB tools | 2 | # Makefile for USB tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | PTHREAD_LIBS = -lpthread | 4 | PTHREAD_LIBS = -lpthread |
6 | WARNINGS = -Wall -Wextra | 5 | WARNINGS = -Wall -Wextra |
7 | CFLAGS = $(WARNINGS) -g -I../include | 6 | CFLAGS = $(WARNINGS) -g -I../include |
diff --git a/tools/vm/Makefile b/tools/vm/Makefile index be320b905ea7..20f6cf04377f 100644 --- a/tools/vm/Makefile +++ b/tools/vm/Makefile | |||
@@ -6,7 +6,6 @@ TARGETS=page-types slabinfo page_owner_sort | |||
6 | LIB_DIR = ../lib/api | 6 | LIB_DIR = ../lib/api |
7 | LIBS = $(LIB_DIR)/libapi.a | 7 | LIBS = $(LIB_DIR)/libapi.a |
8 | 8 | ||
9 | CC = $(CROSS_COMPILE)gcc | ||
10 | CFLAGS = -Wall -Wextra -I../lib/ | 9 | CFLAGS = -Wall -Wextra -I../lib/ |
11 | LDFLAGS = $(LIBS) | 10 | LDFLAGS = $(LIBS) |
12 | 11 | ||
diff --git a/tools/wmi/Makefile b/tools/wmi/Makefile index e664f1167388..e0e87239126b 100644 --- a/tools/wmi/Makefile +++ b/tools/wmi/Makefile | |||
@@ -2,7 +2,6 @@ PREFIX ?= /usr | |||
2 | SBINDIR ?= sbin | 2 | SBINDIR ?= sbin |
3 | INSTALL ?= install | 3 | INSTALL ?= install |
4 | CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include | 4 | CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include |
5 | CC = $(CROSS_COMPILE)gcc | ||
6 | 5 | ||
7 | TARGET = dell-smbios-example | 6 | TARGET = dell-smbios-example |
8 | 7 | ||