Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.19/0148-4.19.49-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3427 - (hide annotations) (download)
Fri Aug 2 11:47:56 2019 UTC (4 years, 9 months ago) by niro
File size: 104469 byte(s)
-linux-4.19.49
1 niro 3427 diff --git a/Documentation/conf.py b/Documentation/conf.py
2     index b691af4831fa..22c1a6d96f9e 100644
3     --- a/Documentation/conf.py
4     +++ b/Documentation/conf.py
5     @@ -37,7 +37,7 @@ needs_sphinx = '1.3'
6     extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain', 'kfigure', 'sphinx.ext.ifconfig']
7    
8     # The name of the math extension changed on Sphinx 1.4
9     -if major == 1 and minor > 3:
10     +if (major == 1 and minor > 3) or (major > 1):
11     extensions.append("sphinx.ext.imgmath")
12     else:
13     extensions.append("sphinx.ext.pngmath")
14     diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
15     index 9d0a7f08f93b..1159405cb920 100644
16     --- a/Documentation/sphinx/kerneldoc.py
17     +++ b/Documentation/sphinx/kerneldoc.py
18     @@ -37,7 +37,19 @@ import glob
19     from docutils import nodes, statemachine
20     from docutils.statemachine import ViewList
21     from docutils.parsers.rst import directives, Directive
22     -from sphinx.ext.autodoc import AutodocReporter
23     +
24     +#
25     +# AutodocReporter is only good up to Sphinx 1.7
26     +#
27     +import sphinx
28     +
29     +Use_SSI = sphinx.__version__[:3] >= '1.7'
30     +if Use_SSI:
31     + from sphinx.util.docutils import switch_source_input
32     +else:
33     + from sphinx.ext.autodoc import AutodocReporter
34     +
35     +import kernellog
36    
37     __version__ = '1.0'
38    
39     @@ -90,7 +102,8 @@ class KernelDocDirective(Directive):
40     cmd += [filename]
41    
42     try:
43     - env.app.verbose('calling kernel-doc \'%s\'' % (" ".join(cmd)))
44     + kernellog.verbose(env.app,
45     + 'calling kernel-doc \'%s\'' % (" ".join(cmd)))
46    
47     p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
48     out, err = p.communicate()
49     @@ -100,7 +113,8 @@ class KernelDocDirective(Directive):
50     if p.returncode != 0:
51     sys.stderr.write(err)
52    
53     - env.app.warn('kernel-doc \'%s\' failed with return code %d' % (" ".join(cmd), p.returncode))
54     + kernellog.warn(env.app,
55     + 'kernel-doc \'%s\' failed with return code %d' % (" ".join(cmd), p.returncode))
56     return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
57     elif env.config.kerneldoc_verbosity > 0:
58     sys.stderr.write(err)
59     @@ -121,20 +135,28 @@ class KernelDocDirective(Directive):
60     lineoffset += 1
61    
62     node = nodes.section()
63     - buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
64     + self.do_parse(result, node)
65     +
66     + return node.children
67     +
68     + except Exception as e: # pylint: disable=W0703
69     + kernellog.warn(env.app, 'kernel-doc \'%s\' processing failed with: %s' %
70     + (" ".join(cmd), str(e)))
71     + return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
72     +
73     + def do_parse(self, result, node):
74     + if Use_SSI:
75     + with switch_source_input(self.state, result):
76     + self.state.nested_parse(result, 0, node, match_titles=1)
77     + else:
78     + save = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
79     self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
80     self.state.memo.title_styles, self.state.memo.section_level = [], 0
81     try:
82     self.state.nested_parse(result, 0, node, match_titles=1)
83     finally:
84     - self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
85     + self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = save
86    
87     - return node.children
88     -
89     - except Exception as e: # pylint: disable=W0703
90     - env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
91     - (" ".join(cmd), str(e)))
92     - return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
93    
94     def setup(app):
95     app.add_config_value('kerneldoc_bin', None, 'env')
96     diff --git a/Documentation/sphinx/kernellog.py b/Documentation/sphinx/kernellog.py
97     new file mode 100644
98     index 000000000000..af924f51a7dc
99     --- /dev/null
100     +++ b/Documentation/sphinx/kernellog.py
101     @@ -0,0 +1,28 @@
102     +# SPDX-License-Identifier: GPL-2.0
103     +#
104     +# Sphinx has deprecated its older logging interface, but the replacement
105     +# only goes back to 1.6. So here's a wrapper layer to keep around for
106     +# as long as we support 1.4.
107     +#
108     +import sphinx
109     +
110     +if sphinx.__version__[:3] >= '1.6':
111     + UseLogging = True
112     + from sphinx.util import logging
113     + logger = logging.getLogger('kerneldoc')
114     +else:
115     + UseLogging = False
116     +
117     +def warn(app, message):
118     + if UseLogging:
119     + logger.warning(message)
120     + else:
121     + app.warn(message)
122     +
123     +def verbose(app, message):
124     + if UseLogging:
125     + logger.verbose(message)
126     + else:
127     + app.verbose(message)
128     +
129     +
130     diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure.py
131     index b97228d2cc0e..fbfe6693bb60 100644
132     --- a/Documentation/sphinx/kfigure.py
133     +++ b/Documentation/sphinx/kfigure.py
134     @@ -60,6 +60,8 @@ import sphinx
135     from sphinx.util.nodes import clean_astext
136     from six import iteritems
137    
138     +import kernellog
139     +
140     PY3 = sys.version_info[0] == 3
141    
142     if PY3:
143     @@ -171,20 +173,20 @@ def setupTools(app):
144     This function is called once, when the builder is initiated.
145     """
146     global dot_cmd, convert_cmd # pylint: disable=W0603
147     - app.verbose("kfigure: check installed tools ...")
148     + kernellog.verbose(app, "kfigure: check installed tools ...")
149    
150     dot_cmd = which('dot')
151     convert_cmd = which('convert')
152    
153     if dot_cmd:
154     - app.verbose("use dot(1) from: " + dot_cmd)
155     + kernellog.verbose(app, "use dot(1) from: " + dot_cmd)
156     else:
157     - app.warn("dot(1) not found, for better output quality install "
158     - "graphviz from http://www.graphviz.org")
159     + kernellog.warn(app, "dot(1) not found, for better output quality install "
160     + "graphviz from http://www.graphviz.org")
161     if convert_cmd:
162     - app.verbose("use convert(1) from: " + convert_cmd)
163     + kernellog.verbose(app, "use convert(1) from: " + convert_cmd)
164     else:
165     - app.warn(
166     + kernellog.warn(app,
167     "convert(1) not found, for SVG to PDF conversion install "
168     "ImageMagick (https://www.imagemagick.org)")
169    
170     @@ -220,12 +222,13 @@ def convert_image(img_node, translator, src_fname=None):
171    
172     # in kernel builds, use 'make SPHINXOPTS=-v' to see verbose messages
173    
174     - app.verbose('assert best format for: ' + img_node['uri'])
175     + kernellog.verbose(app, 'assert best format for: ' + img_node['uri'])
176    
177     if in_ext == '.dot':
178    
179     if not dot_cmd:
180     - app.verbose("dot from graphviz not available / include DOT raw.")
181     + kernellog.verbose(app,
182     + "dot from graphviz not available / include DOT raw.")
183     img_node.replace_self(file2literal(src_fname))
184    
185     elif translator.builder.format == 'latex':
186     @@ -252,7 +255,8 @@ def convert_image(img_node, translator, src_fname=None):
187    
188     if translator.builder.format == 'latex':
189     if convert_cmd is None:
190     - app.verbose("no SVG to PDF conversion available / include SVG raw.")
191     + kernellog.verbose(app,
192     + "no SVG to PDF conversion available / include SVG raw.")
193     img_node.replace_self(file2literal(src_fname))
194     else:
195     dst_fname = path.join(translator.builder.outdir, fname + '.pdf')
196     @@ -265,18 +269,19 @@ def convert_image(img_node, translator, src_fname=None):
197     _name = dst_fname[len(translator.builder.outdir) + 1:]
198    
199     if isNewer(dst_fname, src_fname):
200     - app.verbose("convert: {out}/%s already exists and is newer" % _name)
201     + kernellog.verbose(app,
202     + "convert: {out}/%s already exists and is newer" % _name)
203    
204     else:
205     ok = False
206     mkdir(path.dirname(dst_fname))
207    
208     if in_ext == '.dot':
209     - app.verbose('convert DOT to: {out}/' + _name)
210     + kernellog.verbose(app, 'convert DOT to: {out}/' + _name)
211     ok = dot2format(app, src_fname, dst_fname)
212    
213     elif in_ext == '.svg':
214     - app.verbose('convert SVG to: {out}/' + _name)
215     + kernellog.verbose(app, 'convert SVG to: {out}/' + _name)
216     ok = svg2pdf(app, src_fname, dst_fname)
217    
218     if not ok:
219     @@ -305,7 +310,8 @@ def dot2format(app, dot_fname, out_fname):
220     with open(out_fname, "w") as out:
221     exit_code = subprocess.call(cmd, stdout = out)
222     if exit_code != 0:
223     - app.warn("Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
224     + kernellog.warn(app,
225     + "Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
226     return bool(exit_code == 0)
227    
228     def svg2pdf(app, svg_fname, pdf_fname):
229     @@ -322,7 +328,7 @@ def svg2pdf(app, svg_fname, pdf_fname):
230     # use stdout and stderr from parent
231     exit_code = subprocess.call(cmd)
232     if exit_code != 0:
233     - app.warn("Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
234     + kernellog.warn(app, "Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
235     return bool(exit_code == 0)
236    
237    
238     @@ -415,15 +421,15 @@ def visit_kernel_render(self, node):
239     app = self.builder.app
240     srclang = node.get('srclang')
241    
242     - app.verbose('visit kernel-render node lang: "%s"' % (srclang))
243     + kernellog.verbose(app, 'visit kernel-render node lang: "%s"' % (srclang))
244    
245     tmp_ext = RENDER_MARKUP_EXT.get(srclang, None)
246     if tmp_ext is None:
247     - app.warn('kernel-render: "%s" unknown / include raw.' % (srclang))
248     + kernellog.warn(app, 'kernel-render: "%s" unknown / include raw.' % (srclang))
249     return
250    
251     if not dot_cmd and tmp_ext == '.dot':
252     - app.verbose("dot from graphviz not available / include raw.")
253     + kernellog.verbose(app, "dot from graphviz not available / include raw.")
254     return
255    
256     literal_block = node[0]
257     diff --git a/Makefile b/Makefile
258     index 42529a87f3b4..e84966c49117 100644
259     --- a/Makefile
260     +++ b/Makefile
261     @@ -1,7 +1,7 @@
262     # SPDX-License-Identifier: GPL-2.0
263     VERSION = 4
264     PATCHLEVEL = 19
265     -SUBLEVEL = 48
266     +SUBLEVEL = 49
267     EXTRAVERSION =
268     NAME = "People's Front"
269    
270     diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
271     index 6f91e8116514..162a95ed0881 100644
272     --- a/arch/arm64/kernel/sys.c
273     +++ b/arch/arm64/kernel/sys.c
274     @@ -50,7 +50,7 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
275     /*
276     * Wrappers to pass the pt_regs argument.
277     */
278     -#define sys_personality sys_arm64_personality
279     +#define __arm64_sys_personality __arm64_sys_arm64_personality
280    
281     asmlinkage long sys_ni_syscall(const struct pt_regs *);
282     #define __arm64_sys_ni_syscall sys_ni_syscall
283     diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
284     index f7ea8e21656b..e7f5ef6bed0f 100644
285     --- a/arch/mips/kvm/mips.c
286     +++ b/arch/mips/kvm/mips.c
287     @@ -1099,6 +1099,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
288     case KVM_CAP_MAX_VCPUS:
289     r = KVM_MAX_VCPUS;
290     break;
291     + case KVM_CAP_MAX_VCPU_ID:
292     + r = KVM_MAX_VCPU_ID;
293     + break;
294     case KVM_CAP_MIPS_FPU:
295     /* We don't handle systems with inconsistent cpu_has_fpu */
296     r = !!raw_cpu_has_fpu;
297     diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
298     index 30c2eb766954..aae34f218ab4 100644
299     --- a/arch/powerpc/kvm/book3s_xive.c
300     +++ b/arch/powerpc/kvm/book3s_xive.c
301     @@ -1723,7 +1723,6 @@ static void kvmppc_xive_cleanup_irq(u32 hw_num, struct xive_irq_data *xd)
302     {
303     xive_vm_esb_load(xd, XIVE_ESB_SET_PQ_01);
304     xive_native_configure_irq(hw_num, 0, MASKED, 0);
305     - xive_cleanup_irq_data(xd);
306     }
307    
308     static void kvmppc_xive_free_sources(struct kvmppc_xive_src_block *sb)
309     @@ -1737,9 +1736,10 @@ static void kvmppc_xive_free_sources(struct kvmppc_xive_src_block *sb)
310     continue;
311    
312     kvmppc_xive_cleanup_irq(state->ipi_number, &state->ipi_data);
313     + xive_cleanup_irq_data(&state->ipi_data);
314     xive_native_free_irq(state->ipi_number);
315    
316     - /* Pass-through, cleanup too */
317     + /* Pass-through, cleanup too but keep IRQ hw data */
318     if (state->pt_number)
319     kvmppc_xive_cleanup_irq(state->pt_number, state->pt_data);
320    
321     diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
322     index 79b79408d92e..578174a33d22 100644
323     --- a/arch/powerpc/kvm/powerpc.c
324     +++ b/arch/powerpc/kvm/powerpc.c
325     @@ -632,6 +632,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
326     case KVM_CAP_MAX_VCPUS:
327     r = KVM_MAX_VCPUS;
328     break;
329     + case KVM_CAP_MAX_VCPU_ID:
330     + r = KVM_MAX_VCPU_ID;
331     + break;
332     #ifdef CONFIG_PPC_BOOK3S_64
333     case KVM_CAP_PPC_GET_SMMU_INFO:
334     r = 1;
335     diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
336     index 81f8a0c838ae..4004dbdab9c7 100644
337     --- a/arch/powerpc/perf/core-book3s.c
338     +++ b/arch/powerpc/perf/core-book3s.c
339     @@ -1827,6 +1827,7 @@ static int power_pmu_event_init(struct perf_event *event)
340     int n;
341     int err;
342     struct cpu_hw_events *cpuhw;
343     + u64 bhrb_filter;
344    
345     if (!ppmu)
346     return -ENOENT;
347     @@ -1932,13 +1933,14 @@ static int power_pmu_event_init(struct perf_event *event)
348     err = power_check_constraints(cpuhw, events, cflags, n + 1);
349    
350     if (has_branch_stack(event)) {
351     - cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
352     + bhrb_filter = ppmu->bhrb_filter_map(
353     event->attr.branch_sample_type);
354    
355     - if (cpuhw->bhrb_filter == -1) {
356     + if (bhrb_filter == -1) {
357     put_cpu_var(cpu_hw_events);
358     return -EOPNOTSUPP;
359     }
360     + cpuhw->bhrb_filter = bhrb_filter;
361     }
362    
363     put_cpu_var(cpu_hw_events);
364     diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
365     index d12a2db26353..d10feef93b6b 100644
366     --- a/arch/powerpc/perf/power8-pmu.c
367     +++ b/arch/powerpc/perf/power8-pmu.c
368     @@ -29,6 +29,7 @@ enum {
369     #define POWER8_MMCRA_IFM1 0x0000000040000000UL
370     #define POWER8_MMCRA_IFM2 0x0000000080000000UL
371     #define POWER8_MMCRA_IFM3 0x00000000C0000000UL
372     +#define POWER8_MMCRA_BHRB_MASK 0x00000000C0000000UL
373    
374     /*
375     * Raw event encoding for PowerISA v2.07 (Power8):
376     @@ -243,6 +244,8 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type)
377    
378     static void power8_config_bhrb(u64 pmu_bhrb_filter)
379     {
380     + pmu_bhrb_filter &= POWER8_MMCRA_BHRB_MASK;
381     +
382     /* Enable BHRB filter in PMU */
383     mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter));
384     }
385     diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
386     index e012b1030a5b..c07b1615ee39 100644
387     --- a/arch/powerpc/perf/power9-pmu.c
388     +++ b/arch/powerpc/perf/power9-pmu.c
389     @@ -100,6 +100,7 @@ enum {
390     #define POWER9_MMCRA_IFM1 0x0000000040000000UL
391     #define POWER9_MMCRA_IFM2 0x0000000080000000UL
392     #define POWER9_MMCRA_IFM3 0x00000000C0000000UL
393     +#define POWER9_MMCRA_BHRB_MASK 0x00000000C0000000UL
394    
395     /* Nasty Power9 specific hack */
396     #define PVR_POWER9_CUMULUS 0x00002000
397     @@ -308,6 +309,8 @@ static u64 power9_bhrb_filter_map(u64 branch_sample_type)
398    
399     static void power9_config_bhrb(u64 pmu_bhrb_filter)
400     {
401     + pmu_bhrb_filter &= POWER9_MMCRA_BHRB_MASK;
402     +
403     /* Enable BHRB filter in PMU */
404     mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter));
405     }
406     diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
407     index c54cb26eb7f5..8ff7cb3da1cb 100644
408     --- a/arch/s390/crypto/aes_s390.c
409     +++ b/arch/s390/crypto/aes_s390.c
410     @@ -27,14 +27,14 @@
411     #include <linux/module.h>
412     #include <linux/cpufeature.h>
413     #include <linux/init.h>
414     -#include <linux/spinlock.h>
415     +#include <linux/mutex.h>
416     #include <linux/fips.h>
417     #include <linux/string.h>
418     #include <crypto/xts.h>
419     #include <asm/cpacf.h>
420    
421     static u8 *ctrblk;
422     -static DEFINE_SPINLOCK(ctrblk_lock);
423     +static DEFINE_MUTEX(ctrblk_lock);
424    
425     static cpacf_mask_t km_functions, kmc_functions, kmctr_functions,
426     kma_functions;
427     @@ -698,7 +698,7 @@ static int ctr_aes_crypt(struct blkcipher_desc *desc, unsigned long modifier,
428     unsigned int n, nbytes;
429     int ret, locked;
430    
431     - locked = spin_trylock(&ctrblk_lock);
432     + locked = mutex_trylock(&ctrblk_lock);
433    
434     ret = blkcipher_walk_virt_block(desc, walk, AES_BLOCK_SIZE);
435     while ((nbytes = walk->nbytes) >= AES_BLOCK_SIZE) {
436     @@ -716,7 +716,7 @@ static int ctr_aes_crypt(struct blkcipher_desc *desc, unsigned long modifier,
437     ret = blkcipher_walk_done(desc, walk, nbytes - n);
438     }
439     if (locked)
440     - spin_unlock(&ctrblk_lock);
441     + mutex_unlock(&ctrblk_lock);
442     /*
443     * final block may be < AES_BLOCK_SIZE, copy only nbytes
444     */
445     @@ -826,19 +826,45 @@ static int gcm_aes_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
446     return 0;
447     }
448    
449     -static void gcm_sg_walk_start(struct gcm_sg_walk *gw, struct scatterlist *sg,
450     - unsigned int len)
451     +static void gcm_walk_start(struct gcm_sg_walk *gw, struct scatterlist *sg,
452     + unsigned int len)
453     {
454     memset(gw, 0, sizeof(*gw));
455     gw->walk_bytes_remain = len;
456     scatterwalk_start(&gw->walk, sg);
457     }
458    
459     -static int gcm_sg_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
460     +static inline unsigned int _gcm_sg_clamp_and_map(struct gcm_sg_walk *gw)
461     +{
462     + struct scatterlist *nextsg;
463     +
464     + gw->walk_bytes = scatterwalk_clamp(&gw->walk, gw->walk_bytes_remain);
465     + while (!gw->walk_bytes) {
466     + nextsg = sg_next(gw->walk.sg);
467     + if (!nextsg)
468     + return 0;
469     + scatterwalk_start(&gw->walk, nextsg);
470     + gw->walk_bytes = scatterwalk_clamp(&gw->walk,
471     + gw->walk_bytes_remain);
472     + }
473     + gw->walk_ptr = scatterwalk_map(&gw->walk);
474     + return gw->walk_bytes;
475     +}
476     +
477     +static inline void _gcm_sg_unmap_and_advance(struct gcm_sg_walk *gw,
478     + unsigned int nbytes)
479     +{
480     + gw->walk_bytes_remain -= nbytes;
481     + scatterwalk_unmap(&gw->walk);
482     + scatterwalk_advance(&gw->walk, nbytes);
483     + scatterwalk_done(&gw->walk, 0, gw->walk_bytes_remain);
484     + gw->walk_ptr = NULL;
485     +}
486     +
487     +static int gcm_in_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
488     {
489     int n;
490    
491     - /* minbytesneeded <= AES_BLOCK_SIZE */
492     if (gw->buf_bytes && gw->buf_bytes >= minbytesneeded) {
493     gw->ptr = gw->buf;
494     gw->nbytes = gw->buf_bytes;
495     @@ -851,13 +877,11 @@ static int gcm_sg_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
496     goto out;
497     }
498    
499     - gw->walk_bytes = scatterwalk_clamp(&gw->walk, gw->walk_bytes_remain);
500     - if (!gw->walk_bytes) {
501     - scatterwalk_start(&gw->walk, sg_next(gw->walk.sg));
502     - gw->walk_bytes = scatterwalk_clamp(&gw->walk,
503     - gw->walk_bytes_remain);
504     + if (!_gcm_sg_clamp_and_map(gw)) {
505     + gw->ptr = NULL;
506     + gw->nbytes = 0;
507     + goto out;
508     }
509     - gw->walk_ptr = scatterwalk_map(&gw->walk);
510    
511     if (!gw->buf_bytes && gw->walk_bytes >= minbytesneeded) {
512     gw->ptr = gw->walk_ptr;
513     @@ -869,51 +893,90 @@ static int gcm_sg_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
514     n = min(gw->walk_bytes, AES_BLOCK_SIZE - gw->buf_bytes);
515     memcpy(gw->buf + gw->buf_bytes, gw->walk_ptr, n);
516     gw->buf_bytes += n;
517     - gw->walk_bytes_remain -= n;
518     - scatterwalk_unmap(&gw->walk);
519     - scatterwalk_advance(&gw->walk, n);
520     - scatterwalk_done(&gw->walk, 0, gw->walk_bytes_remain);
521     -
522     + _gcm_sg_unmap_and_advance(gw, n);
523     if (gw->buf_bytes >= minbytesneeded) {
524     gw->ptr = gw->buf;
525     gw->nbytes = gw->buf_bytes;
526     goto out;
527     }
528     -
529     - gw->walk_bytes = scatterwalk_clamp(&gw->walk,
530     - gw->walk_bytes_remain);
531     - if (!gw->walk_bytes) {
532     - scatterwalk_start(&gw->walk, sg_next(gw->walk.sg));
533     - gw->walk_bytes = scatterwalk_clamp(&gw->walk,
534     - gw->walk_bytes_remain);
535     + if (!_gcm_sg_clamp_and_map(gw)) {
536     + gw->ptr = NULL;
537     + gw->nbytes = 0;
538     + goto out;
539     }
540     - gw->walk_ptr = scatterwalk_map(&gw->walk);
541     }
542    
543     out:
544     return gw->nbytes;
545     }
546    
547     -static void gcm_sg_walk_done(struct gcm_sg_walk *gw, unsigned int bytesdone)
548     +static int gcm_out_walk_go(struct gcm_sg_walk *gw, unsigned int minbytesneeded)
549     {
550     - int n;
551     + if (gw->walk_bytes_remain == 0) {
552     + gw->ptr = NULL;
553     + gw->nbytes = 0;
554     + goto out;
555     + }
556    
557     + if (!_gcm_sg_clamp_and_map(gw)) {
558     + gw->ptr = NULL;
559     + gw->nbytes = 0;
560     + goto out;
561     + }
562     +
563     + if (gw->walk_bytes >= minbytesneeded) {
564     + gw->ptr = gw->walk_ptr;
565     + gw->nbytes = gw->walk_bytes;
566     + goto out;
567     + }
568     +
569     + scatterwalk_unmap(&gw->walk);
570     + gw->walk_ptr = NULL;
571     +
572     + gw->ptr = gw->buf;
573     + gw->nbytes = sizeof(gw->buf);
574     +
575     +out:
576     + return gw->nbytes;
577     +}
578     +
579     +static int gcm_in_walk_done(struct gcm_sg_walk *gw, unsigned int bytesdone)
580     +{
581     if (gw->ptr == NULL)
582     - return;
583     + return 0;
584    
585     if (gw->ptr == gw->buf) {
586     - n = gw->buf_bytes - bytesdone;
587     + int n = gw->buf_bytes - bytesdone;
588     if (n > 0) {
589     memmove(gw->buf, gw->buf + bytesdone, n);
590     - gw->buf_bytes -= n;
591     + gw->buf_bytes = n;
592     } else
593     gw->buf_bytes = 0;
594     - } else {
595     - gw->walk_bytes_remain -= bytesdone;
596     - scatterwalk_unmap(&gw->walk);
597     - scatterwalk_advance(&gw->walk, bytesdone);
598     - scatterwalk_done(&gw->walk, 0, gw->walk_bytes_remain);
599     - }
600     + } else
601     + _gcm_sg_unmap_and_advance(gw, bytesdone);
602     +
603     + return bytesdone;
604     +}
605     +
606     +static int gcm_out_walk_done(struct gcm_sg_walk *gw, unsigned int bytesdone)
607     +{
608     + int i, n;
609     +
610     + if (gw->ptr == NULL)
611     + return 0;
612     +
613     + if (gw->ptr == gw->buf) {
614     + for (i = 0; i < bytesdone; i += n) {
615     + if (!_gcm_sg_clamp_and_map(gw))
616     + return i;
617     + n = min(gw->walk_bytes, bytesdone - i);
618     + memcpy(gw->walk_ptr, gw->buf + i, n);
619     + _gcm_sg_unmap_and_advance(gw, n);
620     + }
621     + } else
622     + _gcm_sg_unmap_and_advance(gw, bytesdone);
623     +
624     + return bytesdone;
625     }
626    
627     static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
628     @@ -926,7 +989,7 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
629     unsigned int pclen = req->cryptlen;
630     int ret = 0;
631    
632     - unsigned int len, in_bytes, out_bytes,
633     + unsigned int n, len, in_bytes, out_bytes,
634     min_bytes, bytes, aad_bytes, pc_bytes;
635     struct gcm_sg_walk gw_in, gw_out;
636     u8 tag[GHASH_DIGEST_SIZE];
637     @@ -963,14 +1026,14 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
638     *(u32 *)(param.j0 + ivsize) = 1;
639     memcpy(param.k, ctx->key, ctx->key_len);
640    
641     - gcm_sg_walk_start(&gw_in, req->src, len);
642     - gcm_sg_walk_start(&gw_out, req->dst, len);
643     + gcm_walk_start(&gw_in, req->src, len);
644     + gcm_walk_start(&gw_out, req->dst, len);
645    
646     do {
647     min_bytes = min_t(unsigned int,
648     aadlen > 0 ? aadlen : pclen, AES_BLOCK_SIZE);
649     - in_bytes = gcm_sg_walk_go(&gw_in, min_bytes);
650     - out_bytes = gcm_sg_walk_go(&gw_out, min_bytes);
651     + in_bytes = gcm_in_walk_go(&gw_in, min_bytes);
652     + out_bytes = gcm_out_walk_go(&gw_out, min_bytes);
653     bytes = min(in_bytes, out_bytes);
654    
655     if (aadlen + pclen <= bytes) {
656     @@ -997,8 +1060,11 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
657     gw_in.ptr + aad_bytes, pc_bytes,
658     gw_in.ptr, aad_bytes);
659    
660     - gcm_sg_walk_done(&gw_in, aad_bytes + pc_bytes);
661     - gcm_sg_walk_done(&gw_out, aad_bytes + pc_bytes);
662     + n = aad_bytes + pc_bytes;
663     + if (gcm_in_walk_done(&gw_in, n) != n)
664     + return -ENOMEM;
665     + if (gcm_out_walk_done(&gw_out, n) != n)
666     + return -ENOMEM;
667     aadlen -= aad_bytes;
668     pclen -= pc_bytes;
669     } while (aadlen + pclen > 0);
670     diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
671     index 5346b5a80bb6..65bda1178963 100644
672     --- a/arch/s390/crypto/des_s390.c
673     +++ b/arch/s390/crypto/des_s390.c
674     @@ -14,6 +14,7 @@
675     #include <linux/cpufeature.h>
676     #include <linux/crypto.h>
677     #include <linux/fips.h>
678     +#include <linux/mutex.h>
679     #include <crypto/algapi.h>
680     #include <crypto/des.h>
681     #include <asm/cpacf.h>
682     @@ -21,7 +22,7 @@
683     #define DES3_KEY_SIZE (3 * DES_KEY_SIZE)
684    
685     static u8 *ctrblk;
686     -static DEFINE_SPINLOCK(ctrblk_lock);
687     +static DEFINE_MUTEX(ctrblk_lock);
688    
689     static cpacf_mask_t km_functions, kmc_functions, kmctr_functions;
690    
691     @@ -387,7 +388,7 @@ static int ctr_desall_crypt(struct blkcipher_desc *desc, unsigned long fc,
692     unsigned int n, nbytes;
693     int ret, locked;
694    
695     - locked = spin_trylock(&ctrblk_lock);
696     + locked = mutex_trylock(&ctrblk_lock);
697    
698     ret = blkcipher_walk_virt_block(desc, walk, DES_BLOCK_SIZE);
699     while ((nbytes = walk->nbytes) >= DES_BLOCK_SIZE) {
700     @@ -404,7 +405,7 @@ static int ctr_desall_crypt(struct blkcipher_desc *desc, unsigned long fc,
701     ret = blkcipher_walk_done(desc, walk, nbytes - n);
702     }
703     if (locked)
704     - spin_unlock(&ctrblk_lock);
705     + mutex_unlock(&ctrblk_lock);
706     /* final block may be < DES_BLOCK_SIZE, copy only nbytes */
707     if (nbytes) {
708     cpacf_kmctr(fc, ctx->key, buf, walk->src.virt.addr,
709     diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
710     index ac5da6b0b862..f538e3fac7ad 100644
711     --- a/arch/s390/kvm/kvm-s390.c
712     +++ b/arch/s390/kvm/kvm-s390.c
713     @@ -489,6 +489,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
714     break;
715     case KVM_CAP_NR_VCPUS:
716     case KVM_CAP_MAX_VCPUS:
717     + case KVM_CAP_MAX_VCPU_ID:
718     r = KVM_S390_BSCA_CPU_SLOTS;
719     if (!kvm_s390_use_sca_entries())
720     r = KVM_MAX_VCPUS;
721     diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
722     index d245f89d1395..d220b6848746 100644
723     --- a/arch/sparc/mm/ultra.S
724     +++ b/arch/sparc/mm/ultra.S
725     @@ -587,7 +587,7 @@ xcall_flush_tlb_kernel_range: /* 44 insns */
726     sub %g7, %g1, %g3
727     srlx %g3, 18, %g2
728     brnz,pn %g2, 2f
729     - add %g2, 1, %g2
730     + sethi %hi(PAGE_SIZE), %g2
731     sub %g3, %g2, %g3
732     or %g1, 0x20, %g1 ! Nucleus
733     1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
734     @@ -751,7 +751,7 @@ __cheetah_xcall_flush_tlb_kernel_range: /* 44 insns */
735     sub %g7, %g1, %g3
736     srlx %g3, 18, %g2
737     brnz,pn %g2, 2f
738     - add %g2, 1, %g2
739     + sethi %hi(PAGE_SIZE), %g2
740     sub %g3, %g2, %g3
741     or %g1, 0x20, %g1 ! Nucleus
742     1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
743     diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
744     index 4d2a401c178b..9f033dfd2766 100644
745     --- a/arch/x86/kernel/ftrace.c
746     +++ b/arch/x86/kernel/ftrace.c
747     @@ -752,18 +752,21 @@ union ftrace_op_code_union {
748     } __attribute__((packed));
749     };
750    
751     +#define RET_SIZE 1
752     +
753     static unsigned long
754     create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
755     {
756     - unsigned const char *jmp;
757     unsigned long start_offset;
758     unsigned long end_offset;
759     unsigned long op_offset;
760     unsigned long offset;
761     + unsigned long npages;
762     unsigned long size;
763     - unsigned long ip;
764     + unsigned long retq;
765     unsigned long *ptr;
766     void *trampoline;
767     + void *ip;
768     /* 48 8b 15 <offset> is movq <offset>(%rip), %rdx */
769     unsigned const char op_ref[] = { 0x48, 0x8b, 0x15 };
770     union ftrace_op_code_union op_ptr;
771     @@ -783,27 +786,28 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
772    
773     /*
774     * Allocate enough size to store the ftrace_caller code,
775     - * the jmp to ftrace_epilogue, as well as the address of
776     - * the ftrace_ops this trampoline is used for.
777     + * the iret , as well as the address of the ftrace_ops this
778     + * trampoline is used for.
779     */
780     - trampoline = alloc_tramp(size + MCOUNT_INSN_SIZE + sizeof(void *));
781     + trampoline = alloc_tramp(size + RET_SIZE + sizeof(void *));
782     if (!trampoline)
783     return 0;
784    
785     - *tramp_size = size + MCOUNT_INSN_SIZE + sizeof(void *);
786     + *tramp_size = size + RET_SIZE + sizeof(void *);
787     + npages = DIV_ROUND_UP(*tramp_size, PAGE_SIZE);
788    
789     /* Copy ftrace_caller onto the trampoline memory */
790     ret = probe_kernel_read(trampoline, (void *)start_offset, size);
791     - if (WARN_ON(ret < 0)) {
792     - tramp_free(trampoline, *tramp_size);
793     - return 0;
794     - }
795     + if (WARN_ON(ret < 0))
796     + goto fail;
797    
798     - ip = (unsigned long)trampoline + size;
799     + ip = trampoline + size;
800    
801     - /* The trampoline ends with a jmp to ftrace_epilogue */
802     - jmp = ftrace_jmp_replace(ip, (unsigned long)ftrace_epilogue);
803     - memcpy(trampoline + size, jmp, MCOUNT_INSN_SIZE);
804     + /* The trampoline ends with ret(q) */
805     + retq = (unsigned long)ftrace_stub;
806     + ret = probe_kernel_read(ip, (void *)retq, RET_SIZE);
807     + if (WARN_ON(ret < 0))
808     + goto fail;
809    
810     /*
811     * The address of the ftrace_ops that is used for this trampoline
812     @@ -813,17 +817,15 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
813     * the global function_trace_op variable.
814     */
815    
816     - ptr = (unsigned long *)(trampoline + size + MCOUNT_INSN_SIZE);
817     + ptr = (unsigned long *)(trampoline + size + RET_SIZE);
818     *ptr = (unsigned long)ops;
819    
820     op_offset -= start_offset;
821     memcpy(&op_ptr, trampoline + op_offset, OP_REF_SIZE);
822    
823     /* Are we pointing to the reference? */
824     - if (WARN_ON(memcmp(op_ptr.op, op_ref, 3) != 0)) {
825     - tramp_free(trampoline, *tramp_size);
826     - return 0;
827     - }
828     + if (WARN_ON(memcmp(op_ptr.op, op_ref, 3) != 0))
829     + goto fail;
830    
831     /* Load the contents of ptr into the callback parameter */
832     offset = (unsigned long)ptr;
833     @@ -837,7 +839,16 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
834     /* ALLOC_TRAMP flags lets us know we created it */
835     ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
836    
837     + /*
838     + * Module allocation needs to be completed by making the page
839     + * executable. The page is still writable, which is a security hazard,
840     + * but anyhow ftrace breaks W^X completely.
841     + */
842     + set_memory_x((unsigned long)trampoline, npages);
843     return (unsigned long)trampoline;
844     +fail:
845     + tramp_free(trampoline, *tramp_size);
846     + return 0;
847     }
848    
849     static unsigned long calc_trampoline_call_offset(bool save_regs)
850     diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
851     index 91b2cff4b79a..75f2b36b41a6 100644
852     --- a/arch/x86/kernel/ftrace_64.S
853     +++ b/arch/x86/kernel/ftrace_64.S
854     @@ -171,9 +171,6 @@ GLOBAL(ftrace_call)
855     restore_mcount_regs
856    
857     /*
858     - * The copied trampoline must call ftrace_epilogue as it
859     - * still may need to call the function graph tracer.
860     - *
861     * The code up to this label is copied into trampolines so
862     * think twice before adding any new code or changing the
863     * layout here.
864     @@ -185,7 +182,10 @@ GLOBAL(ftrace_graph_call)
865     jmp ftrace_stub
866     #endif
867    
868     -/* This is weak to keep gas from relaxing the jumps */
869     +/*
870     + * This is weak to keep gas from relaxing the jumps.
871     + * It is also used to copy the retq for trampolines.
872     + */
873     WEAK(ftrace_stub)
874     retq
875     ENDPROC(ftrace_caller)
876     diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
877     index 544bc2dfe408..e83a057564d1 100644
878     --- a/arch/x86/kernel/kprobes/core.c
879     +++ b/arch/x86/kernel/kprobes/core.c
880     @@ -431,8 +431,20 @@ void *alloc_insn_page(void)
881     void *page;
882    
883     page = module_alloc(PAGE_SIZE);
884     - if (page)
885     - set_memory_ro((unsigned long)page & PAGE_MASK, 1);
886     + if (!page)
887     + return NULL;
888     +
889     + /*
890     + * First make the page read-only, and only then make it executable to
891     + * prevent it from being W+X in between.
892     + */
893     + set_memory_ro((unsigned long)page, 1);
894     +
895     + /*
896     + * TODO: Once additional kernel code protection mechanisms are set, ensure
897     + * that the page was not maliciously altered and it is still zeroed.
898     + */
899     + set_memory_x((unsigned long)page, 1);
900    
901     return page;
902     }
903     @@ -440,8 +452,12 @@ void *alloc_insn_page(void)
904     /* Recover page to RW mode before releasing it */
905     void free_insn_page(void *page)
906     {
907     - set_memory_nx((unsigned long)page & PAGE_MASK, 1);
908     - set_memory_rw((unsigned long)page & PAGE_MASK, 1);
909     + /*
910     + * First make the page non-executable, and only then make it writable to
911     + * prevent it from being W+X in between.
912     + */
913     + set_memory_nx((unsigned long)page, 1);
914     + set_memory_rw((unsigned long)page, 1);
915     module_memfree(page);
916     }
917    
918     diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
919     index 2fb152d813c1..85e6d5620188 100644
920     --- a/arch/x86/kernel/vmlinux.lds.S
921     +++ b/arch/x86/kernel/vmlinux.lds.S
922     @@ -151,10 +151,10 @@ SECTIONS
923     *(.text.__x86.indirect_thunk)
924     __indirect_thunk_end = .;
925     #endif
926     - } :text = 0x9090
927    
928     - /* End of text section */
929     - _etext = .;
930     + /* End of text section */
931     + _etext = .;
932     + } :text = 0x9090
933    
934     NOTES :text :note
935    
936     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
937     index be4ba0975a0f..7fed1d6dd1a1 100644
938     --- a/arch/x86/kvm/x86.c
939     +++ b/arch/x86/kvm/x86.c
940     @@ -2987,6 +2987,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
941     case KVM_CAP_MAX_VCPUS:
942     r = KVM_MAX_VCPUS;
943     break;
944     + case KVM_CAP_MAX_VCPU_ID:
945     + r = KVM_MAX_VCPU_ID;
946     + break;
947     case KVM_CAP_NR_MEMSLOTS:
948     r = KVM_USER_MEM_SLOTS;
949     break;
950     diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
951     index 9cbe8f5c9aca..6e241a3c31ee 100644
952     --- a/drivers/gpu/drm/drm_crtc.c
953     +++ b/drivers/gpu/drm/drm_crtc.c
954     @@ -595,6 +595,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
955    
956     plane = crtc->primary;
957    
958     + /* allow disabling with the primary plane leased */
959     + if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
960     + return -EACCES;
961     +
962     mutex_lock(&crtc->dev->mode_config.mutex);
963     drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
964     retry:
965     diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
966     index d36b1be632d9..2411b6de055e 100644
967     --- a/drivers/gpu/drm/drm_plane.c
968     +++ b/drivers/gpu/drm/drm_plane.c
969     @@ -940,6 +940,11 @@ retry:
970     if (ret)
971     goto out;
972    
973     + if (!drm_lease_held(file_priv, crtc->cursor->base.id)) {
974     + ret = -EACCES;
975     + goto out;
976     + }
977     +
978     ret = drm_mode_cursor_universal(crtc, req, file_priv, &ctx);
979     goto out;
980     }
981     @@ -1042,6 +1047,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
982    
983     plane = crtc->primary;
984    
985     + if (!drm_lease_held(file_priv, plane->base.id))
986     + return -EACCES;
987     +
988     if (crtc->funcs->page_flip_target) {
989     u32 current_vblank;
990     int r;
991     diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h
992     index eef54e9b5d77..7957eafa5f0e 100644
993     --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h
994     +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h
995     @@ -38,6 +38,7 @@ struct nvkm_i2c_bus {
996     struct mutex mutex;
997     struct list_head head;
998     struct i2c_adapter i2c;
999     + u8 enabled;
1000     };
1001    
1002     int nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *);
1003     @@ -57,6 +58,7 @@ struct nvkm_i2c_aux {
1004     struct mutex mutex;
1005     struct list_head head;
1006     struct i2c_adapter i2c;
1007     + u8 enabled;
1008    
1009     u32 intr;
1010     };
1011     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
1012     index 4c1f547da463..b4e7404fe660 100644
1013     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
1014     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
1015     @@ -105,9 +105,15 @@ nvkm_i2c_aux_acquire(struct nvkm_i2c_aux *aux)
1016     {
1017     struct nvkm_i2c_pad *pad = aux->pad;
1018     int ret;
1019     +
1020     AUX_TRACE(aux, "acquire");
1021     mutex_lock(&aux->mutex);
1022     - ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_AUX);
1023     +
1024     + if (aux->enabled)
1025     + ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_AUX);
1026     + else
1027     + ret = -EIO;
1028     +
1029     if (ret)
1030     mutex_unlock(&aux->mutex);
1031     return ret;
1032     @@ -145,6 +151,24 @@ nvkm_i2c_aux_del(struct nvkm_i2c_aux **paux)
1033     }
1034     }
1035    
1036     +void
1037     +nvkm_i2c_aux_init(struct nvkm_i2c_aux *aux)
1038     +{
1039     + AUX_TRACE(aux, "init");
1040     + mutex_lock(&aux->mutex);
1041     + aux->enabled = true;
1042     + mutex_unlock(&aux->mutex);
1043     +}
1044     +
1045     +void
1046     +nvkm_i2c_aux_fini(struct nvkm_i2c_aux *aux)
1047     +{
1048     + AUX_TRACE(aux, "fini");
1049     + mutex_lock(&aux->mutex);
1050     + aux->enabled = false;
1051     + mutex_unlock(&aux->mutex);
1052     +}
1053     +
1054     int
1055     nvkm_i2c_aux_ctor(const struct nvkm_i2c_aux_func *func,
1056     struct nvkm_i2c_pad *pad, int id,
1057     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h
1058     index 7d56c4ba693c..08f6b2ee64ab 100644
1059     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h
1060     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h
1061     @@ -16,6 +16,8 @@ int nvkm_i2c_aux_ctor(const struct nvkm_i2c_aux_func *, struct nvkm_i2c_pad *,
1062     int nvkm_i2c_aux_new_(const struct nvkm_i2c_aux_func *, struct nvkm_i2c_pad *,
1063     int id, struct nvkm_i2c_aux **);
1064     void nvkm_i2c_aux_del(struct nvkm_i2c_aux **);
1065     +void nvkm_i2c_aux_init(struct nvkm_i2c_aux *);
1066     +void nvkm_i2c_aux_fini(struct nvkm_i2c_aux *);
1067     int nvkm_i2c_aux_xfer(struct nvkm_i2c_aux *, bool retry, u8 type,
1068     u32 addr, u8 *data, u8 *size);
1069    
1070     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
1071     index 4f197b15acf6..ecacb22834d7 100644
1072     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
1073     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
1074     @@ -160,8 +160,18 @@ nvkm_i2c_fini(struct nvkm_subdev *subdev, bool suspend)
1075     {
1076     struct nvkm_i2c *i2c = nvkm_i2c(subdev);
1077     struct nvkm_i2c_pad *pad;
1078     + struct nvkm_i2c_bus *bus;
1079     + struct nvkm_i2c_aux *aux;
1080     u32 mask;
1081    
1082     + list_for_each_entry(aux, &i2c->aux, head) {
1083     + nvkm_i2c_aux_fini(aux);
1084     + }
1085     +
1086     + list_for_each_entry(bus, &i2c->bus, head) {
1087     + nvkm_i2c_bus_fini(bus);
1088     + }
1089     +
1090     if ((mask = (1 << i2c->func->aux) - 1), i2c->func->aux_stat) {
1091     i2c->func->aux_mask(i2c, NVKM_I2C_ANY, mask, 0);
1092     i2c->func->aux_stat(i2c, &mask, &mask, &mask, &mask);
1093     @@ -180,6 +190,7 @@ nvkm_i2c_init(struct nvkm_subdev *subdev)
1094     struct nvkm_i2c *i2c = nvkm_i2c(subdev);
1095     struct nvkm_i2c_bus *bus;
1096     struct nvkm_i2c_pad *pad;
1097     + struct nvkm_i2c_aux *aux;
1098    
1099     list_for_each_entry(pad, &i2c->pad, head) {
1100     nvkm_i2c_pad_init(pad);
1101     @@ -189,6 +200,10 @@ nvkm_i2c_init(struct nvkm_subdev *subdev)
1102     nvkm_i2c_bus_init(bus);
1103     }
1104    
1105     + list_for_each_entry(aux, &i2c->aux, head) {
1106     + nvkm_i2c_aux_init(aux);
1107     + }
1108     +
1109     return 0;
1110     }
1111    
1112     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c
1113     index 807a2b67bd64..ed50cc3736b9 100644
1114     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c
1115     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c
1116     @@ -110,6 +110,19 @@ nvkm_i2c_bus_init(struct nvkm_i2c_bus *bus)
1117     BUS_TRACE(bus, "init");
1118     if (bus->func->init)
1119     bus->func->init(bus);
1120     +
1121     + mutex_lock(&bus->mutex);
1122     + bus->enabled = true;
1123     + mutex_unlock(&bus->mutex);
1124     +}
1125     +
1126     +void
1127     +nvkm_i2c_bus_fini(struct nvkm_i2c_bus *bus)
1128     +{
1129     + BUS_TRACE(bus, "fini");
1130     + mutex_lock(&bus->mutex);
1131     + bus->enabled = false;
1132     + mutex_unlock(&bus->mutex);
1133     }
1134    
1135     void
1136     @@ -126,9 +139,15 @@ nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *bus)
1137     {
1138     struct nvkm_i2c_pad *pad = bus->pad;
1139     int ret;
1140     +
1141     BUS_TRACE(bus, "acquire");
1142     mutex_lock(&bus->mutex);
1143     - ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_I2C);
1144     +
1145     + if (bus->enabled)
1146     + ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_I2C);
1147     + else
1148     + ret = -EIO;
1149     +
1150     if (ret)
1151     mutex_unlock(&bus->mutex);
1152     return ret;
1153     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.h b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.h
1154     index bea0dd33961e..465464bba58b 100644
1155     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.h
1156     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.h
1157     @@ -18,6 +18,7 @@ int nvkm_i2c_bus_new_(const struct nvkm_i2c_bus_func *, struct nvkm_i2c_pad *,
1158     int id, struct nvkm_i2c_bus **);
1159     void nvkm_i2c_bus_del(struct nvkm_i2c_bus **);
1160     void nvkm_i2c_bus_init(struct nvkm_i2c_bus *);
1161     +void nvkm_i2c_bus_fini(struct nvkm_i2c_bus *);
1162    
1163     int nvkm_i2c_bit_xfer(struct nvkm_i2c_bus *, struct i2c_msg *, int);
1164    
1165     diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
1166     index f814d37b1db2..00a06768edb2 100644
1167     --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
1168     +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
1169     @@ -442,6 +442,14 @@ static int rockchip_drm_platform_remove(struct platform_device *pdev)
1170     return 0;
1171     }
1172    
1173     +static void rockchip_drm_platform_shutdown(struct platform_device *pdev)
1174     +{
1175     + struct drm_device *drm = platform_get_drvdata(pdev);
1176     +
1177     + if (drm)
1178     + drm_atomic_helper_shutdown(drm);
1179     +}
1180     +
1181     static const struct of_device_id rockchip_drm_dt_ids[] = {
1182     { .compatible = "rockchip,display-subsystem", },
1183     { /* sentinel */ },
1184     @@ -451,6 +459,7 @@ MODULE_DEVICE_TABLE(of, rockchip_drm_dt_ids);
1185     static struct platform_driver rockchip_drm_platform_driver = {
1186     .probe = rockchip_drm_platform_probe,
1187     .remove = rockchip_drm_platform_remove,
1188     + .shutdown = rockchip_drm_platform_shutdown,
1189     .driver = {
1190     .name = "rockchip-drm",
1191     .of_match_table = rockchip_drm_dt_ids,
1192     diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1193     index a564b5dfe082..dc9b1398adb9 100644
1194     --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1195     +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1196     @@ -177,7 +177,8 @@ static int sun8i_hdmi_phy_config_h3(struct dw_hdmi *hdmi,
1197     SUN8I_HDMI_PHY_ANA_CFG2_REG_BIGSW |
1198     SUN8I_HDMI_PHY_ANA_CFG2_REG_SLV(4);
1199     ana_cfg3_init |= SUN8I_HDMI_PHY_ANA_CFG3_REG_AMPCK(9) |
1200     - SUN8I_HDMI_PHY_ANA_CFG3_REG_AMP(13);
1201     + SUN8I_HDMI_PHY_ANA_CFG3_REG_AMP(13) |
1202     + SUN8I_HDMI_PHY_ANA_CFG3_REG_EMP(3);
1203     }
1204    
1205     regmap_update_bits(phy->regs, SUN8I_HDMI_PHY_ANA_CFG1_REG,
1206     @@ -501,22 +502,13 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
1207     goto err_put_clk_pll0;
1208     }
1209     }
1210     -
1211     - ret = sun8i_phy_clk_create(phy, dev,
1212     - phy->variant->has_second_pll);
1213     - if (ret) {
1214     - dev_err(dev, "Couldn't create the PHY clock\n");
1215     - goto err_put_clk_pll1;
1216     - }
1217     -
1218     - clk_prepare_enable(phy->clk_phy);
1219     }
1220    
1221     phy->rst_phy = of_reset_control_get_shared(node, "phy");
1222     if (IS_ERR(phy->rst_phy)) {
1223     dev_err(dev, "Could not get phy reset control\n");
1224     ret = PTR_ERR(phy->rst_phy);
1225     - goto err_disable_clk_phy;
1226     + goto err_put_clk_pll1;
1227     }
1228    
1229     ret = reset_control_deassert(phy->rst_phy);
1230     @@ -537,18 +529,29 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
1231     goto err_disable_clk_bus;
1232     }
1233    
1234     + if (phy->variant->has_phy_clk) {
1235     + ret = sun8i_phy_clk_create(phy, dev,
1236     + phy->variant->has_second_pll);
1237     + if (ret) {
1238     + dev_err(dev, "Couldn't create the PHY clock\n");
1239     + goto err_disable_clk_mod;
1240     + }
1241     +
1242     + clk_prepare_enable(phy->clk_phy);
1243     + }
1244     +
1245     hdmi->phy = phy;
1246    
1247     return 0;
1248    
1249     +err_disable_clk_mod:
1250     + clk_disable_unprepare(phy->clk_mod);
1251     err_disable_clk_bus:
1252     clk_disable_unprepare(phy->clk_bus);
1253     err_deassert_rst_phy:
1254     reset_control_assert(phy->rst_phy);
1255     err_put_rst_phy:
1256     reset_control_put(phy->rst_phy);
1257     -err_disable_clk_phy:
1258     - clk_disable_unprepare(phy->clk_phy);
1259     err_put_clk_pll1:
1260     clk_put(phy->clk_pll1);
1261     err_put_clk_pll0:
1262     diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
1263     index 4f80100ff5f3..4cce11fd8836 100644
1264     --- a/drivers/gpu/drm/tegra/gem.c
1265     +++ b/drivers/gpu/drm/tegra/gem.c
1266     @@ -204,7 +204,7 @@ static void tegra_bo_free(struct drm_device *drm, struct tegra_bo *bo)
1267     {
1268     if (bo->pages) {
1269     dma_unmap_sg(drm->dev, bo->sgt->sgl, bo->sgt->nents,
1270     - DMA_BIDIRECTIONAL);
1271     + DMA_FROM_DEVICE);
1272     drm_gem_put_pages(&bo->gem, bo->pages, true, true);
1273     sg_free_table(bo->sgt);
1274     kfree(bo->sgt);
1275     @@ -230,7 +230,7 @@ static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
1276     }
1277    
1278     err = dma_map_sg(drm->dev, bo->sgt->sgl, bo->sgt->nents,
1279     - DMA_BIDIRECTIONAL);
1280     + DMA_FROM_DEVICE);
1281     if (err == 0) {
1282     err = -EFAULT;
1283     goto free_sgt;
1284     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1285     index c72b942f2bdf..82ae68716696 100644
1286     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1287     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1288     @@ -1291,7 +1291,13 @@ static int vmw_master_set(struct drm_device *dev,
1289     }
1290    
1291     dev_priv->active_master = vmaster;
1292     - drm_sysfs_hotplug_event(dev);
1293     +
1294     + /*
1295     + * Inform a new master that the layout may have changed while
1296     + * it was gone.
1297     + */
1298     + if (!from_open)
1299     + drm_sysfs_hotplug_event(dev);
1300    
1301     return 0;
1302     }
1303     diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
1304     index 745ed43a22d6..2fd717d8dd30 100644
1305     --- a/drivers/i2c/busses/i2c-mlxcpld.c
1306     +++ b/drivers/i2c/busses/i2c-mlxcpld.c
1307     @@ -503,6 +503,7 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
1308     platform_set_drvdata(pdev, priv);
1309    
1310     priv->dev = &pdev->dev;
1311     + priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR;
1312    
1313     /* Register with i2c layer */
1314     mlxcpld_i2c_adapter.timeout = usecs_to_jiffies(MLXCPLD_I2C_XFER_TO);
1315     @@ -518,7 +519,6 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
1316     mlxcpld_i2c_adapter.nr = pdev->id;
1317     priv->adap = mlxcpld_i2c_adapter;
1318     priv->adap.dev.parent = &pdev->dev;
1319     - priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR;
1320     i2c_set_adapdata(&priv->adap, priv);
1321    
1322     err = i2c_add_numbered_adapter(&priv->adap);
1323     diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
1324     index e6c554e6ba58..e47380b96b1d 100644
1325     --- a/drivers/i2c/busses/i2c-synquacer.c
1326     +++ b/drivers/i2c/busses/i2c-synquacer.c
1327     @@ -356,7 +356,7 @@ static int synquacer_i2c_doxfer(struct synquacer_i2c *i2c,
1328     /* wait 2 clock periods to ensure the stop has been through the bus */
1329     udelay(DIV_ROUND_UP(2 * 1000, i2c->speed_khz));
1330    
1331     - return 0;
1332     + return ret;
1333     }
1334    
1335     static irqreturn_t synquacer_i2c_isr(int irq, void *dev_id)
1336     diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
1337     index 8b4568edd5cb..7f16c77b99fb 100644
1338     --- a/drivers/iio/adc/ti-ads8688.c
1339     +++ b/drivers/iio/adc/ti-ads8688.c
1340     @@ -397,7 +397,7 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
1341     }
1342    
1343     iio_push_to_buffers_with_timestamp(indio_dev, buffer,
1344     - pf->timestamp);
1345     + iio_get_time_ns(indio_dev));
1346    
1347     iio_trigger_notify_done(indio_dev->trig);
1348    
1349     diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
1350     index 883a47562055..714a97f91319 100644
1351     --- a/drivers/iio/dac/ds4424.c
1352     +++ b/drivers/iio/dac/ds4424.c
1353     @@ -166,7 +166,7 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev)
1354     {
1355     int ret, val;
1356    
1357     - ret = ds4424_get_value(indio_dev, &val, DS4424_DAC_ADDR(0));
1358     + ret = ds4424_get_value(indio_dev, &val, 0);
1359     if (ret < 0)
1360     dev_err(&indio_dev->dev,
1361     "%s failed. ret: %d\n", __func__, ret);
1362     diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
1363     index be3634407f1f..3071d9bc77f4 100644
1364     --- a/drivers/media/usb/siano/smsusb.c
1365     +++ b/drivers/media/usb/siano/smsusb.c
1366     @@ -401,6 +401,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
1367     struct smsusb_device_t *dev;
1368     void *mdev;
1369     int i, rc;
1370     + int align = 0;
1371    
1372     /* create device object */
1373     dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
1374     @@ -412,6 +413,24 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
1375     dev->udev = interface_to_usbdev(intf);
1376     dev->state = SMSUSB_DISCONNECTED;
1377    
1378     + for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
1379     + struct usb_endpoint_descriptor *desc =
1380     + &intf->cur_altsetting->endpoint[i].desc;
1381     +
1382     + if (desc->bEndpointAddress & USB_DIR_IN) {
1383     + dev->in_ep = desc->bEndpointAddress;
1384     + align = usb_endpoint_maxp(desc) - sizeof(struct sms_msg_hdr);
1385     + } else {
1386     + dev->out_ep = desc->bEndpointAddress;
1387     + }
1388     + }
1389     +
1390     + pr_debug("in_ep = %02x, out_ep = %02x\n", dev->in_ep, dev->out_ep);
1391     + if (!dev->in_ep || !dev->out_ep || align < 0) { /* Missing endpoints? */
1392     + smsusb_term_device(intf);
1393     + return -ENODEV;
1394     + }
1395     +
1396     params.device_type = sms_get_board(board_id)->type;
1397    
1398     switch (params.device_type) {
1399     @@ -426,24 +445,12 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
1400     /* fall-thru */
1401     default:
1402     dev->buffer_size = USB2_BUFFER_SIZE;
1403     - dev->response_alignment =
1404     - le16_to_cpu(dev->udev->ep_in[1]->desc.wMaxPacketSize) -
1405     - sizeof(struct sms_msg_hdr);
1406     + dev->response_alignment = align;
1407    
1408     params.flags |= SMS_DEVICE_FAMILY2;
1409     break;
1410     }
1411    
1412     - for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
1413     - if (intf->cur_altsetting->endpoint[i].desc. bEndpointAddress & USB_DIR_IN)
1414     - dev->in_ep = intf->cur_altsetting->endpoint[i].desc.bEndpointAddress;
1415     - else
1416     - dev->out_ep = intf->cur_altsetting->endpoint[i].desc.bEndpointAddress;
1417     - }
1418     -
1419     - pr_debug("in_ep = %02x, out_ep = %02x\n",
1420     - dev->in_ep, dev->out_ep);
1421     -
1422     params.device = &dev->udev->dev;
1423     params.usb_device = dev->udev;
1424     params.buffer_size = dev->buffer_size;
1425     diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
1426     index 6f1fd40fce10..c3ddbf6c202a 100644
1427     --- a/drivers/media/usb/uvc/uvc_driver.c
1428     +++ b/drivers/media/usb/uvc/uvc_driver.c
1429     @@ -914,7 +914,7 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id,
1430     unsigned int size;
1431     unsigned int i;
1432    
1433     - extra_size = ALIGN(extra_size, sizeof(*entity->pads));
1434     + extra_size = roundup(extra_size, sizeof(*entity->pads));
1435     num_inputs = (type & UVC_TERM_OUTPUT) ? num_pads : num_pads - 1;
1436     size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads
1437     + num_inputs;
1438     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
1439     index 1068a2a4494c..144e0b83b24b 100644
1440     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
1441     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
1442     @@ -490,11 +490,18 @@ fail:
1443     return -ENOMEM;
1444     }
1445    
1446     -void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr)
1447     +void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr)
1448     +{
1449     + struct brcmf_bcdc *bcdc = drvr->proto->pd;
1450     +
1451     + brcmf_fws_detach_pre_delif(bcdc->fws);
1452     +}
1453     +
1454     +void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr)
1455     {
1456     struct brcmf_bcdc *bcdc = drvr->proto->pd;
1457    
1458     drvr->proto->pd = NULL;
1459     - brcmf_fws_detach(bcdc->fws);
1460     + brcmf_fws_detach_post_delif(bcdc->fws);
1461     kfree(bcdc);
1462     }
1463     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h
1464     index 3b0e9eff21b5..4bc52240ccea 100644
1465     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h
1466     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h
1467     @@ -18,14 +18,16 @@
1468    
1469     #ifdef CONFIG_BRCMFMAC_PROTO_BCDC
1470     int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr);
1471     -void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr);
1472     +void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr);
1473     +void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr);
1474     void brcmf_proto_bcdc_txflowblock(struct device *dev, bool state);
1475     void brcmf_proto_bcdc_txcomplete(struct device *dev, struct sk_buff *txp,
1476     bool success);
1477     struct brcmf_fws_info *drvr_to_fws(struct brcmf_pub *drvr);
1478     #else
1479     static inline int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr) { return 0; }
1480     -static inline void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr) {}
1481     +static void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr) {};
1482     +static inline void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr) {}
1483     #endif
1484    
1485     #endif /* BRCMFMAC_BCDC_H */
1486     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
1487     index 36a04c1144e5..0f56be13c7ad 100644
1488     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
1489     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
1490     @@ -1244,6 +1244,8 @@ void brcmf_detach(struct device *dev)
1491    
1492     brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN);
1493    
1494     + brcmf_proto_detach_pre_delif(drvr);
1495     +
1496     /* make sure primary interface removed last */
1497     for (i = BRCMF_MAX_IFS-1; i > -1; i--)
1498     brcmf_remove_interface(drvr->iflist[i], false);
1499     @@ -1253,7 +1255,7 @@ void brcmf_detach(struct device *dev)
1500    
1501     brcmf_bus_stop(drvr->bus_if);
1502    
1503     - brcmf_proto_detach(drvr);
1504     + brcmf_proto_detach_post_delif(drvr);
1505    
1506     bus_if->drvr = NULL;
1507     wiphy_free(drvr->wiphy);
1508     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
1509     index 5a0a29c4cdea..1de8497d92b8 100644
1510     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
1511     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
1512     @@ -2410,17 +2410,25 @@ struct brcmf_fws_info *brcmf_fws_attach(struct brcmf_pub *drvr)
1513     return fws;
1514    
1515     fail:
1516     - brcmf_fws_detach(fws);
1517     + brcmf_fws_detach_pre_delif(fws);
1518     + brcmf_fws_detach_post_delif(fws);
1519     return ERR_PTR(rc);
1520     }
1521    
1522     -void brcmf_fws_detach(struct brcmf_fws_info *fws)
1523     +void brcmf_fws_detach_pre_delif(struct brcmf_fws_info *fws)
1524     {
1525     if (!fws)
1526     return;
1527     -
1528     - if (fws->fws_wq)
1529     + if (fws->fws_wq) {
1530     destroy_workqueue(fws->fws_wq);
1531     + fws->fws_wq = NULL;
1532     + }
1533     +}
1534     +
1535     +void brcmf_fws_detach_post_delif(struct brcmf_fws_info *fws)
1536     +{
1537     + if (!fws)
1538     + return;
1539    
1540     /* cleanup */
1541     brcmf_fws_lock(fws);
1542     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
1543     index 4e6835766d5d..749c06dcdc17 100644
1544     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
1545     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
1546     @@ -19,7 +19,8 @@
1547     #define FWSIGNAL_H_
1548    
1549     struct brcmf_fws_info *brcmf_fws_attach(struct brcmf_pub *drvr);
1550     -void brcmf_fws_detach(struct brcmf_fws_info *fws);
1551     +void brcmf_fws_detach_pre_delif(struct brcmf_fws_info *fws);
1552     +void brcmf_fws_detach_post_delif(struct brcmf_fws_info *fws);
1553     void brcmf_fws_debugfs_create(struct brcmf_pub *drvr);
1554     bool brcmf_fws_queue_skbs(struct brcmf_fws_info *fws);
1555     bool brcmf_fws_fc_active(struct brcmf_fws_info *fws);
1556     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
1557     index c5ff551ec659..74e6fdbd3a2b 100644
1558     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
1559     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
1560     @@ -67,16 +67,22 @@ fail:
1561     return -ENOMEM;
1562     }
1563    
1564     -void brcmf_proto_detach(struct brcmf_pub *drvr)
1565     +void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr)
1566     {
1567     brcmf_dbg(TRACE, "Enter\n");
1568    
1569     if (drvr->proto) {
1570     if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
1571     - brcmf_proto_bcdc_detach(drvr);
1572     + brcmf_proto_bcdc_detach_post_delif(drvr);
1573     else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF)
1574     brcmf_proto_msgbuf_detach(drvr);
1575     kfree(drvr->proto);
1576     drvr->proto = NULL;
1577     }
1578     }
1579     +
1580     +void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr)
1581     +{
1582     + if (drvr->proto && drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
1583     + brcmf_proto_bcdc_detach_pre_delif(drvr);
1584     +}
1585     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
1586     index d3c3b9a815ad..72355aea9028 100644
1587     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
1588     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
1589     @@ -54,7 +54,8 @@ struct brcmf_proto {
1590    
1591    
1592     int brcmf_proto_attach(struct brcmf_pub *drvr);
1593     -void brcmf_proto_detach(struct brcmf_pub *drvr);
1594     +void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr);
1595     +void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr);
1596    
1597     static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
1598     struct sk_buff *skb,
1599     diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
1600     index 45c0b1f4cb69..a09c1c3cf831 100644
1601     --- a/drivers/of/dynamic.c
1602     +++ b/drivers/of/dynamic.c
1603     @@ -205,15 +205,24 @@ static void __of_attach_node(struct device_node *np)
1604     const __be32 *phandle;
1605     int sz;
1606    
1607     - np->name = __of_get_property(np, "name", NULL) ? : "<NULL>";
1608     - np->type = __of_get_property(np, "device_type", NULL) ? : "<NULL>";
1609     -
1610     - phandle = __of_get_property(np, "phandle", &sz);
1611     - if (!phandle)
1612     - phandle = __of_get_property(np, "linux,phandle", &sz);
1613     - if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle)
1614     - phandle = __of_get_property(np, "ibm,phandle", &sz);
1615     - np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0;
1616     + if (!of_node_check_flag(np, OF_OVERLAY)) {
1617     + np->name = __of_get_property(np, "name", NULL);
1618     + np->type = __of_get_property(np, "device_type", NULL);
1619     + if (!np->name)
1620     + np->name = "<NULL>";
1621     + if (!np->type)
1622     + np->type = "<NULL>";
1623     +
1624     + phandle = __of_get_property(np, "phandle", &sz);
1625     + if (!phandle)
1626     + phandle = __of_get_property(np, "linux,phandle", &sz);
1627     + if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle)
1628     + phandle = __of_get_property(np, "ibm,phandle", &sz);
1629     + if (phandle && (sz >= 4))
1630     + np->phandle = be32_to_cpup(phandle);
1631     + else
1632     + np->phandle = 0;
1633     + }
1634    
1635     np->child = NULL;
1636     np->sibling = np->parent->child;
1637     diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
1638     index 9808aae4621a..2edb59039b5f 100644
1639     --- a/drivers/of/overlay.c
1640     +++ b/drivers/of/overlay.c
1641     @@ -287,7 +287,12 @@ err_free_target_path:
1642     * @target may be either in the live devicetree or in a new subtree that
1643     * is contained in the changeset.
1644     *
1645     - * Some special properties are not updated (no error returned).
1646     + * Some special properties are not added or updated (no error returned):
1647     + * "name", "phandle", "linux,phandle".
1648     + *
1649     + * Properties "#address-cells" and "#size-cells" are not updated if they
1650     + * are already in the live tree, but if present in the live tree, the values
1651     + * in the overlay must match the values in the live tree.
1652     *
1653     * Update of property in symbols node is not allowed.
1654     *
1655     @@ -300,11 +305,13 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
1656     {
1657     struct property *new_prop = NULL, *prop;
1658     int ret = 0;
1659     + bool check_for_non_overlay_node = false;
1660    
1661     - if (!of_prop_cmp(overlay_prop->name, "name") ||
1662     - !of_prop_cmp(overlay_prop->name, "phandle") ||
1663     - !of_prop_cmp(overlay_prop->name, "linux,phandle"))
1664     - return 0;
1665     + if (target->in_livetree)
1666     + if (!of_prop_cmp(overlay_prop->name, "name") ||
1667     + !of_prop_cmp(overlay_prop->name, "phandle") ||
1668     + !of_prop_cmp(overlay_prop->name, "linux,phandle"))
1669     + return 0;
1670    
1671     if (target->in_livetree)
1672     prop = of_find_property(target->np, overlay_prop->name, NULL);
1673     @@ -322,12 +329,36 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
1674     if (!new_prop)
1675     return -ENOMEM;
1676    
1677     - if (!prop)
1678     + if (!prop) {
1679     + check_for_non_overlay_node = true;
1680     + if (!target->in_livetree) {
1681     + new_prop->next = target->np->deadprops;
1682     + target->np->deadprops = new_prop;
1683     + }
1684     ret = of_changeset_add_property(&ovcs->cset, target->np,
1685     new_prop);
1686     - else
1687     + } else if (!of_prop_cmp(prop->name, "#address-cells")) {
1688     + if (!of_prop_val_eq(prop, new_prop)) {
1689     + pr_err("ERROR: changing value of #address-cells is not allowed in %pOF\n",
1690     + target->np);
1691     + ret = -EINVAL;
1692     + }
1693     + } else if (!of_prop_cmp(prop->name, "#size-cells")) {
1694     + if (!of_prop_val_eq(prop, new_prop)) {
1695     + pr_err("ERROR: changing value of #size-cells is not allowed in %pOF\n",
1696     + target->np);
1697     + ret = -EINVAL;
1698     + }
1699     + } else {
1700     + check_for_non_overlay_node = true;
1701     ret = of_changeset_update_property(&ovcs->cset, target->np,
1702     new_prop);
1703     + }
1704     +
1705     + if (check_for_non_overlay_node &&
1706     + !of_node_check_flag(target->np, OF_OVERLAY))
1707     + pr_err("WARNING: memory leak will occur if overlay removed, property: %pOF/%s\n",
1708     + target->np, new_prop->name);
1709    
1710     if (ret) {
1711     kfree(new_prop->name);
1712     @@ -382,9 +413,10 @@ static int add_changeset_node(struct overlay_changeset *ovcs,
1713     struct target *target, struct device_node *node)
1714     {
1715     const char *node_kbasename;
1716     + const __be32 *phandle;
1717     struct device_node *tchild;
1718     struct target target_child;
1719     - int ret = 0;
1720     + int ret = 0, size;
1721    
1722     node_kbasename = kbasename(node->full_name);
1723    
1724     @@ -398,6 +430,19 @@ static int add_changeset_node(struct overlay_changeset *ovcs,
1725     return -ENOMEM;
1726    
1727     tchild->parent = target->np;
1728     + tchild->name = __of_get_property(node, "name", NULL);
1729     + tchild->type = __of_get_property(node, "device_type", NULL);
1730     +
1731     + if (!tchild->name)
1732     + tchild->name = "<NULL>";
1733     + if (!tchild->type)
1734     + tchild->type = "<NULL>";
1735     +
1736     + /* ignore obsolete "linux,phandle" */
1737     + phandle = __of_get_property(node, "phandle", &size);
1738     + if (phandle && (size == 4))
1739     + tchild->phandle = be32_to_cpup(phandle);
1740     +
1741     of_node_set_flag(tchild, OF_OVERLAY);
1742    
1743     ret = of_changeset_attach_node(&ovcs->cset, tchild);
1744     diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
1745     index 1b4d6a3afb8f..3d971ffbd4bc 100644
1746     --- a/drivers/s390/scsi/zfcp_ext.h
1747     +++ b/drivers/s390/scsi/zfcp_ext.h
1748     @@ -164,6 +164,7 @@ extern const struct attribute_group *zfcp_port_attr_groups[];
1749     extern struct mutex zfcp_sysfs_port_units_mutex;
1750     extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
1751     extern struct device_attribute *zfcp_sysfs_shost_attrs[];
1752     +bool zfcp_sysfs_port_is_removing(const struct zfcp_port *const port);
1753    
1754     /* zfcp_unit.c */
1755     extern int zfcp_unit_add(struct zfcp_port *, u64);
1756     diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
1757     index a4bbfa4ef653..588bf5ac6fb9 100644
1758     --- a/drivers/s390/scsi/zfcp_scsi.c
1759     +++ b/drivers/s390/scsi/zfcp_scsi.c
1760     @@ -125,6 +125,15 @@ static int zfcp_scsi_slave_alloc(struct scsi_device *sdev)
1761    
1762     zfcp_sdev->erp_action.port = port;
1763    
1764     + mutex_lock(&zfcp_sysfs_port_units_mutex);
1765     + if (zfcp_sysfs_port_is_removing(port)) {
1766     + /* port is already gone */
1767     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
1768     + put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
1769     + return -ENXIO;
1770     + }
1771     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
1772     +
1773     unit = zfcp_unit_find(port, zfcp_scsi_dev_lun(sdev));
1774     if (unit)
1775     put_device(&unit->dev);
1776     diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
1777     index b277be6f7611..af197e2b3e69 100644
1778     --- a/drivers/s390/scsi/zfcp_sysfs.c
1779     +++ b/drivers/s390/scsi/zfcp_sysfs.c
1780     @@ -235,6 +235,53 @@ static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
1781    
1782     DEFINE_MUTEX(zfcp_sysfs_port_units_mutex);
1783    
1784     +static void zfcp_sysfs_port_set_removing(struct zfcp_port *const port)
1785     +{
1786     + lockdep_assert_held(&zfcp_sysfs_port_units_mutex);
1787     + atomic_set(&port->units, -1);
1788     +}
1789     +
1790     +bool zfcp_sysfs_port_is_removing(const struct zfcp_port *const port)
1791     +{
1792     + lockdep_assert_held(&zfcp_sysfs_port_units_mutex);
1793     + return atomic_read(&port->units) == -1;
1794     +}
1795     +
1796     +static bool zfcp_sysfs_port_in_use(struct zfcp_port *const port)
1797     +{
1798     + struct zfcp_adapter *const adapter = port->adapter;
1799     + unsigned long flags;
1800     + struct scsi_device *sdev;
1801     + bool in_use = true;
1802     +
1803     + mutex_lock(&zfcp_sysfs_port_units_mutex);
1804     + if (atomic_read(&port->units) > 0)
1805     + goto unlock_port_units_mutex; /* zfcp_unit(s) under port */
1806     +
1807     + spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
1808     + __shost_for_each_device(sdev, adapter->scsi_host) {
1809     + const struct zfcp_scsi_dev *zsdev = sdev_to_zfcp(sdev);
1810     +
1811     + if (sdev->sdev_state == SDEV_DEL ||
1812     + sdev->sdev_state == SDEV_CANCEL)
1813     + continue;
1814     + if (zsdev->port != port)
1815     + continue;
1816     + /* alive scsi_device under port of interest */
1817     + goto unlock_host_lock;
1818     + }
1819     +
1820     + /* port is about to be removed, so no more unit_add or slave_alloc */
1821     + zfcp_sysfs_port_set_removing(port);
1822     + in_use = false;
1823     +
1824     +unlock_host_lock:
1825     + spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags);
1826     +unlock_port_units_mutex:
1827     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
1828     + return in_use;
1829     +}
1830     +
1831     static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
1832     struct device_attribute *attr,
1833     const char *buf, size_t count)
1834     @@ -257,15 +304,11 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
1835     else
1836     retval = 0;
1837    
1838     - mutex_lock(&zfcp_sysfs_port_units_mutex);
1839     - if (atomic_read(&port->units) > 0) {
1840     + if (zfcp_sysfs_port_in_use(port)) {
1841     retval = -EBUSY;
1842     - mutex_unlock(&zfcp_sysfs_port_units_mutex);
1843     + put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
1844     goto out;
1845     }
1846     - /* port is about to be removed, so no more unit_add */
1847     - atomic_set(&port->units, -1);
1848     - mutex_unlock(&zfcp_sysfs_port_units_mutex);
1849    
1850     write_lock_irq(&adapter->port_list_lock);
1851     list_del(&port->list);
1852     diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
1853     index 1bf0a0984a09..e67bf7388cae 100644
1854     --- a/drivers/s390/scsi/zfcp_unit.c
1855     +++ b/drivers/s390/scsi/zfcp_unit.c
1856     @@ -124,7 +124,7 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
1857     int retval = 0;
1858    
1859     mutex_lock(&zfcp_sysfs_port_units_mutex);
1860     - if (atomic_read(&port->units) == -1) {
1861     + if (zfcp_sysfs_port_is_removing(port)) {
1862     /* port is already gone */
1863     retval = -ENODEV;
1864     goto out;
1865     @@ -168,8 +168,14 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
1866     write_lock_irq(&port->unit_list_lock);
1867     list_add_tail(&unit->list, &port->unit_list);
1868     write_unlock_irq(&port->unit_list_lock);
1869     + /*
1870     + * lock order: shost->scan_mutex before zfcp_sysfs_port_units_mutex
1871     + * due to zfcp_unit_scsi_scan() => zfcp_scsi_slave_alloc()
1872     + */
1873     + mutex_unlock(&zfcp_sysfs_port_units_mutex);
1874    
1875     zfcp_unit_scsi_scan(unit);
1876     + return retval;
1877    
1878     out:
1879     mutex_unlock(&zfcp_sysfs_port_units_mutex);
1880     diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
1881     index 099f70798fdd..645ffb5332b4 100644
1882     --- a/drivers/scsi/lpfc/lpfc_nvme.c
1883     +++ b/drivers/scsi/lpfc/lpfc_nvme.c
1884     @@ -2477,14 +2477,14 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
1885     lpfc_nvme_template.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1;
1886     lpfc_nvme_template.max_hw_queues = phba->cfg_nvme_io_channel;
1887    
1888     + if (!IS_ENABLED(CONFIG_NVME_FC))
1889     + return ret;
1890     +
1891     cstat = kmalloc((sizeof(struct lpfc_nvme_ctrl_stat) *
1892     phba->cfg_nvme_io_channel), GFP_KERNEL);
1893     if (!cstat)
1894     return -ENOMEM;
1895    
1896     - if (!IS_ENABLED(CONFIG_NVME_FC))
1897     - return ret;
1898     -
1899     /* localport is allocated from the stack, but the registration
1900     * call allocates heap memory as well as the private area.
1901     */
1902     diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
1903     index c7c8ef67b67f..3bece6b86831 100644
1904     --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
1905     +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
1906     @@ -410,9 +410,18 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
1907     int dma_buffers;
1908     dma_addr_t dma_addr;
1909    
1910     + if (count >= INT_MAX - PAGE_SIZE)
1911     + return NULL;
1912     +
1913     offset = ((unsigned int)(unsigned long)buf & (PAGE_SIZE - 1));
1914     num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE);
1915    
1916     + if (num_pages > (SIZE_MAX - sizeof(PAGELIST_T) -
1917     + sizeof(struct vchiq_pagelist_info)) /
1918     + (sizeof(u32) + sizeof(pages[0]) +
1919     + sizeof(struct scatterlist)))
1920     + return NULL;
1921     +
1922     pagelist_size = sizeof(PAGELIST_T) +
1923     (num_pages * sizeof(u32)) +
1924     (num_pages * sizeof(pages[0]) +
1925     diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
1926     index 16f7dd266e3b..767ec8184adf 100644
1927     --- a/drivers/staging/wlan-ng/hfa384x_usb.c
1928     +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
1929     @@ -3119,7 +3119,9 @@ static void hfa384x_usbin_callback(struct urb *urb)
1930     break;
1931     }
1932    
1933     + /* Save values from the RX URB before reposting overwrites it. */
1934     urb_status = urb->status;
1935     + usbin = (union hfa384x_usbin *)urb->transfer_buffer;
1936    
1937     if (action != ABORT) {
1938     /* Repost the RX URB */
1939     @@ -3136,7 +3138,6 @@ static void hfa384x_usbin_callback(struct urb *urb)
1940     /* Note: the check of the sw_support field, the type field doesn't
1941     * have bit 12 set like the docs suggest.
1942     */
1943     - usbin = (union hfa384x_usbin *)urb->transfer_buffer;
1944     type = le16_to_cpu(usbin->type);
1945     if (HFA384x_USB_ISRXFRM(type)) {
1946     if (action == HANDLE) {
1947     diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
1948     index 4c4070a202fb..38c48a02b920 100644
1949     --- a/drivers/tty/serial/max310x.c
1950     +++ b/drivers/tty/serial/max310x.c
1951     @@ -576,7 +576,7 @@ static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
1952     }
1953    
1954     /* Configure clock source */
1955     - clksrc = xtal ? MAX310X_CLKSRC_CRYST_BIT : MAX310X_CLKSRC_EXTCLK_BIT;
1956     + clksrc = MAX310X_CLKSRC_EXTCLK_BIT | (xtal ? MAX310X_CLKSRC_CRYST_BIT : 0);
1957    
1958     /* Configure PLL */
1959     if (pllcfg) {
1960     diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
1961     index 736b74fd6623..0f41b936da03 100644
1962     --- a/drivers/tty/serial/msm_serial.c
1963     +++ b/drivers/tty/serial/msm_serial.c
1964     @@ -860,6 +860,7 @@ static void msm_handle_tx(struct uart_port *port)
1965     struct circ_buf *xmit = &msm_port->uart.state->xmit;
1966     struct msm_dma *dma = &msm_port->tx_dma;
1967     unsigned int pio_count, dma_count, dma_min;
1968     + char buf[4] = { 0 };
1969     void __iomem *tf;
1970     int err = 0;
1971    
1972     @@ -869,10 +870,12 @@ static void msm_handle_tx(struct uart_port *port)
1973     else
1974     tf = port->membase + UART_TF;
1975    
1976     + buf[0] = port->x_char;
1977     +
1978     if (msm_port->is_uartdm)
1979     msm_reset_dm_count(port, 1);
1980    
1981     - iowrite8_rep(tf, &port->x_char, 1);
1982     + iowrite32_rep(tf, buf, 1);
1983     port->icount.tx++;
1984     port->x_char = 0;
1985     return;
1986     diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
1987     index 03fe3fb4bff6..040832635a64 100644
1988     --- a/drivers/tty/serial/sh-sci.c
1989     +++ b/drivers/tty/serial/sh-sci.c
1990     @@ -1542,6 +1542,13 @@ static void sci_request_dma(struct uart_port *port)
1991    
1992     dev_dbg(port->dev, "%s: port %d\n", __func__, port->line);
1993    
1994     + /*
1995     + * DMA on console may interfere with Kernel log messages which use
1996     + * plain putchar(). So, simply don't use it with a console.
1997     + */
1998     + if (uart_console(port))
1999     + return;
2000     +
2001     if (!port->dev->of_node)
2002     return;
2003    
2004     diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
2005     index f93b948acfa5..d673e3592662 100644
2006     --- a/drivers/tty/vt/vt.c
2007     +++ b/drivers/tty/vt/vt.c
2008     @@ -1059,6 +1059,13 @@ static void visual_init(struct vc_data *vc, int num, int init)
2009     vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
2010     }
2011    
2012     +
2013     +static void visual_deinit(struct vc_data *vc)
2014     +{
2015     + vc->vc_sw->con_deinit(vc);
2016     + module_put(vc->vc_sw->owner);
2017     +}
2018     +
2019     int vc_allocate(unsigned int currcons) /* return 0 on success */
2020     {
2021     struct vt_notifier_param param;
2022     @@ -1106,6 +1113,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
2023    
2024     return 0;
2025     err_free:
2026     + visual_deinit(vc);
2027     kfree(vc);
2028     vc_cons[currcons].d = NULL;
2029     return -ENOMEM;
2030     @@ -1334,9 +1342,8 @@ struct vc_data *vc_deallocate(unsigned int currcons)
2031     param.vc = vc = vc_cons[currcons].d;
2032     atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
2033     vcs_remove_sysfs(currcons);
2034     - vc->vc_sw->con_deinit(vc);
2035     + visual_deinit(vc);
2036     put_pid(vc->vt_pid);
2037     - module_put(vc->vc_sw->owner);
2038     vc_uniscr_set(vc, NULL);
2039     kfree(vc->vc_screenbuf);
2040     vc_cons[currcons].d = NULL;
2041     diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
2042     index 7b5cb28ffb35..e723ddd79bcf 100644
2043     --- a/drivers/usb/core/config.c
2044     +++ b/drivers/usb/core/config.c
2045     @@ -936,8 +936,8 @@ int usb_get_bos_descriptor(struct usb_device *dev)
2046    
2047     /* Get BOS descriptor */
2048     ret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);
2049     - if (ret < USB_DT_BOS_SIZE) {
2050     - dev_err(ddev, "unable to get BOS descriptor\n");
2051     + if (ret < USB_DT_BOS_SIZE || bos->bLength < USB_DT_BOS_SIZE) {
2052     + dev_err(ddev, "unable to get BOS descriptor or descriptor too short\n");
2053     if (ret >= 0)
2054     ret = -ENOMSG;
2055     kfree(bos);
2056     diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
2057     index 8bc35d53408b..6082b008969b 100644
2058     --- a/drivers/usb/core/quirks.c
2059     +++ b/drivers/usb/core/quirks.c
2060     @@ -209,6 +209,9 @@ static const struct usb_device_id usb_quirk_list[] = {
2061     /* Microsoft LifeCam-VX700 v2.0 */
2062     { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
2063    
2064     + /* Microsoft Surface Dock Ethernet (RTL8153 GigE) */
2065     + { USB_DEVICE(0x045e, 0x07c6), .driver_info = USB_QUIRK_NO_LPM },
2066     +
2067     /* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */
2068     { USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME },
2069    
2070     diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
2071     index f054464347c9..b62953ee0fc6 100644
2072     --- a/drivers/usb/host/xhci-ring.c
2073     +++ b/drivers/usb/host/xhci-ring.c
2074     @@ -656,6 +656,7 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
2075     struct device *dev = xhci_to_hcd(xhci)->self.controller;
2076     struct xhci_segment *seg = td->bounce_seg;
2077     struct urb *urb = td->urb;
2078     + size_t len;
2079    
2080     if (!ring || !seg || !urb)
2081     return;
2082     @@ -666,11 +667,14 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
2083     return;
2084     }
2085    
2086     - /* for in tranfers we need to copy the data from bounce to sg */
2087     - sg_pcopy_from_buffer(urb->sg, urb->num_mapped_sgs, seg->bounce_buf,
2088     - seg->bounce_len, seg->bounce_offs);
2089     dma_unmap_single(dev, seg->bounce_dma, ring->bounce_buf_len,
2090     DMA_FROM_DEVICE);
2091     + /* for in tranfers we need to copy the data from bounce to sg */
2092     + len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, seg->bounce_buf,
2093     + seg->bounce_len, seg->bounce_offs);
2094     + if (len != seg->bounce_len)
2095     + xhci_warn(xhci, "WARN Wrong bounce buffer read length: %zu != %d\n",
2096     + len, seg->bounce_len);
2097     seg->bounce_len = 0;
2098     seg->bounce_offs = 0;
2099     }
2100     @@ -3104,6 +3108,7 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
2101     unsigned int unalign;
2102     unsigned int max_pkt;
2103     u32 new_buff_len;
2104     + size_t len;
2105    
2106     max_pkt = usb_endpoint_maxp(&urb->ep->desc);
2107     unalign = (enqd_len + *trb_buff_len) % max_pkt;
2108     @@ -3134,8 +3139,12 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
2109    
2110     /* create a max max_pkt sized bounce buffer pointed to by last trb */
2111     if (usb_urb_dir_out(urb)) {
2112     - sg_pcopy_to_buffer(urb->sg, urb->num_mapped_sgs,
2113     + len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
2114     seg->bounce_buf, new_buff_len, enqd_len);
2115     + if (len != seg->bounce_len)
2116     + xhci_warn(xhci,
2117     + "WARN Wrong bounce buffer write length: %zu != %d\n",
2118     + len, seg->bounce_len);
2119     seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,
2120     max_pkt, DMA_TO_DEVICE);
2121     } else {
2122     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2123     index dae3be1b9c8f..f30b065095fa 100644
2124     --- a/drivers/usb/host/xhci.c
2125     +++ b/drivers/usb/host/xhci.c
2126     @@ -9,6 +9,7 @@
2127     */
2128    
2129     #include <linux/pci.h>
2130     +#include <linux/iopoll.h>
2131     #include <linux/irq.h>
2132     #include <linux/log2.h>
2133     #include <linux/module.h>
2134     @@ -52,7 +53,6 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
2135     return false;
2136     }
2137    
2138     -/* TODO: copied from ehci-hcd.c - can this be refactored? */
2139     /*
2140     * xhci_handshake - spin reading hc until handshake completes or fails
2141     * @ptr: address of hc register to be read
2142     @@ -69,18 +69,16 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
2143     int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
2144     {
2145     u32 result;
2146     + int ret;
2147    
2148     - do {
2149     - result = readl(ptr);
2150     - if (result == ~(u32)0) /* card removed */
2151     - return -ENODEV;
2152     - result &= mask;
2153     - if (result == done)
2154     - return 0;
2155     - udelay(1);
2156     - usec--;
2157     - } while (usec > 0);
2158     - return -ETIMEDOUT;
2159     + ret = readl_poll_timeout_atomic(ptr, result,
2160     + (result & mask) == done ||
2161     + result == U32_MAX,
2162     + 1, usec);
2163     + if (result == U32_MAX) /* card removed */
2164     + return -ENODEV;
2165     +
2166     + return ret;
2167     }
2168    
2169     /*
2170     @@ -4289,7 +4287,6 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
2171     pm_addr = ports[port_num]->addr + PORTPMSC;
2172     pm_val = readl(pm_addr);
2173     hlpm_addr = ports[port_num]->addr + PORTHLPMC;
2174     - field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
2175    
2176     xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
2177     enable ? "enable" : "disable", port_num + 1);
2178     @@ -4301,6 +4298,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
2179     * default one which works with mixed HIRD and BESL
2180     * systems. See XHCI_DEFAULT_BESL definition in xhci.h
2181     */
2182     + field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
2183     if ((field & USB_BESL_SUPPORT) &&
2184     (field & USB_BESL_BASELINE_VALID))
2185     hird = USB_GET_BESL_BASELINE(field);
2186     diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
2187     index 7b9adeb3e7aa..a32d61a79ab8 100644
2188     --- a/drivers/usb/misc/rio500.c
2189     +++ b/drivers/usb/misc/rio500.c
2190     @@ -86,9 +86,22 @@ static int close_rio(struct inode *inode, struct file *file)
2191     {
2192     struct rio_usb_data *rio = &rio_instance;
2193    
2194     - rio->isopen = 0;
2195     + /* against disconnect() */
2196     + mutex_lock(&rio500_mutex);
2197     + mutex_lock(&(rio->lock));
2198    
2199     - dev_info(&rio->rio_dev->dev, "Rio closed.\n");
2200     + rio->isopen = 0;
2201     + if (!rio->present) {
2202     + /* cleanup has been delayed */
2203     + kfree(rio->ibuf);
2204     + kfree(rio->obuf);
2205     + rio->ibuf = NULL;
2206     + rio->obuf = NULL;
2207     + } else {
2208     + dev_info(&rio->rio_dev->dev, "Rio closed.\n");
2209     + }
2210     + mutex_unlock(&(rio->lock));
2211     + mutex_unlock(&rio500_mutex);
2212     return 0;
2213     }
2214    
2215     @@ -447,15 +460,23 @@ static int probe_rio(struct usb_interface *intf,
2216     {
2217     struct usb_device *dev = interface_to_usbdev(intf);
2218     struct rio_usb_data *rio = &rio_instance;
2219     - int retval;
2220     + int retval = 0;
2221    
2222     - dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum);
2223     + mutex_lock(&rio500_mutex);
2224     + if (rio->present) {
2225     + dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum);
2226     + retval = -EBUSY;
2227     + goto bail_out;
2228     + } else {
2229     + dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum);
2230     + }
2231    
2232     retval = usb_register_dev(intf, &usb_rio_class);
2233     if (retval) {
2234     dev_err(&dev->dev,
2235     "Not able to get a minor for this device.\n");
2236     - return -ENOMEM;
2237     + retval = -ENOMEM;
2238     + goto bail_out;
2239     }
2240    
2241     rio->rio_dev = dev;
2242     @@ -464,7 +485,8 @@ static int probe_rio(struct usb_interface *intf,
2243     dev_err(&dev->dev,
2244     "probe_rio: Not enough memory for the output buffer\n");
2245     usb_deregister_dev(intf, &usb_rio_class);
2246     - return -ENOMEM;
2247     + retval = -ENOMEM;
2248     + goto bail_out;
2249     }
2250     dev_dbg(&intf->dev, "obuf address:%p\n", rio->obuf);
2251    
2252     @@ -473,7 +495,8 @@ static int probe_rio(struct usb_interface *intf,
2253     "probe_rio: Not enough memory for the input buffer\n");
2254     usb_deregister_dev(intf, &usb_rio_class);
2255     kfree(rio->obuf);
2256     - return -ENOMEM;
2257     + retval = -ENOMEM;
2258     + goto bail_out;
2259     }
2260     dev_dbg(&intf->dev, "ibuf address:%p\n", rio->ibuf);
2261    
2262     @@ -481,8 +504,10 @@ static int probe_rio(struct usb_interface *intf,
2263    
2264     usb_set_intfdata (intf, rio);
2265     rio->present = 1;
2266     +bail_out:
2267     + mutex_unlock(&rio500_mutex);
2268    
2269     - return 0;
2270     + return retval;
2271     }
2272    
2273     static void disconnect_rio(struct usb_interface *intf)
2274     diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
2275     index 3198d0477cf8..c4f6ac5f035e 100644
2276     --- a/drivers/usb/misc/sisusbvga/sisusb.c
2277     +++ b/drivers/usb/misc/sisusbvga/sisusb.c
2278     @@ -3029,6 +3029,13 @@ static int sisusb_probe(struct usb_interface *intf,
2279    
2280     mutex_init(&(sisusb->lock));
2281    
2282     + sisusb->sisusb_dev = dev;
2283     + sisusb->vrambase = SISUSB_PCI_MEMBASE;
2284     + sisusb->mmiobase = SISUSB_PCI_MMIOBASE;
2285     + sisusb->mmiosize = SISUSB_PCI_MMIOSIZE;
2286     + sisusb->ioportbase = SISUSB_PCI_IOPORTBASE;
2287     + /* Everything else is zero */
2288     +
2289     /* Register device */
2290     retval = usb_register_dev(intf, &usb_sisusb_class);
2291     if (retval) {
2292     @@ -3039,13 +3046,7 @@ static int sisusb_probe(struct usb_interface *intf,
2293     goto error_1;
2294     }
2295    
2296     - sisusb->sisusb_dev = dev;
2297     - sisusb->minor = intf->minor;
2298     - sisusb->vrambase = SISUSB_PCI_MEMBASE;
2299     - sisusb->mmiobase = SISUSB_PCI_MMIOBASE;
2300     - sisusb->mmiosize = SISUSB_PCI_MMIOSIZE;
2301     - sisusb->ioportbase = SISUSB_PCI_IOPORTBASE;
2302     - /* Everything else is zero */
2303     + sisusb->minor = intf->minor;
2304    
2305     /* Allocate buffers */
2306     sisusb->ibufsize = SISUSB_IBUF_SIZE;
2307     diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
2308     index c0d6ff1baa72..7931e6cecc70 100644
2309     --- a/drivers/usb/usbip/stub_dev.c
2310     +++ b/drivers/usb/usbip/stub_dev.c
2311     @@ -301,9 +301,17 @@ static int stub_probe(struct usb_device *udev)
2312     const char *udev_busid = dev_name(&udev->dev);
2313     struct bus_id_priv *busid_priv;
2314     int rc = 0;
2315     + char save_status;
2316    
2317     dev_dbg(&udev->dev, "Enter probe\n");
2318    
2319     + /* Not sure if this is our device. Allocate here to avoid
2320     + * calling alloc while holding busid_table lock.
2321     + */
2322     + sdev = stub_device_alloc(udev);
2323     + if (!sdev)
2324     + return -ENOMEM;
2325     +
2326     /* check we should claim or not by busid_table */
2327     busid_priv = get_busid_priv(udev_busid);
2328     if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) ||
2329     @@ -318,6 +326,9 @@ static int stub_probe(struct usb_device *udev)
2330     * See driver_probe_device() in driver/base/dd.c
2331     */
2332     rc = -ENODEV;
2333     + if (!busid_priv)
2334     + goto sdev_free;
2335     +
2336     goto call_put_busid_priv;
2337     }
2338    
2339     @@ -337,12 +348,6 @@ static int stub_probe(struct usb_device *udev)
2340     goto call_put_busid_priv;
2341     }
2342    
2343     - /* ok, this is my device */
2344     - sdev = stub_device_alloc(udev);
2345     - if (!sdev) {
2346     - rc = -ENOMEM;
2347     - goto call_put_busid_priv;
2348     - }
2349    
2350     dev_info(&udev->dev,
2351     "usbip-host: register new device (bus %u dev %u)\n",
2352     @@ -352,9 +357,16 @@ static int stub_probe(struct usb_device *udev)
2353    
2354     /* set private data to usb_device */
2355     dev_set_drvdata(&udev->dev, sdev);
2356     +
2357     busid_priv->sdev = sdev;
2358     busid_priv->udev = udev;
2359    
2360     + save_status = busid_priv->status;
2361     + busid_priv->status = STUB_BUSID_ALLOC;
2362     +
2363     + /* release the busid_lock */
2364     + put_busid_priv(busid_priv);
2365     +
2366     /*
2367     * Claim this hub port.
2368     * It doesn't matter what value we pass as owner
2369     @@ -372,10 +384,8 @@ static int stub_probe(struct usb_device *udev)
2370     dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
2371     goto err_files;
2372     }
2373     - busid_priv->status = STUB_BUSID_ALLOC;
2374    
2375     - rc = 0;
2376     - goto call_put_busid_priv;
2377     + return 0;
2378    
2379     err_files:
2380     usb_hub_release_port(udev->parent, udev->portnum,
2381     @@ -384,23 +394,30 @@ err_port:
2382     dev_set_drvdata(&udev->dev, NULL);
2383     usb_put_dev(udev);
2384    
2385     + /* we already have busid_priv, just lock busid_lock */
2386     + spin_lock(&busid_priv->busid_lock);
2387     busid_priv->sdev = NULL;
2388     - stub_device_free(sdev);
2389     + busid_priv->status = save_status;
2390     + spin_unlock(&busid_priv->busid_lock);
2391     + /* lock is released - go to free */
2392     + goto sdev_free;
2393    
2394     call_put_busid_priv:
2395     + /* release the busid_lock */
2396     put_busid_priv(busid_priv);
2397     +
2398     +sdev_free:
2399     + stub_device_free(sdev);
2400     +
2401     return rc;
2402     }
2403    
2404     static void shutdown_busid(struct bus_id_priv *busid_priv)
2405     {
2406     - if (busid_priv->sdev && !busid_priv->shutdown_busid) {
2407     - busid_priv->shutdown_busid = 1;
2408     - usbip_event_add(&busid_priv->sdev->ud, SDEV_EVENT_REMOVED);
2409     + usbip_event_add(&busid_priv->sdev->ud, SDEV_EVENT_REMOVED);
2410    
2411     - /* wait for the stop of the event handler */
2412     - usbip_stop_eh(&busid_priv->sdev->ud);
2413     - }
2414     + /* wait for the stop of the event handler */
2415     + usbip_stop_eh(&busid_priv->sdev->ud);
2416     }
2417    
2418     /*
2419     @@ -427,11 +444,16 @@ static void stub_disconnect(struct usb_device *udev)
2420     /* get stub_device */
2421     if (!sdev) {
2422     dev_err(&udev->dev, "could not get device");
2423     - goto call_put_busid_priv;
2424     + /* release busid_lock */
2425     + put_busid_priv(busid_priv);
2426     + return;
2427     }
2428    
2429     dev_set_drvdata(&udev->dev, NULL);
2430    
2431     + /* release busid_lock before call to remove device files */
2432     + put_busid_priv(busid_priv);
2433     +
2434     /*
2435     * NOTE: rx/tx threads are invoked for each usb_device.
2436     */
2437     @@ -442,27 +464,36 @@ static void stub_disconnect(struct usb_device *udev)
2438     (struct usb_dev_state *) udev);
2439     if (rc) {
2440     dev_dbg(&udev->dev, "unable to release port\n");
2441     - goto call_put_busid_priv;
2442     + return;
2443     }
2444    
2445     /* If usb reset is called from event handler */
2446     if (usbip_in_eh(current))
2447     - goto call_put_busid_priv;
2448     + return;
2449     +
2450     + /* we already have busid_priv, just lock busid_lock */
2451     + spin_lock(&busid_priv->busid_lock);
2452     + if (!busid_priv->shutdown_busid)
2453     + busid_priv->shutdown_busid = 1;
2454     + /* release busid_lock */
2455     + spin_unlock(&busid_priv->busid_lock);
2456    
2457     /* shutdown the current connection */
2458     shutdown_busid(busid_priv);
2459    
2460     usb_put_dev(sdev->udev);
2461    
2462     + /* we already have busid_priv, just lock busid_lock */
2463     + spin_lock(&busid_priv->busid_lock);
2464     /* free sdev */
2465     busid_priv->sdev = NULL;
2466     stub_device_free(sdev);
2467    
2468     if (busid_priv->status == STUB_BUSID_ALLOC)
2469     busid_priv->status = STUB_BUSID_ADDED;
2470     -
2471     -call_put_busid_priv:
2472     - put_busid_priv(busid_priv);
2473     + /* release busid_lock */
2474     + spin_unlock(&busid_priv->busid_lock);
2475     + return;
2476     }
2477    
2478     #ifdef CONFIG_PM
2479     diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
2480     index 5d961e3ac66e..b96d4e779333 100644
2481     --- a/drivers/video/fbdev/core/fbcon.c
2482     +++ b/drivers/video/fbdev/core/fbcon.c
2483     @@ -1237,7 +1237,7 @@ finished:
2484     if (free_font)
2485     vc->vc_font.data = NULL;
2486    
2487     - if (vc->vc_hi_font_mask)
2488     + if (vc->vc_hi_font_mask && vc->vc_screenbuf)
2489     set_vc_hi_font(vc, false);
2490    
2491     if (!con_is_bound(&fb_con))
2492     diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2493     index 59f361f7d0c1..c1cd3fe2b295 100644
2494     --- a/fs/btrfs/inode.c
2495     +++ b/fs/btrfs/inode.c
2496     @@ -6426,8 +6426,18 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
2497     btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size +
2498     name_len * 2);
2499     inode_inc_iversion(&parent_inode->vfs_inode);
2500     - parent_inode->vfs_inode.i_mtime = parent_inode->vfs_inode.i_ctime =
2501     - current_time(&parent_inode->vfs_inode);
2502     + /*
2503     + * If we are replaying a log tree, we do not want to update the mtime
2504     + * and ctime of the parent directory with the current time, since the
2505     + * log replay procedure is responsible for setting them to their correct
2506     + * values (the ones it had when the fsync was done).
2507     + */
2508     + if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) {
2509     + struct timespec64 now = current_time(&parent_inode->vfs_inode);
2510     +
2511     + parent_inode->vfs_inode.i_mtime = now;
2512     + parent_inode->vfs_inode.i_ctime = now;
2513     + }
2514     ret = btrfs_update_inode(trans, root, &parent_inode->vfs_inode);
2515     if (ret)
2516     btrfs_abort_transaction(trans, ret);
2517     diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
2518     index 635e419f2a2d..258392b75048 100644
2519     --- a/fs/btrfs/send.c
2520     +++ b/fs/btrfs/send.c
2521     @@ -5021,6 +5021,12 @@ static int send_hole(struct send_ctx *sctx, u64 end)
2522     if (offset >= sctx->cur_inode_size)
2523     return 0;
2524    
2525     + /*
2526     + * Don't go beyond the inode's i_size due to prealloc extents that start
2527     + * after the i_size.
2528     + */
2529     + end = min_t(u64, end, sctx->cur_inode_size);
2530     +
2531     if (sctx->flags & BTRFS_SEND_FLAG_NO_FILE_DATA)
2532     return send_update_extent(sctx, offset, end - offset);
2533    
2534     diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
2535     index 75051d36dc1a..0d5840d20efc 100644
2536     --- a/fs/btrfs/tree-log.c
2537     +++ b/fs/btrfs/tree-log.c
2538     @@ -3037,6 +3037,12 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2539     root->log_transid++;
2540     log->log_transid = root->log_transid;
2541     root->log_start_pid = 0;
2542     + /*
2543     + * Update or create log root item under the root's log_mutex to prevent
2544     + * races with concurrent log syncs that can lead to failure to update
2545     + * log root item because it was not created yet.
2546     + */
2547     + ret = update_log_root(trans, log);
2548     /*
2549     * IO has been started, blocks of the log tree have WRITTEN flag set
2550     * in their headers. new modifications of the log will be written to
2551     @@ -3056,8 +3062,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2552    
2553     mutex_unlock(&log_root_tree->log_mutex);
2554    
2555     - ret = update_log_root(trans, log);
2556     -
2557     mutex_lock(&log_root_tree->log_mutex);
2558     if (atomic_dec_and_test(&log_root_tree->log_writers)) {
2559     /* atomic_dec_and_test implies a barrier */
2560     @@ -5308,7 +5312,6 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
2561     {
2562     int ret = 0;
2563     struct dentry *old_parent = NULL;
2564     - struct btrfs_inode *orig_inode = inode;
2565    
2566     /*
2567     * for regular files, if its inode is already on disk, we don't
2568     @@ -5328,16 +5331,6 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
2569     }
2570    
2571     while (1) {
2572     - /*
2573     - * If we are logging a directory then we start with our inode,
2574     - * not our parent's inode, so we need to skip setting the
2575     - * logged_trans so that further down in the log code we don't
2576     - * think this inode has already been logged.
2577     - */
2578     - if (inode != orig_inode)
2579     - inode->logged_trans = trans->transid;
2580     - smp_mb();
2581     -
2582     if (btrfs_must_commit_transaction(trans, inode)) {
2583     ret = 1;
2584     break;
2585     @@ -6066,7 +6059,6 @@ void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
2586     * if this directory was already logged any new
2587     * names for this file/dir will get recorded
2588     */
2589     - smp_mb();
2590     if (dir->logged_trans == trans->transid)
2591     return;
2592    
2593     diff --git a/fs/cifs/file.c b/fs/cifs/file.c
2594     index d6b45682833b..23cee91ed442 100644
2595     --- a/fs/cifs/file.c
2596     +++ b/fs/cifs/file.c
2597     @@ -2988,7 +2988,9 @@ cifs_read_allocate_pages(struct cifs_readdata *rdata, unsigned int nr_pages)
2598     }
2599    
2600     if (rc) {
2601     - for (i = 0; i < nr_pages; i++) {
2602     + unsigned int nr_page_failed = i;
2603     +
2604     + for (i = 0; i < nr_page_failed; i++) {
2605     put_page(rdata->pages[i]);
2606     rdata->pages[i] = NULL;
2607     }
2608     diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
2609     index 33afb637e6f8..c181f1621e1a 100644
2610     --- a/fs/cifs/smb2pdu.c
2611     +++ b/fs/cifs/smb2pdu.c
2612     @@ -887,7 +887,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
2613     * not supported error. Client should accept it.
2614     */
2615     cifs_dbg(VFS, "Server does not support validate negotiate\n");
2616     - return 0;
2617     + rc = 0;
2618     + goto out_free_inbuf;
2619     } else if (rc != 0) {
2620     cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
2621     rc = -EIO;
2622     diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
2623     index 9846f7e95282..7147e4aebecc 100644
2624     --- a/fs/lockd/xdr.c
2625     +++ b/fs/lockd/xdr.c
2626     @@ -127,7 +127,7 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)
2627    
2628     locks_init_lock(fl);
2629     fl->fl_owner = current->files;
2630     - fl->fl_pid = current->tgid;
2631     + fl->fl_pid = (pid_t)lock->svid;
2632     fl->fl_flags = FL_POSIX;
2633     fl->fl_type = F_RDLCK; /* as good as anything else */
2634     start = ntohl(*p++);
2635     @@ -269,7 +269,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
2636     memset(lock, 0, sizeof(*lock));
2637     locks_init_lock(&lock->fl);
2638     lock->svid = ~(u32) 0;
2639     - lock->fl.fl_pid = current->tgid;
2640     + lock->fl.fl_pid = (pid_t)lock->svid;
2641    
2642     if (!(p = nlm_decode_cookie(p, &argp->cookie))
2643     || !(p = xdr_decode_string_inplace(p, &lock->caller,
2644     diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
2645     index 70154f376695..7ed9edf9aed4 100644
2646     --- a/fs/lockd/xdr4.c
2647     +++ b/fs/lockd/xdr4.c
2648     @@ -119,7 +119,7 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
2649    
2650     locks_init_lock(fl);
2651     fl->fl_owner = current->files;
2652     - fl->fl_pid = current->tgid;
2653     + fl->fl_pid = (pid_t)lock->svid;
2654     fl->fl_flags = FL_POSIX;
2655     fl->fl_type = F_RDLCK; /* as good as anything else */
2656     p = xdr_decode_hyper(p, &start);
2657     @@ -266,7 +266,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
2658     memset(lock, 0, sizeof(*lock));
2659     locks_init_lock(&lock->fl);
2660     lock->svid = ~(u32) 0;
2661     - lock->fl.fl_pid = current->tgid;
2662     + lock->fl.fl_pid = (pid_t)lock->svid;
2663    
2664     if (!(p = nlm4_decode_cookie(p, &argp->cookie))
2665     || !(p = xdr_decode_string_inplace(p, &lock->caller,
2666     diff --git a/include/linux/bitops.h b/include/linux/bitops.h
2667     index 7ddb1349394d..7ac2e46112b7 100644
2668     --- a/include/linux/bitops.h
2669     +++ b/include/linux/bitops.h
2670     @@ -60,7 +60,7 @@ static __always_inline unsigned long hweight_long(unsigned long w)
2671     */
2672     static inline __u64 rol64(__u64 word, unsigned int shift)
2673     {
2674     - return (word << shift) | (word >> (64 - shift));
2675     + return (word << (shift & 63)) | (word >> ((-shift) & 63));
2676     }
2677    
2678     /**
2679     @@ -70,7 +70,7 @@ static inline __u64 rol64(__u64 word, unsigned int shift)
2680     */
2681     static inline __u64 ror64(__u64 word, unsigned int shift)
2682     {
2683     - return (word >> shift) | (word << (64 - shift));
2684     + return (word >> (shift & 63)) | (word << ((-shift) & 63));
2685     }
2686    
2687     /**
2688     @@ -80,7 +80,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
2689     */
2690     static inline __u32 rol32(__u32 word, unsigned int shift)
2691     {
2692     - return (word << shift) | (word >> ((-shift) & 31));
2693     + return (word << (shift & 31)) | (word >> ((-shift) & 31));
2694     }
2695    
2696     /**
2697     @@ -90,7 +90,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
2698     */
2699     static inline __u32 ror32(__u32 word, unsigned int shift)
2700     {
2701     - return (word >> shift) | (word << (32 - shift));
2702     + return (word >> (shift & 31)) | (word << ((-shift) & 31));
2703     }
2704    
2705     /**
2706     @@ -100,7 +100,7 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
2707     */
2708     static inline __u16 rol16(__u16 word, unsigned int shift)
2709     {
2710     - return (word << shift) | (word >> (16 - shift));
2711     + return (word << (shift & 15)) | (word >> ((-shift) & 15));
2712     }
2713    
2714     /**
2715     @@ -110,7 +110,7 @@ static inline __u16 rol16(__u16 word, unsigned int shift)
2716     */
2717     static inline __u16 ror16(__u16 word, unsigned int shift)
2718     {
2719     - return (word >> shift) | (word << (16 - shift));
2720     + return (word >> (shift & 15)) | (word << ((-shift) & 15));
2721     }
2722    
2723     /**
2724     @@ -120,7 +120,7 @@ static inline __u16 ror16(__u16 word, unsigned int shift)
2725     */
2726     static inline __u8 rol8(__u8 word, unsigned int shift)
2727     {
2728     - return (word << shift) | (word >> (8 - shift));
2729     + return (word << (shift & 7)) | (word >> ((-shift) & 7));
2730     }
2731    
2732     /**
2733     @@ -130,7 +130,7 @@ static inline __u8 rol8(__u8 word, unsigned int shift)
2734     */
2735     static inline __u8 ror8(__u8 word, unsigned int shift)
2736     {
2737     - return (word >> shift) | (word << (8 - shift));
2738     + return (word >> (shift & 7)) | (word << ((-shift) & 7));
2739     }
2740    
2741     /**
2742     diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
2743     index a8ff0ca0c321..3ebee1ce6f98 100644
2744     --- a/include/linux/compiler-gcc.h
2745     +++ b/include/linux/compiler-gcc.h
2746     @@ -201,6 +201,10 @@
2747     #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
2748     #endif
2749    
2750     +#if GCC_VERSION >= 90100
2751     +#define __copy(symbol) __attribute__((__copy__(symbol)))
2752     +#endif
2753     +
2754     #if !defined(__noclone)
2755     #define __noclone /* not needed */
2756     #endif
2757     diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
2758     index c2ded31a4cec..2b8ed70c4c77 100644
2759     --- a/include/linux/compiler_types.h
2760     +++ b/include/linux/compiler_types.h
2761     @@ -180,6 +180,10 @@ struct ftrace_likely_data {
2762     #define __diag_GCC(version, severity, string)
2763     #endif
2764    
2765     +#ifndef __copy
2766     +# define __copy(symbol)
2767     +#endif
2768     +
2769     #define __diag_push() __diag(push)
2770     #define __diag_pop() __diag(pop)
2771    
2772     diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
2773     index aa5efd9351eb..d5ceb2839a2d 100644
2774     --- a/include/linux/list_lru.h
2775     +++ b/include/linux/list_lru.h
2776     @@ -54,6 +54,7 @@ struct list_lru {
2777     #ifdef CONFIG_MEMCG_KMEM
2778     struct list_head list;
2779     int shrinker_id;
2780     + bool memcg_aware;
2781     #endif
2782     };
2783    
2784     diff --git a/include/linux/module.h b/include/linux/module.h
2785     index c71044644979..9915397715fc 100644
2786     --- a/include/linux/module.h
2787     +++ b/include/linux/module.h
2788     @@ -130,13 +130,13 @@ extern void cleanup_module(void);
2789     #define module_init(initfn) \
2790     static inline initcall_t __maybe_unused __inittest(void) \
2791     { return initfn; } \
2792     - int init_module(void) __attribute__((alias(#initfn)));
2793     + int init_module(void) __copy(initfn) __attribute__((alias(#initfn)));
2794    
2795     /* This is only required if you want to be unloadable. */
2796     #define module_exit(exitfn) \
2797     static inline exitcall_t __maybe_unused __exittest(void) \
2798     { return exitfn; } \
2799     - void cleanup_module(void) __attribute__((alias(#exitfn)));
2800     + void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn)));
2801    
2802     #endif
2803    
2804     diff --git a/include/linux/of.h b/include/linux/of.h
2805     index f2c80cc4641d..d5a863c1ee39 100644
2806     --- a/include/linux/of.h
2807     +++ b/include/linux/of.h
2808     @@ -968,6 +968,12 @@ static inline int of_cpu_node_to_id(struct device_node *np)
2809     #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
2810     #endif
2811    
2812     +static inline int of_prop_val_eq(struct property *p1, struct property *p2)
2813     +{
2814     + return p1->length == p2->length &&
2815     + !memcmp(p1->value, p2->value, (size_t)p1->length);
2816     +}
2817     +
2818     #if defined(CONFIG_OF) && defined(CONFIG_NUMA)
2819     extern int of_node_to_nid(struct device_node *np);
2820     #else
2821     diff --git a/kernel/signal.c b/kernel/signal.c
2822     index 9102d60fc5c6..0e6bc3049427 100644
2823     --- a/kernel/signal.c
2824     +++ b/kernel/signal.c
2825     @@ -2436,6 +2436,8 @@ relock:
2826     if (signal_group_exit(signal)) {
2827     ksig->info.si_signo = signr = SIGKILL;
2828     sigdelset(&current->pending.signal, SIGKILL);
2829     + trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
2830     + &sighand->action[SIGKILL - 1]);
2831     recalc_sigpending();
2832     goto fatal;
2833     }
2834     diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
2835     index 5a1c64a26e81..2fb78467582b 100644
2836     --- a/kernel/trace/trace_events_filter.c
2837     +++ b/kernel/trace/trace_events_filter.c
2838     @@ -427,7 +427,7 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
2839     op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL);
2840     if (!op_stack)
2841     return ERR_PTR(-ENOMEM);
2842     - prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL);
2843     + prog_stack = kcalloc(nr_preds, sizeof(*prog_stack), GFP_KERNEL);
2844     if (!prog_stack) {
2845     parse_error(pe, -ENOMEM, 0);
2846     goto out_free;
2847     @@ -576,7 +576,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
2848     out_free:
2849     kfree(op_stack);
2850     kfree(inverts);
2851     - kfree(prog_stack);
2852     + if (prog_stack) {
2853     + for (i = 0; prog_stack[i].pred; i++)
2854     + kfree(prog_stack[i].pred);
2855     + kfree(prog_stack);
2856     + }
2857     return ERR_PTR(ret);
2858     }
2859    
2860     diff --git a/mm/list_lru.c b/mm/list_lru.c
2861     index 5b30625fd365..f0a15d32b959 100644
2862     --- a/mm/list_lru.c
2863     +++ b/mm/list_lru.c
2864     @@ -37,11 +37,7 @@ static int lru_shrinker_id(struct list_lru *lru)
2865    
2866     static inline bool list_lru_memcg_aware(struct list_lru *lru)
2867     {
2868     - /*
2869     - * This needs node 0 to be always present, even
2870     - * in the systems supporting sparse numa ids.
2871     - */
2872     - return !!lru->node[0].memcg_lrus;
2873     + return lru->memcg_aware;
2874     }
2875    
2876     static inline struct list_lru_one *
2877     @@ -451,6 +447,8 @@ static int memcg_init_list_lru(struct list_lru *lru, bool memcg_aware)
2878     {
2879     int i;
2880    
2881     + lru->memcg_aware = memcg_aware;
2882     +
2883     if (!memcg_aware)
2884     return 0;
2885    
2886     diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
2887     index 552d5efd7cb7..17f06079a712 100644
2888     --- a/scripts/gcc-plugins/gcc-common.h
2889     +++ b/scripts/gcc-plugins/gcc-common.h
2890     @@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
2891     void dump_gimple_stmt(pretty_printer *, gimple, int, int);
2892     #endif
2893    
2894     +#ifndef __unused
2895     #define __unused __attribute__((__unused__))
2896     +#endif
2897     +#ifndef __visible
2898     #define __visible __attribute__((visibility("default")))
2899     +#endif
2900    
2901     #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
2902     #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
2903     diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
2904     index 8a3905bb02c7..6a314fb0d480 100644
2905     --- a/security/integrity/evm/evm_crypto.c
2906     +++ b/security/integrity/evm/evm_crypto.c
2907     @@ -89,6 +89,9 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
2908     tfm = &hmac_tfm;
2909     algo = evm_hmac;
2910     } else {
2911     + if (hash_algo >= HASH_ALGO__LAST)
2912     + return ERR_PTR(-EINVAL);
2913     +
2914     tfm = &evm_tfm[hash_algo];
2915     algo = hash_algo_name[hash_algo];
2916     }
2917     diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
2918     index 8c9499867c91..93babb60b05a 100644
2919     --- a/security/integrity/ima/ima_policy.c
2920     +++ b/security/integrity/ima/ima_policy.c
2921     @@ -1059,10 +1059,10 @@ enum {
2922     };
2923    
2924     static const char *const mask_tokens[] = {
2925     - "MAY_EXEC",
2926     - "MAY_WRITE",
2927     - "MAY_READ",
2928     - "MAY_APPEND"
2929     + "^MAY_EXEC",
2930     + "^MAY_WRITE",
2931     + "^MAY_READ",
2932     + "^MAY_APPEND"
2933     };
2934    
2935     #define __ima_hook_stringify(str) (#str),
2936     @@ -1122,6 +1122,7 @@ int ima_policy_show(struct seq_file *m, void *v)
2937     struct ima_rule_entry *entry = v;
2938     int i;
2939     char tbuf[64] = {0,};
2940     + int offset = 0;
2941    
2942     rcu_read_lock();
2943    
2944     @@ -1145,15 +1146,17 @@ int ima_policy_show(struct seq_file *m, void *v)
2945     if (entry->flags & IMA_FUNC)
2946     policy_func_show(m, entry->func);
2947    
2948     - if (entry->flags & IMA_MASK) {
2949     + if ((entry->flags & IMA_MASK) || (entry->flags & IMA_INMASK)) {
2950     + if (entry->flags & IMA_MASK)
2951     + offset = 1;
2952     if (entry->mask & MAY_EXEC)
2953     - seq_printf(m, pt(Opt_mask), mt(mask_exec));
2954     + seq_printf(m, pt(Opt_mask), mt(mask_exec) + offset);
2955     if (entry->mask & MAY_WRITE)
2956     - seq_printf(m, pt(Opt_mask), mt(mask_write));
2957     + seq_printf(m, pt(Opt_mask), mt(mask_write) + offset);
2958     if (entry->mask & MAY_READ)
2959     - seq_printf(m, pt(Opt_mask), mt(mask_read));
2960     + seq_printf(m, pt(Opt_mask), mt(mask_read) + offset);
2961     if (entry->mask & MAY_APPEND)
2962     - seq_printf(m, pt(Opt_mask), mt(mask_append));
2963     + seq_printf(m, pt(Opt_mask), mt(mask_append) + offset);
2964     seq_puts(m, " ");
2965     }
2966    
2967     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2968     index adce5b60d5b4..5e6cb625db83 100644
2969     --- a/sound/pci/hda/patch_realtek.c
2970     +++ b/sound/pci/hda/patch_realtek.c
2971     @@ -6084,13 +6084,15 @@ static const struct hda_fixup alc269_fixups[] = {
2972     .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
2973     },
2974     [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
2975     - .type = HDA_FIXUP_PINS,
2976     - .v.pins = (const struct hda_pintbl[]) {
2977     - { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2978     - { }
2979     + .type = HDA_FIXUP_VERBS,
2980     + .v.verbs = (const struct hda_verb[]) {
2981     + /* Enable the Mic */
2982     + { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
2983     + { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
2984     + {}
2985     },
2986     .chained = true,
2987     - .chain_id = ALC255_FIXUP_HEADSET_MODE
2988     + .chain_id = ALC269_FIXUP_LIFEBOOK_EXTMIC
2989     },
2990     [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
2991     .type = HDA_FIXUP_PINS,
2992     @@ -7121,6 +7123,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
2993     {0x18, 0x02a11030},
2994     {0x19, 0x0181303F},
2995     {0x21, 0x0221102f}),
2996     + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
2997     + {0x12, 0x90a60140},
2998     + {0x14, 0x90170120},
2999     + {0x21, 0x02211030}),
3000     SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
3001     {0x12, 0x90a601c0},
3002     {0x14, 0x90171120},
3003     @@ -7558,7 +7564,7 @@ static int patch_alc269(struct hda_codec *codec)
3004    
3005     spec = codec->spec;
3006     spec->gen.shared_mic_vref_pin = 0x18;
3007     - codec->power_save_node = 1;
3008     + codec->power_save_node = 0;
3009    
3010     #ifdef CONFIG_PM
3011     codec->patch_ops.suspend = alc269_suspend;
3012     diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
3013     index aa28510d23ad..bbcb0d4d83ae 100644
3014     --- a/sound/usb/line6/driver.c
3015     +++ b/sound/usb/line6/driver.c
3016     @@ -720,6 +720,15 @@ static int line6_init_cap_control(struct usb_line6 *line6)
3017     return 0;
3018     }
3019    
3020     +static void line6_startup_work(struct work_struct *work)
3021     +{
3022     + struct usb_line6 *line6 =
3023     + container_of(work, struct usb_line6, startup_work.work);
3024     +
3025     + if (line6->startup)
3026     + line6->startup(line6);
3027     +}
3028     +
3029     /*
3030     Probe USB device.
3031     */
3032     @@ -755,6 +764,7 @@ int line6_probe(struct usb_interface *interface,
3033     line6->properties = properties;
3034     line6->usbdev = usbdev;
3035     line6->ifcdev = &interface->dev;
3036     + INIT_DELAYED_WORK(&line6->startup_work, line6_startup_work);
3037    
3038     strcpy(card->id, properties->id);
3039     strcpy(card->driver, driver_name);
3040     @@ -825,6 +835,8 @@ void line6_disconnect(struct usb_interface *interface)
3041     if (WARN_ON(usbdev != line6->usbdev))
3042     return;
3043    
3044     + cancel_delayed_work(&line6->startup_work);
3045     +
3046     if (line6->urb_listen != NULL)
3047     line6_stop_listen(line6);
3048    
3049     diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h
3050     index 61425597eb61..650d909c9c4f 100644
3051     --- a/sound/usb/line6/driver.h
3052     +++ b/sound/usb/line6/driver.h
3053     @@ -178,11 +178,15 @@ struct usb_line6 {
3054     fifo;
3055     } messages;
3056    
3057     + /* Work for delayed PCM startup */
3058     + struct delayed_work startup_work;
3059     +
3060     /* If MIDI is supported, buffer_message contains the pre-processed data;
3061     * otherwise the data is only in urb_listen (buffer_incoming).
3062     */
3063     void (*process_message)(struct usb_line6 *);
3064     void (*disconnect)(struct usb_line6 *line6);
3065     + void (*startup)(struct usb_line6 *line6);
3066     };
3067    
3068     extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
3069     diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c
3070     index 325b07b98b3c..7e39083f8f76 100644
3071     --- a/sound/usb/line6/toneport.c
3072     +++ b/sound/usb/line6/toneport.c
3073     @@ -54,9 +54,6 @@ struct usb_line6_toneport {
3074     /* Firmware version (x 100) */
3075     u8 firmware_version;
3076    
3077     - /* Work for delayed PCM startup */
3078     - struct delayed_work pcm_work;
3079     -
3080     /* Device type */
3081     enum line6_device_type type;
3082    
3083     @@ -241,12 +238,8 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
3084     return 1;
3085     }
3086    
3087     -static void toneport_start_pcm(struct work_struct *work)
3088     +static void toneport_startup(struct usb_line6 *line6)
3089     {
3090     - struct usb_line6_toneport *toneport =
3091     - container_of(work, struct usb_line6_toneport, pcm_work.work);
3092     - struct usb_line6 *line6 = &toneport->line6;
3093     -
3094     line6_pcm_acquire(line6->line6pcm, LINE6_STREAM_MONITOR, true);
3095     }
3096    
3097     @@ -394,7 +387,7 @@ static int toneport_setup(struct usb_line6_toneport *toneport)
3098     if (toneport_has_led(toneport))
3099     toneport_update_led(toneport);
3100    
3101     - schedule_delayed_work(&toneport->pcm_work,
3102     + schedule_delayed_work(&toneport->line6.startup_work,
3103     msecs_to_jiffies(TONEPORT_PCM_DELAY * 1000));
3104     return 0;
3105     }
3106     @@ -407,8 +400,6 @@ static void line6_toneport_disconnect(struct usb_line6 *line6)
3107     struct usb_line6_toneport *toneport =
3108     (struct usb_line6_toneport *)line6;
3109    
3110     - cancel_delayed_work_sync(&toneport->pcm_work);
3111     -
3112     if (toneport_has_led(toneport))
3113     toneport_remove_leds(toneport);
3114     }
3115     @@ -424,9 +415,9 @@ static int toneport_init(struct usb_line6 *line6,
3116     struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
3117    
3118     toneport->type = id->driver_info;
3119     - INIT_DELAYED_WORK(&toneport->pcm_work, toneport_start_pcm);
3120    
3121     line6->disconnect = line6_toneport_disconnect;
3122     + line6->startup = toneport_startup;
3123    
3124     /* initialize PCM subsystem: */
3125     err = line6_init_pcm(line6, &toneport_pcm_properties);
3126     diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
3127     index fef3527af3bd..02bac8abd206 100644
3128     --- a/virt/kvm/arm/arm.c
3129     +++ b/virt/kvm/arm/arm.c
3130     @@ -223,6 +223,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
3131     case KVM_CAP_MAX_VCPUS:
3132     r = KVM_MAX_VCPUS;
3133     break;
3134     + case KVM_CAP_MAX_VCPU_ID:
3135     + r = KVM_MAX_VCPU_ID;
3136     + break;
3137     case KVM_CAP_NR_MEMSLOTS:
3138     r = KVM_USER_MEM_SLOTS;
3139     break;
3140     diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
3141     index e909d9907b50..2b36a51afb57 100644
3142     --- a/virt/kvm/kvm_main.c
3143     +++ b/virt/kvm/kvm_main.c
3144     @@ -2965,8 +2965,6 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
3145     case KVM_CAP_MULTI_ADDRESS_SPACE:
3146     return KVM_ADDRESS_SPACE_NUM;
3147     #endif
3148     - case KVM_CAP_MAX_VCPU_ID:
3149     - return KVM_MAX_VCPU_ID;
3150     default:
3151     break;
3152     }