Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Tue, 29 Oct 2019 14:00:29
Message-Id: 1572357542.ea39ab94c49422a3942982b14a59f641a194d2c2.mpagano@gentoo
1 commit: ea39ab94c49422a3942982b14a59f641a194d2c2
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Oct 11 17:01:55 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 29 13:59:02 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=ea39ab94
7
8 Linux patch 4.14.149
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1148_linux-4.14.149.patch | 2026 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2030 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 140c250..3bfe86d 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -635,6 +635,10 @@ Patch: 1147_linux-4.14.148.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.148
23
24 +Patch: 1148_linux-4.14.149.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.149
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/1148_linux-4.14.149.patch b/1148_linux-4.14.149.patch
33 new file mode 100644
34 index 0000000..15c4987
35 --- /dev/null
36 +++ b/1148_linux-4.14.149.patch
37 @@ -0,0 +1,2026 @@
38 +diff --git a/Makefile b/Makefile
39 +index feecefa13ca6..93c3467eeb8c 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 148
47 ++SUBLEVEL = 149
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
52 +index 3b7488fce3db..7de26809340a 100644
53 +--- a/arch/powerpc/kvm/book3s_hv.c
54 ++++ b/arch/powerpc/kvm/book3s_hv.c
55 +@@ -1356,7 +1356,14 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
56 + *val = get_reg_val(id, vcpu->arch.pspb);
57 + break;
58 + case KVM_REG_PPC_DPDES:
59 +- *val = get_reg_val(id, vcpu->arch.vcore->dpdes);
60 ++ /*
61 ++ * On POWER9, where we are emulating msgsndp etc.,
62 ++ * we return 1 bit for each vcpu, which can come from
63 ++ * either vcore->dpdes or doorbell_request.
64 ++ * On POWER8, doorbell_request is 0.
65 ++ */
66 ++ *val = get_reg_val(id, vcpu->arch.vcore->dpdes |
67 ++ vcpu->arch.doorbell_request);
68 + break;
69 + case KVM_REG_PPC_VTB:
70 + *val = get_reg_val(id, vcpu->arch.vcore->vtb);
71 +diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
72 +index 3c75eee45edf..46f99fc1901c 100644
73 +--- a/arch/powerpc/kvm/book3s_xive.c
74 ++++ b/arch/powerpc/kvm/book3s_xive.c
75 +@@ -1001,20 +1001,22 @@ void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
76 + /* Mask the VP IPI */
77 + xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
78 +
79 +- /* Disable the VP */
80 +- xive_native_disable_vp(xc->vp_id);
81 +-
82 +- /* Free the queues & associated interrupts */
83 ++ /* Free escalations */
84 + for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
85 +- struct xive_q *q = &xc->queues[i];
86 +-
87 +- /* Free the escalation irq */
88 + if (xc->esc_virq[i]) {
89 + free_irq(xc->esc_virq[i], vcpu);
90 + irq_dispose_mapping(xc->esc_virq[i]);
91 + kfree(xc->esc_virq_names[i]);
92 + }
93 +- /* Free the queue */
94 ++ }
95 ++
96 ++ /* Disable the VP */
97 ++ xive_native_disable_vp(xc->vp_id);
98 ++
99 ++ /* Free the queues */
100 ++ for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
101 ++ struct xive_q *q = &xc->queues[i];
102 ++
103 + xive_native_disable_queue(xc->vp_id, q, i);
104 + if (q->qpage) {
105 + free_pages((unsigned long)q->qpage,
106 +diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
107 +index 87687e46b48b..58c14749bb0c 100644
108 +--- a/arch/powerpc/mm/hash_utils_64.c
109 ++++ b/arch/powerpc/mm/hash_utils_64.c
110 +@@ -35,6 +35,7 @@
111 + #include <linux/memblock.h>
112 + #include <linux/context_tracking.h>
113 + #include <linux/libfdt.h>
114 ++#include <linux/cpu.h>
115 +
116 + #include <asm/debugfs.h>
117 + #include <asm/processor.h>
118 +@@ -1852,10 +1853,16 @@ static int hpt_order_get(void *data, u64 *val)
119 +
120 + static int hpt_order_set(void *data, u64 val)
121 + {
122 ++ int ret;
123 ++
124 + if (!mmu_hash_ops.resize_hpt)
125 + return -ENODEV;
126 +
127 +- return mmu_hash_ops.resize_hpt(val);
128 ++ cpus_read_lock();
129 ++ ret = mmu_hash_ops.resize_hpt(val);
130 ++ cpus_read_unlock();
131 ++
132 ++ return ret;
133 + }
134 +
135 + DEFINE_SIMPLE_ATTRIBUTE(fops_hpt_order, hpt_order_get, hpt_order_set, "%llu\n");
136 +diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
137 +index c8a743af6bf5..597fcbf7a39e 100644
138 +--- a/arch/powerpc/platforms/powernv/opal.c
139 ++++ b/arch/powerpc/platforms/powernv/opal.c
140 +@@ -617,7 +617,10 @@ static ssize_t symbol_map_read(struct file *fp, struct kobject *kobj,
141 + bin_attr->size);
142 + }
143 +
144 +-static BIN_ATTR_RO(symbol_map, 0);
145 ++static struct bin_attribute symbol_map_attr = {
146 ++ .attr = {.name = "symbol_map", .mode = 0400},
147 ++ .read = symbol_map_read
148 ++};
149 +
150 + static void opal_export_symmap(void)
151 + {
152 +@@ -634,10 +637,10 @@ static void opal_export_symmap(void)
153 + return;
154 +
155 + /* Setup attributes */
156 +- bin_attr_symbol_map.private = __va(be64_to_cpu(syms[0]));
157 +- bin_attr_symbol_map.size = be64_to_cpu(syms[1]);
158 ++ symbol_map_attr.private = __va(be64_to_cpu(syms[0]));
159 ++ symbol_map_attr.size = be64_to_cpu(syms[1]);
160 +
161 +- rc = sysfs_create_bin_file(opal_kobj, &bin_attr_symbol_map);
162 ++ rc = sysfs_create_bin_file(opal_kobj, &symbol_map_attr);
163 + if (rc)
164 + pr_warn("Error %d creating OPAL symbols file\n", rc);
165 + }
166 +diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
167 +index 55e97565ed2d..eb738ef57792 100644
168 +--- a/arch/powerpc/platforms/pseries/lpar.c
169 ++++ b/arch/powerpc/platforms/pseries/lpar.c
170 +@@ -643,7 +643,10 @@ static int pseries_lpar_resize_hpt_commit(void *data)
171 + return 0;
172 + }
173 +
174 +-/* Must be called in user context */
175 ++/*
176 ++ * Must be called in process context. The caller must hold the
177 ++ * cpus_lock.
178 ++ */
179 + static int pseries_lpar_resize_hpt(unsigned long shift)
180 + {
181 + struct hpt_resize_state state = {
182 +@@ -699,7 +702,8 @@ static int pseries_lpar_resize_hpt(unsigned long shift)
183 +
184 + t1 = ktime_get();
185 +
186 +- rc = stop_machine(pseries_lpar_resize_hpt_commit, &state, NULL);
187 ++ rc = stop_machine_cpuslocked(pseries_lpar_resize_hpt_commit,
188 ++ &state, NULL);
189 +
190 + t2 = ktime_get();
191 +
192 +diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
193 +index 7d4c5500c6c2..1bb7ea6afcf9 100644
194 +--- a/arch/s390/kernel/process.c
195 ++++ b/arch/s390/kernel/process.c
196 +@@ -185,20 +185,30 @@ unsigned long get_wchan(struct task_struct *p)
197 +
198 + if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p))
199 + return 0;
200 ++
201 ++ if (!try_get_task_stack(p))
202 ++ return 0;
203 ++
204 + low = task_stack_page(p);
205 + high = (struct stack_frame *) task_pt_regs(p);
206 + sf = (struct stack_frame *) p->thread.ksp;
207 +- if (sf <= low || sf > high)
208 +- return 0;
209 ++ if (sf <= low || sf > high) {
210 ++ return_address = 0;
211 ++ goto out;
212 ++ }
213 + for (count = 0; count < 16; count++) {
214 + sf = (struct stack_frame *) sf->back_chain;
215 +- if (sf <= low || sf > high)
216 +- return 0;
217 ++ if (sf <= low || sf > high) {
218 ++ return_address = 0;
219 ++ goto out;
220 ++ }
221 + return_address = sf->gprs[8];
222 + if (!in_sched_functions(return_address))
223 +- return return_address;
224 ++ goto out;
225 + }
226 +- return 0;
227 ++out:
228 ++ put_task_stack(p);
229 ++ return return_address;
230 + }
231 +
232 + unsigned long arch_align_stack(unsigned long sp)
233 +diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
234 +index ed0bdd220e1a..bd074acd0d1f 100644
235 +--- a/arch/s390/kernel/topology.c
236 ++++ b/arch/s390/kernel/topology.c
237 +@@ -300,7 +300,8 @@ int arch_update_cpu_topology(void)
238 + rc = __arch_update_cpu_topology();
239 + for_each_online_cpu(cpu) {
240 + dev = get_cpu_device(cpu);
241 +- kobject_uevent(&dev->kobj, KOBJ_CHANGE);
242 ++ if (dev)
243 ++ kobject_uevent(&dev->kobj, KOBJ_CHANGE);
244 + }
245 + return rc;
246 + }
247 +diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
248 +index a27fb640adbe..cab41bc2572f 100644
249 +--- a/arch/s390/kvm/kvm-s390.c
250 ++++ b/arch/s390/kvm/kvm-s390.c
251 +@@ -3658,7 +3658,7 @@ static long kvm_s390_guest_mem_op(struct kvm_vcpu *vcpu,
252 + const u64 supported_flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION
253 + | KVM_S390_MEMOP_F_CHECK_ONLY;
254 +
255 +- if (mop->flags & ~supported_flags)
256 ++ if (mop->flags & ~supported_flags || mop->ar >= NUM_ACRS || !mop->size)
257 + return -EINVAL;
258 +
259 + if (mop->size > MEM_OP_MAX_SIZE)
260 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
261 +index a5a77a19adf6..7784b02312ca 100644
262 +--- a/arch/x86/kvm/vmx.c
263 ++++ b/arch/x86/kvm/vmx.c
264 +@@ -8026,7 +8026,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
265 + /* _system ok, nested_vmx_check_permission has verified cpl=0 */
266 + if (kvm_write_guest_virt_system(vcpu, gva, &field_value,
267 + (is_long_mode(vcpu) ? 8 : 4),
268 +- NULL))
269 ++ &e))
270 + kvm_inject_page_fault(vcpu, &e);
271 + }
272 +
273 +diff --git a/crypto/skcipher.c b/crypto/skcipher.c
274 +index c5501404f145..915bbae3d5bc 100644
275 +--- a/crypto/skcipher.c
276 ++++ b/crypto/skcipher.c
277 +@@ -95,7 +95,7 @@ static inline u8 *skcipher_get_spot(u8 *start, unsigned int len)
278 + return max(start, end_page);
279 + }
280 +
281 +-static void skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
282 ++static int skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
283 + {
284 + u8 *addr;
285 +
286 +@@ -103,19 +103,21 @@ static void skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
287 + addr = skcipher_get_spot(addr, bsize);
288 + scatterwalk_copychunks(addr, &walk->out, bsize,
289 + (walk->flags & SKCIPHER_WALK_PHYS) ? 2 : 1);
290 ++ return 0;
291 + }
292 +
293 + int skcipher_walk_done(struct skcipher_walk *walk, int err)
294 + {
295 +- unsigned int n; /* bytes processed */
296 +- bool more;
297 ++ unsigned int n = walk->nbytes;
298 ++ unsigned int nbytes = 0;
299 +
300 +- if (unlikely(err < 0))
301 ++ if (!n)
302 + goto finish;
303 +
304 +- n = walk->nbytes - err;
305 +- walk->total -= n;
306 +- more = (walk->total != 0);
307 ++ if (likely(err >= 0)) {
308 ++ n -= err;
309 ++ nbytes = walk->total - n;
310 ++ }
311 +
312 + if (likely(!(walk->flags & (SKCIPHER_WALK_PHYS |
313 + SKCIPHER_WALK_SLOW |
314 +@@ -131,7 +133,7 @@ unmap_src:
315 + memcpy(walk->dst.virt.addr, walk->page, n);
316 + skcipher_unmap_dst(walk);
317 + } else if (unlikely(walk->flags & SKCIPHER_WALK_SLOW)) {
318 +- if (err) {
319 ++ if (err > 0) {
320 + /*
321 + * Didn't process all bytes. Either the algorithm is
322 + * broken, or this was the last step and it turned out
323 +@@ -139,27 +141,29 @@ unmap_src:
324 + * the algorithm requires it.
325 + */
326 + err = -EINVAL;
327 +- goto finish;
328 +- }
329 +- skcipher_done_slow(walk, n);
330 +- goto already_advanced;
331 ++ nbytes = 0;
332 ++ } else
333 ++ n = skcipher_done_slow(walk, n);
334 + }
335 +
336 ++ if (err > 0)
337 ++ err = 0;
338 ++
339 ++ walk->total = nbytes;
340 ++ walk->nbytes = 0;
341 ++
342 + scatterwalk_advance(&walk->in, n);
343 + scatterwalk_advance(&walk->out, n);
344 +-already_advanced:
345 +- scatterwalk_done(&walk->in, 0, more);
346 +- scatterwalk_done(&walk->out, 1, more);
347 ++ scatterwalk_done(&walk->in, 0, nbytes);
348 ++ scatterwalk_done(&walk->out, 1, nbytes);
349 +
350 +- if (more) {
351 ++ if (nbytes) {
352 + crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
353 + CRYPTO_TFM_REQ_MAY_SLEEP : 0);
354 + return skcipher_walk_next(walk);
355 + }
356 +- err = 0;
357 +-finish:
358 +- walk->nbytes = 0;
359 +
360 ++finish:
361 + /* Short-circuit for the common/fast path. */
362 + if (!((unsigned long)walk->buffer | (unsigned long)walk->page))
363 + goto out;
364 +diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
365 +index e4b049f281f5..a23460084955 100644
366 +--- a/drivers/block/nbd.c
367 ++++ b/drivers/block/nbd.c
368 +@@ -106,6 +106,7 @@ struct nbd_device {
369 + struct nbd_config *config;
370 + struct mutex config_lock;
371 + struct gendisk *disk;
372 ++ struct workqueue_struct *recv_workq;
373 +
374 + struct list_head list;
375 + struct task_struct *task_recv;
376 +@@ -132,9 +133,10 @@ static struct dentry *nbd_dbg_dir;
377 +
378 + #define NBD_MAGIC 0x68797548
379 +
380 ++#define NBD_DEF_BLKSIZE 1024
381 ++
382 + static unsigned int nbds_max = 16;
383 + static int max_part = 16;
384 +-static struct workqueue_struct *recv_workqueue;
385 + static int part_shift;
386 +
387 + static int nbd_dev_dbg_init(struct nbd_device *nbd);
388 +@@ -1013,7 +1015,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
389 + /* We take the tx_mutex in an error path in the recv_work, so we
390 + * need to queue_work outside of the tx_mutex.
391 + */
392 +- queue_work(recv_workqueue, &args->work);
393 ++ queue_work(nbd->recv_workq, &args->work);
394 +
395 + atomic_inc(&config->live_connections);
396 + wake_up(&config->conn_wait);
397 +@@ -1118,6 +1120,10 @@ static void nbd_config_put(struct nbd_device *nbd)
398 + kfree(nbd->config);
399 + nbd->config = NULL;
400 +
401 ++ if (nbd->recv_workq)
402 ++ destroy_workqueue(nbd->recv_workq);
403 ++ nbd->recv_workq = NULL;
404 ++
405 + nbd->tag_set.timeout = 0;
406 + queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
407 +
408 +@@ -1143,6 +1149,14 @@ static int nbd_start_device(struct nbd_device *nbd)
409 + return -EINVAL;
410 + }
411 +
412 ++ nbd->recv_workq = alloc_workqueue("knbd%d-recv",
413 ++ WQ_MEM_RECLAIM | WQ_HIGHPRI |
414 ++ WQ_UNBOUND, 0, nbd->index);
415 ++ if (!nbd->recv_workq) {
416 ++ dev_err(disk_to_dev(nbd->disk), "Could not allocate knbd recv work queue.\n");
417 ++ return -ENOMEM;
418 ++ }
419 ++
420 + blk_mq_update_nr_hw_queues(&nbd->tag_set, config->num_connections);
421 + nbd->task_recv = current;
422 +
423 +@@ -1173,7 +1187,7 @@ static int nbd_start_device(struct nbd_device *nbd)
424 + INIT_WORK(&args->work, recv_work);
425 + args->nbd = nbd;
426 + args->index = i;
427 +- queue_work(recv_workqueue, &args->work);
428 ++ queue_work(nbd->recv_workq, &args->work);
429 + }
430 + nbd_size_update(nbd);
431 + return error;
432 +@@ -1193,8 +1207,10 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
433 + mutex_unlock(&nbd->config_lock);
434 + ret = wait_event_interruptible(config->recv_wq,
435 + atomic_read(&config->recv_threads) == 0);
436 +- if (ret)
437 ++ if (ret) {
438 + sock_shutdown(nbd);
439 ++ flush_workqueue(nbd->recv_workq);
440 ++ }
441 + mutex_lock(&nbd->config_lock);
442 + bd_set_size(bdev, 0);
443 + /* user requested, ignore socket errors */
444 +@@ -1216,6 +1232,14 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
445 + nbd_config_put(nbd);
446 + }
447 +
448 ++static bool nbd_is_valid_blksize(unsigned long blksize)
449 ++{
450 ++ if (!blksize || !is_power_of_2(blksize) || blksize < 512 ||
451 ++ blksize > PAGE_SIZE)
452 ++ return false;
453 ++ return true;
454 ++}
455 ++
456 + /* Must be called with config_lock held */
457 + static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
458 + unsigned int cmd, unsigned long arg)
459 +@@ -1231,8 +1255,9 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
460 + case NBD_SET_SOCK:
461 + return nbd_add_socket(nbd, arg, false);
462 + case NBD_SET_BLKSIZE:
463 +- if (!arg || !is_power_of_2(arg) || arg < 512 ||
464 +- arg > PAGE_SIZE)
465 ++ if (!arg)
466 ++ arg = NBD_DEF_BLKSIZE;
467 ++ if (!nbd_is_valid_blksize(arg))
468 + return -EINVAL;
469 + nbd_size_set(nbd, arg,
470 + div_s64(config->bytesize, arg));
471 +@@ -1312,7 +1337,7 @@ static struct nbd_config *nbd_alloc_config(void)
472 + atomic_set(&config->recv_threads, 0);
473 + init_waitqueue_head(&config->recv_wq);
474 + init_waitqueue_head(&config->conn_wait);
475 +- config->blksize = 1024;
476 ++ config->blksize = NBD_DEF_BLKSIZE;
477 + atomic_set(&config->live_connections, 0);
478 + try_module_get(THIS_MODULE);
479 + return config;
480 +@@ -1744,6 +1769,12 @@ again:
481 + if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]) {
482 + u64 bsize =
483 + nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
484 ++ if (!bsize)
485 ++ bsize = NBD_DEF_BLKSIZE;
486 ++ if (!nbd_is_valid_blksize(bsize)) {
487 ++ ret = -EINVAL;
488 ++ goto out;
489 ++ }
490 + nbd_size_set(nbd, bsize, div64_u64(config->bytesize, bsize));
491 + }
492 + if (info->attrs[NBD_ATTR_TIMEOUT]) {
493 +@@ -1819,6 +1850,12 @@ static void nbd_disconnect_and_put(struct nbd_device *nbd)
494 + mutex_lock(&nbd->config_lock);
495 + nbd_disconnect(nbd);
496 + mutex_unlock(&nbd->config_lock);
497 ++ /*
498 ++ * Make sure recv thread has finished, so it does not drop the last
499 ++ * config ref and try to destroy the workqueue from inside the work
500 ++ * queue.
501 ++ */
502 ++ flush_workqueue(nbd->recv_workq);
503 + if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
504 + &nbd->config->runtime_flags))
505 + nbd_config_put(nbd);
506 +@@ -2199,19 +2236,12 @@ static int __init nbd_init(void)
507 +
508 + if (nbds_max > 1UL << (MINORBITS - part_shift))
509 + return -EINVAL;
510 +- recv_workqueue = alloc_workqueue("knbd-recv",
511 +- WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
512 +- if (!recv_workqueue)
513 +- return -ENOMEM;
514 +
515 +- if (register_blkdev(NBD_MAJOR, "nbd")) {
516 +- destroy_workqueue(recv_workqueue);
517 ++ if (register_blkdev(NBD_MAJOR, "nbd"))
518 + return -EIO;
519 +- }
520 +
521 + if (genl_register_family(&nbd_genl_family)) {
522 + unregister_blkdev(NBD_MAJOR, "nbd");
523 +- destroy_workqueue(recv_workqueue);
524 + return -EINVAL;
525 + }
526 + nbd_dbg_init();
527 +@@ -2253,7 +2283,6 @@ static void __exit nbd_cleanup(void)
528 +
529 + idr_destroy(&nbd_index_idr);
530 + genl_unregister_family(&nbd_genl_family);
531 +- destroy_workqueue(recv_workqueue);
532 + unregister_blkdev(NBD_MAJOR, "nbd");
533 + }
534 +
535 +diff --git a/drivers/crypto/caam/caamalg_desc.c b/drivers/crypto/caam/caamalg_desc.c
536 +index 530c14ee32de..b23c7b72525c 100644
537 +--- a/drivers/crypto/caam/caamalg_desc.c
538 ++++ b/drivers/crypto/caam/caamalg_desc.c
539 +@@ -476,6 +476,7 @@ void cnstr_shdsc_aead_givencap(u32 * const desc, struct alginfo *cdata,
540 + const bool is_qi)
541 + {
542 + u32 geniv, moveiv;
543 ++ u32 *wait_cmd;
544 +
545 + /* Note: Context registers are saved. */
546 + init_sh_desc_key_aead(desc, cdata, adata, is_rfc3686, nonce);
547 +@@ -566,6 +567,14 @@ copy_iv:
548 +
549 + /* Will read cryptlen */
550 + append_math_add(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
551 ++
552 ++ /*
553 ++ * Wait for IV transfer (ofifo -> class2) to finish before starting
554 ++ * ciphertext transfer (ofifo -> external memory).
555 ++ */
556 ++ wait_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | JUMP_COND_NIFP);
557 ++ set_jump_tgt_here(desc, wait_cmd);
558 ++
559 + append_seq_fifo_load(desc, 0, FIFOLD_CLASS_BOTH | KEY_VLF |
560 + FIFOLD_TYPE_MSG1OUT2 | FIFOLD_TYPE_LASTBOTH);
561 + append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | KEY_VLF);
562 +diff --git a/drivers/crypto/caam/caamalg_desc.h b/drivers/crypto/caam/caamalg_desc.h
563 +index e412ec8f7005..9197b55d708a 100644
564 +--- a/drivers/crypto/caam/caamalg_desc.h
565 ++++ b/drivers/crypto/caam/caamalg_desc.h
566 +@@ -12,7 +12,7 @@
567 + #define DESC_AEAD_BASE (4 * CAAM_CMD_SZ)
568 + #define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 11 * CAAM_CMD_SZ)
569 + #define DESC_AEAD_DEC_LEN (DESC_AEAD_BASE + 15 * CAAM_CMD_SZ)
570 +-#define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 7 * CAAM_CMD_SZ)
571 ++#define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 8 * CAAM_CMD_SZ)
572 + #define DESC_QI_AEAD_ENC_LEN (DESC_AEAD_ENC_LEN + 3 * CAAM_CMD_SZ)
573 + #define DESC_QI_AEAD_DEC_LEN (DESC_AEAD_DEC_LEN + 3 * CAAM_CMD_SZ)
574 + #define DESC_QI_AEAD_GIVENC_LEN (DESC_AEAD_GIVENC_LEN + 3 * CAAM_CMD_SZ)
575 +diff --git a/drivers/crypto/cavium/zip/zip_main.c b/drivers/crypto/cavium/zip/zip_main.c
576 +index a6425a7afa7b..279ffdd8b53d 100644
577 +--- a/drivers/crypto/cavium/zip/zip_main.c
578 ++++ b/drivers/crypto/cavium/zip/zip_main.c
579 +@@ -595,6 +595,7 @@ static const struct file_operations zip_stats_fops = {
580 + .owner = THIS_MODULE,
581 + .open = zip_stats_open,
582 + .read = seq_read,
583 ++ .release = single_release,
584 + };
585 +
586 + static int zip_clear_open(struct inode *inode, struct file *file)
587 +@@ -606,6 +607,7 @@ static const struct file_operations zip_clear_fops = {
588 + .owner = THIS_MODULE,
589 + .open = zip_clear_open,
590 + .read = seq_read,
591 ++ .release = single_release,
592 + };
593 +
594 + static int zip_regs_open(struct inode *inode, struct file *file)
595 +@@ -617,6 +619,7 @@ static const struct file_operations zip_regs_fops = {
596 + .owner = THIS_MODULE,
597 + .open = zip_regs_open,
598 + .read = seq_read,
599 ++ .release = single_release,
600 + };
601 +
602 + /* Root directory for thunderx_zip debugfs entry */
603 +diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
604 +index 5c4c0a253129..d78f8d5c89c3 100644
605 +--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
606 ++++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
607 +@@ -95,7 +95,7 @@ struct service_hndl {
608 +
609 + static inline int get_current_node(void)
610 + {
611 +- return topology_physical_package_id(smp_processor_id());
612 ++ return topology_physical_package_id(raw_smp_processor_id());
613 + }
614 +
615 + int adf_service_register(struct service_hndl *service);
616 +diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
617 +index ae712159246f..6627a7dce95c 100644
618 +--- a/drivers/devfreq/tegra-devfreq.c
619 ++++ b/drivers/devfreq/tegra-devfreq.c
620 +@@ -485,11 +485,11 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
621 + {
622 + struct tegra_devfreq *tegra = dev_get_drvdata(dev);
623 + struct dev_pm_opp *opp;
624 +- unsigned long rate = *freq * KHZ;
625 ++ unsigned long rate;
626 +
627 +- opp = devfreq_recommended_opp(dev, &rate, flags);
628 ++ opp = devfreq_recommended_opp(dev, freq, flags);
629 + if (IS_ERR(opp)) {
630 +- dev_err(dev, "Failed to find opp for %lu KHz\n", *freq);
631 ++ dev_err(dev, "Failed to find opp for %lu Hz\n", *freq);
632 + return PTR_ERR(opp);
633 + }
634 + rate = dev_pm_opp_get_freq(opp);
635 +@@ -498,8 +498,6 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
636 + clk_set_min_rate(tegra->emc_clock, rate);
637 + clk_set_rate(tegra->emc_clock, 0);
638 +
639 +- *freq = rate;
640 +-
641 + return 0;
642 + }
643 +
644 +@@ -509,7 +507,7 @@ static int tegra_devfreq_get_dev_status(struct device *dev,
645 + struct tegra_devfreq *tegra = dev_get_drvdata(dev);
646 + struct tegra_devfreq_device *actmon_dev;
647 +
648 +- stat->current_frequency = tegra->cur_freq;
649 ++ stat->current_frequency = tegra->cur_freq * KHZ;
650 +
651 + /* To be used by the tegra governor */
652 + stat->private_data = tegra;
653 +@@ -564,7 +562,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,
654 + target_freq = max(target_freq, dev->target_freq);
655 + }
656 +
657 +- *freq = target_freq;
658 ++ *freq = target_freq * KHZ;
659 +
660 + return 0;
661 + }
662 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
663 +index e16229000a98..884ed359f249 100644
664 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
665 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
666 +@@ -540,6 +540,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
667 + if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
668 + sh_num = 0xffffffff;
669 +
670 ++ if (info->read_mmr_reg.count > 128)
671 ++ return -EINVAL;
672 ++
673 + regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL);
674 + if (!regs)
675 + return -ENOMEM;
676 +diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
677 +index 41ebb37aaa79..844e1142a122 100644
678 +--- a/drivers/gpu/drm/omapdrm/dss/dss.c
679 ++++ b/drivers/gpu/drm/omapdrm/dss/dss.c
680 +@@ -1100,7 +1100,7 @@ static const struct dss_features omap34xx_dss_feats = {
681 +
682 + static const struct dss_features omap3630_dss_feats = {
683 + .model = DSS_MODEL_OMAP3,
684 +- .fck_div_max = 32,
685 ++ .fck_div_max = 31,
686 + .fck_freq_max = 173000000,
687 + .dss_fck_multiplier = 1,
688 + .parent_clk_name = "dpll4_ck",
689 +diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
690 +index 78cb3b8881fa..b0141ba7b741 100644
691 +--- a/drivers/hwtracing/coresight/coresight-etm4x.c
692 ++++ b/drivers/hwtracing/coresight/coresight-etm4x.c
693 +@@ -181,6 +181,12 @@ static void etm4_enable_hw(void *info)
694 + if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0))
695 + dev_err(drvdata->dev,
696 + "timeout while waiting for Idle Trace Status\n");
697 ++ /*
698 ++ * As recommended by section 4.3.7 ("Synchronization when using the
699 ++ * memory-mapped interface") of ARM IHI 0064D
700 ++ */
701 ++ dsb(sy);
702 ++ isb();
703 +
704 + CS_LOCK(drvdata->base);
705 +
706 +@@ -331,8 +337,12 @@ static void etm4_disable_hw(void *info)
707 + /* EN, bit[0] Trace unit enable bit */
708 + control &= ~0x1;
709 +
710 +- /* make sure everything completes before disabling */
711 +- mb();
712 ++ /*
713 ++ * Make sure everything completes before disabling, as recommended
714 ++ * by section 7.3.77 ("TRCVICTLR, ViewInst Main Control Register,
715 ++ * SSTATUS") of ARM IHI 0064D
716 ++ */
717 ++ dsb(sy);
718 + isb();
719 + writel_relaxed(control, drvdata->base + TRCPRGCTLR);
720 +
721 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
722 +index bcfa84aa2113..176cbc67d08a 100644
723 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
724 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
725 +@@ -435,7 +435,12 @@ static int esdhc_of_enable_dma(struct sdhci_host *host)
726 + dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
727 +
728 + value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
729 +- value |= ESDHC_DMA_SNOOP;
730 ++
731 ++ if (of_dma_is_coherent(dev->of_node))
732 ++ value |= ESDHC_DMA_SNOOP;
733 ++ else
734 ++ value &= ~ESDHC_DMA_SNOOP;
735 ++
736 + sdhci_writel(host, value, ESDHC_DMA_SYSCTL);
737 + return 0;
738 + }
739 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
740 +index 3741d4c846e5..5807028c8309 100644
741 +--- a/drivers/mmc/host/sdhci.c
742 ++++ b/drivers/mmc/host/sdhci.c
743 +@@ -2638,6 +2638,7 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p)
744 + static void sdhci_adma_show_error(struct sdhci_host *host)
745 + {
746 + void *desc = host->adma_table;
747 ++ dma_addr_t dma = host->adma_addr;
748 +
749 + sdhci_dumpregs(host);
750 +
751 +@@ -2645,18 +2646,21 @@ static void sdhci_adma_show_error(struct sdhci_host *host)
752 + struct sdhci_adma2_64_desc *dma_desc = desc;
753 +
754 + if (host->flags & SDHCI_USE_64_BIT_DMA)
755 +- DBG("%p: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n",
756 +- desc, le32_to_cpu(dma_desc->addr_hi),
757 ++ SDHCI_DUMP("%08llx: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n",
758 ++ (unsigned long long)dma,
759 ++ le32_to_cpu(dma_desc->addr_hi),
760 + le32_to_cpu(dma_desc->addr_lo),
761 + le16_to_cpu(dma_desc->len),
762 + le16_to_cpu(dma_desc->cmd));
763 + else
764 +- DBG("%p: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n",
765 +- desc, le32_to_cpu(dma_desc->addr_lo),
766 ++ SDHCI_DUMP("%08llx: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n",
767 ++ (unsigned long long)dma,
768 ++ le32_to_cpu(dma_desc->addr_lo),
769 + le16_to_cpu(dma_desc->len),
770 + le16_to_cpu(dma_desc->cmd));
771 +
772 + desc += host->desc_sz;
773 ++ dma += host->desc_sz;
774 +
775 + if (dma_desc->cmd & cpu_to_le16(ADMA2_END))
776 + break;
777 +@@ -2732,7 +2736,8 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
778 + != MMC_BUS_TEST_R)
779 + host->data->error = -EILSEQ;
780 + else if (intmask & SDHCI_INT_ADMA_ERROR) {
781 +- pr_err("%s: ADMA error\n", mmc_hostname(host->mmc));
782 ++ pr_err("%s: ADMA error: 0x%08x\n", mmc_hostname(host->mmc),
783 ++ intmask);
784 + sdhci_adma_show_error(host);
785 + host->data->error = -EIO;
786 + if (host->ops->adma_workaround)
787 +diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
788 +index d8c448beab24..ec0b3d025867 100644
789 +--- a/drivers/net/can/spi/mcp251x.c
790 ++++ b/drivers/net/can/spi/mcp251x.c
791 +@@ -627,7 +627,7 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv,
792 + static int mcp251x_hw_reset(struct spi_device *spi)
793 + {
794 + struct mcp251x_priv *priv = spi_get_drvdata(spi);
795 +- u8 reg;
796 ++ unsigned long timeout;
797 + int ret;
798 +
799 + /* Wait for oscillator startup timer after power up */
800 +@@ -641,10 +641,19 @@ static int mcp251x_hw_reset(struct spi_device *spi)
801 + /* Wait for oscillator startup timer after reset */
802 + mdelay(MCP251X_OST_DELAY_MS);
803 +
804 +- reg = mcp251x_read_reg(spi, CANSTAT);
805 +- if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
806 +- return -ENODEV;
807 +-
808 ++ /* Wait for reset to finish */
809 ++ timeout = jiffies + HZ;
810 ++ while ((mcp251x_read_reg(spi, CANSTAT) & CANCTRL_REQOP_MASK) !=
811 ++ CANCTRL_REQOP_CONF) {
812 ++ usleep_range(MCP251X_OST_DELAY_MS * 1000,
813 ++ MCP251X_OST_DELAY_MS * 1000 * 2);
814 ++
815 ++ if (time_after(jiffies, timeout)) {
816 ++ dev_err(&spi->dev,
817 ++ "MCP251x didn't enter in conf mode after reset\n");
818 ++ return -EBUSY;
819 ++ }
820 ++ }
821 + return 0;
822 + }
823 +
824 +diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
825 +index ef688518ad77..8e2cbc88df98 100644
826 +--- a/drivers/net/ieee802154/atusb.c
827 ++++ b/drivers/net/ieee802154/atusb.c
828 +@@ -907,10 +907,11 @@ static void atusb_disconnect(struct usb_interface *interface)
829 +
830 + ieee802154_unregister_hw(atusb->hw);
831 +
832 ++ usb_put_dev(atusb->usb_dev);
833 ++
834 + ieee802154_free_hw(atusb->hw);
835 +
836 + usb_set_intfdata(interface, NULL);
837 +- usb_put_dev(atusb->usb_dev);
838 +
839 + pr_debug("atusb_disconnect done\n");
840 + }
841 +diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
842 +index 9793b296108f..3f2e4ef695d7 100644
843 +--- a/drivers/pwm/pwm-stm32-lp.c
844 ++++ b/drivers/pwm/pwm-stm32-lp.c
845 +@@ -59,6 +59,12 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm,
846 + /* Calculate the period and prescaler value */
847 + div = (unsigned long long)clk_get_rate(priv->clk) * state->period;
848 + do_div(div, NSEC_PER_SEC);
849 ++ if (!div) {
850 ++ /* Clock is too slow to achieve requested period. */
851 ++ dev_dbg(priv->chip.dev, "Can't reach %u ns\n", state->period);
852 ++ return -EINVAL;
853 ++ }
854 ++
855 + prd = div;
856 + while (div > STM32_LPTIM_MAX_ARR) {
857 + presc++;
858 +diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
859 +index 34b9ad6b3143..158b5ce45b3b 100644
860 +--- a/drivers/s390/cio/ccwgroup.c
861 ++++ b/drivers/s390/cio/ccwgroup.c
862 +@@ -369,7 +369,7 @@ int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
863 + goto error;
864 + }
865 + /* Check for trailing stuff. */
866 +- if (i == num_devices && strlen(buf) > 0) {
867 ++ if (i == num_devices && buf && strlen(buf) > 0) {
868 + rc = -EINVAL;
869 + goto error;
870 + }
871 +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
872 +index d3e504c3c362..dadff1838fec 100644
873 +--- a/drivers/s390/cio/css.c
874 ++++ b/drivers/s390/cio/css.c
875 +@@ -1178,6 +1178,8 @@ device_initcall(cio_settle_init);
876 +
877 + int sch_is_pseudo_sch(struct subchannel *sch)
878 + {
879 ++ if (!sch->dev.parent)
880 ++ return 0;
881 + return sch == to_css(sch->dev.parent)->pseudo_subchannel;
882 + }
883 +
884 +diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
885 +index 17d6079c7642..456ef213dc14 100644
886 +--- a/drivers/thermal/thermal_core.c
887 ++++ b/drivers/thermal/thermal_core.c
888 +@@ -299,7 +299,7 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
889 + mod_delayed_work(system_freezable_wq, &tz->poll_queue,
890 + msecs_to_jiffies(delay));
891 + else
892 +- cancel_delayed_work(&tz->poll_queue);
893 ++ cancel_delayed_work_sync(&tz->poll_queue);
894 + }
895 +
896 + static void monitor_thermal_zone(struct thermal_zone_device *tz)
897 +diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
898 +index fd91007b4e41..cee7334b2a00 100644
899 +--- a/drivers/watchdog/aspeed_wdt.c
900 ++++ b/drivers/watchdog/aspeed_wdt.c
901 +@@ -38,6 +38,7 @@ static const struct aspeed_wdt_config ast2500_config = {
902 + static const struct of_device_id aspeed_wdt_of_table[] = {
903 + { .compatible = "aspeed,ast2400-wdt", .data = &ast2400_config },
904 + { .compatible = "aspeed,ast2500-wdt", .data = &ast2500_config },
905 ++ { .compatible = "aspeed,ast2600-wdt", .data = &ast2500_config },
906 + { },
907 + };
908 + MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table);
909 +@@ -257,7 +258,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
910 + set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
911 + }
912 +
913 +- if (of_device_is_compatible(np, "aspeed,ast2500-wdt")) {
914 ++ if ((of_device_is_compatible(np, "aspeed,ast2500-wdt")) ||
915 ++ (of_device_is_compatible(np, "aspeed,ast2600-wdt"))) {
916 + u32 reg = readl(wdt->base + WDT_RESET_WIDTH);
917 +
918 + reg &= config->ext_pulse_width_mask;
919 +diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
920 +index 5098982e1a58..e5c162b05376 100644
921 +--- a/drivers/watchdog/imx2_wdt.c
922 ++++ b/drivers/watchdog/imx2_wdt.c
923 +@@ -58,7 +58,7 @@
924 +
925 + #define IMX2_WDT_WMCR 0x08 /* Misc Register */
926 +
927 +-#define IMX2_WDT_MAX_TIME 128
928 ++#define IMX2_WDT_MAX_TIME 128U
929 + #define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */
930 +
931 + #define WDOG_SEC_TO_COUNT(s) ((s * 2 - 1) << 8)
932 +@@ -183,7 +183,7 @@ static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
933 + {
934 + unsigned int actual;
935 +
936 +- actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
937 ++ actual = min(new_timeout, IMX2_WDT_MAX_TIME);
938 + __imx2_wdt_set_timeout(wdog, actual);
939 + wdog->timeout = new_timeout;
940 + return 0;
941 +diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c
942 +index 7494dbeb4409..db58aaa4dc59 100644
943 +--- a/drivers/xen/pci.c
944 ++++ b/drivers/xen/pci.c
945 +@@ -29,6 +29,8 @@
946 + #include "../pci/pci.h"
947 + #ifdef CONFIG_PCI_MMCONFIG
948 + #include <asm/pci_x86.h>
949 ++
950 ++static int xen_mcfg_late(void);
951 + #endif
952 +
953 + static bool __read_mostly pci_seg_supported = true;
954 +@@ -40,7 +42,18 @@ static int xen_add_device(struct device *dev)
955 + #ifdef CONFIG_PCI_IOV
956 + struct pci_dev *physfn = pci_dev->physfn;
957 + #endif
958 +-
959 ++#ifdef CONFIG_PCI_MMCONFIG
960 ++ static bool pci_mcfg_reserved = false;
961 ++ /*
962 ++ * Reserve MCFG areas in Xen on first invocation due to this being
963 ++ * potentially called from inside of acpi_init immediately after
964 ++ * MCFG table has been finally parsed.
965 ++ */
966 ++ if (!pci_mcfg_reserved) {
967 ++ xen_mcfg_late();
968 ++ pci_mcfg_reserved = true;
969 ++ }
970 ++#endif
971 + if (pci_seg_supported) {
972 + struct {
973 + struct physdev_pci_device_add add;
974 +@@ -213,7 +226,7 @@ static int __init register_xen_pci_notifier(void)
975 + arch_initcall(register_xen_pci_notifier);
976 +
977 + #ifdef CONFIG_PCI_MMCONFIG
978 +-static int __init xen_mcfg_late(void)
979 ++static int xen_mcfg_late(void)
980 + {
981 + struct pci_mmcfg_region *cfg;
982 + int rc;
983 +@@ -252,8 +265,4 @@ static int __init xen_mcfg_late(void)
984 + }
985 + return 0;
986 + }
987 +-/*
988 +- * Needs to be done after acpi_init which are subsys_initcall.
989 +- */
990 +-subsys_initcall_sync(xen_mcfg_late);
991 + #endif
992 +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
993 +index 53877e078a7b..6f59bd875a22 100644
994 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
995 ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
996 +@@ -55,6 +55,7 @@
997 + #include <linux/string.h>
998 + #include <linux/slab.h>
999 + #include <linux/miscdevice.h>
1000 ++#include <linux/workqueue.h>
1001 +
1002 + #include <xen/xenbus.h>
1003 + #include <xen/xen.h>
1004 +@@ -113,6 +114,8 @@ struct xenbus_file_priv {
1005 + wait_queue_head_t read_waitq;
1006 +
1007 + struct kref kref;
1008 ++
1009 ++ struct work_struct wq;
1010 + };
1011 +
1012 + /* Read out any raw xenbus messages queued up. */
1013 +@@ -297,14 +300,14 @@ static void watch_fired(struct xenbus_watch *watch,
1014 + mutex_unlock(&adap->dev_data->reply_mutex);
1015 + }
1016 +
1017 +-static void xenbus_file_free(struct kref *kref)
1018 ++static void xenbus_worker(struct work_struct *wq)
1019 + {
1020 + struct xenbus_file_priv *u;
1021 + struct xenbus_transaction_holder *trans, *tmp;
1022 + struct watch_adapter *watch, *tmp_watch;
1023 + struct read_buffer *rb, *tmp_rb;
1024 +
1025 +- u = container_of(kref, struct xenbus_file_priv, kref);
1026 ++ u = container_of(wq, struct xenbus_file_priv, wq);
1027 +
1028 + /*
1029 + * No need for locking here because there are no other users,
1030 +@@ -330,6 +333,18 @@ static void xenbus_file_free(struct kref *kref)
1031 + kfree(u);
1032 + }
1033 +
1034 ++static void xenbus_file_free(struct kref *kref)
1035 ++{
1036 ++ struct xenbus_file_priv *u;
1037 ++
1038 ++ /*
1039 ++ * We might be called in xenbus_thread().
1040 ++ * Use workqueue to avoid deadlock.
1041 ++ */
1042 ++ u = container_of(kref, struct xenbus_file_priv, kref);
1043 ++ schedule_work(&u->wq);
1044 ++}
1045 ++
1046 + static struct xenbus_transaction_holder *xenbus_get_transaction(
1047 + struct xenbus_file_priv *u, uint32_t tx_id)
1048 + {
1049 +@@ -626,6 +641,7 @@ static int xenbus_file_open(struct inode *inode, struct file *filp)
1050 + INIT_LIST_HEAD(&u->watches);
1051 + INIT_LIST_HEAD(&u->read_buffers);
1052 + init_waitqueue_head(&u->read_waitq);
1053 ++ INIT_WORK(&u->wq, xenbus_worker);
1054 +
1055 + mutex_init(&u->reply_mutex);
1056 + mutex_init(&u->msgbuffer_mutex);
1057 +diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
1058 +index 89e69904976a..2651192f0166 100644
1059 +--- a/fs/9p/vfs_file.c
1060 ++++ b/fs/9p/vfs_file.c
1061 +@@ -528,6 +528,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
1062 + v9inode = V9FS_I(inode);
1063 + mutex_lock(&v9inode->v_mutex);
1064 + if (!v9inode->writeback_fid &&
1065 ++ (vma->vm_flags & VM_SHARED) &&
1066 + (vma->vm_flags & VM_WRITE)) {
1067 + /*
1068 + * clone a fid and add it to writeback_fid
1069 +@@ -629,6 +630,8 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
1070 + (vma->vm_end - vma->vm_start - 1),
1071 + };
1072 +
1073 ++ if (!(vma->vm_flags & VM_SHARED))
1074 ++ return;
1075 +
1076 + p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
1077 +
1078 +diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
1079 +index 9bda8c7a80a0..879bc0825093 100644
1080 +--- a/fs/ceph/inode.c
1081 ++++ b/fs/ceph/inode.c
1082 +@@ -789,7 +789,12 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
1083 + ci->i_version = le64_to_cpu(info->version);
1084 + inode->i_version++;
1085 + inode->i_rdev = le32_to_cpu(info->rdev);
1086 +- inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
1087 ++ /* directories have fl_stripe_unit set to zero */
1088 ++ if (le32_to_cpu(info->layout.fl_stripe_unit))
1089 ++ inode->i_blkbits =
1090 ++ fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
1091 ++ else
1092 ++ inode->i_blkbits = CEPH_BLOCK_SHIFT;
1093 +
1094 + if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) &&
1095 + (issued & CEPH_CAP_AUTH_EXCL) == 0) {
1096 +diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
1097 +index e1ded4bd6115..b968334f841e 100644
1098 +--- a/fs/ceph/mds_client.c
1099 ++++ b/fs/ceph/mds_client.c
1100 +@@ -3543,7 +3543,9 @@ static void delayed_work(struct work_struct *work)
1101 + pr_info("mds%d hung\n", s->s_mds);
1102 + }
1103 + }
1104 +- if (s->s_state < CEPH_MDS_SESSION_OPEN) {
1105 ++ if (s->s_state == CEPH_MDS_SESSION_NEW ||
1106 ++ s->s_state == CEPH_MDS_SESSION_RESTARTING ||
1107 ++ s->s_state == CEPH_MDS_SESSION_REJECTED) {
1108 + /* this mds is failed or recovering, just wait */
1109 + ceph_put_mds_session(s);
1110 + continue;
1111 +diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
1112 +index e9e97803442a..55db06c7c587 100644
1113 +--- a/fs/fuse/cuse.c
1114 ++++ b/fs/fuse/cuse.c
1115 +@@ -513,6 +513,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
1116 + rc = cuse_send_init(cc);
1117 + if (rc) {
1118 + fuse_dev_free(fud);
1119 ++ fuse_conn_put(&cc->fc);
1120 + return rc;
1121 + }
1122 + file->private_data = fud;
1123 +diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
1124 +index 549c916d2859..525684b0056f 100644
1125 +--- a/fs/nfs/nfs4xdr.c
1126 ++++ b/fs/nfs/nfs4xdr.c
1127 +@@ -1132,7 +1132,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1128 + } else
1129 + *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1130 + }
1131 +- if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) {
1132 ++ if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) {
1133 + *p++ = cpu_to_be32(label->lfs);
1134 + *p++ = cpu_to_be32(label->pi);
1135 + *p++ = cpu_to_be32(label->len);
1136 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
1137 +index 96867fb159bf..ec04cce31814 100644
1138 +--- a/fs/nfs/pnfs.c
1139 ++++ b/fs/nfs/pnfs.c
1140 +@@ -1319,10 +1319,15 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
1141 + const nfs4_stateid *res_stateid = NULL;
1142 + struct nfs4_xdr_opaque_data *ld_private = args->ld_private;
1143 +
1144 +- if (ret == 0) {
1145 +- arg_stateid = &args->stateid;
1146 ++ switch (ret) {
1147 ++ case -NFS4ERR_NOMATCHING_LAYOUT:
1148 ++ break;
1149 ++ case 0:
1150 + if (res->lrs_present)
1151 + res_stateid = &res->stateid;
1152 ++ /* Fallthrough */
1153 ++ default:
1154 ++ arg_stateid = &args->stateid;
1155 + }
1156 + pnfs_layoutreturn_free_lsegs(lo, arg_stateid, &args->range,
1157 + res_stateid);
1158 +diff --git a/fs/statfs.c b/fs/statfs.c
1159 +index c25dd9a26cc1..ca1084cbe03c 100644
1160 +--- a/fs/statfs.c
1161 ++++ b/fs/statfs.c
1162 +@@ -304,19 +304,10 @@ COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *,
1163 + static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)
1164 + {
1165 + struct compat_statfs64 buf;
1166 +- if (sizeof(ubuf->f_bsize) == 4) {
1167 +- if ((kbuf->f_type | kbuf->f_bsize | kbuf->f_namelen |
1168 +- kbuf->f_frsize | kbuf->f_flags) & 0xffffffff00000000ULL)
1169 +- return -EOVERFLOW;
1170 +- /* f_files and f_ffree may be -1; it's okay
1171 +- * to stuff that into 32 bits */
1172 +- if (kbuf->f_files != 0xffffffffffffffffULL
1173 +- && (kbuf->f_files & 0xffffffff00000000ULL))
1174 +- return -EOVERFLOW;
1175 +- if (kbuf->f_ffree != 0xffffffffffffffffULL
1176 +- && (kbuf->f_ffree & 0xffffffff00000000ULL))
1177 +- return -EOVERFLOW;
1178 +- }
1179 ++
1180 ++ if ((kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL)
1181 ++ return -EOVERFLOW;
1182 ++
1183 + memset(&buf, 0, sizeof(struct compat_statfs64));
1184 + buf.f_type = kbuf->f_type;
1185 + buf.f_bsize = kbuf->f_bsize;
1186 +diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
1187 +index 55a604ad459f..2e179778576c 100644
1188 +--- a/include/linux/ieee80211.h
1189 ++++ b/include/linux/ieee80211.h
1190 +@@ -2743,4 +2743,57 @@ static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb)
1191 + return true;
1192 + }
1193 +
1194 ++struct element {
1195 ++ u8 id;
1196 ++ u8 datalen;
1197 ++ u8 data[];
1198 ++} __packed;
1199 ++
1200 ++/* element iteration helpers */
1201 ++#define for_each_element(_elem, _data, _datalen) \
1202 ++ for (_elem = (const struct element *)(_data); \
1203 ++ (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
1204 ++ (int)sizeof(*_elem) && \
1205 ++ (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
1206 ++ (int)sizeof(*_elem) + _elem->datalen; \
1207 ++ _elem = (const struct element *)(_elem->data + _elem->datalen))
1208 ++
1209 ++#define for_each_element_id(element, _id, data, datalen) \
1210 ++ for_each_element(element, data, datalen) \
1211 ++ if (element->id == (_id))
1212 ++
1213 ++#define for_each_element_extid(element, extid, data, datalen) \
1214 ++ for_each_element(element, data, datalen) \
1215 ++ if (element->id == WLAN_EID_EXTENSION && \
1216 ++ element->datalen > 0 && \
1217 ++ element->data[0] == (extid))
1218 ++
1219 ++#define for_each_subelement(sub, element) \
1220 ++ for_each_element(sub, (element)->data, (element)->datalen)
1221 ++
1222 ++#define for_each_subelement_id(sub, id, element) \
1223 ++ for_each_element_id(sub, id, (element)->data, (element)->datalen)
1224 ++
1225 ++#define for_each_subelement_extid(sub, extid, element) \
1226 ++ for_each_element_extid(sub, extid, (element)->data, (element)->datalen)
1227 ++
1228 ++/**
1229 ++ * for_each_element_completed - determine if element parsing consumed all data
1230 ++ * @element: element pointer after for_each_element() or friends
1231 ++ * @data: same data pointer as passed to for_each_element() or friends
1232 ++ * @datalen: same data length as passed to for_each_element() or friends
1233 ++ *
1234 ++ * This function returns %true if all the data was parsed or considered
1235 ++ * while walking the elements. Only use this if your for_each_element()
1236 ++ * loop cannot be broken out of, otherwise it always returns %false.
1237 ++ *
1238 ++ * If some data was malformed, this returns %false since the last parsed
1239 ++ * element will not fill the whole remaining data.
1240 ++ */
1241 ++static inline bool for_each_element_completed(const struct element *element,
1242 ++ const void *data, size_t datalen)
1243 ++{
1244 ++ return (const u8 *)element == (const u8 *)data + datalen;
1245 ++}
1246 ++
1247 + #endif /* LINUX_IEEE80211_H */
1248 +diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
1249 +index 344b96c206a3..14a35befad6c 100644
1250 +--- a/include/sound/soc-dapm.h
1251 ++++ b/include/sound/soc-dapm.h
1252 +@@ -349,6 +349,8 @@ struct device;
1253 + #define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */
1254 + #define SND_SOC_DAPM_PRE_POST_PMD \
1255 + (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)
1256 ++#define SND_SOC_DAPM_PRE_POST_PMU \
1257 ++ (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)
1258 +
1259 + /* convenience event type detection */
1260 + #define SND_SOC_DAPM_EVENT_ON(e) \
1261 +diff --git a/kernel/elfcore.c b/kernel/elfcore.c
1262 +index fc482c8e0bd8..57fb4dcff434 100644
1263 +--- a/kernel/elfcore.c
1264 ++++ b/kernel/elfcore.c
1265 +@@ -3,6 +3,7 @@
1266 + #include <linux/fs.h>
1267 + #include <linux/mm.h>
1268 + #include <linux/binfmts.h>
1269 ++#include <linux/elfcore.h>
1270 +
1271 + Elf_Half __weak elf_core_extra_phdrs(void)
1272 + {
1273 +diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
1274 +index 1e882dfc8b79..3a6aeae98a4a 100644
1275 +--- a/kernel/locking/qspinlock_paravirt.h
1276 ++++ b/kernel/locking/qspinlock_paravirt.h
1277 +@@ -247,7 +247,7 @@ pv_wait_early(struct pv_node *prev, int loop)
1278 + if ((loop & PV_PREV_CHECK_MASK) != 0)
1279 + return false;
1280 +
1281 +- return READ_ONCE(prev->state) != vcpu_running || vcpu_is_preempted(prev->cpu);
1282 ++ return READ_ONCE(prev->state) != vcpu_running;
1283 + }
1284 +
1285 + /*
1286 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
1287 +index 3d24d401b9d4..32ba789c544c 100644
1288 +--- a/kernel/sched/core.c
1289 ++++ b/kernel/sched/core.c
1290 +@@ -1111,7 +1111,8 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
1291 + if (cpumask_equal(&p->cpus_allowed, new_mask))
1292 + goto out;
1293 +
1294 +- if (!cpumask_intersects(new_mask, cpu_valid_mask)) {
1295 ++ dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
1296 ++ if (dest_cpu >= nr_cpu_ids) {
1297 + ret = -EINVAL;
1298 + goto out;
1299 + }
1300 +@@ -1132,7 +1133,6 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
1301 + if (cpumask_test_cpu(task_cpu(p), new_mask))
1302 + goto out;
1303 +
1304 +- dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
1305 + if (task_running(rq, p) || p->state == TASK_WAKING) {
1306 + struct migration_arg arg = { p, dest_cpu };
1307 + /* Need help from migration thread: drop lock and wait. */
1308 +diff --git a/kernel/time/tick-broadcast-hrtimer.c b/kernel/time/tick-broadcast-hrtimer.c
1309 +index 58045eb976c3..c750c80570e8 100644
1310 +--- a/kernel/time/tick-broadcast-hrtimer.c
1311 ++++ b/kernel/time/tick-broadcast-hrtimer.c
1312 +@@ -44,34 +44,39 @@ static int bc_shutdown(struct clock_event_device *evt)
1313 + */
1314 + static int bc_set_next(ktime_t expires, struct clock_event_device *bc)
1315 + {
1316 +- int bc_moved;
1317 + /*
1318 +- * We try to cancel the timer first. If the callback is on
1319 +- * flight on some other cpu then we let it handle it. If we
1320 +- * were able to cancel the timer nothing can rearm it as we
1321 +- * own broadcast_lock.
1322 ++ * This is called either from enter/exit idle code or from the
1323 ++ * broadcast handler. In all cases tick_broadcast_lock is held.
1324 + *
1325 +- * However we can also be called from the event handler of
1326 +- * ce_broadcast_hrtimer itself when it expires. We cannot
1327 +- * restart the timer because we are in the callback, but we
1328 +- * can set the expiry time and let the callback return
1329 +- * HRTIMER_RESTART.
1330 ++ * hrtimer_cancel() cannot be called here neither from the
1331 ++ * broadcast handler nor from the enter/exit idle code. The idle
1332 ++ * code can run into the problem described in bc_shutdown() and the
1333 ++ * broadcast handler cannot wait for itself to complete for obvious
1334 ++ * reasons.
1335 + *
1336 +- * Since we are in the idle loop at this point and because
1337 +- * hrtimer_{start/cancel} functions call into tracing,
1338 +- * calls to these functions must be bound within RCU_NONIDLE.
1339 ++ * Each caller tries to arm the hrtimer on its own CPU, but if the
1340 ++ * hrtimer callbback function is currently running, then
1341 ++ * hrtimer_start() cannot move it and the timer stays on the CPU on
1342 ++ * which it is assigned at the moment.
1343 ++ *
1344 ++ * As this can be called from idle code, the hrtimer_start()
1345 ++ * invocation has to be wrapped with RCU_NONIDLE() as
1346 ++ * hrtimer_start() can call into tracing.
1347 + */
1348 +- RCU_NONIDLE({
1349 +- bc_moved = hrtimer_try_to_cancel(&bctimer) >= 0;
1350 +- if (bc_moved)
1351 +- hrtimer_start(&bctimer, expires,
1352 +- HRTIMER_MODE_ABS_PINNED);});
1353 +- if (bc_moved) {
1354 +- /* Bind the "device" to the cpu */
1355 +- bc->bound_on = smp_processor_id();
1356 +- } else if (bc->bound_on == smp_processor_id()) {
1357 +- hrtimer_set_expires(&bctimer, expires);
1358 +- }
1359 ++ RCU_NONIDLE( {
1360 ++ hrtimer_start(&bctimer, expires, HRTIMER_MODE_ABS_PINNED);
1361 ++ /*
1362 ++ * The core tick broadcast mode expects bc->bound_on to be set
1363 ++ * correctly to prevent a CPU which has the broadcast hrtimer
1364 ++ * armed from going deep idle.
1365 ++ *
1366 ++ * As tick_broadcast_lock is held, nothing can change the cpu
1367 ++ * base which was just established in hrtimer_start() above. So
1368 ++ * the below access is safe even without holding the hrtimer
1369 ++ * base lock.
1370 ++ */
1371 ++ bc->bound_on = bctimer.base->cpu_base->cpu;
1372 ++ } );
1373 + return 0;
1374 + }
1375 +
1376 +@@ -97,10 +102,6 @@ static enum hrtimer_restart bc_handler(struct hrtimer *t)
1377 + {
1378 + ce_broadcast_hrtimer.event_handler(&ce_broadcast_hrtimer);
1379 +
1380 +- if (clockevent_state_oneshot(&ce_broadcast_hrtimer))
1381 +- if (ce_broadcast_hrtimer.next_event != KTIME_MAX)
1382 +- return HRTIMER_RESTART;
1383 +-
1384 + return HRTIMER_NORESTART;
1385 + }
1386 +
1387 +diff --git a/kernel/time/timer.c b/kernel/time/timer.c
1388 +index f17c76a1a05f..9f8e8892e5b0 100644
1389 +--- a/kernel/time/timer.c
1390 ++++ b/kernel/time/timer.c
1391 +@@ -1545,21 +1545,23 @@ void timer_clear_idle(void)
1392 + static int collect_expired_timers(struct timer_base *base,
1393 + struct hlist_head *heads)
1394 + {
1395 ++ unsigned long now = READ_ONCE(jiffies);
1396 ++
1397 + /*
1398 + * NOHZ optimization. After a long idle sleep we need to forward the
1399 + * base to current jiffies. Avoid a loop by searching the bitfield for
1400 + * the next expiring timer.
1401 + */
1402 +- if ((long)(jiffies - base->clk) > 2) {
1403 ++ if ((long)(now - base->clk) > 2) {
1404 + unsigned long next = __next_timer_interrupt(base);
1405 +
1406 + /*
1407 + * If the next timer is ahead of time forward to current
1408 + * jiffies, otherwise forward to the next expiry time:
1409 + */
1410 +- if (time_after(next, jiffies)) {
1411 ++ if (time_after(next, now)) {
1412 + /* The call site will increment clock! */
1413 +- base->clk = jiffies - 1;
1414 ++ base->clk = now - 1;
1415 + return 0;
1416 + }
1417 + base->clk = next;
1418 +diff --git a/mm/usercopy.c b/mm/usercopy.c
1419 +index 975f7dff8059..f8d74e09f8e4 100644
1420 +--- a/mm/usercopy.c
1421 ++++ b/mm/usercopy.c
1422 +@@ -15,6 +15,7 @@
1423 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1424 +
1425 + #include <linux/mm.h>
1426 ++#include <linux/highmem.h>
1427 + #include <linux/slab.h>
1428 + #include <linux/sched.h>
1429 + #include <linux/sched/task.h>
1430 +@@ -203,7 +204,12 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
1431 + if (!virt_addr_valid(ptr))
1432 + return NULL;
1433 +
1434 +- page = virt_to_head_page(ptr);
1435 ++ /*
1436 ++ * When CONFIG_HIGHMEM=y, kmap_to_page() will give either the
1437 ++ * highmem page or fallback to virt_to_page(). The following
1438 ++ * is effectively a highmem-aware virt_to_head_page().
1439 ++ */
1440 ++ page = compound_head(kmap_to_page((void *)ptr));
1441 +
1442 + /* Check slab allocator for flags and size. */
1443 + if (PageSlab(page))
1444 +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
1445 +index b149a7219084..7ef126489d4e 100644
1446 +--- a/net/netfilter/nf_tables_api.c
1447 ++++ b/net/netfilter/nf_tables_api.c
1448 +@@ -3131,8 +3131,11 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
1449 + NFT_SET_OBJECT))
1450 + return -EINVAL;
1451 + /* Only one of these operations is supported */
1452 +- if ((flags & (NFT_SET_MAP | NFT_SET_EVAL | NFT_SET_OBJECT)) ==
1453 +- (NFT_SET_MAP | NFT_SET_EVAL | NFT_SET_OBJECT))
1454 ++ if ((flags & (NFT_SET_MAP | NFT_SET_OBJECT)) ==
1455 ++ (NFT_SET_MAP | NFT_SET_OBJECT))
1456 ++ return -EOPNOTSUPP;
1457 ++ if ((flags & (NFT_SET_EVAL | NFT_SET_OBJECT)) ==
1458 ++ (NFT_SET_EVAL | NFT_SET_OBJECT))
1459 + return -EOPNOTSUPP;
1460 + }
1461 +
1462 +diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
1463 +index 475570e89ede..44015a151ad6 100644
1464 +--- a/net/netfilter/nft_lookup.c
1465 ++++ b/net/netfilter/nft_lookup.c
1466 +@@ -76,9 +76,6 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
1467 + if (IS_ERR(set))
1468 + return PTR_ERR(set);
1469 +
1470 +- if (set->flags & NFT_SET_EVAL)
1471 +- return -EOPNOTSUPP;
1472 +-
1473 + priv->sreg = nft_parse_register(tb[NFTA_LOOKUP_SREG]);
1474 + err = nft_validate_register_load(priv->sreg, set->klen);
1475 + if (err < 0)
1476 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
1477 +index f19d5a55f09e..ec504c4a397b 100644
1478 +--- a/net/wireless/nl80211.c
1479 ++++ b/net/wireless/nl80211.c
1480 +@@ -199,6 +199,38 @@ cfg80211_get_dev_from_info(struct net *netns, struct genl_info *info)
1481 + return __cfg80211_rdev_from_attrs(netns, info->attrs);
1482 + }
1483 +
1484 ++static int validate_beacon_head(const struct nlattr *attr,
1485 ++ struct netlink_ext_ack *extack)
1486 ++{
1487 ++ const u8 *data = nla_data(attr);
1488 ++ unsigned int len = nla_len(attr);
1489 ++ const struct element *elem;
1490 ++ const struct ieee80211_mgmt *mgmt = (void *)data;
1491 ++ unsigned int fixedlen = offsetof(struct ieee80211_mgmt,
1492 ++ u.beacon.variable);
1493 ++
1494 ++ if (len < fixedlen)
1495 ++ goto err;
1496 ++
1497 ++ if (ieee80211_hdrlen(mgmt->frame_control) !=
1498 ++ offsetof(struct ieee80211_mgmt, u.beacon))
1499 ++ goto err;
1500 ++
1501 ++ data += fixedlen;
1502 ++ len -= fixedlen;
1503 ++
1504 ++ for_each_element(elem, data, len) {
1505 ++ /* nothing */
1506 ++ }
1507 ++
1508 ++ if (for_each_element_completed(elem, data, len))
1509 ++ return 0;
1510 ++
1511 ++err:
1512 ++ NL_SET_ERR_MSG_ATTR(extack, attr, "malformed beacon head");
1513 ++ return -EINVAL;
1514 ++}
1515 ++
1516 + /* policy for the attributes */
1517 + static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
1518 + [NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
1519 +@@ -2111,6 +2143,8 @@ static int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
1520 +
1521 + control_freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
1522 +
1523 ++ memset(chandef, 0, sizeof(*chandef));
1524 ++
1525 + chandef->chan = ieee80211_get_channel(&rdev->wiphy, control_freq);
1526 + chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1527 + chandef->center_freq1 = control_freq;
1528 +@@ -2580,7 +2614,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
1529 +
1530 + if (rdev->ops->get_channel) {
1531 + int ret;
1532 +- struct cfg80211_chan_def chandef;
1533 ++ struct cfg80211_chan_def chandef = {};
1534 +
1535 + ret = rdev_get_channel(rdev, wdev, &chandef);
1536 + if (ret == 0) {
1537 +@@ -3736,6 +3770,12 @@ static int nl80211_parse_beacon(struct nlattr *attrs[],
1538 + memset(bcn, 0, sizeof(*bcn));
1539 +
1540 + if (attrs[NL80211_ATTR_BEACON_HEAD]) {
1541 ++ int ret = validate_beacon_head(attrs[NL80211_ATTR_BEACON_HEAD],
1542 ++ NULL);
1543 ++
1544 ++ if (ret)
1545 ++ return ret;
1546 ++
1547 + bcn->head = nla_data(attrs[NL80211_ATTR_BEACON_HEAD]);
1548 + bcn->head_len = nla_len(attrs[NL80211_ATTR_BEACON_HEAD]);
1549 + if (!bcn->head_len)
1550 +diff --git a/net/wireless/reg.c b/net/wireless/reg.c
1551 +index 376f08798169..b940d5c2003b 100644
1552 +--- a/net/wireless/reg.c
1553 ++++ b/net/wireless/reg.c
1554 +@@ -1567,7 +1567,7 @@ static void reg_call_notifier(struct wiphy *wiphy,
1555 +
1556 + static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
1557 + {
1558 +- struct cfg80211_chan_def chandef;
1559 ++ struct cfg80211_chan_def chandef = {};
1560 + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1561 + enum nl80211_iftype iftype;
1562 +
1563 +diff --git a/net/wireless/scan.c b/net/wireless/scan.c
1564 +index 5ed0ed0559dc..ea47ef156e7d 100644
1565 +--- a/net/wireless/scan.c
1566 ++++ b/net/wireless/scan.c
1567 +@@ -484,6 +484,8 @@ const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
1568 + const u8 *match, int match_len,
1569 + int match_offset)
1570 + {
1571 ++ const struct element *elem;
1572 ++
1573 + /* match_offset can't be smaller than 2, unless match_len is
1574 + * zero, in which case match_offset must be zero as well.
1575 + */
1576 +@@ -491,14 +493,10 @@ const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
1577 + (!match_len && match_offset)))
1578 + return NULL;
1579 +
1580 +- while (len >= 2 && len >= ies[1] + 2) {
1581 +- if ((ies[0] == eid) &&
1582 +- (ies[1] + 2 >= match_offset + match_len) &&
1583 +- !memcmp(ies + match_offset, match, match_len))
1584 +- return ies;
1585 +-
1586 +- len -= ies[1] + 2;
1587 +- ies += ies[1] + 2;
1588 ++ for_each_element_id(elem, eid, ies, len) {
1589 ++ if (elem->datalen >= match_offset - 2 + match_len &&
1590 ++ !memcmp(elem->data + match_offset - 2, match, match_len))
1591 ++ return (void *)elem;
1592 + }
1593 +
1594 + return NULL;
1595 +diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
1596 +index 7ca04a7de85a..bf3bae4ac5f4 100644
1597 +--- a/net/wireless/wext-compat.c
1598 ++++ b/net/wireless/wext-compat.c
1599 +@@ -800,7 +800,7 @@ static int cfg80211_wext_giwfreq(struct net_device *dev,
1600 + {
1601 + struct wireless_dev *wdev = dev->ieee80211_ptr;
1602 + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1603 +- struct cfg80211_chan_def chandef;
1604 ++ struct cfg80211_chan_def chandef = {};
1605 + int ret;
1606 +
1607 + switch (wdev->iftype) {
1608 +diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
1609 +index af680b5b678a..06b0ee75f34f 100644
1610 +--- a/security/integrity/ima/ima_crypto.c
1611 ++++ b/security/integrity/ima/ima_crypto.c
1612 +@@ -293,8 +293,11 @@ static int ima_calc_file_hash_atfm(struct file *file,
1613 + rbuf_len = min_t(loff_t, i_size - offset, rbuf_size[active]);
1614 + rc = integrity_kernel_read(file, offset, rbuf[active],
1615 + rbuf_len);
1616 +- if (rc != rbuf_len)
1617 ++ if (rc != rbuf_len) {
1618 ++ if (rc >= 0)
1619 ++ rc = -EINVAL;
1620 + goto out3;
1621 ++ }
1622 +
1623 + if (rbuf[1] && offset) {
1624 + /* Using two buffers, and it is not the first
1625 +diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
1626 +index b649675d190d..10764c1e854e 100644
1627 +--- a/sound/soc/codecs/sgtl5000.c
1628 ++++ b/sound/soc/codecs/sgtl5000.c
1629 +@@ -35,6 +35,13 @@
1630 + #define SGTL5000_DAP_REG_OFFSET 0x0100
1631 + #define SGTL5000_MAX_REG_OFFSET 0x013A
1632 +
1633 ++/* Delay for the VAG ramp up */
1634 ++#define SGTL5000_VAG_POWERUP_DELAY 500 /* ms */
1635 ++/* Delay for the VAG ramp down */
1636 ++#define SGTL5000_VAG_POWERDOWN_DELAY 500 /* ms */
1637 ++
1638 ++#define SGTL5000_OUTPUTS_MUTE (SGTL5000_HP_MUTE | SGTL5000_LINE_OUT_MUTE)
1639 ++
1640 + /* default value of sgtl5000 registers */
1641 + static const struct reg_default sgtl5000_reg_defaults[] = {
1642 + { SGTL5000_CHIP_DIG_POWER, 0x0000 },
1643 +@@ -120,6 +127,13 @@ enum {
1644 + I2S_LRCLK_STRENGTH_HIGH,
1645 + };
1646 +
1647 ++enum {
1648 ++ HP_POWER_EVENT,
1649 ++ DAC_POWER_EVENT,
1650 ++ ADC_POWER_EVENT,
1651 ++ LAST_POWER_EVENT = ADC_POWER_EVENT
1652 ++};
1653 ++
1654 + /* sgtl5000 private structure in codec */
1655 + struct sgtl5000_priv {
1656 + int sysclk; /* sysclk rate */
1657 +@@ -133,8 +147,117 @@ struct sgtl5000_priv {
1658 + u8 micbias_resistor;
1659 + u8 micbias_voltage;
1660 + u8 lrclk_strength;
1661 ++ u16 mute_state[LAST_POWER_EVENT + 1];
1662 + };
1663 +
1664 ++static inline int hp_sel_input(struct snd_soc_component *component)
1665 ++{
1666 ++ unsigned int ana_reg = 0;
1667 ++
1668 ++ snd_soc_component_read(component, SGTL5000_CHIP_ANA_CTRL, &ana_reg);
1669 ++
1670 ++ return (ana_reg & SGTL5000_HP_SEL_MASK) >> SGTL5000_HP_SEL_SHIFT;
1671 ++}
1672 ++
1673 ++static inline u16 mute_output(struct snd_soc_component *component,
1674 ++ u16 mute_mask)
1675 ++{
1676 ++ unsigned int mute_reg = 0;
1677 ++
1678 ++ snd_soc_component_read(component, SGTL5000_CHIP_ANA_CTRL, &mute_reg);
1679 ++
1680 ++ snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
1681 ++ mute_mask, mute_mask);
1682 ++ return mute_reg;
1683 ++}
1684 ++
1685 ++static inline void restore_output(struct snd_soc_component *component,
1686 ++ u16 mute_mask, u16 mute_reg)
1687 ++{
1688 ++ snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
1689 ++ mute_mask, mute_reg);
1690 ++}
1691 ++
1692 ++static void vag_power_on(struct snd_soc_component *component, u32 source)
1693 ++{
1694 ++ unsigned int ana_reg = 0;
1695 ++
1696 ++ snd_soc_component_read(component, SGTL5000_CHIP_ANA_POWER, &ana_reg);
1697 ++
1698 ++ if (ana_reg & SGTL5000_VAG_POWERUP)
1699 ++ return;
1700 ++
1701 ++ snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
1702 ++ SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
1703 ++
1704 ++ /* When VAG powering on to get local loop from Line-In, the sleep
1705 ++ * is required to avoid loud pop.
1706 ++ */
1707 ++ if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN &&
1708 ++ source == HP_POWER_EVENT)
1709 ++ msleep(SGTL5000_VAG_POWERUP_DELAY);
1710 ++}
1711 ++
1712 ++static int vag_power_consumers(struct snd_soc_component *component,
1713 ++ u16 ana_pwr_reg, u32 source)
1714 ++{
1715 ++ int consumers = 0;
1716 ++
1717 ++ /* count dac/adc consumers unconditional */
1718 ++ if (ana_pwr_reg & SGTL5000_DAC_POWERUP)
1719 ++ consumers++;
1720 ++ if (ana_pwr_reg & SGTL5000_ADC_POWERUP)
1721 ++ consumers++;
1722 ++
1723 ++ /*
1724 ++ * If the event comes from HP and Line-In is selected,
1725 ++ * current action is 'DAC to be powered down'.
1726 ++ * As HP_POWERUP is not set when HP muxed to line-in,
1727 ++ * we need to keep VAG power ON.
1728 ++ */
1729 ++ if (source == HP_POWER_EVENT) {
1730 ++ if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN)
1731 ++ consumers++;
1732 ++ } else {
1733 ++ if (ana_pwr_reg & SGTL5000_HP_POWERUP)
1734 ++ consumers++;
1735 ++ }
1736 ++
1737 ++ return consumers;
1738 ++}
1739 ++
1740 ++static void vag_power_off(struct snd_soc_component *component, u32 source)
1741 ++{
1742 ++ unsigned int ana_pwr = SGTL5000_VAG_POWERUP;
1743 ++
1744 ++ snd_soc_component_read(component, SGTL5000_CHIP_ANA_POWER, &ana_pwr);
1745 ++
1746 ++ if (!(ana_pwr & SGTL5000_VAG_POWERUP))
1747 ++ return;
1748 ++
1749 ++ /*
1750 ++ * This function calls when any of VAG power consumers is disappearing.
1751 ++ * Thus, if there is more than one consumer at the moment, as minimum
1752 ++ * one consumer will definitely stay after the end of the current
1753 ++ * event.
1754 ++ * Don't clear VAG_POWERUP if 2 or more consumers of VAG present:
1755 ++ * - LINE_IN (for HP events) / HP (for DAC/ADC events)
1756 ++ * - DAC
1757 ++ * - ADC
1758 ++ * (the current consumer is disappearing right now)
1759 ++ */
1760 ++ if (vag_power_consumers(component, ana_pwr, source) >= 2)
1761 ++ return;
1762 ++
1763 ++ snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
1764 ++ SGTL5000_VAG_POWERUP, 0);
1765 ++ /* In power down case, we need wait 400-1000 ms
1766 ++ * when VAG fully ramped down.
1767 ++ * As longer we wait, as smaller pop we've got.
1768 ++ */
1769 ++ msleep(SGTL5000_VAG_POWERDOWN_DELAY);
1770 ++}
1771 ++
1772 + /*
1773 + * mic_bias power on/off share the same register bits with
1774 + * output impedance of mic bias, when power on mic bias, we
1775 +@@ -166,36 +289,46 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
1776 + return 0;
1777 + }
1778 +
1779 +-/*
1780 +- * As manual described, ADC/DAC only works when VAG powerup,
1781 +- * So enabled VAG before ADC/DAC up.
1782 +- * In power down case, we need wait 400ms when vag fully ramped down.
1783 +- */
1784 +-static int power_vag_event(struct snd_soc_dapm_widget *w,
1785 +- struct snd_kcontrol *kcontrol, int event)
1786 ++static int vag_and_mute_control(struct snd_soc_component *component,
1787 ++ int event, int event_source)
1788 + {
1789 +- struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1790 +- const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
1791 ++ static const u16 mute_mask[] = {
1792 ++ /*
1793 ++ * Mask for HP_POWER_EVENT.
1794 ++ * Muxing Headphones have to be wrapped with mute/unmute
1795 ++ * headphones only.
1796 ++ */
1797 ++ SGTL5000_HP_MUTE,
1798 ++ /*
1799 ++ * Masks for DAC_POWER_EVENT/ADC_POWER_EVENT.
1800 ++ * Muxing DAC or ADC block have to be wrapped with mute/unmute
1801 ++ * both headphones and line-out.
1802 ++ */
1803 ++ SGTL5000_OUTPUTS_MUTE,
1804 ++ SGTL5000_OUTPUTS_MUTE
1805 ++ };
1806 ++
1807 ++ struct sgtl5000_priv *sgtl5000 =
1808 ++ snd_soc_component_get_drvdata(component);
1809 +
1810 + switch (event) {
1811 ++ case SND_SOC_DAPM_PRE_PMU:
1812 ++ sgtl5000->mute_state[event_source] =
1813 ++ mute_output(component, mute_mask[event_source]);
1814 ++ break;
1815 + case SND_SOC_DAPM_POST_PMU:
1816 +- snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
1817 +- SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
1818 +- msleep(400);
1819 ++ vag_power_on(component, event_source);
1820 ++ restore_output(component, mute_mask[event_source],
1821 ++ sgtl5000->mute_state[event_source]);
1822 + break;
1823 +-
1824 + case SND_SOC_DAPM_PRE_PMD:
1825 +- /*
1826 +- * Don't clear VAG_POWERUP, when both DAC and ADC are
1827 +- * operational to prevent inadvertently starving the
1828 +- * other one of them.
1829 +- */
1830 +- if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) &
1831 +- mask) != mask) {
1832 +- snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
1833 +- SGTL5000_VAG_POWERUP, 0);
1834 +- msleep(400);
1835 +- }
1836 ++ sgtl5000->mute_state[event_source] =
1837 ++ mute_output(component, mute_mask[event_source]);
1838 ++ vag_power_off(component, event_source);
1839 ++ break;
1840 ++ case SND_SOC_DAPM_POST_PMD:
1841 ++ restore_output(component, mute_mask[event_source],
1842 ++ sgtl5000->mute_state[event_source]);
1843 + break;
1844 + default:
1845 + break;
1846 +@@ -204,6 +337,41 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
1847 + return 0;
1848 + }
1849 +
1850 ++/*
1851 ++ * Mute Headphone when power it up/down.
1852 ++ * Control VAG power on HP power path.
1853 ++ */
1854 ++static int headphone_pga_event(struct snd_soc_dapm_widget *w,
1855 ++ struct snd_kcontrol *kcontrol, int event)
1856 ++{
1857 ++ struct snd_soc_component *component =
1858 ++ snd_soc_dapm_to_component(w->dapm);
1859 ++
1860 ++ return vag_and_mute_control(component, event, HP_POWER_EVENT);
1861 ++}
1862 ++
1863 ++/* As manual describes, ADC/DAC powering up/down requires
1864 ++ * to mute outputs to avoid pops.
1865 ++ * Control VAG power on ADC/DAC power path.
1866 ++ */
1867 ++static int adc_updown_depop(struct snd_soc_dapm_widget *w,
1868 ++ struct snd_kcontrol *kcontrol, int event)
1869 ++{
1870 ++ struct snd_soc_component *component =
1871 ++ snd_soc_dapm_to_component(w->dapm);
1872 ++
1873 ++ return vag_and_mute_control(component, event, ADC_POWER_EVENT);
1874 ++}
1875 ++
1876 ++static int dac_updown_depop(struct snd_soc_dapm_widget *w,
1877 ++ struct snd_kcontrol *kcontrol, int event)
1878 ++{
1879 ++ struct snd_soc_component *component =
1880 ++ snd_soc_dapm_to_component(w->dapm);
1881 ++
1882 ++ return vag_and_mute_control(component, event, DAC_POWER_EVENT);
1883 ++}
1884 ++
1885 + /* input sources for ADC */
1886 + static const char *adc_mux_text[] = {
1887 + "MIC_IN", "LINE_IN"
1888 +@@ -239,7 +407,10 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
1889 + mic_bias_event,
1890 + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
1891 +
1892 +- SND_SOC_DAPM_PGA("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0),
1893 ++ SND_SOC_DAPM_PGA_E("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0,
1894 ++ headphone_pga_event,
1895 ++ SND_SOC_DAPM_PRE_POST_PMU |
1896 ++ SND_SOC_DAPM_PRE_POST_PMD),
1897 + SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),
1898 +
1899 + SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux),
1900 +@@ -255,11 +426,12 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
1901 + 0, SGTL5000_CHIP_DIG_POWER,
1902 + 1, 0),
1903 +
1904 +- SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0),
1905 +- SND_SOC_DAPM_DAC("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0),
1906 +-
1907 +- SND_SOC_DAPM_PRE("VAG_POWER_PRE", power_vag_event),
1908 +- SND_SOC_DAPM_POST("VAG_POWER_POST", power_vag_event),
1909 ++ SND_SOC_DAPM_ADC_E("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0,
1910 ++ adc_updown_depop, SND_SOC_DAPM_PRE_POST_PMU |
1911 ++ SND_SOC_DAPM_PRE_POST_PMD),
1912 ++ SND_SOC_DAPM_DAC_E("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0,
1913 ++ dac_updown_depop, SND_SOC_DAPM_PRE_POST_PMU |
1914 ++ SND_SOC_DAPM_PRE_POST_PMD),
1915 + };
1916 +
1917 + /* routes for sgtl5000 */
1918 +diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
1919 +index a26c44cf31aa..8107f060fa84 100644
1920 +--- a/tools/lib/traceevent/Makefile
1921 ++++ b/tools/lib/traceevent/Makefile
1922 +@@ -259,8 +259,8 @@ endef
1923 +
1924 + define do_generate_dynamic_list_file
1925 + symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | \
1926 +- xargs echo "U W w" | tr ' ' '\n' | sort -u | xargs echo`;\
1927 +- if [ "$$symbol_type" = "U W w" ];then \
1928 ++ xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\
1929 ++ if [ "$$symbol_type" = "U W" ];then \
1930 + (echo '{'; \
1931 + $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\
1932 + echo '};'; \
1933 +diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
1934 +index 7989dd6289e7..8211e8010e09 100644
1935 +--- a/tools/lib/traceevent/event-parse.c
1936 ++++ b/tools/lib/traceevent/event-parse.c
1937 +@@ -268,10 +268,10 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
1938 + errno = ENOMEM;
1939 + return -1;
1940 + }
1941 ++ pevent->cmdlines = cmdlines;
1942 +
1943 + cmdlines[pevent->cmdline_count].comm = strdup(comm);
1944 + if (!cmdlines[pevent->cmdline_count].comm) {
1945 +- free(cmdlines);
1946 + errno = ENOMEM;
1947 + return -1;
1948 + }
1949 +@@ -282,7 +282,6 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
1950 + pevent->cmdline_count++;
1951 +
1952 + qsort(cmdlines, pevent->cmdline_count, sizeof(*cmdlines), cmdline_cmp);
1953 +- pevent->cmdlines = cmdlines;
1954 +
1955 + return 0;
1956 + }
1957 +diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
1958 +index f362ee46506a..b97e31498ff7 100644
1959 +--- a/tools/perf/Makefile.config
1960 ++++ b/tools/perf/Makefile.config
1961 +@@ -795,7 +795,7 @@ ifndef NO_JVMTI
1962 + JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
1963 + else
1964 + ifneq (,$(wildcard /usr/sbin/alternatives))
1965 +- JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
1966 ++ JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')
1967 + endif
1968 + endif
1969 + ifndef JDIR
1970 +diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
1971 +index 05920e3edf7a..47357973b55b 100644
1972 +--- a/tools/perf/arch/x86/util/unwind-libunwind.c
1973 ++++ b/tools/perf/arch/x86/util/unwind-libunwind.c
1974 +@@ -1,11 +1,11 @@
1975 + // SPDX-License-Identifier: GPL-2.0
1976 +
1977 + #include <errno.h>
1978 ++#include "../../util/debug.h"
1979 + #ifndef REMOTE_UNWIND_LIBUNWIND
1980 + #include <libunwind.h>
1981 + #include "perf_regs.h"
1982 + #include "../../util/unwind.h"
1983 +-#include "../../util/debug.h"
1984 + #endif
1985 +
1986 + #ifdef HAVE_ARCH_X86_64_SUPPORT
1987 +diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
1988 +index 52486c90ab93..0801e0ffba4a 100644
1989 +--- a/tools/perf/builtin-stat.c
1990 ++++ b/tools/perf/builtin-stat.c
1991 +@@ -2769,8 +2769,11 @@ int cmd_stat(int argc, const char **argv)
1992 + fprintf(output, "[ perf stat: executing run #%d ... ]\n",
1993 + run_idx + 1);
1994 +
1995 ++ if (run_idx != 0)
1996 ++ perf_evlist__reset_prev_raw_counts(evsel_list);
1997 ++
1998 + status = run_perf_stat(argc, argv);
1999 +- if (forever && status != -1) {
2000 ++ if (forever && status != -1 && !interval) {
2001 + print_counters(NULL, argc, argv);
2002 + perf_stat__reset_stats();
2003 + }
2004 +diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
2005 +index e1fe446f65da..c892bb4f26c3 100644
2006 +--- a/tools/perf/util/header.c
2007 ++++ b/tools/perf/util/header.c
2008 +@@ -1063,7 +1063,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
2009 +
2010 + scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path);
2011 + if (sysfs__read_str(file, &cache->map, &len)) {
2012 +- free(cache->map);
2013 ++ free(cache->size);
2014 + free(cache->type);
2015 + return -1;
2016 + }
2017 +diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
2018 +index c9bae5fb8b47..d028c2786802 100644
2019 +--- a/tools/perf/util/stat.c
2020 ++++ b/tools/perf/util/stat.c
2021 +@@ -154,6 +154,15 @@ static void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
2022 + evsel->prev_raw_counts = NULL;
2023 + }
2024 +
2025 ++static void perf_evsel__reset_prev_raw_counts(struct perf_evsel *evsel)
2026 ++{
2027 ++ if (evsel->prev_raw_counts) {
2028 ++ evsel->prev_raw_counts->aggr.val = 0;
2029 ++ evsel->prev_raw_counts->aggr.ena = 0;
2030 ++ evsel->prev_raw_counts->aggr.run = 0;
2031 ++ }
2032 ++}
2033 ++
2034 + static int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw)
2035 + {
2036 + int ncpus = perf_evsel__nr_cpus(evsel);
2037 +@@ -204,6 +213,14 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist)
2038 + }
2039 + }
2040 +
2041 ++void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist)
2042 ++{
2043 ++ struct perf_evsel *evsel;
2044 ++
2045 ++ evlist__for_each_entry(evlist, evsel)
2046 ++ perf_evsel__reset_prev_raw_counts(evsel);
2047 ++}
2048 ++
2049 + static void zero_per_pkg(struct perf_evsel *counter)
2050 + {
2051 + if (counter->per_pkg_mask)
2052 +diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
2053 +index 96326b1f9443..bdfbed8e2df2 100644
2054 +--- a/tools/perf/util/stat.h
2055 ++++ b/tools/perf/util/stat.h
2056 +@@ -100,6 +100,7 @@ void perf_stat__collect_metric_expr(struct perf_evlist *);
2057 + int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
2058 + void perf_evlist__free_stats(struct perf_evlist *evlist);
2059 + void perf_evlist__reset_stats(struct perf_evlist *evlist);
2060 ++void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist);
2061 +
2062 + int perf_stat_process_counter(struct perf_stat_config *config,
2063 + struct perf_evsel *counter);