1 |
commit: 0e48f80db777845a4ff23c262674ad2515652533 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 19 23:44:50 2020 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 19 23:44:50 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=0e48f80d |
7 |
|
8 |
Linux patch 4.19.105 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1104_linux-4.19.105.patch | 1521 +++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 1525 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 6839197..f83fdcc 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -455,6 +455,10 @@ Patch: 1103_linux-4.19.104.patch |
21 |
From: https://www.kernel.org |
22 |
Desc: Linux 4.19.104 |
23 |
|
24 |
+Patch: 1104_linux-4.19.105.patch |
25 |
+From: https://www.kernel.org |
26 |
+Desc: Linux 4.19.105 |
27 |
+ |
28 |
Patch: 1500_XATTR_USER_PREFIX.patch |
29 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
30 |
Desc: Support for namespace user.pax.* on tmpfs. |
31 |
|
32 |
diff --git a/1104_linux-4.19.105.patch b/1104_linux-4.19.105.patch |
33 |
new file mode 100644 |
34 |
index 0000000..183f892 |
35 |
--- /dev/null |
36 |
+++ b/1104_linux-4.19.105.patch |
37 |
@@ -0,0 +1,1521 @@ |
38 |
+diff --git a/Makefile b/Makefile |
39 |
+index 004d964cca50..eef7de60cd94 100644 |
40 |
+--- a/Makefile |
41 |
++++ b/Makefile |
42 |
+@@ -1,7 +1,7 @@ |
43 |
+ # SPDX-License-Identifier: GPL-2.0 |
44 |
+ VERSION = 4 |
45 |
+ PATCHLEVEL = 19 |
46 |
+-SUBLEVEL = 104 |
47 |
++SUBLEVEL = 105 |
48 |
+ EXTRAVERSION = |
49 |
+ NAME = "People's Front" |
50 |
+ |
51 |
+diff --git a/arch/arm/mach-npcm/Kconfig b/arch/arm/mach-npcm/Kconfig |
52 |
+index 684c9c9a32bd..1d17515deb4e 100644 |
53 |
+--- a/arch/arm/mach-npcm/Kconfig |
54 |
++++ b/arch/arm/mach-npcm/Kconfig |
55 |
+@@ -10,7 +10,7 @@ config ARCH_NPCM7XX |
56 |
+ depends on ARCH_MULTI_V7 |
57 |
+ select PINCTRL_NPCM7XX |
58 |
+ select NPCM7XX_TIMER |
59 |
+- select ARCH_REQUIRE_GPIOLIB |
60 |
++ select GPIOLIB |
61 |
+ select CACHE_L2X0 |
62 |
+ select ARM_GIC |
63 |
+ select HAVE_ARM_TWD if SMP |
64 |
+diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c |
65 |
+index 1375307fbe4d..ac3126aba036 100644 |
66 |
+--- a/arch/arm64/kernel/cpufeature.c |
67 |
++++ b/arch/arm64/kernel/cpufeature.c |
68 |
+@@ -42,9 +42,7 @@ EXPORT_SYMBOL_GPL(elf_hwcap); |
69 |
+ #define COMPAT_ELF_HWCAP_DEFAULT \ |
70 |
+ (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ |
71 |
+ COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\ |
72 |
+- COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\ |
73 |
+- COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\ |
74 |
+- COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV|\ |
75 |
++ COMPAT_HWCAP_TLS|COMPAT_HWCAP_IDIV|\ |
76 |
+ COMPAT_HWCAP_LPAE) |
77 |
+ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT; |
78 |
+ unsigned int compat_elf_hwcap2 __read_mostly; |
79 |
+@@ -1341,17 +1339,30 @@ static const struct arm64_cpu_capabilities arm64_features[] = { |
80 |
+ {}, |
81 |
+ }; |
82 |
+ |
83 |
+-#define HWCAP_CAP(reg, field, s, min_value, cap_type, cap) \ |
84 |
+- { \ |
85 |
+- .desc = #cap, \ |
86 |
+- .type = ARM64_CPUCAP_SYSTEM_FEATURE, \ |
87 |
++ |
88 |
++#define HWCAP_CPUID_MATCH(reg, field, s, min_value) \ |
89 |
+ .matches = has_cpuid_feature, \ |
90 |
+ .sys_reg = reg, \ |
91 |
+ .field_pos = field, \ |
92 |
+ .sign = s, \ |
93 |
+ .min_field_value = min_value, \ |
94 |
++ |
95 |
++#define __HWCAP_CAP(name, cap_type, cap) \ |
96 |
++ .desc = name, \ |
97 |
++ .type = ARM64_CPUCAP_SYSTEM_FEATURE, \ |
98 |
+ .hwcap_type = cap_type, \ |
99 |
+ .hwcap = cap, \ |
100 |
++ |
101 |
++#define HWCAP_CAP(reg, field, s, min_value, cap_type, cap) \ |
102 |
++ { \ |
103 |
++ __HWCAP_CAP(#cap, cap_type, cap) \ |
104 |
++ HWCAP_CPUID_MATCH(reg, field, s, min_value) \ |
105 |
++ } |
106 |
++ |
107 |
++#define HWCAP_CAP_MATCH(match, cap_type, cap) \ |
108 |
++ { \ |
109 |
++ __HWCAP_CAP(#cap, cap_type, cap) \ |
110 |
++ .matches = match, \ |
111 |
+ } |
112 |
+ |
113 |
+ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = { |
114 |
+@@ -1387,8 +1398,35 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = { |
115 |
+ {}, |
116 |
+ }; |
117 |
+ |
118 |
++#ifdef CONFIG_COMPAT |
119 |
++static bool compat_has_neon(const struct arm64_cpu_capabilities *cap, int scope) |
120 |
++{ |
121 |
++ /* |
122 |
++ * Check that all of MVFR1_EL1.{SIMDSP, SIMDInt, SIMDLS} are available, |
123 |
++ * in line with that of arm32 as in vfp_init(). We make sure that the |
124 |
++ * check is future proof, by making sure value is non-zero. |
125 |
++ */ |
126 |
++ u32 mvfr1; |
127 |
++ |
128 |
++ WARN_ON(scope == SCOPE_LOCAL_CPU && preemptible()); |
129 |
++ if (scope == SCOPE_SYSTEM) |
130 |
++ mvfr1 = read_sanitised_ftr_reg(SYS_MVFR1_EL1); |
131 |
++ else |
132 |
++ mvfr1 = read_sysreg_s(SYS_MVFR1_EL1); |
133 |
++ |
134 |
++ return cpuid_feature_extract_unsigned_field(mvfr1, MVFR1_SIMDSP_SHIFT) && |
135 |
++ cpuid_feature_extract_unsigned_field(mvfr1, MVFR1_SIMDINT_SHIFT) && |
136 |
++ cpuid_feature_extract_unsigned_field(mvfr1, MVFR1_SIMDLS_SHIFT); |
137 |
++} |
138 |
++#endif |
139 |
++ |
140 |
+ static const struct arm64_cpu_capabilities compat_elf_hwcaps[] = { |
141 |
+ #ifdef CONFIG_COMPAT |
142 |
++ HWCAP_CAP_MATCH(compat_has_neon, CAP_COMPAT_HWCAP, COMPAT_HWCAP_NEON), |
143 |
++ HWCAP_CAP(SYS_MVFR1_EL1, MVFR1_SIMDFMAC_SHIFT, FTR_UNSIGNED, 1, CAP_COMPAT_HWCAP, COMPAT_HWCAP_VFPv4), |
144 |
++ /* Arm v8 mandates MVFR0.FPDP == {0, 2}. So, piggy back on this for the presence of VFP support */ |
145 |
++ HWCAP_CAP(SYS_MVFR0_EL1, MVFR0_FPDP_SHIFT, FTR_UNSIGNED, 2, CAP_COMPAT_HWCAP, COMPAT_HWCAP_VFP), |
146 |
++ HWCAP_CAP(SYS_MVFR0_EL1, MVFR0_FPDP_SHIFT, FTR_UNSIGNED, 2, CAP_COMPAT_HWCAP, COMPAT_HWCAP_VFPv3), |
147 |
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, FTR_UNSIGNED, 2, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_PMULL), |
148 |
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_AES_SHIFT, FTR_UNSIGNED, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_AES), |
149 |
+ HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_SHA1_SHIFT, FTR_UNSIGNED, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_SHA1), |
150 |
+diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c |
151 |
+index 58c53bc96928..14fdbaa6ee3a 100644 |
152 |
+--- a/arch/arm64/kernel/fpsimd.c |
153 |
++++ b/arch/arm64/kernel/fpsimd.c |
154 |
+@@ -218,6 +218,7 @@ static void sve_free(struct task_struct *task) |
155 |
+ static void task_fpsimd_load(void) |
156 |
+ { |
157 |
+ WARN_ON(!in_softirq() && !irqs_disabled()); |
158 |
++ WARN_ON(!system_supports_fpsimd()); |
159 |
+ |
160 |
+ if (system_supports_sve() && test_thread_flag(TIF_SVE)) |
161 |
+ sve_load_state(sve_pffr(¤t->thread), |
162 |
+@@ -238,6 +239,7 @@ void fpsimd_save(void) |
163 |
+ struct user_fpsimd_state *st = __this_cpu_read(fpsimd_last_state.st); |
164 |
+ /* set by fpsimd_bind_task_to_cpu() or fpsimd_bind_state_to_cpu() */ |
165 |
+ |
166 |
++ WARN_ON(!system_supports_fpsimd()); |
167 |
+ WARN_ON(!in_softirq() && !irqs_disabled()); |
168 |
+ |
169 |
+ if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) { |
170 |
+@@ -977,6 +979,7 @@ void fpsimd_bind_task_to_cpu(void) |
171 |
+ struct fpsimd_last_state_struct *last = |
172 |
+ this_cpu_ptr(&fpsimd_last_state); |
173 |
+ |
174 |
++ WARN_ON(!system_supports_fpsimd()); |
175 |
+ last->st = ¤t->thread.uw.fpsimd_state; |
176 |
+ current->thread.fpsimd_cpu = smp_processor_id(); |
177 |
+ |
178 |
+@@ -996,6 +999,7 @@ void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *st) |
179 |
+ struct fpsimd_last_state_struct *last = |
180 |
+ this_cpu_ptr(&fpsimd_last_state); |
181 |
+ |
182 |
++ WARN_ON(!system_supports_fpsimd()); |
183 |
+ WARN_ON(!in_softirq() && !irqs_disabled()); |
184 |
+ |
185 |
+ last->st = st; |
186 |
+@@ -1008,8 +1012,19 @@ void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *st) |
187 |
+ */ |
188 |
+ void fpsimd_restore_current_state(void) |
189 |
+ { |
190 |
+- if (!system_supports_fpsimd()) |
191 |
++ /* |
192 |
++ * For the tasks that were created before we detected the absence of |
193 |
++ * FP/SIMD, the TIF_FOREIGN_FPSTATE could be set via fpsimd_thread_switch(), |
194 |
++ * e.g, init. This could be then inherited by the children processes. |
195 |
++ * If we later detect that the system doesn't support FP/SIMD, |
196 |
++ * we must clear the flag for all the tasks to indicate that the |
197 |
++ * FPSTATE is clean (as we can't have one) to avoid looping for ever in |
198 |
++ * do_notify_resume(). |
199 |
++ */ |
200 |
++ if (!system_supports_fpsimd()) { |
201 |
++ clear_thread_flag(TIF_FOREIGN_FPSTATE); |
202 |
+ return; |
203 |
++ } |
204 |
+ |
205 |
+ local_bh_disable(); |
206 |
+ |
207 |
+@@ -1028,7 +1043,7 @@ void fpsimd_restore_current_state(void) |
208 |
+ */ |
209 |
+ void fpsimd_update_current_state(struct user_fpsimd_state const *state) |
210 |
+ { |
211 |
+- if (!system_supports_fpsimd()) |
212 |
++ if (WARN_ON(!system_supports_fpsimd())) |
213 |
+ return; |
214 |
+ |
215 |
+ local_bh_disable(); |
216 |
+@@ -1055,6 +1070,7 @@ void fpsimd_flush_task_state(struct task_struct *t) |
217 |
+ |
218 |
+ void fpsimd_flush_cpu_state(void) |
219 |
+ { |
220 |
++ WARN_ON(!system_supports_fpsimd()); |
221 |
+ __this_cpu_write(fpsimd_last_state.st, NULL); |
222 |
+ set_thread_flag(TIF_FOREIGN_FPSTATE); |
223 |
+ } |
224 |
+diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c |
225 |
+index d668c13218b8..d6a49bb07a5f 100644 |
226 |
+--- a/arch/arm64/kernel/process.c |
227 |
++++ b/arch/arm64/kernel/process.c |
228 |
+@@ -414,6 +414,13 @@ static void ssbs_thread_switch(struct task_struct *next) |
229 |
+ if (unlikely(next->flags & PF_KTHREAD)) |
230 |
+ return; |
231 |
+ |
232 |
++ /* |
233 |
++ * If all CPUs implement the SSBS extension, then we just need to |
234 |
++ * context-switch the PSTATE field. |
235 |
++ */ |
236 |
++ if (cpu_have_feature(cpu_feature(SSBS))) |
237 |
++ return; |
238 |
++ |
239 |
+ /* If the mitigation is enabled, then we leave SSBS clear. */ |
240 |
+ if ((arm64_get_ssbd_state() == ARM64_SSBD_FORCE_ENABLE) || |
241 |
+ test_tsk_thread_flag(next, TIF_SSBD)) |
242 |
+diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c |
243 |
+index 6290a4e81d57..f3978931aaf4 100644 |
244 |
+--- a/arch/arm64/kvm/hyp/switch.c |
245 |
++++ b/arch/arm64/kvm/hyp/switch.c |
246 |
+@@ -37,7 +37,15 @@ |
247 |
+ /* Check whether the FP regs were dirtied while in the host-side run loop: */ |
248 |
+ static bool __hyp_text update_fp_enabled(struct kvm_vcpu *vcpu) |
249 |
+ { |
250 |
+- if (vcpu->arch.host_thread_info->flags & _TIF_FOREIGN_FPSTATE) |
251 |
++ /* |
252 |
++ * When the system doesn't support FP/SIMD, we cannot rely on |
253 |
++ * the _TIF_FOREIGN_FPSTATE flag. However, we always inject an |
254 |
++ * abort on the very first access to FP and thus we should never |
255 |
++ * see KVM_ARM64_FP_ENABLED. For added safety, make sure we always |
256 |
++ * trap the accesses. |
257 |
++ */ |
258 |
++ if (!system_supports_fpsimd() || |
259 |
++ vcpu->arch.host_thread_info->flags & _TIF_FOREIGN_FPSTATE) |
260 |
+ vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED | |
261 |
+ KVM_ARM64_FP_HOST); |
262 |
+ |
263 |
+diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h |
264 |
+index 2dc9eb4e1acc..b6a4ce9dafaf 100644 |
265 |
+--- a/arch/s390/include/asm/timex.h |
266 |
++++ b/arch/s390/include/asm/timex.h |
267 |
+@@ -155,7 +155,7 @@ static inline void get_tod_clock_ext(char *clk) |
268 |
+ |
269 |
+ static inline unsigned long long get_tod_clock(void) |
270 |
+ { |
271 |
+- unsigned char clk[STORE_CLOCK_EXT_SIZE]; |
272 |
++ char clk[STORE_CLOCK_EXT_SIZE]; |
273 |
+ |
274 |
+ get_tod_clock_ext(clk); |
275 |
+ return *((unsigned long long *)&clk[1]); |
276 |
+diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c |
277 |
+index defb536aebce..c3ec535fd36b 100644 |
278 |
+--- a/arch/x86/events/amd/core.c |
279 |
++++ b/arch/x86/events/amd/core.c |
280 |
+@@ -245,6 +245,7 @@ static const u64 amd_f17h_perfmon_event_map[PERF_COUNT_HW_MAX] = |
281 |
+ [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, |
282 |
+ [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, |
283 |
+ [PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60, |
284 |
++ [PERF_COUNT_HW_CACHE_MISSES] = 0x0964, |
285 |
+ [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, |
286 |
+ [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, |
287 |
+ [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x0287, |
288 |
+diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c |
289 |
+index e91814d1a27f..79caeba8b6f0 100644 |
290 |
+--- a/arch/x86/events/intel/ds.c |
291 |
++++ b/arch/x86/events/intel/ds.c |
292 |
+@@ -1402,6 +1402,8 @@ intel_pmu_save_and_restart_reload(struct perf_event *event, int count) |
293 |
+ old = ((s64)(prev_raw_count << shift) >> shift); |
294 |
+ local64_add(new - old + count * period, &event->count); |
295 |
+ |
296 |
++ local64_set(&hwc->period_left, -new); |
297 |
++ |
298 |
+ perf_event_update_userpage(event); |
299 |
+ |
300 |
+ return 0; |
301 |
+diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h |
302 |
+index 100ae4fabf17..61f10a4fd807 100644 |
303 |
+--- a/arch/x86/kvm/paging_tmpl.h |
304 |
++++ b/arch/x86/kvm/paging_tmpl.h |
305 |
+@@ -36,7 +36,7 @@ |
306 |
+ #define PT_GUEST_ACCESSED_SHIFT PT_ACCESSED_SHIFT |
307 |
+ #define PT_HAVE_ACCESSED_DIRTY(mmu) true |
308 |
+ #ifdef CONFIG_X86_64 |
309 |
+- #define PT_MAX_FULL_LEVELS 4 |
310 |
++ #define PT_MAX_FULL_LEVELS PT64_ROOT_MAX_LEVEL |
311 |
+ #define CMPXCHG cmpxchg |
312 |
+ #else |
313 |
+ #define CMPXCHG cmpxchg64 |
314 |
+diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c |
315 |
+index 3791ce8d269e..997926a9121c 100644 |
316 |
+--- a/arch/x86/kvm/vmx/vmx.c |
317 |
++++ b/arch/x86/kvm/vmx/vmx.c |
318 |
+@@ -2968,6 +2968,9 @@ void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) |
319 |
+ |
320 |
+ static int get_ept_level(struct kvm_vcpu *vcpu) |
321 |
+ { |
322 |
++ /* Nested EPT currently only supports 4-level walks. */ |
323 |
++ if (is_guest_mode(vcpu) && nested_cpu_has_ept(get_vmcs12(vcpu))) |
324 |
++ return 4; |
325 |
+ if (cpu_has_vmx_ept_5levels() && (cpuid_maxphyaddr(vcpu) > 48)) |
326 |
+ return 5; |
327 |
+ return 4; |
328 |
+diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c |
329 |
+index 58b789c28b48..94eea2ac6251 100644 |
330 |
+--- a/drivers/hwmon/pmbus/ltc2978.c |
331 |
++++ b/drivers/hwmon/pmbus/ltc2978.c |
332 |
+@@ -89,8 +89,8 @@ enum chips { ltc2974, ltc2975, ltc2977, ltc2978, ltc2980, ltc3880, ltc3882, |
333 |
+ |
334 |
+ #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */ |
335 |
+ |
336 |
+-#define LTC_NOT_BUSY BIT(5) |
337 |
+-#define LTC_NOT_PENDING BIT(4) |
338 |
++#define LTC_NOT_BUSY BIT(6) |
339 |
++#define LTC_NOT_PENDING BIT(5) |
340 |
+ |
341 |
+ /* |
342 |
+ * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which |
343 |
+diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c |
344 |
+index b79b61bd6ee4..4e2565cccb8a 100644 |
345 |
+--- a/drivers/infiniband/core/security.c |
346 |
++++ b/drivers/infiniband/core/security.c |
347 |
+@@ -336,22 +336,16 @@ static struct ib_ports_pkeys *get_new_pps(const struct ib_qp *qp, |
348 |
+ if (!new_pps) |
349 |
+ return NULL; |
350 |
+ |
351 |
+- if (qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) { |
352 |
+- if (!qp_pps) { |
353 |
+- new_pps->main.port_num = qp_attr->port_num; |
354 |
+- new_pps->main.pkey_index = qp_attr->pkey_index; |
355 |
+- } else { |
356 |
+- new_pps->main.port_num = (qp_attr_mask & IB_QP_PORT) ? |
357 |
+- qp_attr->port_num : |
358 |
+- qp_pps->main.port_num; |
359 |
+- |
360 |
+- new_pps->main.pkey_index = |
361 |
+- (qp_attr_mask & IB_QP_PKEY_INDEX) ? |
362 |
+- qp_attr->pkey_index : |
363 |
+- qp_pps->main.pkey_index; |
364 |
+- } |
365 |
++ if (qp_attr_mask & IB_QP_PORT) |
366 |
++ new_pps->main.port_num = |
367 |
++ (qp_pps) ? qp_pps->main.port_num : qp_attr->port_num; |
368 |
++ if (qp_attr_mask & IB_QP_PKEY_INDEX) |
369 |
++ new_pps->main.pkey_index = (qp_pps) ? qp_pps->main.pkey_index : |
370 |
++ qp_attr->pkey_index; |
371 |
++ if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & IB_QP_PORT)) |
372 |
+ new_pps->main.state = IB_PORT_PKEY_VALID; |
373 |
+- } else if (qp_pps) { |
374 |
++ |
375 |
++ if (!(qp_attr_mask & (IB_QP_PKEY_INDEX || IB_QP_PORT)) && qp_pps) { |
376 |
+ new_pps->main.port_num = qp_pps->main.port_num; |
377 |
+ new_pps->main.pkey_index = qp_pps->main.pkey_index; |
378 |
+ if (qp_pps->main.state != IB_PORT_PKEY_NOT_VALID) |
379 |
+diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c |
380 |
+index e012ca80f9d1..5e10a40fd26d 100644 |
381 |
+--- a/drivers/infiniband/core/uverbs_cmd.c |
382 |
++++ b/drivers/infiniband/core/uverbs_cmd.c |
383 |
+@@ -2914,12 +2914,6 @@ static int kern_spec_to_ib_spec_action(struct ib_uverbs_file *ufile, |
384 |
+ return 0; |
385 |
+ } |
386 |
+ |
387 |
+-static size_t kern_spec_filter_sz(const struct ib_uverbs_flow_spec_hdr *spec) |
388 |
+-{ |
389 |
+- /* Returns user space filter size, includes padding */ |
390 |
+- return (spec->size - sizeof(struct ib_uverbs_flow_spec_hdr)) / 2; |
391 |
+-} |
392 |
+- |
393 |
+ static ssize_t spec_filter_size(const void *kern_spec_filter, u16 kern_filter_size, |
394 |
+ u16 ib_real_filter_sz) |
395 |
+ { |
396 |
+@@ -3063,11 +3057,16 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type, |
397 |
+ static int kern_spec_to_ib_spec_filter(struct ib_uverbs_flow_spec *kern_spec, |
398 |
+ union ib_flow_spec *ib_spec) |
399 |
+ { |
400 |
+- ssize_t kern_filter_sz; |
401 |
++ size_t kern_filter_sz; |
402 |
+ void *kern_spec_mask; |
403 |
+ void *kern_spec_val; |
404 |
+ |
405 |
+- kern_filter_sz = kern_spec_filter_sz(&kern_spec->hdr); |
406 |
++ if (check_sub_overflow((size_t)kern_spec->hdr.size, |
407 |
++ sizeof(struct ib_uverbs_flow_spec_hdr), |
408 |
++ &kern_filter_sz)) |
409 |
++ return -EINVAL; |
410 |
++ |
411 |
++ kern_filter_sz /= 2; |
412 |
+ |
413 |
+ kern_spec_val = (void *)kern_spec + |
414 |
+ sizeof(struct ib_uverbs_flow_spec_hdr); |
415 |
+diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c |
416 |
+index bedd5fba33b0..01ed0a667928 100644 |
417 |
+--- a/drivers/infiniband/hw/hfi1/affinity.c |
418 |
++++ b/drivers/infiniband/hw/hfi1/affinity.c |
419 |
+@@ -478,6 +478,8 @@ static int _dev_comp_vect_mappings_create(struct hfi1_devdata *dd, |
420 |
+ rvt_get_ibdev_name(&(dd)->verbs_dev.rdi), i, cpu); |
421 |
+ } |
422 |
+ |
423 |
++ free_cpumask_var(available_cpus); |
424 |
++ free_cpumask_var(non_intr_cpus); |
425 |
+ return 0; |
426 |
+ |
427 |
+ fail: |
428 |
+diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c |
429 |
+index 34ffca618427..adeb259458de 100644 |
430 |
+--- a/drivers/infiniband/hw/hfi1/file_ops.c |
431 |
++++ b/drivers/infiniband/hw/hfi1/file_ops.c |
432 |
+@@ -200,23 +200,24 @@ static int hfi1_file_open(struct inode *inode, struct file *fp) |
433 |
+ |
434 |
+ fd = kzalloc(sizeof(*fd), GFP_KERNEL); |
435 |
+ |
436 |
+- if (fd) { |
437 |
+- fd->rec_cpu_num = -1; /* no cpu affinity by default */ |
438 |
+- fd->mm = current->mm; |
439 |
+- mmgrab(fd->mm); |
440 |
+- fd->dd = dd; |
441 |
+- kobject_get(&fd->dd->kobj); |
442 |
+- fp->private_data = fd; |
443 |
+- } else { |
444 |
+- fp->private_data = NULL; |
445 |
+- |
446 |
+- if (atomic_dec_and_test(&dd->user_refcount)) |
447 |
+- complete(&dd->user_comp); |
448 |
+- |
449 |
+- return -ENOMEM; |
450 |
+- } |
451 |
+- |
452 |
++ if (!fd || init_srcu_struct(&fd->pq_srcu)) |
453 |
++ goto nomem; |
454 |
++ spin_lock_init(&fd->pq_rcu_lock); |
455 |
++ spin_lock_init(&fd->tid_lock); |
456 |
++ spin_lock_init(&fd->invalid_lock); |
457 |
++ fd->rec_cpu_num = -1; /* no cpu affinity by default */ |
458 |
++ fd->mm = current->mm; |
459 |
++ mmgrab(fd->mm); |
460 |
++ fd->dd = dd; |
461 |
++ kobject_get(&fd->dd->kobj); |
462 |
++ fp->private_data = fd; |
463 |
+ return 0; |
464 |
++nomem: |
465 |
++ kfree(fd); |
466 |
++ fp->private_data = NULL; |
467 |
++ if (atomic_dec_and_test(&dd->user_refcount)) |
468 |
++ complete(&dd->user_comp); |
469 |
++ return -ENOMEM; |
470 |
+ } |
471 |
+ |
472 |
+ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, |
473 |
+@@ -301,21 +302,30 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, |
474 |
+ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) |
475 |
+ { |
476 |
+ struct hfi1_filedata *fd = kiocb->ki_filp->private_data; |
477 |
+- struct hfi1_user_sdma_pkt_q *pq = fd->pq; |
478 |
++ struct hfi1_user_sdma_pkt_q *pq; |
479 |
+ struct hfi1_user_sdma_comp_q *cq = fd->cq; |
480 |
+ int done = 0, reqs = 0; |
481 |
+ unsigned long dim = from->nr_segs; |
482 |
++ int idx; |
483 |
+ |
484 |
+- if (!cq || !pq) |
485 |
++ idx = srcu_read_lock(&fd->pq_srcu); |
486 |
++ pq = srcu_dereference(fd->pq, &fd->pq_srcu); |
487 |
++ if (!cq || !pq) { |
488 |
++ srcu_read_unlock(&fd->pq_srcu, idx); |
489 |
+ return -EIO; |
490 |
++ } |
491 |
+ |
492 |
+- if (!iter_is_iovec(from) || !dim) |
493 |
++ if (!iter_is_iovec(from) || !dim) { |
494 |
++ srcu_read_unlock(&fd->pq_srcu, idx); |
495 |
+ return -EINVAL; |
496 |
++ } |
497 |
+ |
498 |
+ trace_hfi1_sdma_request(fd->dd, fd->uctxt->ctxt, fd->subctxt, dim); |
499 |
+ |
500 |
+- if (atomic_read(&pq->n_reqs) == pq->n_max_reqs) |
501 |
++ if (atomic_read(&pq->n_reqs) == pq->n_max_reqs) { |
502 |
++ srcu_read_unlock(&fd->pq_srcu, idx); |
503 |
+ return -ENOSPC; |
504 |
++ } |
505 |
+ |
506 |
+ while (dim) { |
507 |
+ int ret; |
508 |
+@@ -333,6 +343,7 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) |
509 |
+ reqs++; |
510 |
+ } |
511 |
+ |
512 |
++ srcu_read_unlock(&fd->pq_srcu, idx); |
513 |
+ return reqs; |
514 |
+ } |
515 |
+ |
516 |
+@@ -706,6 +717,7 @@ done: |
517 |
+ if (atomic_dec_and_test(&dd->user_refcount)) |
518 |
+ complete(&dd->user_comp); |
519 |
+ |
520 |
++ cleanup_srcu_struct(&fdata->pq_srcu); |
521 |
+ kfree(fdata); |
522 |
+ return 0; |
523 |
+ } |
524 |
+diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h |
525 |
+index 232fc4b59a98..ab981874c71c 100644 |
526 |
+--- a/drivers/infiniband/hw/hfi1/hfi.h |
527 |
++++ b/drivers/infiniband/hw/hfi1/hfi.h |
528 |
+@@ -1376,10 +1376,13 @@ struct mmu_rb_handler; |
529 |
+ |
530 |
+ /* Private data for file operations */ |
531 |
+ struct hfi1_filedata { |
532 |
++ struct srcu_struct pq_srcu; |
533 |
+ struct hfi1_devdata *dd; |
534 |
+ struct hfi1_ctxtdata *uctxt; |
535 |
+ struct hfi1_user_sdma_comp_q *cq; |
536 |
+- struct hfi1_user_sdma_pkt_q *pq; |
537 |
++ /* update side lock for SRCU */ |
538 |
++ spinlock_t pq_rcu_lock; |
539 |
++ struct hfi1_user_sdma_pkt_q __rcu *pq; |
540 |
+ u16 subctxt; |
541 |
+ /* for cpu affinity; -1 if none */ |
542 |
+ int rec_cpu_num; |
543 |
+diff --git a/drivers/infiniband/hw/hfi1/user_exp_rcv.c b/drivers/infiniband/hw/hfi1/user_exp_rcv.c |
544 |
+index 4e986ca4dd35..4e417ed08b09 100644 |
545 |
+--- a/drivers/infiniband/hw/hfi1/user_exp_rcv.c |
546 |
++++ b/drivers/infiniband/hw/hfi1/user_exp_rcv.c |
547 |
+@@ -90,9 +90,6 @@ int hfi1_user_exp_rcv_init(struct hfi1_filedata *fd, |
548 |
+ struct hfi1_devdata *dd = uctxt->dd; |
549 |
+ int ret = 0; |
550 |
+ |
551 |
+- spin_lock_init(&fd->tid_lock); |
552 |
+- spin_lock_init(&fd->invalid_lock); |
553 |
+- |
554 |
+ fd->entry_to_rb = kcalloc(uctxt->expected_count, |
555 |
+ sizeof(struct rb_node *), |
556 |
+ GFP_KERNEL); |
557 |
+@@ -165,10 +162,12 @@ void hfi1_user_exp_rcv_free(struct hfi1_filedata *fd) |
558 |
+ if (fd->handler) { |
559 |
+ hfi1_mmu_rb_unregister(fd->handler); |
560 |
+ } else { |
561 |
++ mutex_lock(&uctxt->exp_mutex); |
562 |
+ if (!EXP_TID_SET_EMPTY(uctxt->tid_full_list)) |
563 |
+ unlock_exp_tids(uctxt, &uctxt->tid_full_list, fd); |
564 |
+ if (!EXP_TID_SET_EMPTY(uctxt->tid_used_list)) |
565 |
+ unlock_exp_tids(uctxt, &uctxt->tid_used_list, fd); |
566 |
++ mutex_unlock(&uctxt->exp_mutex); |
567 |
+ } |
568 |
+ |
569 |
+ kfree(fd->invalid_tids); |
570 |
+diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c |
571 |
+index 684a298e1503..a3b08a9ef5ff 100644 |
572 |
+--- a/drivers/infiniband/hw/hfi1/user_sdma.c |
573 |
++++ b/drivers/infiniband/hw/hfi1/user_sdma.c |
574 |
+@@ -179,7 +179,6 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, |
575 |
+ pq = kzalloc(sizeof(*pq), GFP_KERNEL); |
576 |
+ if (!pq) |
577 |
+ return -ENOMEM; |
578 |
+- |
579 |
+ pq->dd = dd; |
580 |
+ pq->ctxt = uctxt->ctxt; |
581 |
+ pq->subctxt = fd->subctxt; |
582 |
+@@ -236,7 +235,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, |
583 |
+ goto pq_mmu_fail; |
584 |
+ } |
585 |
+ |
586 |
+- fd->pq = pq; |
587 |
++ rcu_assign_pointer(fd->pq, pq); |
588 |
+ fd->cq = cq; |
589 |
+ |
590 |
+ return 0; |
591 |
+@@ -264,8 +263,14 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd, |
592 |
+ |
593 |
+ trace_hfi1_sdma_user_free_queues(uctxt->dd, uctxt->ctxt, fd->subctxt); |
594 |
+ |
595 |
+- pq = fd->pq; |
596 |
++ spin_lock(&fd->pq_rcu_lock); |
597 |
++ pq = srcu_dereference_check(fd->pq, &fd->pq_srcu, |
598 |
++ lockdep_is_held(&fd->pq_rcu_lock)); |
599 |
+ if (pq) { |
600 |
++ rcu_assign_pointer(fd->pq, NULL); |
601 |
++ spin_unlock(&fd->pq_rcu_lock); |
602 |
++ synchronize_srcu(&fd->pq_srcu); |
603 |
++ /* at this point there can be no more new requests */ |
604 |
+ if (pq->handler) |
605 |
+ hfi1_mmu_rb_unregister(pq->handler); |
606 |
+ iowait_sdma_drain(&pq->busy); |
607 |
+@@ -277,7 +282,8 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd, |
608 |
+ kfree(pq->req_in_use); |
609 |
+ kmem_cache_destroy(pq->txreq_cache); |
610 |
+ kfree(pq); |
611 |
+- fd->pq = NULL; |
612 |
++ } else { |
613 |
++ spin_unlock(&fd->pq_rcu_lock); |
614 |
+ } |
615 |
+ if (fd->cq) { |
616 |
+ vfree(fd->cq->comps); |
617 |
+@@ -321,7 +327,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd, |
618 |
+ { |
619 |
+ int ret = 0, i; |
620 |
+ struct hfi1_ctxtdata *uctxt = fd->uctxt; |
621 |
+- struct hfi1_user_sdma_pkt_q *pq = fd->pq; |
622 |
++ struct hfi1_user_sdma_pkt_q *pq = |
623 |
++ srcu_dereference(fd->pq, &fd->pq_srcu); |
624 |
+ struct hfi1_user_sdma_comp_q *cq = fd->cq; |
625 |
+ struct hfi1_devdata *dd = pq->dd; |
626 |
+ unsigned long idx = 0; |
627 |
+diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c |
628 |
+index 7d03680afd91..fbc316775669 100644 |
629 |
+--- a/drivers/infiniband/sw/rdmavt/qp.c |
630 |
++++ b/drivers/infiniband/sw/rdmavt/qp.c |
631 |
+@@ -58,6 +58,8 @@ |
632 |
+ #include "trace.h" |
633 |
+ |
634 |
+ static void rvt_rc_timeout(struct timer_list *t); |
635 |
++static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
636 |
++ enum ib_qp_type type); |
637 |
+ |
638 |
+ /* |
639 |
+ * Convert the AETH RNR timeout code into the number of microseconds. |
640 |
+@@ -268,40 +270,41 @@ no_qp_table: |
641 |
+ } |
642 |
+ |
643 |
+ /** |
644 |
+- * free_all_qps - check for QPs still in use |
645 |
++ * rvt_free_qp_cb - callback function to reset a qp |
646 |
++ * @qp: the qp to reset |
647 |
++ * @v: a 64-bit value |
648 |
++ * |
649 |
++ * This function resets the qp and removes it from the |
650 |
++ * qp hash table. |
651 |
++ */ |
652 |
++static void rvt_free_qp_cb(struct rvt_qp *qp, u64 v) |
653 |
++{ |
654 |
++ unsigned int *qp_inuse = (unsigned int *)v; |
655 |
++ struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); |
656 |
++ |
657 |
++ /* Reset the qp and remove it from the qp hash list */ |
658 |
++ rvt_reset_qp(rdi, qp, qp->ibqp.qp_type); |
659 |
++ |
660 |
++ /* Increment the qp_inuse count */ |
661 |
++ (*qp_inuse)++; |
662 |
++} |
663 |
++ |
664 |
++/** |
665 |
++ * rvt_free_all_qps - check for QPs still in use |
666 |
+ * @rdi: rvt device info structure |
667 |
+ * |
668 |
+ * There should not be any QPs still in use. |
669 |
+ * Free memory for table. |
670 |
++ * Return the number of QPs still in use. |
671 |
+ */ |
672 |
+ static unsigned rvt_free_all_qps(struct rvt_dev_info *rdi) |
673 |
+ { |
674 |
+- unsigned long flags; |
675 |
+- struct rvt_qp *qp; |
676 |
+- unsigned n, qp_inuse = 0; |
677 |
+- spinlock_t *ql; /* work around too long line below */ |
678 |
+- |
679 |
+- if (rdi->driver_f.free_all_qps) |
680 |
+- qp_inuse = rdi->driver_f.free_all_qps(rdi); |
681 |
++ unsigned int qp_inuse = 0; |
682 |
+ |
683 |
+ qp_inuse += rvt_mcast_tree_empty(rdi); |
684 |
+ |
685 |
+- if (!rdi->qp_dev) |
686 |
+- return qp_inuse; |
687 |
++ rvt_qp_iter(rdi, (u64)&qp_inuse, rvt_free_qp_cb); |
688 |
+ |
689 |
+- ql = &rdi->qp_dev->qpt_lock; |
690 |
+- spin_lock_irqsave(ql, flags); |
691 |
+- for (n = 0; n < rdi->qp_dev->qp_table_size; n++) { |
692 |
+- qp = rcu_dereference_protected(rdi->qp_dev->qp_table[n], |
693 |
+- lockdep_is_held(ql)); |
694 |
+- RCU_INIT_POINTER(rdi->qp_dev->qp_table[n], NULL); |
695 |
+- |
696 |
+- for (; qp; qp = rcu_dereference_protected(qp->next, |
697 |
+- lockdep_is_held(ql))) |
698 |
+- qp_inuse++; |
699 |
+- } |
700 |
+- spin_unlock_irqrestore(ql, flags); |
701 |
+- synchronize_rcu(); |
702 |
+ return qp_inuse; |
703 |
+ } |
704 |
+ |
705 |
+@@ -684,14 +687,14 @@ static void rvt_init_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
706 |
+ } |
707 |
+ |
708 |
+ /** |
709 |
+- * rvt_reset_qp - initialize the QP state to the reset state |
710 |
++ * _rvt_reset_qp - initialize the QP state to the reset state |
711 |
+ * @qp: the QP to reset |
712 |
+ * @type: the QP type |
713 |
+ * |
714 |
+ * r_lock, s_hlock, and s_lock are required to be held by the caller |
715 |
+ */ |
716 |
+-static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
717 |
+- enum ib_qp_type type) |
718 |
++static void _rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
719 |
++ enum ib_qp_type type) |
720 |
+ __must_hold(&qp->s_lock) |
721 |
+ __must_hold(&qp->s_hlock) |
722 |
+ __must_hold(&qp->r_lock) |
723 |
+@@ -737,6 +740,27 @@ static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
724 |
+ lockdep_assert_held(&qp->s_lock); |
725 |
+ } |
726 |
+ |
727 |
++/** |
728 |
++ * rvt_reset_qp - initialize the QP state to the reset state |
729 |
++ * @rdi: the device info |
730 |
++ * @qp: the QP to reset |
731 |
++ * @type: the QP type |
732 |
++ * |
733 |
++ * This is the wrapper function to acquire the r_lock, s_hlock, and s_lock |
734 |
++ * before calling _rvt_reset_qp(). |
735 |
++ */ |
736 |
++static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, |
737 |
++ enum ib_qp_type type) |
738 |
++{ |
739 |
++ spin_lock_irq(&qp->r_lock); |
740 |
++ spin_lock(&qp->s_hlock); |
741 |
++ spin_lock(&qp->s_lock); |
742 |
++ _rvt_reset_qp(rdi, qp, type); |
743 |
++ spin_unlock(&qp->s_lock); |
744 |
++ spin_unlock(&qp->s_hlock); |
745 |
++ spin_unlock_irq(&qp->r_lock); |
746 |
++} |
747 |
++ |
748 |
+ /** rvt_free_qpn - Free a qpn from the bit map |
749 |
+ * @qpt: QP table |
750 |
+ * @qpn: queue pair number to free |
751 |
+@@ -1285,7 +1309,7 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
752 |
+ switch (new_state) { |
753 |
+ case IB_QPS_RESET: |
754 |
+ if (qp->state != IB_QPS_RESET) |
755 |
+- rvt_reset_qp(rdi, qp, ibqp->qp_type); |
756 |
++ _rvt_reset_qp(rdi, qp, ibqp->qp_type); |
757 |
+ break; |
758 |
+ |
759 |
+ case IB_QPS_RTR: |
760 |
+@@ -1434,13 +1458,7 @@ int rvt_destroy_qp(struct ib_qp *ibqp) |
761 |
+ struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); |
762 |
+ struct rvt_dev_info *rdi = ib_to_rvt(ibqp->device); |
763 |
+ |
764 |
+- spin_lock_irq(&qp->r_lock); |
765 |
+- spin_lock(&qp->s_hlock); |
766 |
+- spin_lock(&qp->s_lock); |
767 |
+ rvt_reset_qp(rdi, qp, ibqp->qp_type); |
768 |
+- spin_unlock(&qp->s_lock); |
769 |
+- spin_unlock(&qp->s_hlock); |
770 |
+- spin_unlock_irq(&qp->r_lock); |
771 |
+ |
772 |
+ wait_event(qp->wait, !atomic_read(&qp->refcount)); |
773 |
+ /* qpn is now available for use again */ |
774 |
+diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c |
775 |
+index ea089cb091ad..dc06e9844378 100644 |
776 |
+--- a/drivers/infiniband/sw/rxe/rxe_comp.c |
777 |
++++ b/drivers/infiniband/sw/rxe/rxe_comp.c |
778 |
+@@ -329,7 +329,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp, |
779 |
+ qp->comp.psn = pkt->psn; |
780 |
+ if (qp->req.wait_psn) { |
781 |
+ qp->req.wait_psn = 0; |
782 |
+- rxe_run_task(&qp->req.task, 1); |
783 |
++ rxe_run_task(&qp->req.task, 0); |
784 |
+ } |
785 |
+ } |
786 |
+ return COMPST_ERROR_RETRY; |
787 |
+@@ -457,7 +457,7 @@ static void do_complete(struct rxe_qp *qp, struct rxe_send_wqe *wqe) |
788 |
+ */ |
789 |
+ if (qp->req.wait_fence) { |
790 |
+ qp->req.wait_fence = 0; |
791 |
+- rxe_run_task(&qp->req.task, 1); |
792 |
++ rxe_run_task(&qp->req.task, 0); |
793 |
+ } |
794 |
+ } |
795 |
+ |
796 |
+@@ -473,7 +473,7 @@ static inline enum comp_state complete_ack(struct rxe_qp *qp, |
797 |
+ if (qp->req.need_rd_atomic) { |
798 |
+ qp->comp.timeout_retry = 0; |
799 |
+ qp->req.need_rd_atomic = 0; |
800 |
+- rxe_run_task(&qp->req.task, 1); |
801 |
++ rxe_run_task(&qp->req.task, 0); |
802 |
+ } |
803 |
+ } |
804 |
+ |
805 |
+@@ -719,7 +719,7 @@ int rxe_completer(void *arg) |
806 |
+ RXE_CNT_COMP_RETRY); |
807 |
+ qp->req.need_retry = 1; |
808 |
+ qp->comp.started_retry = 1; |
809 |
+- rxe_run_task(&qp->req.task, 1); |
810 |
++ rxe_run_task(&qp->req.task, 0); |
811 |
+ } |
812 |
+ |
813 |
+ if (pkt) { |
814 |
+diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c |
815 |
+index e8d1134943c4..f47e3fca403d 100644 |
816 |
+--- a/drivers/input/mouse/synaptics.c |
817 |
++++ b/drivers/input/mouse/synaptics.c |
818 |
+@@ -149,7 +149,6 @@ static const char * const topbuttonpad_pnp_ids[] = { |
819 |
+ "LEN0042", /* Yoga */ |
820 |
+ "LEN0045", |
821 |
+ "LEN0047", |
822 |
+- "LEN0049", |
823 |
+ "LEN2000", /* S540 */ |
824 |
+ "LEN2001", /* Edge E431 */ |
825 |
+ "LEN2002", /* Edge E531 */ |
826 |
+@@ -169,9 +168,11 @@ static const char * const smbus_pnp_ids[] = { |
827 |
+ /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ |
828 |
+ "LEN0048", /* X1 Carbon 3 */ |
829 |
+ "LEN0046", /* X250 */ |
830 |
++ "LEN0049", /* Yoga 11e */ |
831 |
+ "LEN004a", /* W541 */ |
832 |
+ "LEN005b", /* P50 */ |
833 |
+ "LEN005e", /* T560 */ |
834 |
++ "LEN006c", /* T470s */ |
835 |
+ "LEN0071", /* T480 */ |
836 |
+ "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ |
837 |
+ "LEN0073", /* X1 Carbon G5 (Elantech) */ |
838 |
+@@ -182,6 +183,7 @@ static const char * const smbus_pnp_ids[] = { |
839 |
+ "LEN0097", /* X280 -> ALPS trackpoint */ |
840 |
+ "LEN009b", /* T580 */ |
841 |
+ "LEN200f", /* T450s */ |
842 |
++ "LEN2044", /* L470 */ |
843 |
+ "LEN2054", /* E480 */ |
844 |
+ "LEN2055", /* E580 */ |
845 |
+ "SYN3052", /* HP EliteBook 840 G4 */ |
846 |
+diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c |
847 |
+index b7bd89b3b2f9..f41fd15b7b7c 100644 |
848 |
+--- a/drivers/nvme/host/core.c |
849 |
++++ b/drivers/nvme/host/core.c |
850 |
+@@ -3449,7 +3449,7 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) |
851 |
+ if (!log) |
852 |
+ return; |
853 |
+ |
854 |
+- if (nvme_get_log(ctrl, NVME_NSID_ALL, 0, NVME_LOG_FW_SLOT, log, |
855 |
++ if (nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_FW_SLOT, 0, log, |
856 |
+ sizeof(*log), 0)) |
857 |
+ dev_warn(ctrl->device, "Get FW SLOT INFO log error\n"); |
858 |
+ kfree(log); |
859 |
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c |
860 |
+index 9e467e8a8cb5..ea45112a98be 100644 |
861 |
+--- a/fs/btrfs/disk-io.c |
862 |
++++ b/fs/btrfs/disk-io.c |
863 |
+@@ -3117,6 +3117,7 @@ retry_root_backup: |
864 |
+ /* do not make disk changes in broken FS or nologreplay is given */ |
865 |
+ if (btrfs_super_log_root(disk_super) != 0 && |
866 |
+ !btrfs_test_opt(fs_info, NOLOGREPLAY)) { |
867 |
++ btrfs_info(fs_info, "start tree-log replay"); |
868 |
+ ret = btrfs_replay_log(fs_info, fs_devices); |
869 |
+ if (ret) { |
870 |
+ err = ret; |
871 |
+diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c |
872 |
+index 6648d55e5339..813425df16f7 100644 |
873 |
+--- a/fs/btrfs/extent_map.c |
874 |
++++ b/fs/btrfs/extent_map.c |
875 |
+@@ -228,6 +228,17 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em) |
876 |
+ struct extent_map *merge = NULL; |
877 |
+ struct rb_node *rb; |
878 |
+ |
879 |
++ /* |
880 |
++ * We can't modify an extent map that is in the tree and that is being |
881 |
++ * used by another task, as it can cause that other task to see it in |
882 |
++ * inconsistent state during the merging. We always have 1 reference for |
883 |
++ * the tree and 1 for this task (which is unpinning the extent map or |
884 |
++ * clearing the logging flag), so anything > 2 means it's being used by |
885 |
++ * other tasks too. |
886 |
++ */ |
887 |
++ if (refcount_read(&em->refs) > 2) |
888 |
++ return; |
889 |
++ |
890 |
+ if (em->start != 0) { |
891 |
+ rb = rb_prev(&em->rb_node); |
892 |
+ if (rb) |
893 |
+diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c |
894 |
+index cd2a5864e103..dbc685ca017f 100644 |
895 |
+--- a/fs/btrfs/ref-verify.c |
896 |
++++ b/fs/btrfs/ref-verify.c |
897 |
+@@ -747,6 +747,7 @@ int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes, |
898 |
+ */ |
899 |
+ be = add_block_entry(root->fs_info, bytenr, num_bytes, ref_root); |
900 |
+ if (IS_ERR(be)) { |
901 |
++ kfree(ref); |
902 |
+ kfree(ra); |
903 |
+ ret = PTR_ERR(be); |
904 |
+ goto out; |
905 |
+@@ -760,6 +761,8 @@ int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes, |
906 |
+ "re-allocated a block that still has references to it!"); |
907 |
+ dump_block_entry(fs_info, be); |
908 |
+ dump_ref_action(fs_info, ra); |
909 |
++ kfree(ref); |
910 |
++ kfree(ra); |
911 |
+ goto out_unlock; |
912 |
+ } |
913 |
+ |
914 |
+@@ -822,6 +825,7 @@ int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes, |
915 |
+ "dropping a ref for a existing root that doesn't have a ref on the block"); |
916 |
+ dump_block_entry(fs_info, be); |
917 |
+ dump_ref_action(fs_info, ra); |
918 |
++ kfree(ref); |
919 |
+ kfree(ra); |
920 |
+ goto out_unlock; |
921 |
+ } |
922 |
+@@ -837,6 +841,7 @@ int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes, |
923 |
+ "attempting to add another ref for an existing ref on a tree block"); |
924 |
+ dump_block_entry(fs_info, be); |
925 |
+ dump_ref_action(fs_info, ra); |
926 |
++ kfree(ref); |
927 |
+ kfree(ra); |
928 |
+ goto out_unlock; |
929 |
+ } |
930 |
+diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c |
931 |
+index db4002ecbaca..6a5b16a119ed 100644 |
932 |
+--- a/fs/btrfs/super.c |
933 |
++++ b/fs/btrfs/super.c |
934 |
+@@ -1857,6 +1857,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) |
935 |
+ } |
936 |
+ |
937 |
+ if (btrfs_super_log_root(fs_info->super_copy) != 0) { |
938 |
++ btrfs_warn(fs_info, |
939 |
++ "mount required to replay tree-log, cannot remount read-write"); |
940 |
+ ret = -EINVAL; |
941 |
+ goto restore; |
942 |
+ } |
943 |
+diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c |
944 |
+index 7edc8172c53a..d203cc935ff8 100644 |
945 |
+--- a/fs/ext4/block_validity.c |
946 |
++++ b/fs/ext4/block_validity.c |
947 |
+@@ -203,6 +203,7 @@ static int ext4_protect_reserved_inode(struct super_block *sb, |
948 |
+ return PTR_ERR(inode); |
949 |
+ num = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; |
950 |
+ while (i < num) { |
951 |
++ cond_resched(); |
952 |
+ map.m_lblk = i; |
953 |
+ map.m_len = num - i; |
954 |
+ n = ext4_map_blocks(NULL, inode, &map, 0); |
955 |
+diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c |
956 |
+index d947c5e439cf..ae520a726339 100644 |
957 |
+--- a/fs/ext4/dir.c |
958 |
++++ b/fs/ext4/dir.c |
959 |
+@@ -126,12 +126,14 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) |
960 |
+ if (err != ERR_BAD_DX_DIR) { |
961 |
+ return err; |
962 |
+ } |
963 |
+- /* |
964 |
+- * We don't set the inode dirty flag since it's not |
965 |
+- * critical that it get flushed back to the disk. |
966 |
+- */ |
967 |
+- ext4_clear_inode_flag(file_inode(file), |
968 |
+- EXT4_INODE_INDEX); |
969 |
++ /* Can we just clear INDEX flag to ignore htree information? */ |
970 |
++ if (!ext4_has_metadata_csum(sb)) { |
971 |
++ /* |
972 |
++ * We don't set the inode dirty flag since it's not |
973 |
++ * critical that it gets flushed back to the disk. |
974 |
++ */ |
975 |
++ ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); |
976 |
++ } |
977 |
+ } |
978 |
+ |
979 |
+ if (ext4_has_inline_data(inode)) { |
980 |
+diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h |
981 |
+index f8456a423c4e..5c0e06645b1e 100644 |
982 |
+--- a/fs/ext4/ext4.h |
983 |
++++ b/fs/ext4/ext4.h |
984 |
+@@ -2375,8 +2375,11 @@ void ext4_insert_dentry(struct inode *inode, |
985 |
+ struct ext4_filename *fname); |
986 |
+ static inline void ext4_update_dx_flag(struct inode *inode) |
987 |
+ { |
988 |
+- if (!ext4_has_feature_dir_index(inode->i_sb)) |
989 |
++ if (!ext4_has_feature_dir_index(inode->i_sb)) { |
990 |
++ /* ext4_iget() should have caught this... */ |
991 |
++ WARN_ON_ONCE(ext4_has_feature_metadata_csum(inode->i_sb)); |
992 |
+ ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); |
993 |
++ } |
994 |
+ } |
995 |
+ static const unsigned char ext4_filetype_table[] = { |
996 |
+ DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK |
997 |
+diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c |
998 |
+index 950e3dcff7b0..8e535bb34d5f 100644 |
999 |
+--- a/fs/ext4/inode.c |
1000 |
++++ b/fs/ext4/inode.c |
1001 |
+@@ -4975,6 +4975,18 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, |
1002 |
+ ret = -EFSCORRUPTED; |
1003 |
+ goto bad_inode; |
1004 |
+ } |
1005 |
++ /* |
1006 |
++ * If dir_index is not enabled but there's dir with INDEX flag set, |
1007 |
++ * we'd normally treat htree data as empty space. But with metadata |
1008 |
++ * checksumming that corrupts checksums so forbid that. |
1009 |
++ */ |
1010 |
++ if (!ext4_has_feature_dir_index(sb) && ext4_has_metadata_csum(sb) && |
1011 |
++ ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) { |
1012 |
++ ext4_error_inode(inode, function, line, 0, |
1013 |
++ "iget: Dir with htree data on filesystem without dir_index feature."); |
1014 |
++ ret = -EFSCORRUPTED; |
1015 |
++ goto bad_inode; |
1016 |
++ } |
1017 |
+ ei->i_disksize = inode->i_size; |
1018 |
+ #ifdef CONFIG_QUOTA |
1019 |
+ ei->i_reserved_quota = 0; |
1020 |
+diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c |
1021 |
+index 2305b4374fd3..9d00e0dd2ba9 100644 |
1022 |
+--- a/fs/ext4/mmp.c |
1023 |
++++ b/fs/ext4/mmp.c |
1024 |
+@@ -120,10 +120,10 @@ void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp, |
1025 |
+ { |
1026 |
+ __ext4_warning(sb, function, line, "%s", msg); |
1027 |
+ __ext4_warning(sb, function, line, |
1028 |
+- "MMP failure info: last update time: %llu, last update " |
1029 |
+- "node: %s, last update device: %s", |
1030 |
+- (long long unsigned int) le64_to_cpu(mmp->mmp_time), |
1031 |
+- mmp->mmp_nodename, mmp->mmp_bdevname); |
1032 |
++ "MMP failure info: last update time: %llu, last update node: %.*s, last update device: %.*s", |
1033 |
++ (unsigned long long)le64_to_cpu(mmp->mmp_time), |
1034 |
++ (int)sizeof(mmp->mmp_nodename), mmp->mmp_nodename, |
1035 |
++ (int)sizeof(mmp->mmp_bdevname), mmp->mmp_bdevname); |
1036 |
+ } |
1037 |
+ |
1038 |
+ /* |
1039 |
+@@ -154,6 +154,7 @@ static int kmmpd(void *data) |
1040 |
+ mmp_check_interval = max(EXT4_MMP_CHECK_MULT * mmp_update_interval, |
1041 |
+ EXT4_MMP_MIN_CHECK_INTERVAL); |
1042 |
+ mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); |
1043 |
++ BUILD_BUG_ON(sizeof(mmp->mmp_bdevname) < BDEVNAME_SIZE); |
1044 |
+ bdevname(bh->b_bdev, mmp->mmp_bdevname); |
1045 |
+ |
1046 |
+ memcpy(mmp->mmp_nodename, init_utsname()->nodename, |
1047 |
+@@ -375,7 +376,8 @@ skip: |
1048 |
+ /* |
1049 |
+ * Start a kernel thread to update the MMP block periodically. |
1050 |
+ */ |
1051 |
+- EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, mmpd_data, "kmmpd-%s", |
1052 |
++ EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, mmpd_data, "kmmpd-%.*s", |
1053 |
++ (int)sizeof(mmp->mmp_bdevname), |
1054 |
+ bdevname(bh->b_bdev, |
1055 |
+ mmp->mmp_bdevname)); |
1056 |
+ if (IS_ERR(EXT4_SB(sb)->s_mmp_tsk)) { |
1057 |
+diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c |
1058 |
+index 43dcb91d63f4..4608d0d3b7f9 100644 |
1059 |
+--- a/fs/ext4/namei.c |
1060 |
++++ b/fs/ext4/namei.c |
1061 |
+@@ -2085,6 +2085,13 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, |
1062 |
+ retval = ext4_dx_add_entry(handle, &fname, dir, inode); |
1063 |
+ if (!retval || (retval != ERR_BAD_DX_DIR)) |
1064 |
+ goto out; |
1065 |
++ /* Can we just ignore htree data? */ |
1066 |
++ if (ext4_has_metadata_csum(sb)) { |
1067 |
++ EXT4_ERROR_INODE(dir, |
1068 |
++ "Directory has corrupted htree index."); |
1069 |
++ retval = -EFSCORRUPTED; |
1070 |
++ goto out; |
1071 |
++ } |
1072 |
+ ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); |
1073 |
+ dx_fallback++; |
1074 |
+ ext4_mark_inode_dirty(handle, dir); |
1075 |
+diff --git a/fs/ext4/super.c b/fs/ext4/super.c |
1076 |
+index 32d8bdf683bb..e080e90178a0 100644 |
1077 |
+--- a/fs/ext4/super.c |
1078 |
++++ b/fs/ext4/super.c |
1079 |
+@@ -2923,17 +2923,11 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly) |
1080 |
+ return 0; |
1081 |
+ } |
1082 |
+ |
1083 |
+-#ifndef CONFIG_QUOTA |
1084 |
+- if (ext4_has_feature_quota(sb) && !readonly) { |
1085 |
++#if !defined(CONFIG_QUOTA) || !defined(CONFIG_QFMT_V2) |
1086 |
++ if (!readonly && (ext4_has_feature_quota(sb) || |
1087 |
++ ext4_has_feature_project(sb))) { |
1088 |
+ ext4_msg(sb, KERN_ERR, |
1089 |
+- "Filesystem with quota feature cannot be mounted RDWR " |
1090 |
+- "without CONFIG_QUOTA"); |
1091 |
+- return 0; |
1092 |
+- } |
1093 |
+- if (ext4_has_feature_project(sb) && !readonly) { |
1094 |
+- ext4_msg(sb, KERN_ERR, |
1095 |
+- "Filesystem with project quota feature cannot be mounted RDWR " |
1096 |
+- "without CONFIG_QUOTA"); |
1097 |
++ "The kernel was not built with CONFIG_QUOTA and CONFIG_QFMT_V2"); |
1098 |
+ return 0; |
1099 |
+ } |
1100 |
+ #endif /* CONFIG_QUOTA */ |
1101 |
+@@ -3727,6 +3721,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
1102 |
+ */ |
1103 |
+ sbi->s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT; |
1104 |
+ |
1105 |
++ blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); |
1106 |
++ if (blocksize < EXT4_MIN_BLOCK_SIZE || |
1107 |
++ blocksize > EXT4_MAX_BLOCK_SIZE) { |
1108 |
++ ext4_msg(sb, KERN_ERR, |
1109 |
++ "Unsupported filesystem blocksize %d (%d log_block_size)", |
1110 |
++ blocksize, le32_to_cpu(es->s_log_block_size)); |
1111 |
++ goto failed_mount; |
1112 |
++ } |
1113 |
++ |
1114 |
+ if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { |
1115 |
+ sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; |
1116 |
+ sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO; |
1117 |
+@@ -3744,6 +3747,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
1118 |
+ ext4_msg(sb, KERN_ERR, |
1119 |
+ "unsupported inode size: %d", |
1120 |
+ sbi->s_inode_size); |
1121 |
++ ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize); |
1122 |
+ goto failed_mount; |
1123 |
+ } |
1124 |
+ /* |
1125 |
+@@ -3907,14 +3911,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
1126 |
+ if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) |
1127 |
+ goto failed_mount; |
1128 |
+ |
1129 |
+- blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); |
1130 |
+- if (blocksize < EXT4_MIN_BLOCK_SIZE || |
1131 |
+- blocksize > EXT4_MAX_BLOCK_SIZE) { |
1132 |
+- ext4_msg(sb, KERN_ERR, |
1133 |
+- "Unsupported filesystem blocksize %d (%d log_block_size)", |
1134 |
+- blocksize, le32_to_cpu(es->s_log_block_size)); |
1135 |
+- goto failed_mount; |
1136 |
+- } |
1137 |
+ if (le32_to_cpu(es->s_log_block_size) > |
1138 |
+ (EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE)) { |
1139 |
+ ext4_msg(sb, KERN_ERR, |
1140 |
+diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c |
1141 |
+index 020bd7a0d8e0..c321fa06081c 100644 |
1142 |
+--- a/fs/jbd2/commit.c |
1143 |
++++ b/fs/jbd2/commit.c |
1144 |
+@@ -971,29 +971,33 @@ restart_loop: |
1145 |
+ * it. */ |
1146 |
+ |
1147 |
+ /* |
1148 |
+- * A buffer which has been freed while still being journaled by |
1149 |
+- * a previous transaction. |
1150 |
+- */ |
1151 |
+- if (buffer_freed(bh)) { |
1152 |
++ * A buffer which has been freed while still being journaled |
1153 |
++ * by a previous transaction, refile the buffer to BJ_Forget of |
1154 |
++ * the running transaction. If the just committed transaction |
1155 |
++ * contains "add to orphan" operation, we can completely |
1156 |
++ * invalidate the buffer now. We are rather through in that |
1157 |
++ * since the buffer may be still accessible when blocksize < |
1158 |
++ * pagesize and it is attached to the last partial page. |
1159 |
++ */ |
1160 |
++ if (buffer_freed(bh) && !jh->b_next_transaction) { |
1161 |
++ struct address_space *mapping; |
1162 |
++ |
1163 |
++ clear_buffer_freed(bh); |
1164 |
++ clear_buffer_jbddirty(bh); |
1165 |
++ |
1166 |
+ /* |
1167 |
+- * If the running transaction is the one containing |
1168 |
+- * "add to orphan" operation (b_next_transaction != |
1169 |
+- * NULL), we have to wait for that transaction to |
1170 |
+- * commit before we can really get rid of the buffer. |
1171 |
+- * So just clear b_modified to not confuse transaction |
1172 |
+- * credit accounting and refile the buffer to |
1173 |
+- * BJ_Forget of the running transaction. If the just |
1174 |
+- * committed transaction contains "add to orphan" |
1175 |
+- * operation, we can completely invalidate the buffer |
1176 |
+- * now. We are rather through in that since the |
1177 |
+- * buffer may be still accessible when blocksize < |
1178 |
+- * pagesize and it is attached to the last partial |
1179 |
+- * page. |
1180 |
++ * Block device buffers need to stay mapped all the |
1181 |
++ * time, so it is enough to clear buffer_jbddirty and |
1182 |
++ * buffer_freed bits. For the file mapping buffers (i.e. |
1183 |
++ * journalled data) we need to unmap buffer and clear |
1184 |
++ * more bits. We also need to be careful about the check |
1185 |
++ * because the data page mapping can get cleared under |
1186 |
++ * out hands, which alse need not to clear more bits |
1187 |
++ * because the page and buffers will be freed and can |
1188 |
++ * never be reused once we are done with them. |
1189 |
+ */ |
1190 |
+- jh->b_modified = 0; |
1191 |
+- if (!jh->b_next_transaction) { |
1192 |
+- clear_buffer_freed(bh); |
1193 |
+- clear_buffer_jbddirty(bh); |
1194 |
++ mapping = READ_ONCE(bh->b_page->mapping); |
1195 |
++ if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) { |
1196 |
+ clear_buffer_mapped(bh); |
1197 |
+ clear_buffer_new(bh); |
1198 |
+ clear_buffer_req(bh); |
1199 |
+diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c |
1200 |
+index 911ff18249b7..97ffe12a2262 100644 |
1201 |
+--- a/fs/jbd2/transaction.c |
1202 |
++++ b/fs/jbd2/transaction.c |
1203 |
+@@ -2228,14 +2228,16 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, |
1204 |
+ return -EBUSY; |
1205 |
+ } |
1206 |
+ /* |
1207 |
+- * OK, buffer won't be reachable after truncate. We just set |
1208 |
+- * j_next_transaction to the running transaction (if there is |
1209 |
+- * one) and mark buffer as freed so that commit code knows it |
1210 |
+- * should clear dirty bits when it is done with the buffer. |
1211 |
++ * OK, buffer won't be reachable after truncate. We just clear |
1212 |
++ * b_modified to not confuse transaction credit accounting, and |
1213 |
++ * set j_next_transaction to the running transaction (if there |
1214 |
++ * is one) and mark buffer as freed so that commit code knows |
1215 |
++ * it should clear dirty bits when it is done with the buffer. |
1216 |
+ */ |
1217 |
+ set_buffer_freed(bh); |
1218 |
+ if (journal->j_running_transaction && buffer_jbddirty(bh)) |
1219 |
+ jh->b_next_transaction = journal->j_running_transaction; |
1220 |
++ jh->b_modified = 0; |
1221 |
+ jbd2_journal_put_journal_head(jh); |
1222 |
+ spin_unlock(&journal->j_list_lock); |
1223 |
+ jbd_unlock_bh_state(bh); |
1224 |
+diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c |
1225 |
+index fad795041d32..668b648064b7 100644 |
1226 |
+--- a/fs/nfs/nfs4proc.c |
1227 |
++++ b/fs/nfs/nfs4proc.c |
1228 |
+@@ -5117,7 +5117,7 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr, |
1229 |
+ hdr->timestamp = jiffies; |
1230 |
+ |
1231 |
+ msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; |
1232 |
+- nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 1, 0); |
1233 |
++ nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); |
1234 |
+ nfs4_state_protect_write(server->nfs_client, clnt, msg, hdr); |
1235 |
+ } |
1236 |
+ |
1237 |
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
1238 |
+index ae735bcb9a2c..a8a47e1596dd 100644 |
1239 |
+--- a/sound/pci/hda/patch_realtek.c |
1240 |
++++ b/sound/pci/hda/patch_realtek.c |
1241 |
+@@ -2442,6 +2442,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
1242 |
+ SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
1243 |
+ SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), |
1244 |
+ SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), |
1245 |
++ SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950), |
1246 |
+ SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
1247 |
+ SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), |
1248 |
+ SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
1249 |
+diff --git a/sound/usb/clock.c b/sound/usb/clock.c |
1250 |
+index e31349865f20..bfe5540030b8 100644 |
1251 |
+--- a/sound/usb/clock.c |
1252 |
++++ b/sound/usb/clock.c |
1253 |
+@@ -165,8 +165,34 @@ static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_i |
1254 |
+ return ret; |
1255 |
+ } |
1256 |
+ |
1257 |
++/* |
1258 |
++ * Assume the clock is valid if clock source supports only one single sample |
1259 |
++ * rate, the terminal is connected directly to it (there is no clock selector) |
1260 |
++ * and clock type is internal. This is to deal with some Denon DJ controllers |
1261 |
++ * that always reports that clock is invalid. |
1262 |
++ */ |
1263 |
++static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip, |
1264 |
++ struct audioformat *fmt, |
1265 |
++ int source_id) |
1266 |
++{ |
1267 |
++ if (fmt->protocol == UAC_VERSION_2) { |
1268 |
++ struct uac_clock_source_descriptor *cs_desc = |
1269 |
++ snd_usb_find_clock_source(chip->ctrl_intf, source_id); |
1270 |
++ |
1271 |
++ if (!cs_desc) |
1272 |
++ return false; |
1273 |
++ |
1274 |
++ return (fmt->nr_rates == 1 && |
1275 |
++ (fmt->clock & 0xff) == cs_desc->bClockID && |
1276 |
++ (cs_desc->bmAttributes & 0x3) != |
1277 |
++ UAC_CLOCK_SOURCE_TYPE_EXT); |
1278 |
++ } |
1279 |
++ |
1280 |
++ return false; |
1281 |
++} |
1282 |
++ |
1283 |
+ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, |
1284 |
+- int protocol, |
1285 |
++ struct audioformat *fmt, |
1286 |
+ int source_id) |
1287 |
+ { |
1288 |
+ int err; |
1289 |
+@@ -174,26 +200,26 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, |
1290 |
+ struct usb_device *dev = chip->dev; |
1291 |
+ u32 bmControls; |
1292 |
+ |
1293 |
+- if (protocol == UAC_VERSION_3) { |
1294 |
++ if (fmt->protocol == UAC_VERSION_3) { |
1295 |
+ struct uac3_clock_source_descriptor *cs_desc = |
1296 |
+ snd_usb_find_clock_source_v3(chip->ctrl_intf, source_id); |
1297 |
+ |
1298 |
+ if (!cs_desc) |
1299 |
+- return 0; |
1300 |
++ return false; |
1301 |
+ bmControls = le32_to_cpu(cs_desc->bmControls); |
1302 |
+ } else { /* UAC_VERSION_1/2 */ |
1303 |
+ struct uac_clock_source_descriptor *cs_desc = |
1304 |
+ snd_usb_find_clock_source(chip->ctrl_intf, source_id); |
1305 |
+ |
1306 |
+ if (!cs_desc) |
1307 |
+- return 0; |
1308 |
++ return false; |
1309 |
+ bmControls = cs_desc->bmControls; |
1310 |
+ } |
1311 |
+ |
1312 |
+ /* If a clock source can't tell us whether it's valid, we assume it is */ |
1313 |
+ if (!uac_v2v3_control_is_readable(bmControls, |
1314 |
+ UAC2_CS_CONTROL_CLOCK_VALID)) |
1315 |
+- return 1; |
1316 |
++ return true; |
1317 |
+ |
1318 |
+ err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, |
1319 |
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, |
1320 |
+@@ -205,13 +231,17 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, |
1321 |
+ dev_warn(&dev->dev, |
1322 |
+ "%s(): cannot get clock validity for id %d\n", |
1323 |
+ __func__, source_id); |
1324 |
+- return 0; |
1325 |
++ return false; |
1326 |
+ } |
1327 |
+ |
1328 |
+- return !!data; |
1329 |
++ if (data) |
1330 |
++ return true; |
1331 |
++ else |
1332 |
++ return uac_clock_source_is_valid_quirk(chip, fmt, source_id); |
1333 |
+ } |
1334 |
+ |
1335 |
+-static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1336 |
++static int __uac_clock_find_source(struct snd_usb_audio *chip, |
1337 |
++ struct audioformat *fmt, int entity_id, |
1338 |
+ unsigned long *visited, bool validate) |
1339 |
+ { |
1340 |
+ struct uac_clock_source_descriptor *source; |
1341 |
+@@ -231,7 +261,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1342 |
+ source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); |
1343 |
+ if (source) { |
1344 |
+ entity_id = source->bClockID; |
1345 |
+- if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_2, |
1346 |
++ if (validate && !uac_clock_source_is_valid(chip, fmt, |
1347 |
+ entity_id)) { |
1348 |
+ usb_audio_err(chip, |
1349 |
+ "clock source %d is not valid, cannot use\n", |
1350 |
+@@ -262,8 +292,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1351 |
+ } |
1352 |
+ |
1353 |
+ cur = ret; |
1354 |
+- ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1], |
1355 |
+- visited, validate); |
1356 |
++ ret = __uac_clock_find_source(chip, fmt, |
1357 |
++ selector->baCSourceID[ret - 1], |
1358 |
++ visited, validate); |
1359 |
+ if (!validate || ret > 0 || !chip->autoclock) |
1360 |
+ return ret; |
1361 |
+ |
1362 |
+@@ -274,8 +305,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1363 |
+ if (i == cur) |
1364 |
+ continue; |
1365 |
+ |
1366 |
+- ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1], |
1367 |
+- visited, true); |
1368 |
++ ret = __uac_clock_find_source(chip, fmt, |
1369 |
++ selector->baCSourceID[i - 1], |
1370 |
++ visited, true); |
1371 |
+ if (ret < 0) |
1372 |
+ continue; |
1373 |
+ |
1374 |
+@@ -295,14 +327,16 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1375 |
+ /* FIXME: multipliers only act as pass-thru element for now */ |
1376 |
+ multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); |
1377 |
+ if (multiplier) |
1378 |
+- return __uac_clock_find_source(chip, multiplier->bCSourceID, |
1379 |
+- visited, validate); |
1380 |
++ return __uac_clock_find_source(chip, fmt, |
1381 |
++ multiplier->bCSourceID, |
1382 |
++ visited, validate); |
1383 |
+ |
1384 |
+ return -EINVAL; |
1385 |
+ } |
1386 |
+ |
1387 |
+-static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1388 |
+- unsigned long *visited, bool validate) |
1389 |
++static int __uac3_clock_find_source(struct snd_usb_audio *chip, |
1390 |
++ struct audioformat *fmt, int entity_id, |
1391 |
++ unsigned long *visited, bool validate) |
1392 |
+ { |
1393 |
+ struct uac3_clock_source_descriptor *source; |
1394 |
+ struct uac3_clock_selector_descriptor *selector; |
1395 |
+@@ -321,7 +355,7 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1396 |
+ source = snd_usb_find_clock_source_v3(chip->ctrl_intf, entity_id); |
1397 |
+ if (source) { |
1398 |
+ entity_id = source->bClockID; |
1399 |
+- if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_3, |
1400 |
++ if (validate && !uac_clock_source_is_valid(chip, fmt, |
1401 |
+ entity_id)) { |
1402 |
+ usb_audio_err(chip, |
1403 |
+ "clock source %d is not valid, cannot use\n", |
1404 |
+@@ -352,7 +386,8 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1405 |
+ } |
1406 |
+ |
1407 |
+ cur = ret; |
1408 |
+- ret = __uac3_clock_find_source(chip, selector->baCSourceID[ret - 1], |
1409 |
++ ret = __uac3_clock_find_source(chip, fmt, |
1410 |
++ selector->baCSourceID[ret - 1], |
1411 |
+ visited, validate); |
1412 |
+ if (!validate || ret > 0 || !chip->autoclock) |
1413 |
+ return ret; |
1414 |
+@@ -364,8 +399,9 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1415 |
+ if (i == cur) |
1416 |
+ continue; |
1417 |
+ |
1418 |
+- ret = __uac3_clock_find_source(chip, selector->baCSourceID[i - 1], |
1419 |
+- visited, true); |
1420 |
++ ret = __uac3_clock_find_source(chip, fmt, |
1421 |
++ selector->baCSourceID[i - 1], |
1422 |
++ visited, true); |
1423 |
+ if (ret < 0) |
1424 |
+ continue; |
1425 |
+ |
1426 |
+@@ -386,7 +422,8 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1427 |
+ multiplier = snd_usb_find_clock_multiplier_v3(chip->ctrl_intf, |
1428 |
+ entity_id); |
1429 |
+ if (multiplier) |
1430 |
+- return __uac3_clock_find_source(chip, multiplier->bCSourceID, |
1431 |
++ return __uac3_clock_find_source(chip, fmt, |
1432 |
++ multiplier->bCSourceID, |
1433 |
+ visited, validate); |
1434 |
+ |
1435 |
+ return -EINVAL; |
1436 |
+@@ -403,18 +440,18 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
1437 |
+ * |
1438 |
+ * Returns the clock source UnitID (>=0) on success, or an error. |
1439 |
+ */ |
1440 |
+-int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol, |
1441 |
+- int entity_id, bool validate) |
1442 |
++int snd_usb_clock_find_source(struct snd_usb_audio *chip, |
1443 |
++ struct audioformat *fmt, bool validate) |
1444 |
+ { |
1445 |
+ DECLARE_BITMAP(visited, 256); |
1446 |
+ memset(visited, 0, sizeof(visited)); |
1447 |
+ |
1448 |
+- switch (protocol) { |
1449 |
++ switch (fmt->protocol) { |
1450 |
+ case UAC_VERSION_2: |
1451 |
+- return __uac_clock_find_source(chip, entity_id, visited, |
1452 |
++ return __uac_clock_find_source(chip, fmt, fmt->clock, visited, |
1453 |
+ validate); |
1454 |
+ case UAC_VERSION_3: |
1455 |
+- return __uac3_clock_find_source(chip, entity_id, visited, |
1456 |
++ return __uac3_clock_find_source(chip, fmt, fmt->clock, visited, |
1457 |
+ validate); |
1458 |
+ default: |
1459 |
+ return -EINVAL; |
1460 |
+@@ -515,8 +552,7 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, int iface, |
1461 |
+ * automatic clock selection if the current clock is not |
1462 |
+ * valid. |
1463 |
+ */ |
1464 |
+- clock = snd_usb_clock_find_source(chip, fmt->protocol, |
1465 |
+- fmt->clock, true); |
1466 |
++ clock = snd_usb_clock_find_source(chip, fmt, true); |
1467 |
+ if (clock < 0) { |
1468 |
+ /* We did not find a valid clock, but that might be |
1469 |
+ * because the current sample rate does not match an |
1470 |
+@@ -524,8 +560,7 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, int iface, |
1471 |
+ * and we will do another validation after setting the |
1472 |
+ * rate. |
1473 |
+ */ |
1474 |
+- clock = snd_usb_clock_find_source(chip, fmt->protocol, |
1475 |
+- fmt->clock, false); |
1476 |
++ clock = snd_usb_clock_find_source(chip, fmt, false); |
1477 |
+ if (clock < 0) |
1478 |
+ return clock; |
1479 |
+ } |
1480 |
+@@ -591,7 +626,7 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, int iface, |
1481 |
+ |
1482 |
+ validation: |
1483 |
+ /* validate clock after rate change */ |
1484 |
+- if (!uac_clock_source_is_valid(chip, fmt->protocol, clock)) |
1485 |
++ if (!uac_clock_source_is_valid(chip, fmt, clock)) |
1486 |
+ return -ENXIO; |
1487 |
+ return 0; |
1488 |
+ } |
1489 |
+diff --git a/sound/usb/clock.h b/sound/usb/clock.h |
1490 |
+index 076e31b79ee0..68df0fbe09d0 100644 |
1491 |
+--- a/sound/usb/clock.h |
1492 |
++++ b/sound/usb/clock.h |
1493 |
+@@ -6,7 +6,7 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, |
1494 |
+ struct usb_host_interface *alts, |
1495 |
+ struct audioformat *fmt, int rate); |
1496 |
+ |
1497 |
+-int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol, |
1498 |
+- int entity_id, bool validate); |
1499 |
++int snd_usb_clock_find_source(struct snd_usb_audio *chip, |
1500 |
++ struct audioformat *fmt, bool validate); |
1501 |
+ |
1502 |
+ #endif /* __USBAUDIO_CLOCK_H */ |
1503 |
+diff --git a/sound/usb/format.c b/sound/usb/format.c |
1504 |
+index fd13ac11b136..9d27429ed403 100644 |
1505 |
+--- a/sound/usb/format.c |
1506 |
++++ b/sound/usb/format.c |
1507 |
+@@ -306,8 +306,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, |
1508 |
+ struct usb_device *dev = chip->dev; |
1509 |
+ unsigned char tmp[2], *data; |
1510 |
+ int nr_triplets, data_size, ret = 0; |
1511 |
+- int clock = snd_usb_clock_find_source(chip, fp->protocol, |
1512 |
+- fp->clock, false); |
1513 |
++ int clock = snd_usb_clock_find_source(chip, fp, false); |
1514 |
+ |
1515 |
+ if (clock < 0) { |
1516 |
+ dev_err(&dev->dev, |
1517 |
+diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c |
1518 |
+index 6ac6a0980124..f2e173b9691d 100644 |
1519 |
+--- a/sound/usb/mixer.c |
1520 |
++++ b/sound/usb/mixer.c |
1521 |
+@@ -912,6 +912,15 @@ static int parse_term_proc_unit(struct mixer_build *state, |
1522 |
+ return 0; |
1523 |
+ } |
1524 |
+ |
1525 |
++static int parse_term_effect_unit(struct mixer_build *state, |
1526 |
++ struct usb_audio_term *term, |
1527 |
++ void *p1, int id) |
1528 |
++{ |
1529 |
++ term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */ |
1530 |
++ term->id = id; |
1531 |
++ return 0; |
1532 |
++} |
1533 |
++ |
1534 |
+ static int parse_term_uac2_clock_source(struct mixer_build *state, |
1535 |
+ struct usb_audio_term *term, |
1536 |
+ void *p1, int id) |
1537 |
+@@ -996,8 +1005,7 @@ static int __check_input_term(struct mixer_build *state, int id, |
1538 |
+ UAC3_PROCESSING_UNIT); |
1539 |
+ case PTYPE(UAC_VERSION_2, UAC2_EFFECT_UNIT): |
1540 |
+ case PTYPE(UAC_VERSION_3, UAC3_EFFECT_UNIT): |
1541 |
+- return parse_term_proc_unit(state, term, p1, id, |
1542 |
+- UAC3_EFFECT_UNIT); |
1543 |
++ return parse_term_effect_unit(state, term, p1, id); |
1544 |
+ case PTYPE(UAC_VERSION_1, UAC1_EXTENSION_UNIT): |
1545 |
+ case PTYPE(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2): |
1546 |
+ case PTYPE(UAC_VERSION_3, UAC3_EXTENSION_UNIT): |
1547 |
+diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
1548 |
+index 49f6f6129857..5bbfd7577b33 100644 |
1549 |
+--- a/sound/usb/quirks.c |
1550 |
++++ b/sound/usb/quirks.c |
1551 |
+@@ -1182,6 +1182,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) |
1552 |
+ case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ |
1553 |
+ case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ |
1554 |
+ case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ |
1555 |
++ case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ |
1556 |
+ return true; |
1557 |
+ } |
1558 |
+ |