Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.16 commit in: /
Date: Tue, 05 Jun 2018 11:23:34
Message-Id: 1528197794.3e7962438b88fe111422c8cfb753db35134db8ce.mpagano@gentoo
1 commit: 3e7962438b88fe111422c8cfb753db35134db8ce
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jun 5 11:23:14 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Jun 5 11:23:14 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3e796243
7
8 Linux patch 4.16.14
9
10 0000_README | 4 +
11 1013_linux-4.16.14.patch | 2085 ++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 2089 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index f199583..5691b91 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -95,6 +95,10 @@ Patch: 1012_linux-4.16.13.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.16.13
21
22 +Patch: 1013_linux-4.16.14.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.16.14
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1013_linux-4.16.14.patch b/1013_linux-4.16.14.patch
31 new file mode 100644
32 index 0000000..91e0c4e
33 --- /dev/null
34 +++ b/1013_linux-4.16.14.patch
35 @@ -0,0 +1,2085 @@
36 +diff --git a/Makefile b/Makefile
37 +index 146e527a5e06..a043442e442f 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,7 +1,7 @@
41 + # SPDX-License-Identifier: GPL-2.0
42 + VERSION = 4
43 + PATCHLEVEL = 16
44 +-SUBLEVEL = 13
45 ++SUBLEVEL = 14
46 + EXTRAVERSION =
47 + NAME = Fearless Coyote
48 +
49 +diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
50 +index 57028d49c202..cdcfe4639a83 100644
51 +--- a/arch/mips/kernel/process.c
52 ++++ b/arch/mips/kernel/process.c
53 +@@ -721,6 +721,10 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
54 + if (value & ~known_bits)
55 + return -EOPNOTSUPP;
56 +
57 ++ /* Setting FRE without FR is not supported. */
58 ++ if ((value & (PR_FP_MODE_FR | PR_FP_MODE_FRE)) == PR_FP_MODE_FRE)
59 ++ return -EOPNOTSUPP;
60 ++
61 + /* Avoid inadvertently triggering emulation */
62 + if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu &&
63 + !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64))
64 +diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
65 +index 8d098b9f395c..0c0c23c9c9f5 100644
66 +--- a/arch/mips/kernel/ptrace.c
67 ++++ b/arch/mips/kernel/ptrace.c
68 +@@ -818,7 +818,7 @@ long arch_ptrace(struct task_struct *child, long request,
69 + break;
70 + }
71 + #endif
72 +- tmp = get_fpr32(&fregs[addr - FPR_BASE], 0);
73 ++ tmp = get_fpr64(&fregs[addr - FPR_BASE], 0);
74 + break;
75 + case PC:
76 + tmp = regs->cp0_epc;
77 +diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
78 +index 656a137c1fe2..f30c381d3e1c 100644
79 +--- a/arch/mips/kernel/ptrace32.c
80 ++++ b/arch/mips/kernel/ptrace32.c
81 +@@ -109,7 +109,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
82 + addr & 1);
83 + break;
84 + }
85 +- tmp = get_fpr32(&fregs[addr - FPR_BASE], 0);
86 ++ tmp = get_fpr64(&fregs[addr - FPR_BASE], 0);
87 + break;
88 + case PC:
89 + tmp = regs->cp0_epc;
90 +diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
91 +index 12bc2863a4d6..c8e038800591 100644
92 +--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
93 ++++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
94 +@@ -94,6 +94,11 @@ static struct smca_bank_name smca_names[] = {
95 + [SMCA_SMU] = { "smu", "System Management Unit" },
96 + };
97 +
98 ++static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init =
99 ++{
100 ++ [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 }
101 ++};
102 ++
103 + const char *smca_get_name(enum smca_bank_types t)
104 + {
105 + if (t >= N_SMCA_BANK_TYPES)
106 +@@ -431,52 +436,51 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c)
107 + wrmsr(MSR_CU_DEF_ERR, low, high);
108 + }
109 +
110 +-static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 high,
111 +- unsigned int bank, unsigned int block)
112 ++static u32 smca_get_block_address(unsigned int cpu, unsigned int bank,
113 ++ unsigned int block)
114 + {
115 +- u32 addr = 0, offset = 0;
116 ++ u32 low, high;
117 ++ u32 addr = 0;
118 +
119 +- if ((bank >= mca_cfg.banks) || (block >= NR_BLOCKS))
120 ++ if (smca_get_bank_type(bank) == SMCA_RESERVED)
121 + return addr;
122 +
123 +- /* Get address from already initialized block. */
124 +- if (per_cpu(threshold_banks, cpu)) {
125 +- struct threshold_bank *bankp = per_cpu(threshold_banks, cpu)[bank];
126 ++ if (!block)
127 ++ return MSR_AMD64_SMCA_MCx_MISC(bank);
128 +
129 +- if (bankp && bankp->blocks) {
130 +- struct threshold_block *blockp = &bankp->blocks[block];
131 ++ /* Check our cache first: */
132 ++ if (smca_bank_addrs[bank][block] != -1)
133 ++ return smca_bank_addrs[bank][block];
134 +
135 +- if (blockp)
136 +- return blockp->address;
137 +- }
138 +- }
139 ++ /*
140 ++ * For SMCA enabled processors, BLKPTR field of the first MISC register
141 ++ * (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4).
142 ++ */
143 ++ if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
144 ++ goto out;
145 +
146 +- if (mce_flags.smca) {
147 +- if (smca_get_bank_type(bank) == SMCA_RESERVED)
148 +- return addr;
149 ++ if (!(low & MCI_CONFIG_MCAX))
150 ++ goto out;
151 +
152 +- if (!block) {
153 +- addr = MSR_AMD64_SMCA_MCx_MISC(bank);
154 +- } else {
155 +- /*
156 +- * For SMCA enabled processors, BLKPTR field of the
157 +- * first MISC register (MCx_MISC0) indicates presence of
158 +- * additional MISC register set (MISC1-4).
159 +- */
160 +- u32 low, high;
161 ++ if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
162 ++ (low & MASK_BLKPTR_LO))
163 ++ addr = MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
164 +
165 +- if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
166 +- return addr;
167 ++out:
168 ++ smca_bank_addrs[bank][block] = addr;
169 ++ return addr;
170 ++}
171 +
172 +- if (!(low & MCI_CONFIG_MCAX))
173 +- return addr;
174 ++static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 high,
175 ++ unsigned int bank, unsigned int block)
176 ++{
177 ++ u32 addr = 0, offset = 0;
178 +
179 +- if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
180 +- (low & MASK_BLKPTR_LO))
181 +- addr = MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
182 +- }
183 ++ if ((bank >= mca_cfg.banks) || (block >= NR_BLOCKS))
184 + return addr;
185 +- }
186 ++
187 ++ if (mce_flags.smca)
188 ++ return smca_get_block_address(cpu, bank, block);
189 +
190 + /* Fall back to method we used for older processors: */
191 + switch (block) {
192 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
193 +index 44de0874629f..416abebb8b86 100644
194 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
195 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
196 +@@ -166,10 +166,10 @@ void cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)
197 + cz_dpm_powerup_uvd(hwmgr);
198 + cgs_set_clockgating_state(hwmgr->device,
199 + AMD_IP_BLOCK_TYPE_UVD,
200 +- AMD_PG_STATE_UNGATE);
201 ++ AMD_CG_STATE_UNGATE);
202 + cgs_set_powergating_state(hwmgr->device,
203 + AMD_IP_BLOCK_TYPE_UVD,
204 +- AMD_CG_STATE_UNGATE);
205 ++ AMD_PG_STATE_UNGATE);
206 + cz_dpm_update_uvd_dpm(hwmgr, false);
207 + }
208 +
209 +@@ -197,11 +197,11 @@ void cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
210 + cgs_set_clockgating_state(
211 + hwmgr->device,
212 + AMD_IP_BLOCK_TYPE_VCE,
213 +- AMD_PG_STATE_UNGATE);
214 ++ AMD_CG_STATE_UNGATE);
215 + cgs_set_powergating_state(
216 + hwmgr->device,
217 + AMD_IP_BLOCK_TYPE_VCE,
218 +- AMD_CG_STATE_UNGATE);
219 ++ AMD_PG_STATE_UNGATE);
220 + cz_dpm_update_vce_dpm(hwmgr);
221 + cz_enable_disable_vce_dpm(hwmgr, true);
222 + }
223 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c
224 +index 69a0678ace98..402aa9cb1f78 100644
225 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c
226 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c
227 +@@ -162,7 +162,7 @@ void smu7_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)
228 + AMD_CG_STATE_UNGATE);
229 + cgs_set_powergating_state(hwmgr->device,
230 + AMD_IP_BLOCK_TYPE_UVD,
231 +- AMD_CG_STATE_UNGATE);
232 ++ AMD_PG_STATE_UNGATE);
233 + smu7_update_uvd_dpm(hwmgr, false);
234 + }
235 +
236 +diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
237 +index adf79be42c1e..9ffa66713104 100644
238 +--- a/drivers/gpu/drm/drm_dp_helper.c
239 ++++ b/drivers/gpu/drm/drm_dp_helper.c
240 +@@ -1141,6 +1141,7 @@ int drm_dp_psr_setup_time(const u8 psr_cap[EDP_PSR_RECEIVER_CAP_SIZE])
241 + static const u16 psr_setup_time_us[] = {
242 + PSR_SETUP_TIME(330),
243 + PSR_SETUP_TIME(275),
244 ++ PSR_SETUP_TIME(220),
245 + PSR_SETUP_TIME(165),
246 + PSR_SETUP_TIME(110),
247 + PSR_SETUP_TIME(55),
248 +diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
249 +index 7ed6f7b69556..3ba99c551f61 100644
250 +--- a/drivers/gpu/drm/i915/intel_lvds.c
251 ++++ b/drivers/gpu/drm/i915/intel_lvds.c
252 +@@ -567,6 +567,36 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
253 + return NOTIFY_OK;
254 + }
255 +
256 ++static int
257 ++intel_lvds_connector_register(struct drm_connector *connector)
258 ++{
259 ++ struct intel_lvds_connector *lvds = to_lvds_connector(connector);
260 ++ int ret;
261 ++
262 ++ ret = intel_connector_register(connector);
263 ++ if (ret)
264 ++ return ret;
265 ++
266 ++ lvds->lid_notifier.notifier_call = intel_lid_notify;
267 ++ if (acpi_lid_notifier_register(&lvds->lid_notifier)) {
268 ++ DRM_DEBUG_KMS("lid notifier registration failed\n");
269 ++ lvds->lid_notifier.notifier_call = NULL;
270 ++ }
271 ++
272 ++ return 0;
273 ++}
274 ++
275 ++static void
276 ++intel_lvds_connector_unregister(struct drm_connector *connector)
277 ++{
278 ++ struct intel_lvds_connector *lvds = to_lvds_connector(connector);
279 ++
280 ++ if (lvds->lid_notifier.notifier_call)
281 ++ acpi_lid_notifier_unregister(&lvds->lid_notifier);
282 ++
283 ++ intel_connector_unregister(connector);
284 ++}
285 ++
286 + /**
287 + * intel_lvds_destroy - unregister and free LVDS structures
288 + * @connector: connector to free
289 +@@ -579,9 +609,6 @@ static void intel_lvds_destroy(struct drm_connector *connector)
290 + struct intel_lvds_connector *lvds_connector =
291 + to_lvds_connector(connector);
292 +
293 +- if (lvds_connector->lid_notifier.notifier_call)
294 +- acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
295 +-
296 + if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
297 + kfree(lvds_connector->base.edid);
298 +
299 +@@ -602,8 +629,8 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = {
300 + .fill_modes = drm_helper_probe_single_connector_modes,
301 + .atomic_get_property = intel_digital_connector_atomic_get_property,
302 + .atomic_set_property = intel_digital_connector_atomic_set_property,
303 +- .late_register = intel_connector_register,
304 +- .early_unregister = intel_connector_unregister,
305 ++ .late_register = intel_lvds_connector_register,
306 ++ .early_unregister = intel_lvds_connector_unregister,
307 + .destroy = intel_lvds_destroy,
308 + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
309 + .atomic_duplicate_state = intel_digital_connector_duplicate_state,
310 +@@ -820,6 +847,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
311 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "D525MW"),
312 + },
313 + },
314 ++ {
315 ++ .callback = intel_no_lvds_dmi_callback,
316 ++ .ident = "Radiant P845",
317 ++ .matches = {
318 ++ DMI_MATCH(DMI_SYS_VENDOR, "Radiant Systems Inc"),
319 ++ DMI_MATCH(DMI_PRODUCT_NAME, "P845"),
320 ++ },
321 ++ },
322 +
323 + { } /* terminating entry */
324 + };
325 +@@ -1138,12 +1173,6 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
326 +
327 + lvds_encoder->a3_power = lvds & LVDS_A3_POWER_MASK;
328 +
329 +- lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
330 +- if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
331 +- DRM_DEBUG_KMS("lid notifier registration failed\n");
332 +- lvds_connector->lid_notifier.notifier_call = NULL;
333 +- }
334 +-
335 + return;
336 +
337 + failed:
338 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
339 +index 97000996b8dc..21d746bdc922 100644
340 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
341 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
342 +@@ -328,9 +328,7 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
343 + {
344 + struct rpc_channel channel;
345 + char *msg, *reply = NULL;
346 +- size_t msg_len, reply_len = 0;
347 +- int ret = 0;
348 +-
349 ++ size_t reply_len = 0;
350 +
351 + if (!vmw_msg_enabled)
352 + return -ENODEV;
353 +@@ -338,24 +336,20 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
354 + if (!guest_info_param || !length)
355 + return -EINVAL;
356 +
357 +- msg_len = strlen(guest_info_param) + strlen("info-get ") + 1;
358 +- msg = kzalloc(msg_len, GFP_KERNEL);
359 ++ msg = kasprintf(GFP_KERNEL, "info-get %s", guest_info_param);
360 + if (!msg) {
361 + DRM_ERROR("Cannot allocate memory to get %s", guest_info_param);
362 + return -ENOMEM;
363 + }
364 +
365 +- sprintf(msg, "info-get %s", guest_info_param);
366 ++ if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
367 ++ goto out_open;
368 +
369 +- if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
370 +- vmw_send_msg(&channel, msg) ||
371 +- vmw_recv_msg(&channel, (void *) &reply, &reply_len) ||
372 +- vmw_close_channel(&channel)) {
373 +- DRM_ERROR("Failed to get %s", guest_info_param);
374 +-
375 +- ret = -EINVAL;
376 +- }
377 ++ if (vmw_send_msg(&channel, msg) ||
378 ++ vmw_recv_msg(&channel, (void *) &reply, &reply_len))
379 ++ goto out_msg;
380 +
381 ++ vmw_close_channel(&channel);
382 + if (buffer && reply && reply_len > 0) {
383 + /* Remove reply code, which are the first 2 characters of
384 + * the reply
385 +@@ -372,7 +366,17 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
386 + kfree(reply);
387 + kfree(msg);
388 +
389 +- return ret;
390 ++ return 0;
391 ++
392 ++out_msg:
393 ++ vmw_close_channel(&channel);
394 ++ kfree(reply);
395 ++out_open:
396 ++ *length = 0;
397 ++ kfree(msg);
398 ++ DRM_ERROR("Failed to get %s", guest_info_param);
399 ++
400 ++ return -EINVAL;
401 + }
402 +
403 +
404 +@@ -388,7 +392,6 @@ int vmw_host_log(const char *log)
405 + {
406 + struct rpc_channel channel;
407 + char *msg;
408 +- int msg_len;
409 + int ret = 0;
410 +
411 +
412 +@@ -398,24 +401,28 @@ int vmw_host_log(const char *log)
413 + if (!log)
414 + return ret;
415 +
416 +- msg_len = strlen(log) + strlen("log ") + 1;
417 +- msg = kzalloc(msg_len, GFP_KERNEL);
418 ++ msg = kasprintf(GFP_KERNEL, "log %s", log);
419 + if (!msg) {
420 + DRM_ERROR("Cannot allocate memory for log message\n");
421 + return -ENOMEM;
422 + }
423 +
424 +- sprintf(msg, "log %s", log);
425 ++ if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))
426 ++ goto out_open;
427 +
428 +- if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) ||
429 +- vmw_send_msg(&channel, msg) ||
430 +- vmw_close_channel(&channel)) {
431 +- DRM_ERROR("Failed to send log\n");
432 ++ if (vmw_send_msg(&channel, msg))
433 ++ goto out_msg;
434 +
435 +- ret = -EINVAL;
436 +- }
437 ++ vmw_close_channel(&channel);
438 ++ kfree(msg);
439 +
440 ++ return 0;
441 ++
442 ++out_msg:
443 ++ vmw_close_channel(&channel);
444 ++out_open:
445 + kfree(msg);
446 ++ DRM_ERROR("Failed to send log\n");
447 +
448 +- return ret;
449 ++ return -EINVAL;
450 + }
451 +diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
452 +index dfb57eaa9f22..58ac786634dc 100644
453 +--- a/drivers/hwtracing/intel_th/msu.c
454 ++++ b/drivers/hwtracing/intel_th/msu.c
455 +@@ -741,8 +741,8 @@ static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
456 + /* Reset the page to write-back before releasing */
457 + set_memory_wb((unsigned long)win->block[i].bdesc, 1);
458 + #endif
459 +- dma_free_coherent(msc_dev(msc), size, win->block[i].bdesc,
460 +- win->block[i].addr);
461 ++ dma_free_coherent(msc_dev(msc)->parent->parent, size,
462 ++ win->block[i].bdesc, win->block[i].addr);
463 + }
464 + kfree(win);
465 +
466 +@@ -777,7 +777,7 @@ static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
467 + /* Reset the page to write-back before releasing */
468 + set_memory_wb((unsigned long)win->block[i].bdesc, 1);
469 + #endif
470 +- dma_free_coherent(msc_dev(win->msc), PAGE_SIZE,
471 ++ dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
472 + win->block[i].bdesc, win->block[i].addr);
473 + }
474 +
475 +diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
476 +index f129869e05a9..736862967e32 100644
477 +--- a/drivers/hwtracing/stm/core.c
478 ++++ b/drivers/hwtracing/stm/core.c
479 +@@ -27,6 +27,7 @@
480 + #include <linux/stm.h>
481 + #include <linux/fs.h>
482 + #include <linux/mm.h>
483 ++#include <linux/vmalloc.h>
484 + #include "stm.h"
485 +
486 + #include <uapi/linux/stm.h>
487 +@@ -682,7 +683,7 @@ static void stm_device_release(struct device *dev)
488 + {
489 + struct stm_device *stm = to_stm_device(dev);
490 +
491 +- kfree(stm);
492 ++ vfree(stm);
493 + }
494 +
495 + int stm_register_device(struct device *parent, struct stm_data *stm_data,
496 +@@ -699,7 +700,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
497 + return -EINVAL;
498 +
499 + nmasters = stm_data->sw_end - stm_data->sw_start + 1;
500 +- stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
501 ++ stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
502 + if (!stm)
503 + return -ENOMEM;
504 +
505 +@@ -752,7 +753,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
506 + /* matches device_initialize() above */
507 + put_device(&stm->dev);
508 + err_free:
509 +- kfree(stm);
510 ++ vfree(stm);
511 +
512 + return err;
513 + }
514 +diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
515 +index 72bc2b71765a..47bbed3afc8f 100644
516 +--- a/drivers/iio/adc/Kconfig
517 ++++ b/drivers/iio/adc/Kconfig
518 +@@ -159,6 +159,7 @@ config AT91_SAMA5D2_ADC
519 + depends on ARCH_AT91 || COMPILE_TEST
520 + depends on HAS_IOMEM
521 + depends on HAS_DMA
522 ++ select IIO_BUFFER
523 + select IIO_TRIGGERED_BUFFER
524 + help
525 + Say yes here to build support for Atmel SAMA5D2 ADC which is
526 +diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
527 +index 801afb61310b..d4bbe5b53318 100644
528 +--- a/drivers/iio/adc/ad7793.c
529 ++++ b/drivers/iio/adc/ad7793.c
530 +@@ -348,55 +348,6 @@ static const u16 ad7793_sample_freq_avail[16] = {0, 470, 242, 123, 62, 50, 39,
531 + static const u16 ad7797_sample_freq_avail[16] = {0, 0, 0, 123, 62, 50, 0,
532 + 33, 0, 17, 16, 12, 10, 8, 6, 4};
533 +
534 +-static ssize_t ad7793_read_frequency(struct device *dev,
535 +- struct device_attribute *attr,
536 +- char *buf)
537 +-{
538 +- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
539 +- struct ad7793_state *st = iio_priv(indio_dev);
540 +-
541 +- return sprintf(buf, "%d\n",
542 +- st->chip_info->sample_freq_avail[AD7793_MODE_RATE(st->mode)]);
543 +-}
544 +-
545 +-static ssize_t ad7793_write_frequency(struct device *dev,
546 +- struct device_attribute *attr,
547 +- const char *buf,
548 +- size_t len)
549 +-{
550 +- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
551 +- struct ad7793_state *st = iio_priv(indio_dev);
552 +- long lval;
553 +- int i, ret;
554 +-
555 +- ret = kstrtol(buf, 10, &lval);
556 +- if (ret)
557 +- return ret;
558 +-
559 +- if (lval == 0)
560 +- return -EINVAL;
561 +-
562 +- for (i = 0; i < 16; i++)
563 +- if (lval == st->chip_info->sample_freq_avail[i])
564 +- break;
565 +- if (i == 16)
566 +- return -EINVAL;
567 +-
568 +- ret = iio_device_claim_direct_mode(indio_dev);
569 +- if (ret)
570 +- return ret;
571 +- st->mode &= ~AD7793_MODE_RATE(-1);
572 +- st->mode |= AD7793_MODE_RATE(i);
573 +- ad_sd_write_reg(&st->sd, AD7793_REG_MODE, sizeof(st->mode), st->mode);
574 +- iio_device_release_direct_mode(indio_dev);
575 +-
576 +- return len;
577 +-}
578 +-
579 +-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
580 +- ad7793_read_frequency,
581 +- ad7793_write_frequency);
582 +-
583 + static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
584 + "470 242 123 62 50 39 33 19 17 16 12 10 8 6 4");
585 +
586 +@@ -424,7 +375,6 @@ static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available,
587 + ad7793_show_scale_available, NULL, 0);
588 +
589 + static struct attribute *ad7793_attributes[] = {
590 +- &iio_dev_attr_sampling_frequency.dev_attr.attr,
591 + &iio_const_attr_sampling_frequency_available.dev_attr.attr,
592 + &iio_dev_attr_in_m_in_scale_available.dev_attr.attr,
593 + NULL
594 +@@ -435,7 +385,6 @@ static const struct attribute_group ad7793_attribute_group = {
595 + };
596 +
597 + static struct attribute *ad7797_attributes[] = {
598 +- &iio_dev_attr_sampling_frequency.dev_attr.attr,
599 + &iio_const_attr_sampling_frequency_available_ad7797.dev_attr.attr,
600 + NULL
601 + };
602 +@@ -505,6 +454,10 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
603 + *val -= offset;
604 + }
605 + return IIO_VAL_INT;
606 ++ case IIO_CHAN_INFO_SAMP_FREQ:
607 ++ *val = st->chip_info
608 ++ ->sample_freq_avail[AD7793_MODE_RATE(st->mode)];
609 ++ return IIO_VAL_INT;
610 + }
611 + return -EINVAL;
612 + }
613 +@@ -542,6 +495,26 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
614 + break;
615 + }
616 + break;
617 ++ case IIO_CHAN_INFO_SAMP_FREQ:
618 ++ if (!val) {
619 ++ ret = -EINVAL;
620 ++ break;
621 ++ }
622 ++
623 ++ for (i = 0; i < 16; i++)
624 ++ if (val == st->chip_info->sample_freq_avail[i])
625 ++ break;
626 ++
627 ++ if (i == 16) {
628 ++ ret = -EINVAL;
629 ++ break;
630 ++ }
631 ++
632 ++ st->mode &= ~AD7793_MODE_RATE(-1);
633 ++ st->mode |= AD7793_MODE_RATE(i);
634 ++ ad_sd_write_reg(&st->sd, AD7793_REG_MODE, sizeof(st->mode),
635 ++ st->mode);
636 ++ break;
637 + default:
638 + ret = -EINVAL;
639 + }
640 +diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
641 +index 4eff8351ce29..8729d6524b4d 100644
642 +--- a/drivers/iio/adc/at91-sama5d2_adc.c
643 ++++ b/drivers/iio/adc/at91-sama5d2_adc.c
644 +@@ -333,6 +333,27 @@ static const struct iio_chan_spec at91_adc_channels[] = {
645 + + AT91_SAMA5D2_DIFF_CHAN_CNT + 1),
646 + };
647 +
648 ++static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan)
649 ++{
650 ++ int i;
651 ++
652 ++ for (i = 0; i < indio_dev->num_channels; i++) {
653 ++ if (indio_dev->channels[i].scan_index == chan)
654 ++ return i;
655 ++ }
656 ++ return -EINVAL;
657 ++}
658 ++
659 ++static inline struct iio_chan_spec const *
660 ++at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
661 ++{
662 ++ int index = at91_adc_chan_xlate(indio_dev, chan);
663 ++
664 ++ if (index < 0)
665 ++ return NULL;
666 ++ return indio_dev->channels + index;
667 ++}
668 ++
669 + static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
670 + {
671 + struct iio_dev *indio = iio_trigger_get_drvdata(trig);
672 +@@ -350,8 +371,10 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
673 + at91_adc_writel(st, AT91_SAMA5D2_TRGR, status);
674 +
675 + for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
676 +- struct iio_chan_spec const *chan = indio->channels + bit;
677 ++ struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
678 +
679 ++ if (!chan)
680 ++ continue;
681 + if (state) {
682 + at91_adc_writel(st, AT91_SAMA5D2_CHER,
683 + BIT(chan->channel));
684 +@@ -448,7 +471,11 @@ static int at91_adc_dma_start(struct iio_dev *indio_dev)
685 +
686 + for_each_set_bit(bit, indio_dev->active_scan_mask,
687 + indio_dev->num_channels) {
688 +- struct iio_chan_spec const *chan = indio_dev->channels + bit;
689 ++ struct iio_chan_spec const *chan =
690 ++ at91_adc_chan_get(indio_dev, bit);
691 ++
692 ++ if (!chan)
693 ++ continue;
694 +
695 + st->dma_st.rx_buf_sz += chan->scan_type.storagebits / 8;
696 + }
697 +@@ -526,8 +553,11 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev)
698 + */
699 + for_each_set_bit(bit, indio_dev->active_scan_mask,
700 + indio_dev->num_channels) {
701 +- struct iio_chan_spec const *chan = indio_dev->channels + bit;
702 ++ struct iio_chan_spec const *chan =
703 ++ at91_adc_chan_get(indio_dev, bit);
704 +
705 ++ if (!chan)
706 ++ continue;
707 + if (st->dma_st.dma_chan)
708 + at91_adc_readl(st, chan->address);
709 + }
710 +@@ -587,8 +617,11 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev,
711 +
712 + for_each_set_bit(bit, indio_dev->active_scan_mask,
713 + indio_dev->num_channels) {
714 +- struct iio_chan_spec const *chan = indio_dev->channels + bit;
715 ++ struct iio_chan_spec const *chan =
716 ++ at91_adc_chan_get(indio_dev, bit);
717 +
718 ++ if (!chan)
719 ++ continue;
720 + st->buffer[i] = at91_adc_readl(st, chan->address);
721 + i++;
722 + }
723 +diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
724 +index 01422d11753c..b28a716a23b2 100644
725 +--- a/drivers/iio/adc/stm32-dfsdm-adc.c
726 ++++ b/drivers/iio/adc/stm32-dfsdm-adc.c
727 +@@ -144,6 +144,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
728 + * Leave as soon as if exact resolution if reached.
729 + * Otherwise the higher resolution below 32 bits is kept.
730 + */
731 ++ fl->res = 0;
732 + for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) {
733 + for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) {
734 + if (fast)
735 +@@ -193,7 +194,7 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
736 + }
737 + }
738 +
739 +- if (!fl->fosr)
740 ++ if (!fl->res)
741 + return -EINVAL;
742 +
743 + return 0;
744 +@@ -770,7 +771,7 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
745 + struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
746 + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id];
747 + struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel];
748 +- unsigned int spi_freq = adc->spi_freq;
749 ++ unsigned int spi_freq;
750 + int ret = -EINVAL;
751 +
752 + switch (mask) {
753 +@@ -784,8 +785,18 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
754 + case IIO_CHAN_INFO_SAMP_FREQ:
755 + if (!val)
756 + return -EINVAL;
757 +- if (ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL)
758 ++
759 ++ switch (ch->src) {
760 ++ case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL:
761 + spi_freq = adc->dfsdm->spi_master_freq;
762 ++ break;
763 ++ case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING:
764 ++ case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING:
765 ++ spi_freq = adc->dfsdm->spi_master_freq / 2;
766 ++ break;
767 ++ default:
768 ++ spi_freq = adc->spi_freq;
769 ++ }
770 +
771 + if (spi_freq % val)
772 + dev_warn(&indio_dev->dev,
773 +diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c
774 +index 05e0c353e089..b32bf57910ca 100644
775 +--- a/drivers/iio/buffer/industrialio-buffer-dma.c
776 ++++ b/drivers/iio/buffer/industrialio-buffer-dma.c
777 +@@ -587,7 +587,7 @@ EXPORT_SYMBOL_GPL(iio_dma_buffer_set_bytes_per_datum);
778 + * Should be used as the set_length callback for iio_buffer_access_ops
779 + * struct for DMA buffers.
780 + */
781 +-int iio_dma_buffer_set_length(struct iio_buffer *buffer, int length)
782 ++int iio_dma_buffer_set_length(struct iio_buffer *buffer, unsigned int length)
783 + {
784 + /* Avoid an invalid state */
785 + if (length < 2)
786 +diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
787 +index 047fe757ab97..70c302a93d7f 100644
788 +--- a/drivers/iio/buffer/kfifo_buf.c
789 ++++ b/drivers/iio/buffer/kfifo_buf.c
790 +@@ -22,11 +22,18 @@ struct iio_kfifo {
791 + #define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer)
792 +
793 + static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
794 +- int bytes_per_datum, int length)
795 ++ size_t bytes_per_datum, unsigned int length)
796 + {
797 + if ((length == 0) || (bytes_per_datum == 0))
798 + return -EINVAL;
799 +
800 ++ /*
801 ++ * Make sure we don't overflow an unsigned int after kfifo rounds up to
802 ++ * the next power of 2.
803 ++ */
804 ++ if (roundup_pow_of_two(length) > UINT_MAX / bytes_per_datum)
805 ++ return -EINVAL;
806 ++
807 + return __kfifo_alloc((struct __kfifo *)&buf->kf, length,
808 + bytes_per_datum, GFP_KERNEL);
809 + }
810 +@@ -67,7 +74,7 @@ static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd)
811 + return 0;
812 + }
813 +
814 +-static int iio_set_length_kfifo(struct iio_buffer *r, int length)
815 ++static int iio_set_length_kfifo(struct iio_buffer *r, unsigned int length)
816 + {
817 + /* Avoid an invalid state */
818 + if (length < 2)
819 +diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
820 +index cfb6588565ba..4905a997a7ec 100644
821 +--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
822 ++++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
823 +@@ -178,14 +178,14 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
824 + #ifdef CONFIG_PM
825 + int ret;
826 +
827 +- atomic_set(&st->user_requested_state, state);
828 +-
829 + if (atomic_add_unless(&st->runtime_pm_enable, 1, 1))
830 + pm_runtime_enable(&st->pdev->dev);
831 +
832 +- if (state)
833 ++ if (state) {
834 ++ atomic_inc(&st->user_requested_state);
835 + ret = pm_runtime_get_sync(&st->pdev->dev);
836 +- else {
837 ++ } else {
838 ++ atomic_dec(&st->user_requested_state);
839 + pm_runtime_mark_last_busy(&st->pdev->dev);
840 + pm_runtime_use_autosuspend(&st->pdev->dev);
841 + ret = pm_runtime_put_autosuspend(&st->pdev->dev);
842 +diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
843 +index e9a409d7f4e2..21fbee68b8ed 100644
844 +--- a/drivers/infiniband/core/cache.c
845 ++++ b/drivers/infiniband/core/cache.c
846 +@@ -434,7 +434,7 @@ static int __ib_cache_gid_get(struct ib_device *ib_dev, u8 port, int index,
847 + return -EINVAL;
848 +
849 + if (table->data_vec[index].props & GID_TABLE_ENTRY_INVALID)
850 +- return -EAGAIN;
851 ++ return -EINVAL;
852 +
853 + memcpy(gid, &table->data_vec[index].gid, sizeof(*gid));
854 + if (attr) {
855 +diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
856 +index 29f99529b187..cfcb32559925 100644
857 +--- a/drivers/input/mouse/elan_i2c_smbus.c
858 ++++ b/drivers/input/mouse/elan_i2c_smbus.c
859 +@@ -130,7 +130,7 @@ static int elan_smbus_get_baseline_data(struct i2c_client *client,
860 + bool max_baseline, u8 *value)
861 + {
862 + int error;
863 +- u8 val[3];
864 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
865 +
866 + error = i2c_smbus_read_block_data(client,
867 + max_baseline ?
868 +@@ -149,7 +149,7 @@ static int elan_smbus_get_version(struct i2c_client *client,
869 + bool iap, u8 *version)
870 + {
871 + int error;
872 +- u8 val[3];
873 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
874 +
875 + error = i2c_smbus_read_block_data(client,
876 + iap ? ETP_SMBUS_IAP_VERSION_CMD :
877 +@@ -170,7 +170,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client,
878 + u8 *clickpad)
879 + {
880 + int error;
881 +- u8 val[3];
882 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
883 +
884 + error = i2c_smbus_read_block_data(client,
885 + ETP_SMBUS_SM_VERSION_CMD, val);
886 +@@ -188,7 +188,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client,
887 + static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id)
888 + {
889 + int error;
890 +- u8 val[3];
891 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
892 +
893 + error = i2c_smbus_read_block_data(client,
894 + ETP_SMBUS_UNIQUEID_CMD, val);
895 +@@ -205,7 +205,7 @@ static int elan_smbus_get_checksum(struct i2c_client *client,
896 + bool iap, u16 *csum)
897 + {
898 + int error;
899 +- u8 val[3];
900 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
901 +
902 + error = i2c_smbus_read_block_data(client,
903 + iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
904 +@@ -226,7 +226,7 @@ static int elan_smbus_get_max(struct i2c_client *client,
905 + {
906 + int ret;
907 + int error;
908 +- u8 val[3];
909 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
910 +
911 + ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RANGE_CMD, val);
912 + if (ret != 3) {
913 +@@ -246,7 +246,7 @@ static int elan_smbus_get_resolution(struct i2c_client *client,
914 + {
915 + int ret;
916 + int error;
917 +- u8 val[3];
918 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
919 +
920 + ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RESOLUTION_CMD, val);
921 + if (ret != 3) {
922 +@@ -267,7 +267,7 @@ static int elan_smbus_get_num_traces(struct i2c_client *client,
923 + {
924 + int ret;
925 + int error;
926 +- u8 val[3];
927 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
928 +
929 + ret = i2c_smbus_read_block_data(client, ETP_SMBUS_XY_TRACENUM_CMD, val);
930 + if (ret != 3) {
931 +@@ -294,7 +294,7 @@ static int elan_smbus_iap_get_mode(struct i2c_client *client,
932 + {
933 + int error;
934 + u16 constant;
935 +- u8 val[3];
936 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
937 +
938 + error = i2c_smbus_read_block_data(client, ETP_SMBUS_IAP_CTRL_CMD, val);
939 + if (error < 0) {
940 +@@ -345,7 +345,7 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client)
941 + int len;
942 + int error;
943 + enum tp_mode mode;
944 +- u8 val[3];
945 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
946 + u8 cmd[4] = {0x0F, 0x78, 0x00, 0x06};
947 + u16 password;
948 +
949 +@@ -419,7 +419,7 @@ static int elan_smbus_write_fw_block(struct i2c_client *client,
950 + struct device *dev = &client->dev;
951 + int error;
952 + u16 result;
953 +- u8 val[3];
954 ++ u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
955 +
956 + /*
957 + * Due to the limitation of smbus protocol limiting
958 +diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
959 +index a246fc686bb7..6c4bbd38700e 100644
960 +--- a/drivers/input/mouse/synaptics.c
961 ++++ b/drivers/input/mouse/synaptics.c
962 +@@ -172,6 +172,12 @@ static const char * const smbus_pnp_ids[] = {
963 + "LEN0048", /* X1 Carbon 3 */
964 + "LEN0046", /* X250 */
965 + "LEN004a", /* W541 */
966 ++ "LEN0071", /* T480 */
967 ++ "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */
968 ++ "LEN0073", /* X1 Carbon G5 (Elantech) */
969 ++ "LEN0092", /* X1 Carbon 6 */
970 ++ "LEN0096", /* X280 */
971 ++ "LEN0097", /* X280 -> ALPS trackpoint */
972 + "LEN200f", /* T450s */
973 + NULL
974 + };
975 +diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
976 +index a6884e73d2ab..7ddee980048b 100644
977 +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
978 ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
979 +@@ -372,16 +372,15 @@ static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev,
980 +
981 + /*
982 + * Determine IFS values
983 +- * - Use TXOP_BACKOFF for probe and management frames except beacons
984 ++ * - Use TXOP_BACKOFF for management frames except beacons
985 + * - Use TXOP_SIFS for fragment bursts
986 + * - Use TXOP_HTTXOP for everything else
987 + *
988 + * Note: rt2800 devices won't use CTS protection (if used)
989 + * for frames not transmitted with TXOP_HTTXOP
990 + */
991 +- if ((ieee80211_is_mgmt(hdr->frame_control) &&
992 +- !ieee80211_is_beacon(hdr->frame_control)) ||
993 +- (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
994 ++ if (ieee80211_is_mgmt(hdr->frame_control) &&
995 ++ !ieee80211_is_beacon(hdr->frame_control))
996 + txdesc->u.ht.txop = TXOP_BACKOFF;
997 + else if (!(tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT))
998 + txdesc->u.ht.txop = TXOP_SIFS;
999 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
1000 +index 9cff6bc4049c..cf551785eb08 100644
1001 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
1002 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c
1003 +@@ -299,9 +299,6 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
1004 + writeVal = 0x00000000;
1005 + if (rtlpriv->dm.dynamic_txhighpower_lvl == TXHIGHPWRLEVEL_BT1)
1006 + writeVal = writeVal - 0x06060606;
1007 +- else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
1008 +- TXHIGHPWRLEVEL_BT2)
1009 +- writeVal = writeVal;
1010 + *(p_outwriteval + rf) = writeVal;
1011 + }
1012 + }
1013 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
1014 +index f5259912f049..df3d5051539d 100644
1015 +--- a/drivers/nvme/host/core.c
1016 ++++ b/drivers/nvme/host/core.c
1017 +@@ -1446,8 +1446,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
1018 + if (ns->lba_shift == 0)
1019 + ns->lba_shift = 9;
1020 + ns->noiob = le16_to_cpu(id->noiob);
1021 +- ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
1022 + ns->ms = le16_to_cpu(id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ms);
1023 ++ ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
1024 + /* the PI implementation requires metadata equal t10 pi tuple size */
1025 + if (ns->ms == sizeof(struct t10_pi_tuple))
1026 + ns->pi_type = id->dps & NVME_NS_DPS_PI_MASK;
1027 +diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
1028 +index 95e5c5ea40af..495432f3341b 100644
1029 +--- a/drivers/pinctrl/qcom/pinctrl-msm.c
1030 ++++ b/drivers/pinctrl/qcom/pinctrl-msm.c
1031 +@@ -818,7 +818,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
1032 + return -EINVAL;
1033 +
1034 + chip = &pctrl->chip;
1035 +- chip->base = -1;
1036 ++ chip->base = 0;
1037 + chip->ngpio = ngpio;
1038 + chip->label = dev_name(pctrl->dev);
1039 + chip->parent = pctrl->dev;
1040 +diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
1041 +index 36f6190931bc..456ce9f19569 100644
1042 +--- a/drivers/scsi/scsi_transport_srp.c
1043 ++++ b/drivers/scsi/scsi_transport_srp.c
1044 +@@ -51,6 +51,8 @@ struct srp_internal {
1045 + struct transport_container rport_attr_cont;
1046 + };
1047 +
1048 ++static int scsi_is_srp_rport(const struct device *dev);
1049 ++
1050 + #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
1051 +
1052 + #define dev_to_rport(d) container_of(d, struct srp_rport, dev)
1053 +@@ -60,9 +62,24 @@ static inline struct Scsi_Host *rport_to_shost(struct srp_rport *r)
1054 + return dev_to_shost(r->dev.parent);
1055 + }
1056 +
1057 ++static int find_child_rport(struct device *dev, void *data)
1058 ++{
1059 ++ struct device **child = data;
1060 ++
1061 ++ if (scsi_is_srp_rport(dev)) {
1062 ++ WARN_ON_ONCE(*child);
1063 ++ *child = dev;
1064 ++ }
1065 ++ return 0;
1066 ++}
1067 ++
1068 + static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
1069 + {
1070 +- return transport_class_to_srp_rport(&shost->shost_gendev);
1071 ++ struct device *child = NULL;
1072 ++
1073 ++ WARN_ON_ONCE(device_for_each_child(&shost->shost_gendev, &child,
1074 ++ find_child_rport) < 0);
1075 ++ return child ? dev_to_rport(child) : NULL;
1076 + }
1077 +
1078 + /**
1079 +@@ -600,7 +617,8 @@ enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd)
1080 + struct srp_rport *rport = shost_to_rport(shost);
1081 +
1082 + pr_debug("timeout for sdev %s\n", dev_name(&sdev->sdev_gendev));
1083 +- return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 &&
1084 ++ return rport && rport->fast_io_fail_tmo < 0 &&
1085 ++ rport->dev_loss_tmo < 0 &&
1086 + i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ?
1087 + BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED;
1088 + }
1089 +diff --git a/drivers/soc/lantiq/gphy.c b/drivers/soc/lantiq/gphy.c
1090 +index 8d8659463b3e..feeb17cebc25 100644
1091 +--- a/drivers/soc/lantiq/gphy.c
1092 ++++ b/drivers/soc/lantiq/gphy.c
1093 +@@ -30,7 +30,6 @@ struct xway_gphy_priv {
1094 + struct clk *gphy_clk_gate;
1095 + struct reset_control *gphy_reset;
1096 + struct reset_control *gphy_reset2;
1097 +- struct notifier_block gphy_reboot_nb;
1098 + void __iomem *membase;
1099 + char *fw_name;
1100 + };
1101 +@@ -64,24 +63,6 @@ static const struct of_device_id xway_gphy_match[] = {
1102 + };
1103 + MODULE_DEVICE_TABLE(of, xway_gphy_match);
1104 +
1105 +-static struct xway_gphy_priv *to_xway_gphy_priv(struct notifier_block *nb)
1106 +-{
1107 +- return container_of(nb, struct xway_gphy_priv, gphy_reboot_nb);
1108 +-}
1109 +-
1110 +-static int xway_gphy_reboot_notify(struct notifier_block *reboot_nb,
1111 +- unsigned long code, void *unused)
1112 +-{
1113 +- struct xway_gphy_priv *priv = to_xway_gphy_priv(reboot_nb);
1114 +-
1115 +- if (priv) {
1116 +- reset_control_assert(priv->gphy_reset);
1117 +- reset_control_assert(priv->gphy_reset2);
1118 +- }
1119 +-
1120 +- return NOTIFY_DONE;
1121 +-}
1122 +-
1123 + static int xway_gphy_load(struct device *dev, struct xway_gphy_priv *priv,
1124 + dma_addr_t *dev_addr)
1125 + {
1126 +@@ -205,14 +186,6 @@ static int xway_gphy_probe(struct platform_device *pdev)
1127 + reset_control_deassert(priv->gphy_reset);
1128 + reset_control_deassert(priv->gphy_reset2);
1129 +
1130 +- /* assert the gphy reset because it can hang after a reboot: */
1131 +- priv->gphy_reboot_nb.notifier_call = xway_gphy_reboot_notify;
1132 +- priv->gphy_reboot_nb.priority = -1;
1133 +-
1134 +- ret = register_reboot_notifier(&priv->gphy_reboot_nb);
1135 +- if (ret)
1136 +- dev_warn(dev, "Failed to register reboot notifier\n");
1137 +-
1138 + platform_set_drvdata(pdev, priv);
1139 +
1140 + return ret;
1141 +@@ -220,21 +193,12 @@ static int xway_gphy_probe(struct platform_device *pdev)
1142 +
1143 + static int xway_gphy_remove(struct platform_device *pdev)
1144 + {
1145 +- struct device *dev = &pdev->dev;
1146 + struct xway_gphy_priv *priv = platform_get_drvdata(pdev);
1147 +- int ret;
1148 +-
1149 +- reset_control_assert(priv->gphy_reset);
1150 +- reset_control_assert(priv->gphy_reset2);
1151 +
1152 + iowrite32be(0, priv->membase);
1153 +
1154 + clk_disable_unprepare(priv->gphy_clk_gate);
1155 +
1156 +- ret = unregister_reboot_notifier(&priv->gphy_reboot_nb);
1157 +- if (ret)
1158 +- dev_warn(dev, "Failed to unregister reboot notifier\n");
1159 +-
1160 + return 0;
1161 + }
1162 +
1163 +diff --git a/fs/aio.c b/fs/aio.c
1164 +index 63c0437ab135..3dbfbac2a668 100644
1165 +--- a/fs/aio.c
1166 ++++ b/fs/aio.c
1167 +@@ -643,9 +643,8 @@ static void free_ioctx_users(struct percpu_ref *ref)
1168 + while (!list_empty(&ctx->active_reqs)) {
1169 + req = list_first_entry(&ctx->active_reqs,
1170 + struct aio_kiocb, ki_list);
1171 +-
1172 +- list_del_init(&req->ki_list);
1173 + kiocb_cancel(req);
1174 ++ list_del_init(&req->ki_list);
1175 + }
1176 +
1177 + spin_unlock_irq(&ctx->ctx_lock);
1178 +diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
1179 +index c02781a4c091..5a116b221f11 100644
1180 +--- a/fs/xfs/libxfs/xfs_alloc.c
1181 ++++ b/fs/xfs/libxfs/xfs_alloc.c
1182 +@@ -53,6 +53,23 @@ STATIC int xfs_alloc_ag_vextent_size(xfs_alloc_arg_t *);
1183 + STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,
1184 + xfs_btree_cur_t *, xfs_agblock_t *, xfs_extlen_t *, int *);
1185 +
1186 ++/*
1187 ++ * Size of the AGFL. For CRC-enabled filesystes we steal a couple of slots in
1188 ++ * the beginning of the block for a proper header with the location information
1189 ++ * and CRC.
1190 ++ */
1191 ++unsigned int
1192 ++xfs_agfl_size(
1193 ++ struct xfs_mount *mp)
1194 ++{
1195 ++ unsigned int size = mp->m_sb.sb_sectsize;
1196 ++
1197 ++ if (xfs_sb_version_hascrc(&mp->m_sb))
1198 ++ size -= sizeof(struct xfs_agfl);
1199 ++
1200 ++ return size / sizeof(xfs_agblock_t);
1201 ++}
1202 ++
1203 + unsigned int
1204 + xfs_refc_block(
1205 + struct xfs_mount *mp)
1206 +@@ -550,7 +567,7 @@ xfs_agfl_verify(
1207 + if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
1208 + return __this_address;
1209 +
1210 +- for (i = 0; i < XFS_AGFL_SIZE(mp); i++) {
1211 ++ for (i = 0; i < xfs_agfl_size(mp); i++) {
1212 + if (be32_to_cpu(agfl->agfl_bno[i]) != NULLAGBLOCK &&
1213 + be32_to_cpu(agfl->agfl_bno[i]) >= mp->m_sb.sb_agblocks)
1214 + return __this_address;
1215 +@@ -2053,6 +2070,93 @@ xfs_alloc_space_available(
1216 + return true;
1217 + }
1218 +
1219 ++/*
1220 ++ * Check the agfl fields of the agf for inconsistency or corruption. The purpose
1221 ++ * is to detect an agfl header padding mismatch between current and early v5
1222 ++ * kernels. This problem manifests as a 1-slot size difference between the
1223 ++ * on-disk flcount and the active [first, last] range of a wrapped agfl. This
1224 ++ * may also catch variants of agfl count corruption unrelated to padding. Either
1225 ++ * way, we'll reset the agfl and warn the user.
1226 ++ *
1227 ++ * Return true if a reset is required before the agfl can be used, false
1228 ++ * otherwise.
1229 ++ */
1230 ++static bool
1231 ++xfs_agfl_needs_reset(
1232 ++ struct xfs_mount *mp,
1233 ++ struct xfs_agf *agf)
1234 ++{
1235 ++ uint32_t f = be32_to_cpu(agf->agf_flfirst);
1236 ++ uint32_t l = be32_to_cpu(agf->agf_fllast);
1237 ++ uint32_t c = be32_to_cpu(agf->agf_flcount);
1238 ++ int agfl_size = xfs_agfl_size(mp);
1239 ++ int active;
1240 ++
1241 ++ /* no agfl header on v4 supers */
1242 ++ if (!xfs_sb_version_hascrc(&mp->m_sb))
1243 ++ return false;
1244 ++
1245 ++ /*
1246 ++ * The agf read verifier catches severe corruption of these fields.
1247 ++ * Repeat some sanity checks to cover a packed -> unpacked mismatch if
1248 ++ * the verifier allows it.
1249 ++ */
1250 ++ if (f >= agfl_size || l >= agfl_size)
1251 ++ return true;
1252 ++ if (c > agfl_size)
1253 ++ return true;
1254 ++
1255 ++ /*
1256 ++ * Check consistency between the on-disk count and the active range. An
1257 ++ * agfl padding mismatch manifests as an inconsistent flcount.
1258 ++ */
1259 ++ if (c && l >= f)
1260 ++ active = l - f + 1;
1261 ++ else if (c)
1262 ++ active = agfl_size - f + l + 1;
1263 ++ else
1264 ++ active = 0;
1265 ++
1266 ++ return active != c;
1267 ++}
1268 ++
1269 ++/*
1270 ++ * Reset the agfl to an empty state. Ignore/drop any existing blocks since the
1271 ++ * agfl content cannot be trusted. Warn the user that a repair is required to
1272 ++ * recover leaked blocks.
1273 ++ *
1274 ++ * The purpose of this mechanism is to handle filesystems affected by the agfl
1275 ++ * header padding mismatch problem. A reset keeps the filesystem online with a
1276 ++ * relatively minor free space accounting inconsistency rather than suffer the
1277 ++ * inevitable crash from use of an invalid agfl block.
1278 ++ */
1279 ++static void
1280 ++xfs_agfl_reset(
1281 ++ struct xfs_trans *tp,
1282 ++ struct xfs_buf *agbp,
1283 ++ struct xfs_perag *pag)
1284 ++{
1285 ++ struct xfs_mount *mp = tp->t_mountp;
1286 ++ struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
1287 ++
1288 ++ ASSERT(pag->pagf_agflreset);
1289 ++ trace_xfs_agfl_reset(mp, agf, 0, _RET_IP_);
1290 ++
1291 ++ xfs_warn(mp,
1292 ++ "WARNING: Reset corrupted AGFL on AG %u. %d blocks leaked. "
1293 ++ "Please unmount and run xfs_repair.",
1294 ++ pag->pag_agno, pag->pagf_flcount);
1295 ++
1296 ++ agf->agf_flfirst = 0;
1297 ++ agf->agf_fllast = cpu_to_be32(xfs_agfl_size(mp) - 1);
1298 ++ agf->agf_flcount = 0;
1299 ++ xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLFIRST | XFS_AGF_FLLAST |
1300 ++ XFS_AGF_FLCOUNT);
1301 ++
1302 ++ pag->pagf_flcount = 0;
1303 ++ pag->pagf_agflreset = false;
1304 ++}
1305 ++
1306 + /*
1307 + * Decide whether to use this allocation group for this allocation.
1308 + * If so, fix up the btree freelist's size.
1309 +@@ -2114,6 +2218,10 @@ xfs_alloc_fix_freelist(
1310 + }
1311 + }
1312 +
1313 ++ /* reset a padding mismatched agfl before final free space check */
1314 ++ if (pag->pagf_agflreset)
1315 ++ xfs_agfl_reset(tp, agbp, pag);
1316 ++
1317 + /* If there isn't enough total space or single-extent, reject it. */
1318 + need = xfs_alloc_min_freelist(mp, pag);
1319 + if (!xfs_alloc_space_available(args, need, flags))
1320 +@@ -2266,10 +2374,11 @@ xfs_alloc_get_freelist(
1321 + bno = be32_to_cpu(agfl_bno[be32_to_cpu(agf->agf_flfirst)]);
1322 + be32_add_cpu(&agf->agf_flfirst, 1);
1323 + xfs_trans_brelse(tp, agflbp);
1324 +- if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp))
1325 ++ if (be32_to_cpu(agf->agf_flfirst) == xfs_agfl_size(mp))
1326 + agf->agf_flfirst = 0;
1327 +
1328 + pag = xfs_perag_get(mp, be32_to_cpu(agf->agf_seqno));
1329 ++ ASSERT(!pag->pagf_agflreset);
1330 + be32_add_cpu(&agf->agf_flcount, -1);
1331 + xfs_trans_agflist_delta(tp, -1);
1332 + pag->pagf_flcount--;
1333 +@@ -2377,10 +2486,11 @@ xfs_alloc_put_freelist(
1334 + be32_to_cpu(agf->agf_seqno), &agflbp)))
1335 + return error;
1336 + be32_add_cpu(&agf->agf_fllast, 1);
1337 +- if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp))
1338 ++ if (be32_to_cpu(agf->agf_fllast) == xfs_agfl_size(mp))
1339 + agf->agf_fllast = 0;
1340 +
1341 + pag = xfs_perag_get(mp, be32_to_cpu(agf->agf_seqno));
1342 ++ ASSERT(!pag->pagf_agflreset);
1343 + be32_add_cpu(&agf->agf_flcount, 1);
1344 + xfs_trans_agflist_delta(tp, 1);
1345 + pag->pagf_flcount++;
1346 +@@ -2395,7 +2505,7 @@ xfs_alloc_put_freelist(
1347 +
1348 + xfs_alloc_log_agf(tp, agbp, logflags);
1349 +
1350 +- ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
1351 ++ ASSERT(be32_to_cpu(agf->agf_flcount) <= xfs_agfl_size(mp));
1352 +
1353 + agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
1354 + blockp = &agfl_bno[be32_to_cpu(agf->agf_fllast)];
1355 +@@ -2428,9 +2538,9 @@ xfs_agf_verify(
1356 + if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) &&
1357 + XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
1358 + be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
1359 +- be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) &&
1360 +- be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) &&
1361 +- be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)))
1362 ++ be32_to_cpu(agf->agf_flfirst) < xfs_agfl_size(mp) &&
1363 ++ be32_to_cpu(agf->agf_fllast) < xfs_agfl_size(mp) &&
1364 ++ be32_to_cpu(agf->agf_flcount) <= xfs_agfl_size(mp)))
1365 + return __this_address;
1366 +
1367 + if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 ||
1368 +@@ -2588,6 +2698,7 @@ xfs_alloc_read_agf(
1369 + pag->pagb_count = 0;
1370 + pag->pagb_tree = RB_ROOT;
1371 + pag->pagf_init = 1;
1372 ++ pag->pagf_agflreset = xfs_agfl_needs_reset(mp, agf);
1373 + }
1374 + #ifdef DEBUG
1375 + else if (!XFS_FORCED_SHUTDOWN(mp)) {
1376 +diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
1377 +index 65a0cafe06e4..a311a2414a6b 100644
1378 +--- a/fs/xfs/libxfs/xfs_alloc.h
1379 ++++ b/fs/xfs/libxfs/xfs_alloc.h
1380 +@@ -26,6 +26,8 @@ struct xfs_trans;
1381 +
1382 + extern struct workqueue_struct *xfs_alloc_wq;
1383 +
1384 ++unsigned int xfs_agfl_size(struct xfs_mount *mp);
1385 ++
1386 + /*
1387 + * Freespace allocation types. Argument to xfs_alloc_[v]extent.
1388 + */
1389 +diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
1390 +index 1acb584fc5f7..42956d8d95ed 100644
1391 +--- a/fs/xfs/libxfs/xfs_format.h
1392 ++++ b/fs/xfs/libxfs/xfs_format.h
1393 +@@ -803,24 +803,13 @@ typedef struct xfs_agi {
1394 + &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
1395 + (__be32 *)(bp)->b_addr)
1396 +
1397 +-/*
1398 +- * Size of the AGFL. For CRC-enabled filesystes we steal a couple of
1399 +- * slots in the beginning of the block for a proper header with the
1400 +- * location information and CRC.
1401 +- */
1402 +-#define XFS_AGFL_SIZE(mp) \
1403 +- (((mp)->m_sb.sb_sectsize - \
1404 +- (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
1405 +- sizeof(struct xfs_agfl) : 0)) / \
1406 +- sizeof(xfs_agblock_t))
1407 +-
1408 + typedef struct xfs_agfl {
1409 + __be32 agfl_magicnum;
1410 + __be32 agfl_seqno;
1411 + uuid_t agfl_uuid;
1412 + __be64 agfl_lsn;
1413 + __be32 agfl_crc;
1414 +- __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */
1415 ++ __be32 agfl_bno[]; /* actually xfs_agfl_size(mp) */
1416 + } __attribute__((packed)) xfs_agfl_t;
1417 +
1418 + #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc)
1419 +diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
1420 +index 05c66e05ae20..018aabbd9394 100644
1421 +--- a/fs/xfs/scrub/agheader.c
1422 ++++ b/fs/xfs/scrub/agheader.c
1423 +@@ -80,7 +80,7 @@ xfs_scrub_walk_agfl(
1424 + }
1425 +
1426 + /* first to the end */
1427 +- for (i = flfirst; i < XFS_AGFL_SIZE(mp); i++) {
1428 ++ for (i = flfirst; i < xfs_agfl_size(mp); i++) {
1429 + error = fn(sc, be32_to_cpu(agfl_bno[i]), priv);
1430 + if (error)
1431 + return error;
1432 +@@ -664,7 +664,7 @@ xfs_scrub_agf(
1433 + if (agfl_last > agfl_first)
1434 + fl_count = agfl_last - agfl_first + 1;
1435 + else
1436 +- fl_count = XFS_AGFL_SIZE(mp) - agfl_first + agfl_last + 1;
1437 ++ fl_count = xfs_agfl_size(mp) - agfl_first + agfl_last + 1;
1438 + if (agfl_count != 0 && fl_count != agfl_count)
1439 + xfs_scrub_block_set_corrupt(sc, sc->sa.agf_bp);
1440 +
1441 +@@ -791,7 +791,7 @@ xfs_scrub_agfl(
1442 + /* Allocate buffer to ensure uniqueness of AGFL entries. */
1443 + agf = XFS_BUF_TO_AGF(sc->sa.agf_bp);
1444 + agflcount = be32_to_cpu(agf->agf_flcount);
1445 +- if (agflcount > XFS_AGFL_SIZE(sc->mp)) {
1446 ++ if (agflcount > xfs_agfl_size(sc->mp)) {
1447 + xfs_scrub_block_set_corrupt(sc, sc->sa.agf_bp);
1448 + goto out;
1449 + }
1450 +diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
1451 +index 8b4545623e25..523792768080 100644
1452 +--- a/fs/xfs/xfs_fsops.c
1453 ++++ b/fs/xfs/xfs_fsops.c
1454 +@@ -217,7 +217,7 @@ xfs_growfs_data_private(
1455 + }
1456 +
1457 + agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, bp);
1458 +- for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
1459 ++ for (bucket = 0; bucket < xfs_agfl_size(mp); bucket++)
1460 + agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
1461 +
1462 + error = xfs_bwrite(bp);
1463 +diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
1464 +index e0792d036be2..d359a88ea249 100644
1465 +--- a/fs/xfs/xfs_mount.h
1466 ++++ b/fs/xfs/xfs_mount.h
1467 +@@ -353,6 +353,7 @@ typedef struct xfs_perag {
1468 + char pagi_inodeok; /* The agi is ok for inodes */
1469 + uint8_t pagf_levels[XFS_BTNUM_AGF];
1470 + /* # of levels in bno & cnt btree */
1471 ++ bool pagf_agflreset; /* agfl requires reset before use */
1472 + uint32_t pagf_flcount; /* count of blocks in freelist */
1473 + xfs_extlen_t pagf_freeblks; /* total free blocks */
1474 + xfs_extlen_t pagf_longest; /* longest free space */
1475 +diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
1476 +index 945de08af7ba..a982c0b623d0 100644
1477 +--- a/fs/xfs/xfs_trace.h
1478 ++++ b/fs/xfs/xfs_trace.h
1479 +@@ -1477,7 +1477,7 @@ TRACE_EVENT(xfs_extent_busy_trim,
1480 + __entry->tlen)
1481 + );
1482 +
1483 +-TRACE_EVENT(xfs_agf,
1484 ++DECLARE_EVENT_CLASS(xfs_agf_class,
1485 + TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
1486 + unsigned long caller_ip),
1487 + TP_ARGS(mp, agf, flags, caller_ip),
1488 +@@ -1533,6 +1533,13 @@ TRACE_EVENT(xfs_agf,
1489 + __entry->longest,
1490 + (void *)__entry->caller_ip)
1491 + );
1492 ++#define DEFINE_AGF_EVENT(name) \
1493 ++DEFINE_EVENT(xfs_agf_class, name, \
1494 ++ TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, \
1495 ++ unsigned long caller_ip), \
1496 ++ TP_ARGS(mp, agf, flags, caller_ip))
1497 ++DEFINE_AGF_EVENT(xfs_agf);
1498 ++DEFINE_AGF_EVENT(xfs_agfl_reset);
1499 +
1500 + TRACE_EVENT(xfs_free_extent,
1501 + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1502 +diff --git a/include/linux/iio/buffer_impl.h b/include/linux/iio/buffer_impl.h
1503 +index b9e22b7e2f28..d1171db23742 100644
1504 +--- a/include/linux/iio/buffer_impl.h
1505 ++++ b/include/linux/iio/buffer_impl.h
1506 +@@ -53,7 +53,7 @@ struct iio_buffer_access_funcs {
1507 + int (*request_update)(struct iio_buffer *buffer);
1508 +
1509 + int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
1510 +- int (*set_length)(struct iio_buffer *buffer, int length);
1511 ++ int (*set_length)(struct iio_buffer *buffer, unsigned int length);
1512 +
1513 + int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
1514 + int (*disable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
1515 +@@ -72,10 +72,10 @@ struct iio_buffer_access_funcs {
1516 + */
1517 + struct iio_buffer {
1518 + /** @length: Number of datums in buffer. */
1519 +- int length;
1520 ++ unsigned int length;
1521 +
1522 + /** @bytes_per_datum: Size of individual datum including timestamp. */
1523 +- int bytes_per_datum;
1524 ++ size_t bytes_per_datum;
1525 +
1526 + /**
1527 + * @access: Buffer access functions associated with the
1528 +diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
1529 +index 2e08c6f3ac3e..59dabe8e11aa 100644
1530 +--- a/include/uapi/linux/nl80211.h
1531 ++++ b/include/uapi/linux/nl80211.h
1532 +@@ -2618,7 +2618,7 @@ enum nl80211_attrs {
1533 + #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
1534 + #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
1535 +
1536 +-#define NL80211_WIPHY_NAME_MAXLEN 128
1537 ++#define NL80211_WIPHY_NAME_MAXLEN 64
1538 +
1539 + #define NL80211_MAX_SUPP_RATES 32
1540 + #define NL80211_MAX_SUPP_HT_RATES 77
1541 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
1542 +index 20a2300ae4e8..ed025da81714 100644
1543 +--- a/kernel/trace/trace.c
1544 ++++ b/kernel/trace/trace.c
1545 +@@ -892,7 +892,7 @@ int __trace_bputs(unsigned long ip, const char *str)
1546 + EXPORT_SYMBOL_GPL(__trace_bputs);
1547 +
1548 + #ifdef CONFIG_TRACER_SNAPSHOT
1549 +-static void tracing_snapshot_instance(struct trace_array *tr)
1550 ++void tracing_snapshot_instance(struct trace_array *tr)
1551 + {
1552 + struct tracer *tracer = tr->current_trace;
1553 + unsigned long flags;
1554 +@@ -948,7 +948,7 @@ static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
1555 + struct trace_buffer *size_buf, int cpu_id);
1556 + static void set_buffer_entries(struct trace_buffer *buf, unsigned long val);
1557 +
1558 +-static int alloc_snapshot(struct trace_array *tr)
1559 ++int tracing_alloc_snapshot_instance(struct trace_array *tr)
1560 + {
1561 + int ret;
1562 +
1563 +@@ -994,7 +994,7 @@ int tracing_alloc_snapshot(void)
1564 + struct trace_array *tr = &global_trace;
1565 + int ret;
1566 +
1567 +- ret = alloc_snapshot(tr);
1568 ++ ret = tracing_alloc_snapshot_instance(tr);
1569 + WARN_ON(ret < 0);
1570 +
1571 + return ret;
1572 +@@ -5395,7 +5395,7 @@ static int tracing_set_tracer(struct trace_array *tr, const char *buf)
1573 +
1574 + #ifdef CONFIG_TRACER_MAX_TRACE
1575 + if (t->use_max_tr && !had_max_tr) {
1576 +- ret = alloc_snapshot(tr);
1577 ++ ret = tracing_alloc_snapshot_instance(tr);
1578 + if (ret < 0)
1579 + goto out;
1580 + }
1581 +@@ -6373,7 +6373,7 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
1582 + }
1583 + #endif
1584 + if (!tr->allocated_snapshot) {
1585 +- ret = alloc_snapshot(tr);
1586 ++ ret = tracing_alloc_snapshot_instance(tr);
1587 + if (ret < 0)
1588 + break;
1589 + }
1590 +@@ -7094,7 +7094,7 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
1591 + return ret;
1592 +
1593 + out_reg:
1594 +- ret = alloc_snapshot(tr);
1595 ++ ret = tracing_alloc_snapshot_instance(tr);
1596 + if (ret < 0)
1597 + goto out;
1598 +
1599 +diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
1600 +index 2a6d0325a761..6092711bd0aa 100644
1601 +--- a/kernel/trace/trace.h
1602 ++++ b/kernel/trace/trace.h
1603 +@@ -1812,6 +1812,17 @@ static inline void __init trace_event_init(void) { }
1604 + static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { }
1605 + #endif
1606 +
1607 ++#ifdef CONFIG_TRACER_SNAPSHOT
1608 ++void tracing_snapshot_instance(struct trace_array *tr);
1609 ++int tracing_alloc_snapshot_instance(struct trace_array *tr);
1610 ++#else
1611 ++static inline void tracing_snapshot_instance(struct trace_array *tr) { }
1612 ++static inline int tracing_alloc_snapshot_instance(struct trace_array *tr)
1613 ++{
1614 ++ return 0;
1615 ++}
1616 ++#endif
1617 ++
1618 + extern struct trace_iterator *tracepoint_print_iter;
1619 +
1620 + #endif /* _LINUX_KERNEL_TRACE_H */
1621 +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
1622 +index 87411482a46f..ece7b7e8e96d 100644
1623 +--- a/kernel/trace/trace_events_trigger.c
1624 ++++ b/kernel/trace/trace_events_trigger.c
1625 +@@ -482,9 +482,10 @@ clear_event_triggers(struct trace_array *tr)
1626 + struct trace_event_file *file;
1627 +
1628 + list_for_each_entry(file, &tr->events, list) {
1629 +- struct event_trigger_data *data;
1630 +- list_for_each_entry_rcu(data, &file->triggers, list) {
1631 ++ struct event_trigger_data *data, *n;
1632 ++ list_for_each_entry_safe(data, n, &file->triggers, list) {
1633 + trace_event_trigger_enable_disable(file, 0);
1634 ++ list_del_rcu(&data->list);
1635 + if (data->ops->free)
1636 + data->ops->free(data->ops, data);
1637 + }
1638 +@@ -641,6 +642,7 @@ event_trigger_callback(struct event_command *cmd_ops,
1639 + trigger_data->count = -1;
1640 + trigger_data->ops = trigger_ops;
1641 + trigger_data->cmd_ops = cmd_ops;
1642 ++ trigger_data->private_data = file;
1643 + INIT_LIST_HEAD(&trigger_data->list);
1644 + INIT_LIST_HEAD(&trigger_data->named_list);
1645 +
1646 +@@ -1041,7 +1043,12 @@ static struct event_command trigger_traceoff_cmd = {
1647 + static void
1648 + snapshot_trigger(struct event_trigger_data *data, void *rec)
1649 + {
1650 +- tracing_snapshot();
1651 ++ struct trace_event_file *file = data->private_data;
1652 ++
1653 ++ if (file)
1654 ++ tracing_snapshot_instance(file->tr);
1655 ++ else
1656 ++ tracing_snapshot();
1657 + }
1658 +
1659 + static void
1660 +@@ -1063,7 +1070,7 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
1661 + {
1662 + int ret = register_trigger(glob, ops, data, file);
1663 +
1664 +- if (ret > 0 && tracing_alloc_snapshot() != 0) {
1665 ++ if (ret > 0 && tracing_alloc_snapshot_instance(file->tr) != 0) {
1666 + unregister_trigger(glob, ops, data, file);
1667 + ret = 0;
1668 + }
1669 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
1670 +index 5a68730eebd6..82e8f5ad7c81 100644
1671 +--- a/mm/huge_memory.c
1672 ++++ b/mm/huge_memory.c
1673 +@@ -2432,7 +2432,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,
1674 + __split_huge_page_tail(head, i, lruvec, list);
1675 + /* Some pages can be beyond i_size: drop them from page cache */
1676 + if (head[i].index >= end) {
1677 +- __ClearPageDirty(head + i);
1678 ++ ClearPageDirty(head + i);
1679 + __delete_from_page_cache(head + i, NULL);
1680 + if (IS_ENABLED(CONFIG_SHMEM) && PageSwapBacked(head))
1681 + shmem_uncharge(head->mapping->host, 1);
1682 +diff --git a/mm/vmscan.c b/mm/vmscan.c
1683 +index a47621fa8496..f9ae07ef5ce8 100644
1684 +--- a/mm/vmscan.c
1685 ++++ b/mm/vmscan.c
1686 +@@ -1392,7 +1392,7 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode)
1687 + return ret;
1688 +
1689 + mapping = page_mapping(page);
1690 +- migrate_dirty = mapping && mapping->a_ops->migratepage;
1691 ++ migrate_dirty = !mapping || mapping->a_ops->migratepage;
1692 + unlock_page(page);
1693 + if (!migrate_dirty)
1694 + return ret;
1695 +diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
1696 +index 8900ea5cbabf..1dde563aff1d 100644
1697 +--- a/security/selinux/ss/services.c
1698 ++++ b/security/selinux/ss/services.c
1699 +@@ -1448,7 +1448,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
1700 + scontext_len, &context, def_sid);
1701 + if (rc == -EINVAL && force) {
1702 + context.str = str;
1703 +- context.len = scontext_len;
1704 ++ context.len = strlen(str) + 1;
1705 + str = NULL;
1706 + } else if (rc)
1707 + goto out_unlock;
1708 +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
1709 +index 5409f6f6c48d..3a31b238f885 100644
1710 +--- a/tools/objtool/check.c
1711 ++++ b/tools/objtool/check.c
1712 +@@ -59,6 +59,31 @@ static struct instruction *next_insn_same_sec(struct objtool_file *file,
1713 + return next;
1714 + }
1715 +
1716 ++static struct instruction *next_insn_same_func(struct objtool_file *file,
1717 ++ struct instruction *insn)
1718 ++{
1719 ++ struct instruction *next = list_next_entry(insn, list);
1720 ++ struct symbol *func = insn->func;
1721 ++
1722 ++ if (!func)
1723 ++ return NULL;
1724 ++
1725 ++ if (&next->list != &file->insn_list && next->func == func)
1726 ++ return next;
1727 ++
1728 ++ /* Check if we're already in the subfunction: */
1729 ++ if (func == func->cfunc)
1730 ++ return NULL;
1731 ++
1732 ++ /* Move to the subfunction: */
1733 ++ return find_insn(file, func->cfunc->sec, func->cfunc->offset);
1734 ++}
1735 ++
1736 ++#define func_for_each_insn_all(file, func, insn) \
1737 ++ for (insn = find_insn(file, func->sec, func->offset); \
1738 ++ insn; \
1739 ++ insn = next_insn_same_func(file, insn))
1740 ++
1741 + #define func_for_each_insn(file, func, insn) \
1742 + for (insn = find_insn(file, func->sec, func->offset); \
1743 + insn && &insn->list != &file->insn_list && \
1744 +@@ -149,10 +174,14 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func,
1745 + if (!strcmp(func->name, global_noreturns[i]))
1746 + return 1;
1747 +
1748 +- if (!func->sec)
1749 ++ if (!func->len)
1750 + return 0;
1751 +
1752 +- func_for_each_insn(file, func, insn) {
1753 ++ insn = find_insn(file, func->sec, func->offset);
1754 ++ if (!insn->func)
1755 ++ return 0;
1756 ++
1757 ++ func_for_each_insn_all(file, func, insn) {
1758 + empty = false;
1759 +
1760 + if (insn->type == INSN_RETURN)
1761 +@@ -167,35 +196,28 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func,
1762 + * case, the function's dead-end status depends on whether the target
1763 + * of the sibling call returns.
1764 + */
1765 +- func_for_each_insn(file, func, insn) {
1766 +- if (insn->sec != func->sec ||
1767 +- insn->offset >= func->offset + func->len)
1768 +- break;
1769 +-
1770 ++ func_for_each_insn_all(file, func, insn) {
1771 + if (insn->type == INSN_JUMP_UNCONDITIONAL) {
1772 + struct instruction *dest = insn->jump_dest;
1773 +- struct symbol *dest_func;
1774 +
1775 + if (!dest)
1776 + /* sibling call to another file */
1777 + return 0;
1778 +
1779 +- if (dest->sec != func->sec ||
1780 +- dest->offset < func->offset ||
1781 +- dest->offset >= func->offset + func->len) {
1782 +- /* local sibling call */
1783 +- dest_func = find_symbol_by_offset(dest->sec,
1784 +- dest->offset);
1785 +- if (!dest_func)
1786 +- continue;
1787 ++ if (dest->func && dest->func->pfunc != insn->func->pfunc) {
1788 +
1789 ++ /* local sibling call */
1790 + if (recursion == 5) {
1791 +- WARN_FUNC("infinite recursion (objtool bug!)",
1792 +- dest->sec, dest->offset);
1793 +- return -1;
1794 ++ /*
1795 ++ * Infinite recursion: two functions
1796 ++ * have sibling calls to each other.
1797 ++ * This is a very rare case. It means
1798 ++ * they aren't dead ends.
1799 ++ */
1800 ++ return 0;
1801 + }
1802 +
1803 +- return __dead_end_function(file, dest_func,
1804 ++ return __dead_end_function(file, dest->func,
1805 + recursion + 1);
1806 + }
1807 + }
1808 +@@ -422,7 +444,7 @@ static void add_ignores(struct objtool_file *file)
1809 + if (!ignore_func(file, func))
1810 + continue;
1811 +
1812 +- func_for_each_insn(file, func, insn)
1813 ++ func_for_each_insn_all(file, func, insn)
1814 + insn->ignore = true;
1815 + }
1816 + }
1817 +@@ -782,30 +804,35 @@ static int add_special_section_alts(struct objtool_file *file)
1818 + return ret;
1819 + }
1820 +
1821 +-static int add_switch_table(struct objtool_file *file, struct symbol *func,
1822 +- struct instruction *insn, struct rela *table,
1823 +- struct rela *next_table)
1824 ++static int add_switch_table(struct objtool_file *file, struct instruction *insn,
1825 ++ struct rela *table, struct rela *next_table)
1826 + {
1827 + struct rela *rela = table;
1828 + struct instruction *alt_insn;
1829 + struct alternative *alt;
1830 ++ struct symbol *pfunc = insn->func->pfunc;
1831 ++ unsigned int prev_offset = 0;
1832 +
1833 + list_for_each_entry_from(rela, &file->rodata->rela->rela_list, list) {
1834 + if (rela == next_table)
1835 + break;
1836 +
1837 +- if (rela->sym->sec != insn->sec ||
1838 +- rela->addend <= func->offset ||
1839 +- rela->addend >= func->offset + func->len)
1840 ++ /* Make sure the switch table entries are consecutive: */
1841 ++ if (prev_offset && rela->offset != prev_offset + 8)
1842 + break;
1843 +
1844 +- alt_insn = find_insn(file, insn->sec, rela->addend);
1845 +- if (!alt_insn) {
1846 +- WARN("%s: can't find instruction at %s+0x%x",
1847 +- file->rodata->rela->name, insn->sec->name,
1848 +- rela->addend);
1849 +- return -1;
1850 +- }
1851 ++ /* Detect function pointers from contiguous objects: */
1852 ++ if (rela->sym->sec == pfunc->sec &&
1853 ++ rela->addend == pfunc->offset)
1854 ++ break;
1855 ++
1856 ++ alt_insn = find_insn(file, rela->sym->sec, rela->addend);
1857 ++ if (!alt_insn)
1858 ++ break;
1859 ++
1860 ++ /* Make sure the jmp dest is in the function or subfunction: */
1861 ++ if (alt_insn->func->pfunc != pfunc)
1862 ++ break;
1863 +
1864 + alt = malloc(sizeof(*alt));
1865 + if (!alt) {
1866 +@@ -815,6 +842,13 @@ static int add_switch_table(struct objtool_file *file, struct symbol *func,
1867 +
1868 + alt->insn = alt_insn;
1869 + list_add_tail(&alt->list, &insn->alts);
1870 ++ prev_offset = rela->offset;
1871 ++ }
1872 ++
1873 ++ if (!prev_offset) {
1874 ++ WARN_FUNC("can't find switch jump table",
1875 ++ insn->sec, insn->offset);
1876 ++ return -1;
1877 + }
1878 +
1879 + return 0;
1880 +@@ -869,40 +903,21 @@ static struct rela *find_switch_table(struct objtool_file *file,
1881 + {
1882 + struct rela *text_rela, *rodata_rela;
1883 + struct instruction *orig_insn = insn;
1884 ++ unsigned long table_offset;
1885 +
1886 +- text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len);
1887 +- if (text_rela && text_rela->sym == file->rodata->sym) {
1888 +- /* case 1 */
1889 +- rodata_rela = find_rela_by_dest(file->rodata,
1890 +- text_rela->addend);
1891 +- if (rodata_rela)
1892 +- return rodata_rela;
1893 +-
1894 +- /* case 2 */
1895 +- rodata_rela = find_rela_by_dest(file->rodata,
1896 +- text_rela->addend + 4);
1897 +- if (!rodata_rela)
1898 +- return NULL;
1899 +-
1900 +- file->ignore_unreachables = true;
1901 +- return rodata_rela;
1902 +- }
1903 +-
1904 +- /* case 3 */
1905 + /*
1906 + * Backward search using the @first_jump_src links, these help avoid
1907 + * much of the 'in between' code. Which avoids us getting confused by
1908 + * it.
1909 + */
1910 +- for (insn = list_prev_entry(insn, list);
1911 +-
1912 ++ for (;
1913 + &insn->list != &file->insn_list &&
1914 + insn->sec == func->sec &&
1915 + insn->offset >= func->offset;
1916 +
1917 + insn = insn->first_jump_src ?: list_prev_entry(insn, list)) {
1918 +
1919 +- if (insn->type == INSN_JUMP_DYNAMIC)
1920 ++ if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC)
1921 + break;
1922 +
1923 + /* allow small jumps within the range */
1924 +@@ -918,18 +933,29 @@ static struct rela *find_switch_table(struct objtool_file *file,
1925 + if (!text_rela || text_rela->sym != file->rodata->sym)
1926 + continue;
1927 +
1928 ++ table_offset = text_rela->addend;
1929 ++ if (text_rela->type == R_X86_64_PC32)
1930 ++ table_offset += 4;
1931 ++
1932 + /*
1933 + * Make sure the .rodata address isn't associated with a
1934 + * symbol. gcc jump tables are anonymous data.
1935 + */
1936 +- if (find_symbol_containing(file->rodata, text_rela->addend))
1937 ++ if (find_symbol_containing(file->rodata, table_offset))
1938 + continue;
1939 +
1940 +- rodata_rela = find_rela_by_dest(file->rodata, text_rela->addend);
1941 +- if (!rodata_rela)
1942 +- continue;
1943 ++ rodata_rela = find_rela_by_dest(file->rodata, table_offset);
1944 ++ if (rodata_rela) {
1945 ++ /*
1946 ++ * Use of RIP-relative switch jumps is quite rare, and
1947 ++ * indicates a rare GCC quirk/bug which can leave dead
1948 ++ * code behind.
1949 ++ */
1950 ++ if (text_rela->type == R_X86_64_PC32)
1951 ++ file->ignore_unreachables = true;
1952 +
1953 +- return rodata_rela;
1954 ++ return rodata_rela;
1955 ++ }
1956 + }
1957 +
1958 + return NULL;
1959 +@@ -943,7 +969,7 @@ static int add_func_switch_tables(struct objtool_file *file,
1960 + struct rela *rela, *prev_rela = NULL;
1961 + int ret;
1962 +
1963 +- func_for_each_insn(file, func, insn) {
1964 ++ func_for_each_insn_all(file, func, insn) {
1965 + if (!last)
1966 + last = insn;
1967 +
1968 +@@ -974,8 +1000,7 @@ static int add_func_switch_tables(struct objtool_file *file,
1969 + * the beginning of another switch table in the same function.
1970 + */
1971 + if (prev_jump) {
1972 +- ret = add_switch_table(file, func, prev_jump, prev_rela,
1973 +- rela);
1974 ++ ret = add_switch_table(file, prev_jump, prev_rela, rela);
1975 + if (ret)
1976 + return ret;
1977 + }
1978 +@@ -985,7 +1010,7 @@ static int add_func_switch_tables(struct objtool_file *file,
1979 + }
1980 +
1981 + if (prev_jump) {
1982 +- ret = add_switch_table(file, func, prev_jump, prev_rela, NULL);
1983 ++ ret = add_switch_table(file, prev_jump, prev_rela, NULL);
1984 + if (ret)
1985 + return ret;
1986 + }
1987 +@@ -1749,15 +1774,13 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
1988 + while (1) {
1989 + next_insn = next_insn_same_sec(file, insn);
1990 +
1991 +-
1992 +- if (file->c_file && func && insn->func && func != insn->func) {
1993 ++ if (file->c_file && func && insn->func && func != insn->func->pfunc) {
1994 + WARN("%s() falls through to next function %s()",
1995 + func->name, insn->func->name);
1996 + return 1;
1997 + }
1998 +
1999 +- if (insn->func)
2000 +- func = insn->func;
2001 ++ func = insn->func ? insn->func->pfunc : NULL;
2002 +
2003 + if (func && insn->ignore) {
2004 + WARN_FUNC("BUG: why am I validating an ignored function?",
2005 +@@ -1778,7 +1801,7 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
2006 +
2007 + i = insn;
2008 + save_insn = NULL;
2009 +- func_for_each_insn_continue_reverse(file, func, i) {
2010 ++ func_for_each_insn_continue_reverse(file, insn->func, i) {
2011 + if (i->save) {
2012 + save_insn = i;
2013 + break;
2014 +@@ -1865,7 +1888,7 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
2015 + case INSN_JUMP_UNCONDITIONAL:
2016 + if (insn->jump_dest &&
2017 + (!func || !insn->jump_dest->func ||
2018 +- func == insn->jump_dest->func)) {
2019 ++ insn->jump_dest->func->pfunc == func)) {
2020 + ret = validate_branch(file, insn->jump_dest,
2021 + state);
2022 + if (ret)
2023 +@@ -2060,7 +2083,7 @@ static int validate_functions(struct objtool_file *file)
2024 +
2025 + for_each_sec(file, sec) {
2026 + list_for_each_entry(func, &sec->symbol_list, list) {
2027 +- if (func->type != STT_FUNC)
2028 ++ if (func->type != STT_FUNC || func->pfunc != func)
2029 + continue;
2030 +
2031 + insn = find_insn(file, sec, func->offset);
2032 +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
2033 +index c1c338661699..4e60e105583e 100644
2034 +--- a/tools/objtool/elf.c
2035 ++++ b/tools/objtool/elf.c
2036 +@@ -79,6 +79,19 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
2037 + return NULL;
2038 + }
2039 +
2040 ++struct symbol *find_symbol_by_name(struct elf *elf, const char *name)
2041 ++{
2042 ++ struct section *sec;
2043 ++ struct symbol *sym;
2044 ++
2045 ++ list_for_each_entry(sec, &elf->sections, list)
2046 ++ list_for_each_entry(sym, &sec->symbol_list, list)
2047 ++ if (!strcmp(sym->name, name))
2048 ++ return sym;
2049 ++
2050 ++ return NULL;
2051 ++}
2052 ++
2053 + struct symbol *find_symbol_containing(struct section *sec, unsigned long offset)
2054 + {
2055 + struct symbol *sym;
2056 +@@ -203,10 +216,11 @@ static int read_sections(struct elf *elf)
2057 +
2058 + static int read_symbols(struct elf *elf)
2059 + {
2060 +- struct section *symtab;
2061 +- struct symbol *sym;
2062 ++ struct section *symtab, *sec;
2063 ++ struct symbol *sym, *pfunc;
2064 + struct list_head *entry, *tmp;
2065 + int symbols_nr, i;
2066 ++ char *coldstr;
2067 +
2068 + symtab = find_section_by_name(elf, ".symtab");
2069 + if (!symtab) {
2070 +@@ -281,6 +295,30 @@ static int read_symbols(struct elf *elf)
2071 + hash_add(sym->sec->symbol_hash, &sym->hash, sym->idx);
2072 + }
2073 +
2074 ++ /* Create parent/child links for any cold subfunctions */
2075 ++ list_for_each_entry(sec, &elf->sections, list) {
2076 ++ list_for_each_entry(sym, &sec->symbol_list, list) {
2077 ++ if (sym->type != STT_FUNC)
2078 ++ continue;
2079 ++ sym->pfunc = sym->cfunc = sym;
2080 ++ coldstr = strstr(sym->name, ".cold.");
2081 ++ if (coldstr) {
2082 ++ coldstr[0] = '\0';
2083 ++ pfunc = find_symbol_by_name(elf, sym->name);
2084 ++ coldstr[0] = '.';
2085 ++
2086 ++ if (!pfunc) {
2087 ++ WARN("%s(): can't find parent function",
2088 ++ sym->name);
2089 ++ goto err;
2090 ++ }
2091 ++
2092 ++ sym->pfunc = pfunc;
2093 ++ pfunc->cfunc = sym;
2094 ++ }
2095 ++ }
2096 ++ }
2097 ++
2098 + return 0;
2099 +
2100 + err:
2101 +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
2102 +index d86e2ff14466..de5cd2ddded9 100644
2103 +--- a/tools/objtool/elf.h
2104 ++++ b/tools/objtool/elf.h
2105 +@@ -61,6 +61,7 @@ struct symbol {
2106 + unsigned char bind, type;
2107 + unsigned long offset;
2108 + unsigned int len;
2109 ++ struct symbol *pfunc, *cfunc;
2110 + };
2111 +
2112 + struct rela {
2113 +@@ -86,6 +87,7 @@ struct elf {
2114 + struct elf *elf_open(const char *name, int flags);
2115 + struct section *find_section_by_name(struct elf *elf, const char *name);
2116 + struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset);
2117 ++struct symbol *find_symbol_by_name(struct elf *elf, const char *name);
2118 + struct symbol *find_symbol_containing(struct section *sec, unsigned long offset);
2119 + struct rela *find_rela_by_dest(struct section *sec, unsigned long offset);
2120 + struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset,