Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Sat, 08 Dec 2018 13:22:57
Message-Id: 1544275238.5829d907f1f0a3ef05e7a0339159b485cc84bb50.mpagano@gentoo
1 commit: 5829d907f1f0a3ef05e7a0339159b485cc84bb50
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 8 13:20:38 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 8 13:20:38 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5829d907
7
8 proj/linux-patches: Linux patch 4.14.87
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1086_linux-4.14.87.patch | 2334 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2338 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index b0b15a3..b64e7d4 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -387,6 +387,10 @@ Patch: 1085_4.14.86.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.86
23
24 +Patch: 1086_4.14.87.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.87
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1086_linux-4.14.87.patch b/1086_linux-4.14.87.patch
33 new file mode 100644
34 index 0000000..89e0a61
35 --- /dev/null
36 +++ b/1086_linux-4.14.87.patch
37 @@ -0,0 +1,2334 @@
38 +diff --git a/Makefile b/Makefile
39 +index 572bd98d2344..322484348f3e 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 86
47 ++SUBLEVEL = 87
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +@@ -803,6 +803,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
52 + # disable pointer signed / unsigned warnings in gcc 4.0
53 + KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
54 +
55 ++# disable stringop warnings in gcc 8+
56 ++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
57 ++
58 + # disable invalid "can't wrap" optimizations for signed / pointers
59 + KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
60 +
61 +diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
62 +index 8ff066090680..9d06c9478a0d 100644
63 +--- a/arch/arc/Kconfig
64 ++++ b/arch/arc/Kconfig
65 +@@ -109,7 +109,7 @@ endmenu
66 +
67 + choice
68 + prompt "ARC Instruction Set"
69 +- default ISA_ARCOMPACT
70 ++ default ISA_ARCV2
71 +
72 + config ISA_ARCOMPACT
73 + bool "ARCompact ISA"
74 +diff --git a/arch/arc/Makefile b/arch/arc/Makefile
75 +index 7c6c97782022..2917f56f0ea4 100644
76 +--- a/arch/arc/Makefile
77 ++++ b/arch/arc/Makefile
78 +@@ -6,7 +6,7 @@
79 + # published by the Free Software Foundation.
80 + #
81 +
82 +-KBUILD_DEFCONFIG := nsim_700_defconfig
83 ++KBUILD_DEFCONFIG := nsim_hs_defconfig
84 +
85 + cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
86 + cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
87 +diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig
88 +index ece78630d711..5d5ba2104ba7 100644
89 +--- a/arch/arc/configs/axs101_defconfig
90 ++++ b/arch/arc/configs/axs101_defconfig
91 +@@ -15,6 +15,7 @@ CONFIG_PERF_EVENTS=y
92 + # CONFIG_VM_EVENT_COUNTERS is not set
93 + # CONFIG_SLUB_DEBUG is not set
94 + # CONFIG_COMPAT_BRK is not set
95 ++CONFIG_ISA_ARCOMPACT=y
96 + CONFIG_MODULES=y
97 + CONFIG_MODULE_FORCE_LOAD=y
98 + CONFIG_MODULE_UNLOAD=y
99 +@@ -98,6 +99,7 @@ CONFIG_VFAT_FS=y
100 + CONFIG_NTFS_FS=y
101 + CONFIG_TMPFS=y
102 + CONFIG_NFS_FS=y
103 ++CONFIG_NFS_V3_ACL=y
104 + CONFIG_NLS_CODEPAGE_437=y
105 + CONFIG_NLS_ISO8859_1=y
106 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
107 +diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig
108 +index 240c9251a7d4..0874db2d48a8 100644
109 +--- a/arch/arc/configs/axs103_defconfig
110 ++++ b/arch/arc/configs/axs103_defconfig
111 +@@ -97,6 +97,7 @@ CONFIG_VFAT_FS=y
112 + CONFIG_NTFS_FS=y
113 + CONFIG_TMPFS=y
114 + CONFIG_NFS_FS=y
115 ++CONFIG_NFS_V3_ACL=y
116 + CONFIG_NLS_CODEPAGE_437=y
117 + CONFIG_NLS_ISO8859_1=y
118 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
119 +diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig
120 +index af54b96abee0..cf5df0e1cb08 100644
121 +--- a/arch/arc/configs/axs103_smp_defconfig
122 ++++ b/arch/arc/configs/axs103_smp_defconfig
123 +@@ -100,6 +100,7 @@ CONFIG_VFAT_FS=y
124 + CONFIG_NTFS_FS=y
125 + CONFIG_TMPFS=y
126 + CONFIG_NFS_FS=y
127 ++CONFIG_NFS_V3_ACL=y
128 + CONFIG_NLS_CODEPAGE_437=y
129 + CONFIG_NLS_ISO8859_1=y
130 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
131 +diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
132 +index 762b1fcd93dc..083560e9e571 100644
133 +--- a/arch/arc/configs/hsdk_defconfig
134 ++++ b/arch/arc/configs/hsdk_defconfig
135 +@@ -66,6 +66,7 @@ CONFIG_EXT3_FS=y
136 + CONFIG_VFAT_FS=y
137 + CONFIG_TMPFS=y
138 + CONFIG_NFS_FS=y
139 ++CONFIG_NFS_V3_ACL=y
140 + CONFIG_NLS_CODEPAGE_437=y
141 + CONFIG_NLS_ISO8859_1=y
142 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
143 +diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig
144 +index 7c9c706ae7f6..9121c6ba15d0 100644
145 +--- a/arch/arc/configs/nps_defconfig
146 ++++ b/arch/arc/configs/nps_defconfig
147 +@@ -15,6 +15,7 @@ CONFIG_SYSCTL_SYSCALL=y
148 + CONFIG_EMBEDDED=y
149 + CONFIG_PERF_EVENTS=y
150 + # CONFIG_COMPAT_BRK is not set
151 ++CONFIG_ISA_ARCOMPACT=y
152 + CONFIG_KPROBES=y
153 + CONFIG_MODULES=y
154 + CONFIG_MODULE_FORCE_LOAD=y
155 +@@ -74,6 +75,7 @@ CONFIG_PROC_KCORE=y
156 + CONFIG_TMPFS=y
157 + # CONFIG_MISC_FILESYSTEMS is not set
158 + CONFIG_NFS_FS=y
159 ++CONFIG_NFS_V3_ACL=y
160 + CONFIG_ROOT_NFS=y
161 + CONFIG_DEBUG_INFO=y
162 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
163 +diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig
164 +index b1a78222699c..cdb06417d3d9 100644
165 +--- a/arch/arc/configs/nsim_700_defconfig
166 ++++ b/arch/arc/configs/nsim_700_defconfig
167 +@@ -16,6 +16,7 @@ CONFIG_EMBEDDED=y
168 + CONFIG_PERF_EVENTS=y
169 + # CONFIG_SLUB_DEBUG is not set
170 + # CONFIG_COMPAT_BRK is not set
171 ++CONFIG_ISA_ARCOMPACT=y
172 + CONFIG_KPROBES=y
173 + CONFIG_MODULES=y
174 + # CONFIG_LBDAF is not set
175 +diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig
176 +index 14377b8234f7..c4577bd9196c 100644
177 +--- a/arch/arc/configs/nsimosci_defconfig
178 ++++ b/arch/arc/configs/nsimosci_defconfig
179 +@@ -16,6 +16,7 @@ CONFIG_EMBEDDED=y
180 + CONFIG_PERF_EVENTS=y
181 + # CONFIG_SLUB_DEBUG is not set
182 + # CONFIG_COMPAT_BRK is not set
183 ++CONFIG_ISA_ARCOMPACT=y
184 + CONFIG_KPROBES=y
185 + CONFIG_MODULES=y
186 + # CONFIG_LBDAF is not set
187 +@@ -69,5 +70,6 @@ CONFIG_EXT2_FS_XATTR=y
188 + CONFIG_TMPFS=y
189 + # CONFIG_MISC_FILESYSTEMS is not set
190 + CONFIG_NFS_FS=y
191 ++CONFIG_NFS_V3_ACL=y
192 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
193 + # CONFIG_ENABLE_MUST_CHECK is not set
194 +diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig
195 +index 7e61c923a3cd..b20692c82d3c 100644
196 +--- a/arch/arc/configs/nsimosci_hs_defconfig
197 ++++ b/arch/arc/configs/nsimosci_hs_defconfig
198 +@@ -68,5 +68,6 @@ CONFIG_EXT2_FS_XATTR=y
199 + CONFIG_TMPFS=y
200 + # CONFIG_MISC_FILESYSTEMS is not set
201 + CONFIG_NFS_FS=y
202 ++CONFIG_NFS_V3_ACL=y
203 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
204 + # CONFIG_ENABLE_MUST_CHECK is not set
205 +diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig
206 +index 299fbe8003b2..5ad4949af6d0 100644
207 +--- a/arch/arc/configs/nsimosci_hs_smp_defconfig
208 ++++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
209 +@@ -79,6 +79,7 @@ CONFIG_EXT2_FS_XATTR=y
210 + CONFIG_TMPFS=y
211 + # CONFIG_MISC_FILESYSTEMS is not set
212 + CONFIG_NFS_FS=y
213 ++CONFIG_NFS_V3_ACL=y
214 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
215 + # CONFIG_ENABLE_MUST_CHECK is not set
216 + CONFIG_FTRACE=y
217 +diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
218 +index f30182549395..0130e29eeca1 100644
219 +--- a/arch/arc/configs/tb10x_defconfig
220 ++++ b/arch/arc/configs/tb10x_defconfig
221 +@@ -19,6 +19,7 @@ CONFIG_KALLSYMS_ALL=y
222 + # CONFIG_AIO is not set
223 + CONFIG_EMBEDDED=y
224 + # CONFIG_COMPAT_BRK is not set
225 ++CONFIG_ISA_ARCOMPACT=y
226 + CONFIG_SLAB=y
227 + CONFIG_MODULES=y
228 + CONFIG_MODULE_FORCE_LOAD=y
229 +diff --git a/arch/arc/configs/vdk_hs38_defconfig b/arch/arc/configs/vdk_hs38_defconfig
230 +index 4fcf4f2503f6..4587c9af5afe 100644
231 +--- a/arch/arc/configs/vdk_hs38_defconfig
232 ++++ b/arch/arc/configs/vdk_hs38_defconfig
233 +@@ -88,6 +88,7 @@ CONFIG_NTFS_FS=y
234 + CONFIG_TMPFS=y
235 + CONFIG_JFFS2_FS=y
236 + CONFIG_NFS_FS=y
237 ++CONFIG_NFS_V3_ACL=y
238 + CONFIG_NLS_CODEPAGE_437=y
239 + CONFIG_NLS_ISO8859_1=y
240 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
241 +diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig b/arch/arc/configs/vdk_hs38_smp_defconfig
242 +index 7b71464f6c2f..1855aa995bc9 100644
243 +--- a/arch/arc/configs/vdk_hs38_smp_defconfig
244 ++++ b/arch/arc/configs/vdk_hs38_smp_defconfig
245 +@@ -92,6 +92,7 @@ CONFIG_NTFS_FS=y
246 + CONFIG_TMPFS=y
247 + CONFIG_JFFS2_FS=y
248 + CONFIG_NFS_FS=y
249 ++CONFIG_NFS_V3_ACL=y
250 + CONFIG_NLS_CODEPAGE_437=y
251 + CONFIG_NLS_ISO8859_1=y
252 + # CONFIG_ENABLE_WARN_DEPRECATED is not set
253 +diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
254 +index 7c713025b23f..53ee82b1efa7 100644
255 +--- a/arch/mips/include/asm/syscall.h
256 ++++ b/arch/mips/include/asm/syscall.h
257 +@@ -51,7 +51,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
258 + #ifdef CONFIG_64BIT
259 + case 4: case 5: case 6: case 7:
260 + #ifdef CONFIG_MIPS32_O32
261 +- if (test_thread_flag(TIF_32BIT_REGS))
262 ++ if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
263 + return get_user(*arg, (int *)usp + n);
264 + else
265 + #endif
266 +diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c
267 +index 41b71c4352c2..c1ce6f43642b 100644
268 +--- a/arch/mips/ralink/mt7620.c
269 ++++ b/arch/mips/ralink/mt7620.c
270 +@@ -84,7 +84,7 @@ static struct rt2880_pmx_func pcie_rst_grp[] = {
271 + };
272 + static struct rt2880_pmx_func nd_sd_grp[] = {
273 + FUNC("nand", MT7620_GPIO_MODE_NAND, 45, 15),
274 +- FUNC("sd", MT7620_GPIO_MODE_SD, 45, 15)
275 ++ FUNC("sd", MT7620_GPIO_MODE_SD, 47, 13)
276 + };
277 +
278 + static struct rt2880_pmx_group mt7620a_pinmux_data[] = {
279 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
280 +index 17f08db34547..4dc79d139810 100644
281 +--- a/arch/x86/kvm/svm.c
282 ++++ b/arch/x86/kvm/svm.c
283 +@@ -1399,20 +1399,23 @@ static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu,
284 + static int avic_init_access_page(struct kvm_vcpu *vcpu)
285 + {
286 + struct kvm *kvm = vcpu->kvm;
287 +- int ret;
288 ++ int ret = 0;
289 +
290 ++ mutex_lock(&kvm->slots_lock);
291 + if (kvm->arch.apic_access_page_done)
292 +- return 0;
293 ++ goto out;
294 +
295 +- ret = x86_set_memory_region(kvm,
296 +- APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
297 +- APIC_DEFAULT_PHYS_BASE,
298 +- PAGE_SIZE);
299 ++ ret = __x86_set_memory_region(kvm,
300 ++ APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
301 ++ APIC_DEFAULT_PHYS_BASE,
302 ++ PAGE_SIZE);
303 + if (ret)
304 +- return ret;
305 ++ goto out;
306 +
307 + kvm->arch.apic_access_page_done = true;
308 +- return 0;
309 ++out:
310 ++ mutex_unlock(&kvm->slots_lock);
311 ++ return ret;
312 + }
313 +
314 + static int avic_init_backing_page(struct kvm_vcpu *vcpu)
315 +diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
316 +index dac355812adc..373700c05a00 100644
317 +--- a/drivers/gpu/drm/ast/ast_main.c
318 ++++ b/drivers/gpu/drm/ast/ast_main.c
319 +@@ -583,7 +583,8 @@ void ast_driver_unload(struct drm_device *dev)
320 + drm_mode_config_cleanup(dev);
321 +
322 + ast_mm_fini(ast);
323 +- pci_iounmap(dev->pdev, ast->ioregs);
324 ++ if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
325 ++ pci_iounmap(dev->pdev, ast->ioregs);
326 + pci_iounmap(dev->pdev, ast->regs);
327 + kfree(ast);
328 + }
329 +diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
330 +index 7ff697389d74..fe85d041d0ba 100644
331 +--- a/drivers/gpu/drm/drm_auth.c
332 ++++ b/drivers/gpu/drm/drm_auth.c
333 +@@ -133,6 +133,7 @@ static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
334 +
335 + lockdep_assert_held_once(&dev->master_mutex);
336 +
337 ++ WARN_ON(fpriv->is_master);
338 + old_master = fpriv->master;
339 + fpriv->master = drm_master_create(dev);
340 + if (!fpriv->master) {
341 +@@ -161,6 +162,7 @@ out_err:
342 + /* drop references and restore old master on failure */
343 + drm_master_put(&fpriv->master);
344 + fpriv->master = old_master;
345 ++ fpriv->is_master = 0;
346 +
347 + return ret;
348 + }
349 +diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
350 +index 531e4450c000..5c066448be5b 100644
351 +--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
352 ++++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
353 +@@ -99,7 +99,7 @@ void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe)
354 + /* Wait for for the pipe enable to take effect. */
355 + for (count = 0; count < COUNT_MAX; count++) {
356 + temp = REG_READ(map->conf);
357 +- if ((temp & PIPEACONF_PIPE_STATE) == 1)
358 ++ if (temp & PIPEACONF_PIPE_STATE)
359 + break;
360 + }
361 + }
362 +diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
363 +index cef414466f9f..e5f7a7cf48fa 100644
364 +--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
365 ++++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
366 +@@ -697,6 +697,7 @@ static const struct regmap_config meson_dw_hdmi_regmap_config = {
367 + .reg_read = meson_dw_hdmi_reg_read,
368 + .reg_write = meson_dw_hdmi_reg_write,
369 + .max_register = 0x10000,
370 ++ .fast_io = true,
371 + };
372 +
373 + static bool meson_hdmi_connector_is_available(struct device *dev)
374 +diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c
375 +index 6bcfa527c180..26a0857878bf 100644
376 +--- a/drivers/gpu/drm/meson/meson_viu.c
377 ++++ b/drivers/gpu/drm/meson/meson_viu.c
378 +@@ -184,18 +184,18 @@ void meson_viu_set_osd_lut(struct meson_drm *priv, enum viu_lut_sel_e lut_sel,
379 + if (lut_sel == VIU_LUT_OSD_OETF) {
380 + writel(0, priv->io_base + _REG(addr_port));
381 +
382 +- for (i = 0; i < 20; i++)
383 ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++)
384 + writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16),
385 + priv->io_base + _REG(data_port));
386 +
387 + writel(r_map[OSD_OETF_LUT_SIZE - 1] | (g_map[0] << 16),
388 + priv->io_base + _REG(data_port));
389 +
390 +- for (i = 0; i < 20; i++)
391 ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++)
392 + writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16),
393 + priv->io_base + _REG(data_port));
394 +
395 +- for (i = 0; i < 20; i++)
396 ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++)
397 + writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16),
398 + priv->io_base + _REG(data_port));
399 +
400 +@@ -211,18 +211,18 @@ void meson_viu_set_osd_lut(struct meson_drm *priv, enum viu_lut_sel_e lut_sel,
401 + } else if (lut_sel == VIU_LUT_OSD_EOTF) {
402 + writel(0, priv->io_base + _REG(addr_port));
403 +
404 +- for (i = 0; i < 20; i++)
405 ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++)
406 + writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16),
407 + priv->io_base + _REG(data_port));
408 +
409 + writel(r_map[OSD_EOTF_LUT_SIZE - 1] | (g_map[0] << 16),
410 + priv->io_base + _REG(data_port));
411 +
412 +- for (i = 0; i < 20; i++)
413 ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++)
414 + writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16),
415 + priv->io_base + _REG(data_port));
416 +
417 +- for (i = 0; i < 20; i++)
418 ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++)
419 + writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16),
420 + priv->io_base + _REG(data_port));
421 +
422 +diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
423 +index c75c4df4bc39..2c379774d3f2 100644
424 +--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
425 ++++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
426 +@@ -223,8 +223,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev)
427 + struct device_node *child, *node;
428 + int ret;
429 +
430 +- node = of_find_compatible_node(dev->of_node, NULL,
431 +- "qcom,gpu-pwrlevels");
432 ++ node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels");
433 + if (!node) {
434 + dev_err(dev, "Could not find the GPU powerlevels\n");
435 + return -ENXIO;
436 +@@ -245,6 +244,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev)
437 + dev_pm_opp_add(dev, val, 0);
438 + }
439 +
440 ++ of_node_put(node);
441 ++
442 + return 0;
443 + }
444 +
445 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
446 +index c3a4f5d92391..13a92062e9ca 100644
447 +--- a/drivers/infiniband/hw/mlx5/main.c
448 ++++ b/drivers/infiniband/hw/mlx5/main.c
449 +@@ -869,31 +869,26 @@ enum mlx5_ib_width {
450 + MLX5_IB_WIDTH_12X = 1 << 4
451 + };
452 +
453 +-static int translate_active_width(struct ib_device *ibdev, u8 active_width,
454 ++static void translate_active_width(struct ib_device *ibdev, u8 active_width,
455 + u8 *ib_width)
456 + {
457 + struct mlx5_ib_dev *dev = to_mdev(ibdev);
458 +- int err = 0;
459 +
460 +- if (active_width & MLX5_IB_WIDTH_1X) {
461 ++ if (active_width & MLX5_IB_WIDTH_1X)
462 + *ib_width = IB_WIDTH_1X;
463 +- } else if (active_width & MLX5_IB_WIDTH_2X) {
464 +- mlx5_ib_dbg(dev, "active_width %d is not supported by IB spec\n",
465 +- (int)active_width);
466 +- err = -EINVAL;
467 +- } else if (active_width & MLX5_IB_WIDTH_4X) {
468 ++ else if (active_width & MLX5_IB_WIDTH_4X)
469 + *ib_width = IB_WIDTH_4X;
470 +- } else if (active_width & MLX5_IB_WIDTH_8X) {
471 ++ else if (active_width & MLX5_IB_WIDTH_8X)
472 + *ib_width = IB_WIDTH_8X;
473 +- } else if (active_width & MLX5_IB_WIDTH_12X) {
474 ++ else if (active_width & MLX5_IB_WIDTH_12X)
475 + *ib_width = IB_WIDTH_12X;
476 +- } else {
477 +- mlx5_ib_dbg(dev, "Invalid active_width %d\n",
478 ++ else {
479 ++ mlx5_ib_dbg(dev, "Invalid active_width %d, setting width to default value: 4x\n",
480 + (int)active_width);
481 +- err = -EINVAL;
482 ++ *ib_width = IB_WIDTH_4X;
483 + }
484 +
485 +- return err;
486 ++ return;
487 + }
488 +
489 + static int mlx5_mtu_to_ib_mtu(int mtu)
490 +@@ -1001,10 +996,8 @@ static int mlx5_query_hca_port(struct ib_device *ibdev, u8 port,
491 + if (err)
492 + goto out;
493 +
494 +- err = translate_active_width(ibdev, ib_link_width_oper,
495 +- &props->active_width);
496 +- if (err)
497 +- goto out;
498 ++ translate_active_width(ibdev, ib_link_width_oper, &props->active_width);
499 ++
500 + err = mlx5_query_port_ib_proto_oper(mdev, &props->active_speed, port);
501 + if (err)
502 + goto out;
503 +diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
504 +index 55a73b0ed4c6..e28a5d713d1a 100644
505 +--- a/drivers/infiniband/ulp/iser/iser_verbs.c
506 ++++ b/drivers/infiniband/ulp/iser/iser_verbs.c
507 +@@ -1108,7 +1108,9 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task,
508 + IB_MR_CHECK_SIG_STATUS, &mr_status);
509 + if (ret) {
510 + pr_err("ib_check_mr_status failed, ret %d\n", ret);
511 +- goto err;
512 ++ /* Not a lot we can do, return ambiguous guard error */
513 ++ *sector = 0;
514 ++ return 0x1;
515 + }
516 +
517 + if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
518 +@@ -1136,9 +1138,6 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task,
519 + }
520 +
521 + return 0;
522 +-err:
523 +- /* Not alot we can do here, return ambiguous guard error */
524 +- return 0x1;
525 + }
526 +
527 + void iser_err_comp(struct ib_wc *wc, const char *type)
528 +diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
529 +index 2e52015634f9..f55dcdf99bc5 100644
530 +--- a/drivers/input/joystick/xpad.c
531 ++++ b/drivers/input/joystick/xpad.c
532 +@@ -483,18 +483,18 @@ static const u8 xboxone_hori_init[] = {
533 + };
534 +
535 + /*
536 +- * This packet is required for some of the PDP pads to start
537 ++ * This packet is required for most (all?) of the PDP pads to start
538 + * sending input reports. These pads include: (0x0e6f:0x02ab),
539 +- * (0x0e6f:0x02a4).
540 ++ * (0x0e6f:0x02a4), (0x0e6f:0x02a6).
541 + */
542 + static const u8 xboxone_pdp_init1[] = {
543 + 0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
544 + };
545 +
546 + /*
547 +- * This packet is required for some of the PDP pads to start
548 ++ * This packet is required for most (all?) of the PDP pads to start
549 + * sending input reports. These pads include: (0x0e6f:0x02ab),
550 +- * (0x0e6f:0x02a4).
551 ++ * (0x0e6f:0x02a4), (0x0e6f:0x02a6).
552 + */
553 + static const u8 xboxone_pdp_init2[] = {
554 + 0x06, 0x20, 0x00, 0x02, 0x01, 0x00
555 +@@ -530,12 +530,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
556 + XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
557 + XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
558 + XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
559 +- XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1),
560 +- XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
561 +- XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1),
562 +- XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2),
563 +- XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init1),
564 +- XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init2),
565 ++ XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init1),
566 ++ XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init2),
567 + XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
568 + XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
569 + XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
570 +diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
571 +index 79eb29550c34..0993b3f12df6 100644
572 +--- a/drivers/input/keyboard/cros_ec_keyb.c
573 ++++ b/drivers/input/keyboard/cros_ec_keyb.c
574 +@@ -506,7 +506,8 @@ static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev)
575 + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) {
576 + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i];
577 +
578 +- if (buttons & BIT(map->bit))
579 ++ if ((map->ev_type == EV_KEY && (buttons & BIT(map->bit))) ||
580 ++ (map->ev_type == EV_SW && (switches & BIT(map->bit))))
581 + input_set_capability(idev, map->ev_type, map->code);
582 + }
583 +
584 +diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
585 +index 41614c185918..782dda68d93a 100644
586 +--- a/drivers/input/keyboard/matrix_keypad.c
587 ++++ b/drivers/input/keyboard/matrix_keypad.c
588 +@@ -407,7 +407,7 @@ matrix_keypad_parse_dt(struct device *dev)
589 + struct matrix_keypad_platform_data *pdata;
590 + struct device_node *np = dev->of_node;
591 + unsigned int *gpios;
592 +- int i, nrow, ncol;
593 ++ int ret, i, nrow, ncol;
594 +
595 + if (!np) {
596 + dev_err(dev, "device lacks DT data\n");
597 +@@ -452,12 +452,19 @@ matrix_keypad_parse_dt(struct device *dev)
598 + return ERR_PTR(-ENOMEM);
599 + }
600 +
601 +- for (i = 0; i < pdata->num_row_gpios; i++)
602 +- gpios[i] = of_get_named_gpio(np, "row-gpios", i);
603 ++ for (i = 0; i < nrow; i++) {
604 ++ ret = of_get_named_gpio(np, "row-gpios", i);
605 ++ if (ret < 0)
606 ++ return ERR_PTR(ret);
607 ++ gpios[i] = ret;
608 ++ }
609 +
610 +- for (i = 0; i < pdata->num_col_gpios; i++)
611 +- gpios[pdata->num_row_gpios + i] =
612 +- of_get_named_gpio(np, "col-gpios", i);
613 ++ for (i = 0; i < ncol; i++) {
614 ++ ret = of_get_named_gpio(np, "col-gpios", i);
615 ++ if (ret < 0)
616 ++ return ERR_PTR(ret);
617 ++ gpios[nrow + i] = ret;
618 ++ }
619 +
620 + pdata->row_gpios = gpios;
621 + pdata->col_gpios = &gpios[pdata->num_row_gpios];
622 +@@ -484,10 +491,8 @@ static int matrix_keypad_probe(struct platform_device *pdev)
623 + pdata = dev_get_platdata(&pdev->dev);
624 + if (!pdata) {
625 + pdata = matrix_keypad_parse_dt(&pdev->dev);
626 +- if (IS_ERR(pdata)) {
627 +- dev_err(&pdev->dev, "no platform data defined\n");
628 ++ if (IS_ERR(pdata))
629 + return PTR_ERR(pdata);
630 +- }
631 + } else if (!pdata->keymap_data) {
632 + dev_err(&pdev->dev, "no keymap data defined\n");
633 + return -EINVAL;
634 +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
635 +index 766d30a7b085..368871a398a5 100644
636 +--- a/drivers/input/mouse/elan_i2c_core.c
637 ++++ b/drivers/input/mouse/elan_i2c_core.c
638 +@@ -1264,6 +1264,9 @@ static const struct acpi_device_id elan_acpi_id[] = {
639 + { "ELAN0618", 0 },
640 + { "ELAN061C", 0 },
641 + { "ELAN061D", 0 },
642 ++ { "ELAN061E", 0 },
643 ++ { "ELAN0620", 0 },
644 ++ { "ELAN0621", 0 },
645 + { "ELAN0622", 0 },
646 + { "ELAN1000", 0 },
647 + { }
648 +diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
649 +index 6f36e2d01e2e..65c9095eb517 100644
650 +--- a/drivers/input/mouse/synaptics.c
651 ++++ b/drivers/input/mouse/synaptics.c
652 +@@ -170,6 +170,7 @@ static const char * const smbus_pnp_ids[] = {
653 + "LEN0048", /* X1 Carbon 3 */
654 + "LEN0046", /* X250 */
655 + "LEN004a", /* W541 */
656 ++ "LEN005b", /* P50 */
657 + "LEN0071", /* T480 */
658 + "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */
659 + "LEN0073", /* X1 Carbon G5 (Elantech) */
660 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
661 +index 03c3cf77aaff..99f32202a85c 100644
662 +--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
663 ++++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
664 +@@ -3590,10 +3590,8 @@ static u32 qed_grc_dump_big_ram(struct qed_hwfn *p_hwfn,
665 + total_blocks = big_ram->num_of_blocks[dev_data->chip_id];
666 + ram_size = total_blocks * BIG_RAM_BLOCK_SIZE_DWORDS;
667 +
668 +- strncpy(type_name, big_ram->instance_name,
669 +- strlen(big_ram->instance_name));
670 +- strncpy(mem_name, big_ram->instance_name,
671 +- strlen(big_ram->instance_name));
672 ++ strscpy(type_name, big_ram->instance_name, sizeof(type_name));
673 ++ strscpy(mem_name, big_ram->instance_name, sizeof(mem_name));
674 +
675 + /* Dump memory header */
676 + offset += qed_grc_dump_mem_hdr(p_hwfn,
677 +diff --git a/drivers/reset/core.c b/drivers/reset/core.c
678 +index 1d21c6f7d56c..da4292e9de97 100644
679 +--- a/drivers/reset/core.c
680 ++++ b/drivers/reset/core.c
681 +@@ -566,17 +566,18 @@ EXPORT_SYMBOL_GPL(__devm_reset_control_get);
682 + * device_reset - find reset controller associated with the device
683 + * and perform reset
684 + * @dev: device to be reset by the controller
685 ++ * @optional: whether it is optional to reset the device
686 + *
687 +- * Convenience wrapper for reset_control_get() and reset_control_reset().
688 ++ * Convenience wrapper for __reset_control_get() and reset_control_reset().
689 + * This is useful for the common case of devices with single, dedicated reset
690 + * lines.
691 + */
692 +-int device_reset(struct device *dev)
693 ++int __device_reset(struct device *dev, bool optional)
694 + {
695 + struct reset_control *rstc;
696 + int ret;
697 +
698 +- rstc = reset_control_get(dev, NULL);
699 ++ rstc = __reset_control_get(dev, NULL, 0, 0, optional);
700 + if (IS_ERR(rstc))
701 + return PTR_ERR(rstc);
702 +
703 +@@ -586,7 +587,7 @@ int device_reset(struct device *dev)
704 +
705 + return ret;
706 + }
707 +-EXPORT_SYMBOL_GPL(device_reset);
708 ++EXPORT_SYMBOL_GPL(__device_reset);
709 +
710 + /**
711 + * APIs to manage an array of reset controls.
712 +diff --git a/drivers/scsi/bfa/bfa_fcbuild.c b/drivers/scsi/bfa/bfa_fcbuild.c
713 +index b8dadc9cc993..d3b00a475aeb 100644
714 +--- a/drivers/scsi/bfa/bfa_fcbuild.c
715 ++++ b/drivers/scsi/bfa/bfa_fcbuild.c
716 +@@ -1250,8 +1250,8 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
717 + memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s));
718 +
719 + rspnid->dap = s_id;
720 +- rspnid->spn_len = (u8) strlen((char *)name);
721 +- strncpy((char *)rspnid->spn, (char *)name, rspnid->spn_len);
722 ++ strlcpy(rspnid->spn, name, sizeof(rspnid->spn));
723 ++ rspnid->spn_len = (u8) strlen(rspnid->spn);
724 +
725 + return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s);
726 + }
727 +@@ -1271,8 +1271,8 @@ fc_rsnn_nn_build(struct fchs_s *fchs, void *pyld, u32 s_id,
728 + memset(rsnn_nn, 0, sizeof(struct fcgs_rsnn_nn_req_s));
729 +
730 + rsnn_nn->node_name = node_name;
731 +- rsnn_nn->snn_len = (u8) strlen((char *)name);
732 +- strncpy((char *)rsnn_nn->snn, (char *)name, rsnn_nn->snn_len);
733 ++ strlcpy(rsnn_nn->snn, name, sizeof(rsnn_nn->snn));
734 ++ rsnn_nn->snn_len = (u8) strlen(rsnn_nn->snn);
735 +
736 + return sizeof(struct fcgs_rsnn_nn_req_s) + sizeof(struct ct_hdr_s);
737 + }
738 +diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
739 +index 4aa61e20e82d..932feb0ed4da 100644
740 +--- a/drivers/scsi/bfa/bfa_fcs.c
741 ++++ b/drivers/scsi/bfa/bfa_fcs.c
742 +@@ -769,23 +769,23 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
743 + bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
744 +
745 + /* Model name/number */
746 +- strncpy((char *)&port_cfg->sym_name, model,
747 +- BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
748 +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
749 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
750 ++ strlcpy(port_cfg->sym_name.symname, model,
751 ++ BFA_SYMNAME_MAXLEN);
752 ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
753 ++ BFA_SYMNAME_MAXLEN);
754 +
755 + /* Driver Version */
756 +- strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
757 +- BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
758 +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
759 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
760 ++ strlcat(port_cfg->sym_name.symname, driver_info->version,
761 ++ BFA_SYMNAME_MAXLEN);
762 ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
763 ++ BFA_SYMNAME_MAXLEN);
764 +
765 + /* Host machine name */
766 +- strncat((char *)&port_cfg->sym_name,
767 +- (char *)driver_info->host_machine_name,
768 +- BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
769 +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
770 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
771 ++ strlcat(port_cfg->sym_name.symname,
772 ++ driver_info->host_machine_name,
773 ++ BFA_SYMNAME_MAXLEN);
774 ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
775 ++ BFA_SYMNAME_MAXLEN);
776 +
777 + /*
778 + * Host OS Info :
779 +@@ -793,24 +793,24 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
780 + * OS name string and instead copy the entire OS info string (64 bytes).
781 + */
782 + if (driver_info->host_os_patch[0] == '\0') {
783 +- strncat((char *)&port_cfg->sym_name,
784 +- (char *)driver_info->host_os_name,
785 +- BFA_FCS_OS_STR_LEN);
786 +- strncat((char *)&port_cfg->sym_name,
787 ++ strlcat(port_cfg->sym_name.symname,
788 ++ driver_info->host_os_name,
789 ++ BFA_SYMNAME_MAXLEN);
790 ++ strlcat(port_cfg->sym_name.symname,
791 + BFA_FCS_PORT_SYMBNAME_SEPARATOR,
792 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
793 ++ BFA_SYMNAME_MAXLEN);
794 + } else {
795 +- strncat((char *)&port_cfg->sym_name,
796 +- (char *)driver_info->host_os_name,
797 +- BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
798 +- strncat((char *)&port_cfg->sym_name,
799 ++ strlcat(port_cfg->sym_name.symname,
800 ++ driver_info->host_os_name,
801 ++ BFA_SYMNAME_MAXLEN);
802 ++ strlcat(port_cfg->sym_name.symname,
803 + BFA_FCS_PORT_SYMBNAME_SEPARATOR,
804 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
805 ++ BFA_SYMNAME_MAXLEN);
806 +
807 + /* Append host OS Patch Info */
808 +- strncat((char *)&port_cfg->sym_name,
809 +- (char *)driver_info->host_os_patch,
810 +- BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
811 ++ strlcat(port_cfg->sym_name.symname,
812 ++ driver_info->host_os_patch,
813 ++ BFA_SYMNAME_MAXLEN);
814 + }
815 +
816 + /* null terminate */
817 +@@ -830,26 +830,26 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric)
818 + bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
819 +
820 + /* Model name/number */
821 +- strncpy((char *)&port_cfg->node_sym_name, model,
822 +- BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
823 +- strncat((char *)&port_cfg->node_sym_name,
824 ++ strlcpy(port_cfg->node_sym_name.symname, model,
825 ++ BFA_SYMNAME_MAXLEN);
826 ++ strlcat(port_cfg->node_sym_name.symname,
827 + BFA_FCS_PORT_SYMBNAME_SEPARATOR,
828 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
829 ++ BFA_SYMNAME_MAXLEN);
830 +
831 + /* Driver Version */
832 +- strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version,
833 +- BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
834 +- strncat((char *)&port_cfg->node_sym_name,
835 ++ strlcat(port_cfg->node_sym_name.symname, (char *)driver_info->version,
836 ++ BFA_SYMNAME_MAXLEN);
837 ++ strlcat(port_cfg->node_sym_name.symname,
838 + BFA_FCS_PORT_SYMBNAME_SEPARATOR,
839 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
840 ++ BFA_SYMNAME_MAXLEN);
841 +
842 + /* Host machine name */
843 +- strncat((char *)&port_cfg->node_sym_name,
844 +- (char *)driver_info->host_machine_name,
845 +- BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
846 +- strncat((char *)&port_cfg->node_sym_name,
847 ++ strlcat(port_cfg->node_sym_name.symname,
848 ++ driver_info->host_machine_name,
849 ++ BFA_SYMNAME_MAXLEN);
850 ++ strlcat(port_cfg->node_sym_name.symname,
851 + BFA_FCS_PORT_SYMBNAME_SEPARATOR,
852 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
853 ++ BFA_SYMNAME_MAXLEN);
854 +
855 + /* null terminate */
856 + port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
857 +diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
858 +index 638c0a2857f7..b4f2c1d8742e 100644
859 +--- a/drivers/scsi/bfa/bfa_fcs_lport.c
860 ++++ b/drivers/scsi/bfa/bfa_fcs_lport.c
861 +@@ -2642,10 +2642,10 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
862 + bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc,
863 + hba_attr->fw_version);
864 +
865 +- strncpy(hba_attr->driver_version, (char *)driver_info->version,
866 ++ strlcpy(hba_attr->driver_version, (char *)driver_info->version,
867 + sizeof(hba_attr->driver_version));
868 +
869 +- strncpy(hba_attr->os_name, driver_info->host_os_name,
870 ++ strlcpy(hba_attr->os_name, driver_info->host_os_name,
871 + sizeof(hba_attr->os_name));
872 +
873 + /*
874 +@@ -2653,23 +2653,23 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
875 + * to the os name along with a separator
876 + */
877 + if (driver_info->host_os_patch[0] != '\0') {
878 +- strncat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
879 +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
880 +- strncat(hba_attr->os_name, driver_info->host_os_patch,
881 +- sizeof(driver_info->host_os_patch));
882 ++ strlcat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
883 ++ sizeof(hba_attr->os_name));
884 ++ strlcat(hba_attr->os_name, driver_info->host_os_patch,
885 ++ sizeof(hba_attr->os_name));
886 + }
887 +
888 + /* Retrieve the max frame size from the port attr */
889 + bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr);
890 + hba_attr->max_ct_pyld = fcs_port_attr.max_frm_size;
891 +
892 +- strncpy(hba_attr->node_sym_name.symname,
893 ++ strlcpy(hba_attr->node_sym_name.symname,
894 + port->port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN);
895 + strcpy(hba_attr->vendor_info, "QLogic");
896 + hba_attr->num_ports =
897 + cpu_to_be32(bfa_ioc_get_nports(&port->fcs->bfa->ioc));
898 + hba_attr->fabric_name = port->fabric->lps->pr_nwwn;
899 +- strncpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN);
900 ++ strlcpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN);
901 +
902 + }
903 +
904 +@@ -2736,20 +2736,20 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi,
905 + /*
906 + * OS device Name
907 + */
908 +- strncpy(port_attr->os_device_name, (char *)driver_info->os_device_name,
909 ++ strlcpy(port_attr->os_device_name, driver_info->os_device_name,
910 + sizeof(port_attr->os_device_name));
911 +
912 + /*
913 + * Host name
914 + */
915 +- strncpy(port_attr->host_name, (char *)driver_info->host_machine_name,
916 ++ strlcpy(port_attr->host_name, driver_info->host_machine_name,
917 + sizeof(port_attr->host_name));
918 +
919 + port_attr->node_name = bfa_fcs_lport_get_nwwn(port);
920 + port_attr->port_name = bfa_fcs_lport_get_pwwn(port);
921 +
922 +- strncpy(port_attr->port_sym_name.symname,
923 +- (char *)&bfa_fcs_lport_get_psym_name(port), BFA_SYMNAME_MAXLEN);
924 ++ strlcpy(port_attr->port_sym_name.symname,
925 ++ bfa_fcs_lport_get_psym_name(port).symname, BFA_SYMNAME_MAXLEN);
926 + bfa_fcs_lport_get_attr(port, &lport_attr);
927 + port_attr->port_type = cpu_to_be32(lport_attr.port_type);
928 + port_attr->scos = pport_attr.cos_supported;
929 +@@ -3229,7 +3229,7 @@ bfa_fcs_lport_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
930 + rsp_str[gmal_entry->len-1] = 0;
931 +
932 + /* copy IP Address to fabric */
933 +- strncpy(bfa_fcs_lport_get_fabric_ipaddr(port),
934 ++ strlcpy(bfa_fcs_lport_get_fabric_ipaddr(port),
935 + gmal_entry->ip_addr,
936 + BFA_FCS_FABRIC_IPADDR_SZ);
937 + break;
938 +@@ -4667,21 +4667,13 @@ bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
939 + * to that of the base port.
940 + */
941 +
942 +- strncpy((char *)psymbl,
943 +- (char *) &
944 +- (bfa_fcs_lport_get_psym_name
945 ++ strlcpy(symbl,
946 ++ (char *)&(bfa_fcs_lport_get_psym_name
947 + (bfa_fcs_get_base_port(port->fcs))),
948 +- strlen((char *) &
949 +- bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
950 +- (port->fcs))));
951 +-
952 +- /* Ensure we have a null terminating string. */
953 +- ((char *)psymbl)[strlen((char *) &
954 +- bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
955 +- (port->fcs)))] = 0;
956 +- strncat((char *)psymbl,
957 +- (char *) &(bfa_fcs_lport_get_psym_name(port)),
958 +- strlen((char *) &bfa_fcs_lport_get_psym_name(port)));
959 ++ sizeof(symbl));
960 ++
961 ++ strlcat(symbl, (char *)&(bfa_fcs_lport_get_psym_name(port)),
962 ++ sizeof(symbl));
963 + } else {
964 + psymbl = (u8 *) &(bfa_fcs_lport_get_psym_name(port));
965 + }
966 +@@ -5173,7 +5165,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced)
967 + struct fchs_s fchs;
968 + struct bfa_fcxp_s *fcxp;
969 + u8 symbl[256];
970 +- u8 *psymbl = &symbl[0];
971 + int len;
972 +
973 + /* Avoid sending RSPN in the following states. */
974 +@@ -5203,22 +5194,17 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced)
975 + * For Vports, we append the vport's port symbolic name
976 + * to that of the base port.
977 + */
978 +- strncpy((char *)psymbl, (char *)&(bfa_fcs_lport_get_psym_name
979 ++ strlcpy(symbl, (char *)&(bfa_fcs_lport_get_psym_name
980 + (bfa_fcs_get_base_port(port->fcs))),
981 +- strlen((char *)&bfa_fcs_lport_get_psym_name(
982 +- bfa_fcs_get_base_port(port->fcs))));
983 +-
984 +- /* Ensure we have a null terminating string. */
985 +- ((char *)psymbl)[strlen((char *)&bfa_fcs_lport_get_psym_name(
986 +- bfa_fcs_get_base_port(port->fcs)))] = 0;
987 ++ sizeof(symbl));
988 +
989 +- strncat((char *)psymbl,
990 ++ strlcat(symbl,
991 + (char *)&(bfa_fcs_lport_get_psym_name(port)),
992 +- strlen((char *)&bfa_fcs_lport_get_psym_name(port)));
993 ++ sizeof(symbl));
994 + }
995 +
996 + len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
997 +- bfa_fcs_lport_get_fcid(port), 0, psymbl);
998 ++ bfa_fcs_lport_get_fcid(port), 0, symbl);
999 +
1000 + bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1001 + FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
1002 +diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
1003 +index 256f4afaccf9..a1a183ece093 100644
1004 +--- a/drivers/scsi/bfa/bfa_ioc.c
1005 ++++ b/drivers/scsi/bfa/bfa_ioc.c
1006 +@@ -2803,7 +2803,7 @@ void
1007 + bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer)
1008 + {
1009 + memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
1010 +- strncpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
1011 ++ strlcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
1012 + }
1013 +
1014 + void
1015 +diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
1016 +index e640223bab3c..7356fdec79f5 100644
1017 +--- a/drivers/scsi/bfa/bfa_svc.c
1018 ++++ b/drivers/scsi/bfa/bfa_svc.c
1019 +@@ -350,8 +350,8 @@ bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
1020 + lp.eid = event;
1021 + lp.log_type = BFA_PL_LOG_TYPE_STRING;
1022 + lp.misc = misc;
1023 +- strncpy(lp.log_entry.string_log, log_str,
1024 +- BFA_PL_STRING_LOG_SZ - 1);
1025 ++ strlcpy(lp.log_entry.string_log, log_str,
1026 ++ BFA_PL_STRING_LOG_SZ);
1027 + lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0';
1028 + bfa_plog_add(plog, &lp);
1029 + }
1030 +diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
1031 +index 5caf5f3ff642..ae37010af50f 100644
1032 +--- a/drivers/scsi/bfa/bfad.c
1033 ++++ b/drivers/scsi/bfa/bfad.c
1034 +@@ -983,20 +983,20 @@ bfad_start_ops(struct bfad_s *bfad) {
1035 +
1036 + /* Fill the driver_info info to fcs*/
1037 + memset(&driver_info, 0, sizeof(driver_info));
1038 +- strncpy(driver_info.version, BFAD_DRIVER_VERSION,
1039 +- sizeof(driver_info.version) - 1);
1040 ++ strlcpy(driver_info.version, BFAD_DRIVER_VERSION,
1041 ++ sizeof(driver_info.version));
1042 + if (host_name)
1043 +- strncpy(driver_info.host_machine_name, host_name,
1044 +- sizeof(driver_info.host_machine_name) - 1);
1045 ++ strlcpy(driver_info.host_machine_name, host_name,
1046 ++ sizeof(driver_info.host_machine_name));
1047 + if (os_name)
1048 +- strncpy(driver_info.host_os_name, os_name,
1049 +- sizeof(driver_info.host_os_name) - 1);
1050 ++ strlcpy(driver_info.host_os_name, os_name,
1051 ++ sizeof(driver_info.host_os_name));
1052 + if (os_patch)
1053 +- strncpy(driver_info.host_os_patch, os_patch,
1054 +- sizeof(driver_info.host_os_patch) - 1);
1055 ++ strlcpy(driver_info.host_os_patch, os_patch,
1056 ++ sizeof(driver_info.host_os_patch));
1057 +
1058 +- strncpy(driver_info.os_device_name, bfad->pci_name,
1059 +- sizeof(driver_info.os_device_name) - 1);
1060 ++ strlcpy(driver_info.os_device_name, bfad->pci_name,
1061 ++ sizeof(driver_info.os_device_name));
1062 +
1063 + /* FCS driver info init */
1064 + spin_lock_irqsave(&bfad->bfad_lock, flags);
1065 +diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
1066 +index 13db3b7bc873..d0a504af5b4f 100644
1067 +--- a/drivers/scsi/bfa/bfad_attr.c
1068 ++++ b/drivers/scsi/bfa/bfad_attr.c
1069 +@@ -843,7 +843,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
1070 + char symname[BFA_SYMNAME_MAXLEN];
1071 +
1072 + bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
1073 +- strncpy(symname, port_attr.port_cfg.sym_name.symname,
1074 ++ strlcpy(symname, port_attr.port_cfg.sym_name.symname,
1075 + BFA_SYMNAME_MAXLEN);
1076 + return snprintf(buf, PAGE_SIZE, "%s\n", symname);
1077 + }
1078 +diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
1079 +index 1aa46d0763a0..9081a5f93aae 100644
1080 +--- a/drivers/scsi/bfa/bfad_bsg.c
1081 ++++ b/drivers/scsi/bfa/bfad_bsg.c
1082 +@@ -127,7 +127,7 @@ bfad_iocmd_ioc_get_attr(struct bfad_s *bfad, void *cmd)
1083 +
1084 + /* fill in driver attr info */
1085 + strcpy(iocmd->ioc_attr.driver_attr.driver, BFAD_DRIVER_NAME);
1086 +- strncpy(iocmd->ioc_attr.driver_attr.driver_ver,
1087 ++ strlcpy(iocmd->ioc_attr.driver_attr.driver_ver,
1088 + BFAD_DRIVER_VERSION, BFA_VERSION_LEN);
1089 + strcpy(iocmd->ioc_attr.driver_attr.fw_ver,
1090 + iocmd->ioc_attr.adapter_attr.fw_ver);
1091 +@@ -315,9 +315,9 @@ bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd)
1092 + iocmd->attr.port_type = port_attr.port_type;
1093 + iocmd->attr.loopback = port_attr.loopback;
1094 + iocmd->attr.authfail = port_attr.authfail;
1095 +- strncpy(iocmd->attr.port_symname.symname,
1096 ++ strlcpy(iocmd->attr.port_symname.symname,
1097 + port_attr.port_cfg.sym_name.symname,
1098 +- sizeof(port_attr.port_cfg.sym_name.symname));
1099 ++ sizeof(iocmd->attr.port_symname.symname));
1100 +
1101 + iocmd->status = BFA_STATUS_OK;
1102 + return 0;
1103 +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
1104 +index ea947a7c2596..6b594bc7d94a 100644
1105 +--- a/drivers/scsi/scsi_devinfo.c
1106 ++++ b/drivers/scsi/scsi_devinfo.c
1107 +@@ -34,7 +34,6 @@ struct scsi_dev_info_list_table {
1108 + };
1109 +
1110 +
1111 +-static const char spaces[] = " "; /* 16 of them */
1112 + static unsigned scsi_default_dev_flags;
1113 + static LIST_HEAD(scsi_dev_info_list);
1114 + static char scsi_dev_flags[256];
1115 +@@ -296,20 +295,13 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
1116 + size_t from_length;
1117 +
1118 + from_length = strlen(from);
1119 +- strncpy(to, from, min(to_length, from_length));
1120 +- if (from_length < to_length) {
1121 +- if (compatible) {
1122 +- /*
1123 +- * NUL terminate the string if it is short.
1124 +- */
1125 +- to[from_length] = '\0';
1126 +- } else {
1127 +- /*
1128 +- * space pad the string if it is short.
1129 +- */
1130 +- strncpy(&to[from_length], spaces,
1131 +- to_length - from_length);
1132 +- }
1133 ++ /* this zero-pads the destination */
1134 ++ strncpy(to, from, to_length);
1135 ++ if (from_length < to_length && !compatible) {
1136 ++ /*
1137 ++ * space pad the string if it is short.
1138 ++ */
1139 ++ memset(&to[from_length], ' ', to_length - from_length);
1140 + }
1141 + if (from_length > to_length)
1142 + printk(KERN_WARNING "%s: %s string '%s' is too long\n",
1143 +diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
1144 +index d98d5fe25a17..0421dd9277a8 100644
1145 +--- a/drivers/staging/rts5208/sd.c
1146 ++++ b/drivers/staging/rts5208/sd.c
1147 +@@ -4125,12 +4125,6 @@ RTY_SEND_CMD:
1148 + rtsx_trace(chip);
1149 + return STATUS_FAIL;
1150 + }
1151 +-
1152 +- } else if (rsp_type == SD_RSP_TYPE_R0) {
1153 +- if ((ptr[3] & 0x1E) != 0x03) {
1154 +- rtsx_trace(chip);
1155 +- return STATUS_FAIL;
1156 +- }
1157 + }
1158 + }
1159 + }
1160 +diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
1161 +index 6d8906d65476..7c5d4647cb5e 100644
1162 +--- a/drivers/thermal/hisi_thermal.c
1163 ++++ b/drivers/thermal/hisi_thermal.c
1164 +@@ -26,9 +26,12 @@
1165 +
1166 + #include "thermal_core.h"
1167 +
1168 ++#define TEMP0_LAG (0x0)
1169 + #define TEMP0_TH (0x4)
1170 + #define TEMP0_RST_TH (0x8)
1171 + #define TEMP0_CFG (0xC)
1172 ++#define TEMP0_CFG_SS_MSK (0xF000)
1173 ++#define TEMP0_CFG_HDAK_MSK (0x30)
1174 + #define TEMP0_EN (0x10)
1175 + #define TEMP0_INT_EN (0x14)
1176 + #define TEMP0_INT_CLR (0x18)
1177 +@@ -38,8 +41,10 @@
1178 + #define HISI_TEMP_BASE (-60000)
1179 + #define HISI_TEMP_RESET (100000)
1180 + #define HISI_TEMP_STEP (784)
1181 ++#define HISI_TEMP_LAG (3500)
1182 +
1183 + #define HISI_MAX_SENSORS 4
1184 ++#define HISI_DEFAULT_SENSOR 2
1185 +
1186 + struct hisi_thermal_sensor {
1187 + struct hisi_thermal_data *thermal;
1188 +@@ -54,11 +59,8 @@ struct hisi_thermal_data {
1189 + struct mutex thermal_lock; /* protects register data */
1190 + struct platform_device *pdev;
1191 + struct clk *clk;
1192 +- struct hisi_thermal_sensor sensors[HISI_MAX_SENSORS];
1193 +-
1194 +- int irq, irq_bind_sensor;
1195 +- bool irq_enabled;
1196 +-
1197 ++ struct hisi_thermal_sensor sensors;
1198 ++ int irq;
1199 + void __iomem *regs;
1200 + };
1201 +
1202 +@@ -96,72 +98,107 @@ static inline long hisi_thermal_round_temp(int temp)
1203 + hisi_thermal_temp_to_step(temp));
1204 + }
1205 +
1206 +-static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data,
1207 +- struct hisi_thermal_sensor *sensor)
1208 ++/*
1209 ++ * The lag register contains 5 bits encoding the temperature in steps.
1210 ++ *
1211 ++ * Each time the temperature crosses the threshold boundary, an
1212 ++ * interrupt is raised. It could be when the temperature is going
1213 ++ * above the threshold or below. However, if the temperature is
1214 ++ * fluctuating around this value due to the load, we can receive
1215 ++ * several interrupts which may not desired.
1216 ++ *
1217 ++ * We can setup a temperature representing the delta between the
1218 ++ * threshold and the current temperature when the temperature is
1219 ++ * decreasing.
1220 ++ *
1221 ++ * For instance: the lag register is 5°C, the threshold is 65°C, when
1222 ++ * the temperature reaches 65°C an interrupt is raised and when the
1223 ++ * temperature decrease to 65°C - 5°C another interrupt is raised.
1224 ++ *
1225 ++ * A very short lag can lead to an interrupt storm, a long lag
1226 ++ * increase the latency to react to the temperature changes. In our
1227 ++ * case, that is not really a problem as we are polling the
1228 ++ * temperature.
1229 ++ *
1230 ++ * [0:4] : lag register
1231 ++ *
1232 ++ * The temperature is coded in steps, cf. HISI_TEMP_STEP.
1233 ++ *
1234 ++ * Min : 0x00 : 0.0 °C
1235 ++ * Max : 0x1F : 24.3 °C
1236 ++ *
1237 ++ * The 'value' parameter is in milliCelsius.
1238 ++ */
1239 ++static inline void hisi_thermal_set_lag(void __iomem *addr, int value)
1240 + {
1241 +- long val;
1242 +-
1243 +- mutex_lock(&data->thermal_lock);
1244 +-
1245 +- /* disable interrupt */
1246 +- writel(0x0, data->regs + TEMP0_INT_EN);
1247 +- writel(0x1, data->regs + TEMP0_INT_CLR);
1248 +-
1249 +- /* disable module firstly */
1250 +- writel(0x0, data->regs + TEMP0_EN);
1251 +-
1252 +- /* select sensor id */
1253 +- writel((sensor->id << 12), data->regs + TEMP0_CFG);
1254 +-
1255 +- /* enable module */
1256 +- writel(0x1, data->regs + TEMP0_EN);
1257 +-
1258 +- usleep_range(3000, 5000);
1259 +-
1260 +- val = readl(data->regs + TEMP0_VALUE);
1261 +- val = hisi_thermal_step_to_temp(val);
1262 +-
1263 +- mutex_unlock(&data->thermal_lock);
1264 +-
1265 +- return val;
1266 ++ writel((value / HISI_TEMP_STEP) & 0x1F, addr + TEMP0_LAG);
1267 + }
1268 +
1269 +-static void hisi_thermal_enable_bind_irq_sensor
1270 +- (struct hisi_thermal_data *data)
1271 ++static inline void hisi_thermal_alarm_clear(void __iomem *addr, int value)
1272 + {
1273 +- struct hisi_thermal_sensor *sensor;
1274 +-
1275 +- mutex_lock(&data->thermal_lock);
1276 +-
1277 +- sensor = &data->sensors[data->irq_bind_sensor];
1278 +-
1279 +- /* setting the hdak time */
1280 +- writel(0x0, data->regs + TEMP0_CFG);
1281 ++ writel(value, addr + TEMP0_INT_CLR);
1282 ++}
1283 +
1284 +- /* disable module firstly */
1285 +- writel(0x0, data->regs + TEMP0_RST_MSK);
1286 +- writel(0x0, data->regs + TEMP0_EN);
1287 ++static inline void hisi_thermal_alarm_enable(void __iomem *addr, int value)
1288 ++{
1289 ++ writel(value, addr + TEMP0_INT_EN);
1290 ++}
1291 +
1292 +- /* select sensor id */
1293 +- writel((sensor->id << 12), data->regs + TEMP0_CFG);
1294 ++static inline void hisi_thermal_alarm_set(void __iomem *addr, int temp)
1295 ++{
1296 ++ writel(hisi_thermal_temp_to_step(temp) | 0x0FFFFFF00, addr + TEMP0_TH);
1297 ++}
1298 +
1299 +- /* enable for interrupt */
1300 +- writel(hisi_thermal_temp_to_step(sensor->thres_temp) | 0x0FFFFFF00,
1301 +- data->regs + TEMP0_TH);
1302 ++static inline void hisi_thermal_reset_set(void __iomem *addr, int temp)
1303 ++{
1304 ++ writel(hisi_thermal_temp_to_step(temp), addr + TEMP0_RST_TH);
1305 ++}
1306 +
1307 +- writel(hisi_thermal_temp_to_step(HISI_TEMP_RESET),
1308 +- data->regs + TEMP0_RST_TH);
1309 ++static inline void hisi_thermal_reset_enable(void __iomem *addr, int value)
1310 ++{
1311 ++ writel(value, addr + TEMP0_RST_MSK);
1312 ++}
1313 +
1314 +- /* enable module */
1315 +- writel(0x1, data->regs + TEMP0_RST_MSK);
1316 +- writel(0x1, data->regs + TEMP0_EN);
1317 ++static inline void hisi_thermal_enable(void __iomem *addr, int value)
1318 ++{
1319 ++ writel(value, addr + TEMP0_EN);
1320 ++}
1321 +
1322 +- writel(0x0, data->regs + TEMP0_INT_CLR);
1323 +- writel(0x1, data->regs + TEMP0_INT_EN);
1324 ++static inline int hisi_thermal_get_temperature(void __iomem *addr)
1325 ++{
1326 ++ return hisi_thermal_step_to_temp(readl(addr + TEMP0_VALUE));
1327 ++}
1328 +
1329 +- usleep_range(3000, 5000);
1330 ++/*
1331 ++ * Temperature configuration register - Sensor selection
1332 ++ *
1333 ++ * Bits [19:12]
1334 ++ *
1335 ++ * 0x0: local sensor (default)
1336 ++ * 0x1: remote sensor 1 (ACPU cluster 1)
1337 ++ * 0x2: remote sensor 2 (ACPU cluster 0)
1338 ++ * 0x3: remote sensor 3 (G3D)
1339 ++ */
1340 ++static inline void hisi_thermal_sensor_select(void __iomem *addr, int sensor)
1341 ++{
1342 ++ writel((readl(addr + TEMP0_CFG) & ~TEMP0_CFG_SS_MSK) |
1343 ++ (sensor << 12), addr + TEMP0_CFG);
1344 ++}
1345 +
1346 +- mutex_unlock(&data->thermal_lock);
1347 ++/*
1348 ++ * Temperature configuration register - Hdak conversion polling interval
1349 ++ *
1350 ++ * Bits [5:4]
1351 ++ *
1352 ++ * 0x0 : 0.768 ms
1353 ++ * 0x1 : 6.144 ms
1354 ++ * 0x2 : 49.152 ms
1355 ++ * 0x3 : 393.216 ms
1356 ++ */
1357 ++static inline void hisi_thermal_hdak_set(void __iomem *addr, int value)
1358 ++{
1359 ++ writel((readl(addr + TEMP0_CFG) & ~TEMP0_CFG_HDAK_MSK) |
1360 ++ (value << 4), addr + TEMP0_CFG);
1361 + }
1362 +
1363 + static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data)
1364 +@@ -169,9 +206,9 @@ static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data)
1365 + mutex_lock(&data->thermal_lock);
1366 +
1367 + /* disable sensor module */
1368 +- writel(0x0, data->regs + TEMP0_INT_EN);
1369 +- writel(0x0, data->regs + TEMP0_RST_MSK);
1370 +- writel(0x0, data->regs + TEMP0_EN);
1371 ++ hisi_thermal_enable(data->regs, 0);
1372 ++ hisi_thermal_alarm_enable(data->regs, 0);
1373 ++ hisi_thermal_reset_enable(data->regs, 0);
1374 +
1375 + mutex_unlock(&data->thermal_lock);
1376 + }
1377 +@@ -181,48 +218,10 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp)
1378 + struct hisi_thermal_sensor *sensor = _sensor;
1379 + struct hisi_thermal_data *data = sensor->thermal;
1380 +
1381 +- int sensor_id = -1, i;
1382 +- long max_temp = 0;
1383 ++ *temp = hisi_thermal_get_temperature(data->regs);
1384 +
1385 +- *temp = hisi_thermal_get_sensor_temp(data, sensor);
1386 +-
1387 +- sensor->sensor_temp = *temp;
1388 +-
1389 +- for (i = 0; i < HISI_MAX_SENSORS; i++) {
1390 +- if (!data->sensors[i].tzd)
1391 +- continue;
1392 +-
1393 +- if (data->sensors[i].sensor_temp >= max_temp) {
1394 +- max_temp = data->sensors[i].sensor_temp;
1395 +- sensor_id = i;
1396 +- }
1397 +- }
1398 +-
1399 +- /* If no sensor has been enabled, then skip to enable irq */
1400 +- if (sensor_id == -1)
1401 +- return 0;
1402 +-
1403 +- mutex_lock(&data->thermal_lock);
1404 +- data->irq_bind_sensor = sensor_id;
1405 +- mutex_unlock(&data->thermal_lock);
1406 +-
1407 +- dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%d, thres=%d\n",
1408 +- sensor->id, data->irq_enabled, *temp, sensor->thres_temp);
1409 +- /*
1410 +- * Bind irq to sensor for two cases:
1411 +- * Reenable alarm IRQ if temperature below threshold;
1412 +- * if irq has been enabled, always set it;
1413 +- */
1414 +- if (data->irq_enabled) {
1415 +- hisi_thermal_enable_bind_irq_sensor(data);
1416 +- return 0;
1417 +- }
1418 +-
1419 +- if (max_temp < sensor->thres_temp) {
1420 +- data->irq_enabled = true;
1421 +- hisi_thermal_enable_bind_irq_sensor(data);
1422 +- enable_irq(data->irq);
1423 +- }
1424 ++ dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n",
1425 ++ sensor->id, *temp, sensor->thres_temp);
1426 +
1427 + return 0;
1428 + }
1429 +@@ -231,35 +230,26 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = {
1430 + .get_temp = hisi_thermal_get_temp,
1431 + };
1432 +
1433 +-static irqreturn_t hisi_thermal_alarm_irq(int irq, void *dev)
1434 +-{
1435 +- struct hisi_thermal_data *data = dev;
1436 +-
1437 +- disable_irq_nosync(irq);
1438 +- data->irq_enabled = false;
1439 +-
1440 +- return IRQ_WAKE_THREAD;
1441 +-}
1442 +-
1443 + static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
1444 + {
1445 + struct hisi_thermal_data *data = dev;
1446 +- struct hisi_thermal_sensor *sensor;
1447 +- int i;
1448 ++ struct hisi_thermal_sensor *sensor = &data->sensors;
1449 ++ int temp;
1450 +
1451 +- mutex_lock(&data->thermal_lock);
1452 +- sensor = &data->sensors[data->irq_bind_sensor];
1453 ++ hisi_thermal_alarm_clear(data->regs, 1);
1454 +
1455 +- dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n",
1456 +- sensor->thres_temp);
1457 +- mutex_unlock(&data->thermal_lock);
1458 ++ temp = hisi_thermal_get_temperature(data->regs);
1459 +
1460 +- for (i = 0; i < HISI_MAX_SENSORS; i++) {
1461 +- if (!data->sensors[i].tzd)
1462 +- continue;
1463 ++ if (temp >= sensor->thres_temp) {
1464 ++ dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n",
1465 ++ temp, sensor->thres_temp);
1466 +
1467 +- thermal_zone_device_update(data->sensors[i].tzd,
1468 ++ thermal_zone_device_update(data->sensors.tzd,
1469 + THERMAL_EVENT_UNSPECIFIED);
1470 ++
1471 ++ } else if (temp < sensor->thres_temp) {
1472 ++ dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n",
1473 ++ temp, sensor->thres_temp);
1474 + }
1475 +
1476 + return IRQ_HANDLED;
1477 +@@ -313,11 +303,44 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor,
1478 + on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
1479 + }
1480 +
1481 ++static int hisi_thermal_setup(struct hisi_thermal_data *data)
1482 ++{
1483 ++ struct hisi_thermal_sensor *sensor;
1484 ++
1485 ++ sensor = &data->sensors;
1486 ++
1487 ++ /* disable module firstly */
1488 ++ hisi_thermal_reset_enable(data->regs, 0);
1489 ++ hisi_thermal_enable(data->regs, 0);
1490 ++
1491 ++ /* select sensor id */
1492 ++ hisi_thermal_sensor_select(data->regs, sensor->id);
1493 ++
1494 ++ /* setting the hdak time */
1495 ++ hisi_thermal_hdak_set(data->regs, 0);
1496 ++
1497 ++ /* setting lag value between current temp and the threshold */
1498 ++ hisi_thermal_set_lag(data->regs, HISI_TEMP_LAG);
1499 ++
1500 ++ /* enable for interrupt */
1501 ++ hisi_thermal_alarm_set(data->regs, sensor->thres_temp);
1502 ++
1503 ++ hisi_thermal_reset_set(data->regs, HISI_TEMP_RESET);
1504 ++
1505 ++ /* enable module */
1506 ++ hisi_thermal_reset_enable(data->regs, 1);
1507 ++ hisi_thermal_enable(data->regs, 1);
1508 ++
1509 ++ hisi_thermal_alarm_clear(data->regs, 0);
1510 ++ hisi_thermal_alarm_enable(data->regs, 1);
1511 ++
1512 ++ return 0;
1513 ++}
1514 ++
1515 + static int hisi_thermal_probe(struct platform_device *pdev)
1516 + {
1517 + struct hisi_thermal_data *data;
1518 + struct resource *res;
1519 +- int i;
1520 + int ret;
1521 +
1522 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
1523 +@@ -356,29 +379,30 @@ static int hisi_thermal_probe(struct platform_device *pdev)
1524 + return ret;
1525 + }
1526 +
1527 +- hisi_thermal_enable_bind_irq_sensor(data);
1528 +- data->irq_enabled = true;
1529 ++ ret = hisi_thermal_register_sensor(pdev, data,
1530 ++ &data->sensors,
1531 ++ HISI_DEFAULT_SENSOR);
1532 ++ if (ret) {
1533 ++ dev_err(&pdev->dev, "failed to register thermal sensor: %d\n",
1534 ++ ret);
1535 ++ return ret;
1536 ++ }
1537 +
1538 +- for (i = 0; i < HISI_MAX_SENSORS; ++i) {
1539 +- ret = hisi_thermal_register_sensor(pdev, data,
1540 +- &data->sensors[i], i);
1541 +- if (ret)
1542 +- dev_err(&pdev->dev,
1543 +- "failed to register thermal sensor: %d\n", ret);
1544 +- else
1545 +- hisi_thermal_toggle_sensor(&data->sensors[i], true);
1546 ++ ret = hisi_thermal_setup(data);
1547 ++ if (ret) {
1548 ++ dev_err(&pdev->dev, "Failed to setup the sensor: %d\n", ret);
1549 ++ return ret;
1550 + }
1551 +
1552 +- ret = devm_request_threaded_irq(&pdev->dev, data->irq,
1553 +- hisi_thermal_alarm_irq,
1554 ++ ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL,
1555 + hisi_thermal_alarm_irq_thread,
1556 +- 0, "hisi_thermal", data);
1557 ++ IRQF_ONESHOT, "hisi_thermal", data);
1558 + if (ret < 0) {
1559 + dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
1560 + return ret;
1561 + }
1562 +
1563 +- enable_irq(data->irq);
1564 ++ hisi_thermal_toggle_sensor(&data->sensors, true);
1565 +
1566 + return 0;
1567 + }
1568 +@@ -386,17 +410,9 @@ static int hisi_thermal_probe(struct platform_device *pdev)
1569 + static int hisi_thermal_remove(struct platform_device *pdev)
1570 + {
1571 + struct hisi_thermal_data *data = platform_get_drvdata(pdev);
1572 +- int i;
1573 +-
1574 +- for (i = 0; i < HISI_MAX_SENSORS; i++) {
1575 +- struct hisi_thermal_sensor *sensor = &data->sensors[i];
1576 +-
1577 +- if (!sensor->tzd)
1578 +- continue;
1579 +-
1580 +- hisi_thermal_toggle_sensor(sensor, false);
1581 +- }
1582 ++ struct hisi_thermal_sensor *sensor = &data->sensors;
1583 +
1584 ++ hisi_thermal_toggle_sensor(sensor, false);
1585 + hisi_thermal_disable_sensor(data);
1586 + clk_disable_unprepare(data->clk);
1587 +
1588 +@@ -409,7 +425,6 @@ static int hisi_thermal_suspend(struct device *dev)
1589 + struct hisi_thermal_data *data = dev_get_drvdata(dev);
1590 +
1591 + hisi_thermal_disable_sensor(data);
1592 +- data->irq_enabled = false;
1593 +
1594 + clk_disable_unprepare(data->clk);
1595 +
1596 +@@ -425,8 +440,7 @@ static int hisi_thermal_resume(struct device *dev)
1597 + if (ret)
1598 + return ret;
1599 +
1600 +- data->irq_enabled = true;
1601 +- hisi_thermal_enable_bind_irq_sensor(data);
1602 ++ hisi_thermal_setup(data);
1603 +
1604 + return 0;
1605 + }
1606 +diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
1607 +index 2db68dfe497d..c448225ef5ca 100644
1608 +--- a/drivers/tty/serial/kgdboc.c
1609 ++++ b/drivers/tty/serial/kgdboc.c
1610 +@@ -131,24 +131,6 @@ static void kgdboc_unregister_kbd(void)
1611 + #define kgdboc_restore_input()
1612 + #endif /* ! CONFIG_KDB_KEYBOARD */
1613 +
1614 +-static int kgdboc_option_setup(char *opt)
1615 +-{
1616 +- if (!opt) {
1617 +- pr_err("kgdboc: config string not provided\n");
1618 +- return -EINVAL;
1619 +- }
1620 +-
1621 +- if (strlen(opt) >= MAX_CONFIG_LEN) {
1622 +- printk(KERN_ERR "kgdboc: config string too long\n");
1623 +- return -ENOSPC;
1624 +- }
1625 +- strcpy(config, opt);
1626 +-
1627 +- return 0;
1628 +-}
1629 +-
1630 +-__setup("kgdboc=", kgdboc_option_setup);
1631 +-
1632 + static void cleanup_kgdboc(void)
1633 + {
1634 + if (kgdb_unregister_nmi_console())
1635 +@@ -162,15 +144,13 @@ static int configure_kgdboc(void)
1636 + {
1637 + struct tty_driver *p;
1638 + int tty_line = 0;
1639 +- int err;
1640 ++ int err = -ENODEV;
1641 + char *cptr = config;
1642 + struct console *cons;
1643 +
1644 +- err = kgdboc_option_setup(config);
1645 +- if (err || !strlen(config) || isspace(config[0]))
1646 ++ if (!strlen(config) || isspace(config[0]))
1647 + goto noconfig;
1648 +
1649 +- err = -ENODEV;
1650 + kgdboc_io_ops.is_console = 0;
1651 + kgdb_tty_driver = NULL;
1652 +
1653 +@@ -318,6 +298,25 @@ static struct kgdb_io kgdboc_io_ops = {
1654 + };
1655 +
1656 + #ifdef CONFIG_KGDB_SERIAL_CONSOLE
1657 ++static int kgdboc_option_setup(char *opt)
1658 ++{
1659 ++ if (!opt) {
1660 ++ pr_err("config string not provided\n");
1661 ++ return -EINVAL;
1662 ++ }
1663 ++
1664 ++ if (strlen(opt) >= MAX_CONFIG_LEN) {
1665 ++ pr_err("config string too long\n");
1666 ++ return -ENOSPC;
1667 ++ }
1668 ++ strcpy(config, opt);
1669 ++
1670 ++ return 0;
1671 ++}
1672 ++
1673 ++__setup("kgdboc=", kgdboc_option_setup);
1674 ++
1675 ++
1676 + /* This is only available if kgdboc is a built in for early debugging */
1677 + static int __init kgdboc_early_init(char *opt)
1678 + {
1679 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
1680 +index e42673477c25..858d5812eb8f 100644
1681 +--- a/fs/btrfs/disk-io.c
1682 ++++ b/fs/btrfs/disk-io.c
1683 +@@ -451,9 +451,9 @@ static int btree_read_extent_buffer_pages(struct btrfs_fs_info *fs_info,
1684 + int mirror_num = 0;
1685 + int failed_mirror = 0;
1686 +
1687 +- clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags);
1688 + io_tree = &BTRFS_I(fs_info->btree_inode)->io_tree;
1689 + while (1) {
1690 ++ clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags);
1691 + ret = read_extent_buffer_pages(io_tree, eb, WAIT_COMPLETE,
1692 + btree_get_extent, mirror_num);
1693 + if (!ret) {
1694 +@@ -464,14 +464,6 @@ static int btree_read_extent_buffer_pages(struct btrfs_fs_info *fs_info,
1695 + ret = -EIO;
1696 + }
1697 +
1698 +- /*
1699 +- * This buffer's crc is fine, but its contents are corrupted, so
1700 +- * there is no reason to read the other copies, they won't be
1701 +- * any less wrong.
1702 +- */
1703 +- if (test_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags))
1704 +- break;
1705 +-
1706 + num_copies = btrfs_num_copies(fs_info,
1707 + eb->start, eb->len);
1708 + if (num_copies == 1)
1709 +diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
1710 +index f206aec1525d..ebc882281b39 100644
1711 +--- a/fs/btrfs/tree-checker.c
1712 ++++ b/fs/btrfs/tree-checker.c
1713 +@@ -348,13 +348,11 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
1714 +
1715 + /*
1716 + * Here we don't really care about alignment since extent allocator can
1717 +- * handle it. We care more about the size, as if one block group is
1718 +- * larger than maximum size, it's must be some obvious corruption.
1719 ++ * handle it. We care more about the size.
1720 + */
1721 +- if (key->offset > BTRFS_MAX_DATA_CHUNK_SIZE || key->offset == 0) {
1722 ++ if (key->offset == 0) {
1723 + block_group_err(fs_info, leaf, slot,
1724 +- "invalid block group size, have %llu expect (0, %llu]",
1725 +- key->offset, BTRFS_MAX_DATA_CHUNK_SIZE);
1726 ++ "invalid block group size 0");
1727 + return -EUCLEAN;
1728 + }
1729 +
1730 +diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
1731 +index 08ccabd7047f..5145ae2f0572 100644
1732 +--- a/fs/kernfs/symlink.c
1733 ++++ b/fs/kernfs/symlink.c
1734 +@@ -88,7 +88,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent,
1735 + int slen = strlen(kn->name);
1736 +
1737 + len -= slen;
1738 +- strncpy(s + len, kn->name, slen);
1739 ++ memcpy(s + len, kn->name, slen);
1740 + if (len)
1741 + s[--len] = '/';
1742 +
1743 +diff --git a/fs/udf/super.c b/fs/udf/super.c
1744 +index 9b0d6562d0a1..242d960df9a1 100644
1745 +--- a/fs/udf/super.c
1746 ++++ b/fs/udf/super.c
1747 +@@ -922,16 +922,20 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
1748 + }
1749 +
1750 + ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
1751 +- if (ret < 0)
1752 +- goto out_bh;
1753 +-
1754 +- strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
1755 ++ if (ret < 0) {
1756 ++ strcpy(UDF_SB(sb)->s_volume_ident, "InvalidName");
1757 ++ pr_warn("incorrect volume identification, setting to "
1758 ++ "'InvalidName'\n");
1759 ++ } else {
1760 ++ strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
1761 ++ }
1762 + udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
1763 +
1764 + ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
1765 +- if (ret < 0)
1766 ++ if (ret < 0) {
1767 ++ ret = 0;
1768 + goto out_bh;
1769 +-
1770 ++ }
1771 + outstr[ret] = 0;
1772 + udf_debug("volSetIdent[] = '%s'\n", outstr);
1773 +
1774 +diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
1775 +index 3a3be23689b3..61a1738895b7 100644
1776 +--- a/fs/udf/unicode.c
1777 ++++ b/fs/udf/unicode.c
1778 +@@ -341,6 +341,11 @@ try_again:
1779 + return u_len;
1780 + }
1781 +
1782 ++/*
1783 ++ * Convert CS0 dstring to output charset. Warning: This function may truncate
1784 ++ * input string if it is too long as it is used for informational strings only
1785 ++ * and it is better to truncate the string than to refuse mounting a media.
1786 ++ */
1787 + int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
1788 + const uint8_t *ocu_i, int i_len)
1789 + {
1790 +@@ -349,9 +354,12 @@ int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
1791 + if (i_len > 0) {
1792 + s_len = ocu_i[i_len - 1];
1793 + if (s_len >= i_len) {
1794 +- pr_err("incorrect dstring lengths (%d/%d)\n",
1795 +- s_len, i_len);
1796 +- return -EINVAL;
1797 ++ pr_warn("incorrect dstring lengths (%d/%d),"
1798 ++ " truncating\n", s_len, i_len);
1799 ++ s_len = i_len - 1;
1800 ++ /* 2-byte encoding? Need to round properly... */
1801 ++ if (ocu_i[0] == 16)
1802 ++ s_len -= (s_len - 1) & 2;
1803 + }
1804 + }
1805 +
1806 +diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
1807 +index 3eda623e4cb4..f92e1f2fc846 100644
1808 +--- a/fs/userfaultfd.c
1809 ++++ b/fs/userfaultfd.c
1810 +@@ -1362,6 +1362,19 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
1811 + ret = -EINVAL;
1812 + if (!vma_can_userfault(cur))
1813 + goto out_unlock;
1814 ++
1815 ++ /*
1816 ++ * UFFDIO_COPY will fill file holes even without
1817 ++ * PROT_WRITE. This check enforces that if this is a
1818 ++ * MAP_SHARED, the process has write permission to the backing
1819 ++ * file. If VM_MAYWRITE is set it also enforces that on a
1820 ++ * MAP_SHARED vma: there is no F_WRITE_SEAL and no further
1821 ++ * F_WRITE_SEAL can be taken until the vma is destroyed.
1822 ++ */
1823 ++ ret = -EPERM;
1824 ++ if (unlikely(!(cur->vm_flags & VM_MAYWRITE)))
1825 ++ goto out_unlock;
1826 ++
1827 + /*
1828 + * If this vma contains ending address, and huge pages
1829 + * check alignment.
1830 +@@ -1407,6 +1420,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
1831 + BUG_ON(!vma_can_userfault(vma));
1832 + BUG_ON(vma->vm_userfaultfd_ctx.ctx &&
1833 + vma->vm_userfaultfd_ctx.ctx != ctx);
1834 ++ WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
1835 +
1836 + /*
1837 + * Nothing to do: this vma is already registered into this
1838 +@@ -1553,6 +1567,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
1839 + cond_resched();
1840 +
1841 + BUG_ON(!vma_can_userfault(vma));
1842 ++ WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
1843 +
1844 + /*
1845 + * Nothing to do: this vma is already registered into this
1846 +diff --git a/include/linux/reset.h b/include/linux/reset.h
1847 +index 4c7871ddf3c6..ed6fb0290797 100644
1848 +--- a/include/linux/reset.h
1849 ++++ b/include/linux/reset.h
1850 +@@ -20,22 +20,16 @@ struct reset_control *__reset_control_get(struct device *dev, const char *id,
1851 + int index, bool shared,
1852 + bool optional);
1853 + void reset_control_put(struct reset_control *rstc);
1854 ++int __device_reset(struct device *dev, bool optional);
1855 + struct reset_control *__devm_reset_control_get(struct device *dev,
1856 + const char *id, int index, bool shared,
1857 + bool optional);
1858 +
1859 +-int __must_check device_reset(struct device *dev);
1860 +-
1861 + struct reset_control *devm_reset_control_array_get(struct device *dev,
1862 + bool shared, bool optional);
1863 + struct reset_control *of_reset_control_array_get(struct device_node *np,
1864 + bool shared, bool optional);
1865 +
1866 +-static inline int device_reset_optional(struct device *dev)
1867 +-{
1868 +- return device_reset(dev);
1869 +-}
1870 +-
1871 + #else
1872 +
1873 + static inline int reset_control_reset(struct reset_control *rstc)
1874 +@@ -62,15 +56,9 @@ static inline void reset_control_put(struct reset_control *rstc)
1875 + {
1876 + }
1877 +
1878 +-static inline int __must_check device_reset(struct device *dev)
1879 +-{
1880 +- WARN_ON(1);
1881 +- return -ENOTSUPP;
1882 +-}
1883 +-
1884 +-static inline int device_reset_optional(struct device *dev)
1885 ++static inline int __device_reset(struct device *dev, bool optional)
1886 + {
1887 +- return -ENOTSUPP;
1888 ++ return optional ? 0 : -ENOTSUPP;
1889 + }
1890 +
1891 + static inline struct reset_control *__of_reset_control_get(
1892 +@@ -109,6 +97,16 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional)
1893 +
1894 + #endif /* CONFIG_RESET_CONTROLLER */
1895 +
1896 ++static inline int __must_check device_reset(struct device *dev)
1897 ++{
1898 ++ return __device_reset(dev, false);
1899 ++}
1900 ++
1901 ++static inline int device_reset_optional(struct device *dev)
1902 ++{
1903 ++ return __device_reset(dev, true);
1904 ++}
1905 ++
1906 + /**
1907 + * reset_control_get_exclusive - Lookup and obtain an exclusive reference
1908 + * to a reset controller.
1909 +@@ -127,9 +125,6 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional)
1910 + static inline struct reset_control *
1911 + __must_check reset_control_get_exclusive(struct device *dev, const char *id)
1912 + {
1913 +-#ifndef CONFIG_RESET_CONTROLLER
1914 +- WARN_ON(1);
1915 +-#endif
1916 + return __reset_control_get(dev, id, 0, false, false);
1917 + }
1918 +
1919 +@@ -275,9 +270,6 @@ static inline struct reset_control *
1920 + __must_check devm_reset_control_get_exclusive(struct device *dev,
1921 + const char *id)
1922 + {
1923 +-#ifndef CONFIG_RESET_CONTROLLER
1924 +- WARN_ON(1);
1925 +-#endif
1926 + return __devm_reset_control_get(dev, id, 0, false, false);
1927 + }
1928 +
1929 +diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
1930 +index 014f6fbb3832..b14b0925c184 100644
1931 +--- a/kernel/debug/kdb/kdb_support.c
1932 ++++ b/kernel/debug/kdb/kdb_support.c
1933 +@@ -129,13 +129,13 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
1934 + }
1935 + if (i >= ARRAY_SIZE(kdb_name_table)) {
1936 + debug_kfree(kdb_name_table[0]);
1937 +- memcpy(kdb_name_table, kdb_name_table+1,
1938 ++ memmove(kdb_name_table, kdb_name_table+1,
1939 + sizeof(kdb_name_table[0]) *
1940 + (ARRAY_SIZE(kdb_name_table)-1));
1941 + } else {
1942 + debug_kfree(knt1);
1943 + knt1 = kdb_name_table[i];
1944 +- memcpy(kdb_name_table+i, kdb_name_table+i+1,
1945 ++ memmove(kdb_name_table+i, kdb_name_table+i+1,
1946 + sizeof(kdb_name_table[0]) *
1947 + (ARRAY_SIZE(kdb_name_table)-i-1));
1948 + }
1949 +diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
1950 +index 267f6ef91d97..01941cffa9c2 100644
1951 +--- a/kernel/events/uprobes.c
1952 ++++ b/kernel/events/uprobes.c
1953 +@@ -616,7 +616,7 @@ static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
1954 + BUG_ON((uprobe->offset & ~PAGE_MASK) +
1955 + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
1956 +
1957 +- smp_wmb(); /* pairs with rmb() in find_active_uprobe() */
1958 ++ smp_wmb(); /* pairs with the smp_rmb() in handle_swbp() */
1959 + set_bit(UPROBE_COPY_INSN, &uprobe->flags);
1960 +
1961 + out:
1962 +@@ -1910,10 +1910,18 @@ static void handle_swbp(struct pt_regs *regs)
1963 + * After we hit the bp, _unregister + _register can install the
1964 + * new and not-yet-analyzed uprobe at the same address, restart.
1965 + */
1966 +- smp_rmb(); /* pairs with wmb() in install_breakpoint() */
1967 + if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
1968 + goto out;
1969 +
1970 ++ /*
1971 ++ * Pairs with the smp_wmb() in prepare_uprobe().
1972 ++ *
1973 ++ * Guarantees that if we see the UPROBE_COPY_INSN bit set, then
1974 ++ * we must also see the stores to &uprobe->arch performed by the
1975 ++ * prepare_uprobe() call.
1976 ++ */
1977 ++ smp_rmb();
1978 ++
1979 + /* Tracing handlers use ->utask to communicate with fetch methods */
1980 + if (!get_utask())
1981 + goto out;
1982 +diff --git a/lib/kobject.c b/lib/kobject.c
1983 +index 34f847252c02..bbbb067de8ec 100644
1984 +--- a/lib/kobject.c
1985 ++++ b/lib/kobject.c
1986 +@@ -127,7 +127,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
1987 + int cur = strlen(kobject_name(parent));
1988 + /* back up enough to print this name with '/' */
1989 + length -= cur;
1990 +- strncpy(path + length, kobject_name(parent), cur);
1991 ++ memcpy(path + length, kobject_name(parent), cur);
1992 + *(path + --length) = '/';
1993 + }
1994 +
1995 +diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c
1996 +index 3f415d8101f3..1c3c513add77 100644
1997 +--- a/lib/test_hexdump.c
1998 ++++ b/lib/test_hexdump.c
1999 +@@ -81,7 +81,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize,
2000 + const char *q = *result++;
2001 + size_t amount = strlen(q);
2002 +
2003 +- strncpy(p, q, amount);
2004 ++ memcpy(p, q, amount);
2005 + p += amount;
2006 +
2007 + *p++ = ' ';
2008 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2009 +index f46040aed2da..224cdd953a79 100644
2010 +--- a/mm/hugetlb.c
2011 ++++ b/mm/hugetlb.c
2012 +@@ -4037,7 +4037,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
2013 +
2014 + /* fallback to copy_from_user outside mmap_sem */
2015 + if (unlikely(ret)) {
2016 +- ret = -EFAULT;
2017 ++ ret = -ENOENT;
2018 + *pagep = page;
2019 + /* don't free the page */
2020 + goto out;
2021 +diff --git a/mm/shmem.c b/mm/shmem.c
2022 +index ab7ff0aeae2d..6c10f1d92251 100644
2023 +--- a/mm/shmem.c
2024 ++++ b/mm/shmem.c
2025 +@@ -2244,6 +2244,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
2026 + struct page *page;
2027 + pte_t _dst_pte, *dst_pte;
2028 + int ret;
2029 ++ pgoff_t offset, max_off;
2030 +
2031 + ret = -ENOMEM;
2032 + if (!shmem_inode_acct_block(inode, 1))
2033 +@@ -2266,7 +2267,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
2034 + *pagep = page;
2035 + shmem_inode_unacct_blocks(inode, 1);
2036 + /* don't free the page */
2037 +- return -EFAULT;
2038 ++ return -ENOENT;
2039 + }
2040 + } else { /* mfill_zeropage_atomic */
2041 + clear_highpage(page);
2042 +@@ -2281,6 +2282,12 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
2043 + __SetPageSwapBacked(page);
2044 + __SetPageUptodate(page);
2045 +
2046 ++ ret = -EFAULT;
2047 ++ offset = linear_page_index(dst_vma, dst_addr);
2048 ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
2049 ++ if (unlikely(offset >= max_off))
2050 ++ goto out_release;
2051 ++
2052 + ret = mem_cgroup_try_charge(page, dst_mm, gfp, &memcg, false);
2053 + if (ret)
2054 + goto out_release;
2055 +@@ -2298,9 +2305,25 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
2056 + _dst_pte = mk_pte(page, dst_vma->vm_page_prot);
2057 + if (dst_vma->vm_flags & VM_WRITE)
2058 + _dst_pte = pte_mkwrite(pte_mkdirty(_dst_pte));
2059 ++ else {
2060 ++ /*
2061 ++ * We don't set the pte dirty if the vma has no
2062 ++ * VM_WRITE permission, so mark the page dirty or it
2063 ++ * could be freed from under us. We could do it
2064 ++ * unconditionally before unlock_page(), but doing it
2065 ++ * only if VM_WRITE is not set is faster.
2066 ++ */
2067 ++ set_page_dirty(page);
2068 ++ }
2069 +
2070 +- ret = -EEXIST;
2071 + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
2072 ++
2073 ++ ret = -EFAULT;
2074 ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
2075 ++ if (unlikely(offset >= max_off))
2076 ++ goto out_release_uncharge_unlock;
2077 ++
2078 ++ ret = -EEXIST;
2079 + if (!pte_none(*dst_pte))
2080 + goto out_release_uncharge_unlock;
2081 +
2082 +@@ -2318,13 +2341,15 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
2083 +
2084 + /* No need to invalidate - it was non-present before */
2085 + update_mmu_cache(dst_vma, dst_addr, dst_pte);
2086 +- unlock_page(page);
2087 + pte_unmap_unlock(dst_pte, ptl);
2088 ++ unlock_page(page);
2089 + ret = 0;
2090 + out:
2091 + return ret;
2092 + out_release_uncharge_unlock:
2093 + pte_unmap_unlock(dst_pte, ptl);
2094 ++ ClearPageDirty(page);
2095 ++ delete_from_page_cache(page);
2096 + out_release_uncharge:
2097 + mem_cgroup_cancel_charge(page, memcg, false);
2098 + out_release:
2099 +diff --git a/mm/truncate.c b/mm/truncate.c
2100 +index 2330223841fb..d3a2737cc188 100644
2101 +--- a/mm/truncate.c
2102 ++++ b/mm/truncate.c
2103 +@@ -471,9 +471,13 @@ void truncate_inode_pages_final(struct address_space *mapping)
2104 + */
2105 + spin_lock_irq(&mapping->tree_lock);
2106 + spin_unlock_irq(&mapping->tree_lock);
2107 +-
2108 +- truncate_inode_pages(mapping, 0);
2109 + }
2110 ++
2111 ++ /*
2112 ++ * Cleancache needs notification even if there are no pages or shadow
2113 ++ * entries.
2114 ++ */
2115 ++ truncate_inode_pages(mapping, 0);
2116 + }
2117 + EXPORT_SYMBOL(truncate_inode_pages_final);
2118 +
2119 +diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
2120 +index 81192701964d..5d70fdbd8bc0 100644
2121 +--- a/mm/userfaultfd.c
2122 ++++ b/mm/userfaultfd.c
2123 +@@ -34,6 +34,8 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm,
2124 + void *page_kaddr;
2125 + int ret;
2126 + struct page *page;
2127 ++ pgoff_t offset, max_off;
2128 ++ struct inode *inode;
2129 +
2130 + if (!*pagep) {
2131 + ret = -ENOMEM;
2132 +@@ -49,7 +51,7 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm,
2133 +
2134 + /* fallback to copy_from_user outside mmap_sem */
2135 + if (unlikely(ret)) {
2136 +- ret = -EFAULT;
2137 ++ ret = -ENOENT;
2138 + *pagep = page;
2139 + /* don't free the page */
2140 + goto out;
2141 +@@ -74,8 +76,17 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm,
2142 + if (dst_vma->vm_flags & VM_WRITE)
2143 + _dst_pte = pte_mkwrite(pte_mkdirty(_dst_pte));
2144 +
2145 +- ret = -EEXIST;
2146 + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
2147 ++ if (dst_vma->vm_file) {
2148 ++ /* the shmem MAP_PRIVATE case requires checking the i_size */
2149 ++ inode = dst_vma->vm_file->f_inode;
2150 ++ offset = linear_page_index(dst_vma, dst_addr);
2151 ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
2152 ++ ret = -EFAULT;
2153 ++ if (unlikely(offset >= max_off))
2154 ++ goto out_release_uncharge_unlock;
2155 ++ }
2156 ++ ret = -EEXIST;
2157 + if (!pte_none(*dst_pte))
2158 + goto out_release_uncharge_unlock;
2159 +
2160 +@@ -109,11 +120,22 @@ static int mfill_zeropage_pte(struct mm_struct *dst_mm,
2161 + pte_t _dst_pte, *dst_pte;
2162 + spinlock_t *ptl;
2163 + int ret;
2164 ++ pgoff_t offset, max_off;
2165 ++ struct inode *inode;
2166 +
2167 + _dst_pte = pte_mkspecial(pfn_pte(my_zero_pfn(dst_addr),
2168 + dst_vma->vm_page_prot));
2169 +- ret = -EEXIST;
2170 + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
2171 ++ if (dst_vma->vm_file) {
2172 ++ /* the shmem MAP_PRIVATE case requires checking the i_size */
2173 ++ inode = dst_vma->vm_file->f_inode;
2174 ++ offset = linear_page_index(dst_vma, dst_addr);
2175 ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
2176 ++ ret = -EFAULT;
2177 ++ if (unlikely(offset >= max_off))
2178 ++ goto out_unlock;
2179 ++ }
2180 ++ ret = -EEXIST;
2181 + if (!pte_none(*dst_pte))
2182 + goto out_unlock;
2183 + set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);
2184 +@@ -206,8 +228,9 @@ retry:
2185 + if (!dst_vma || !is_vm_hugetlb_page(dst_vma))
2186 + goto out_unlock;
2187 + /*
2188 +- * Only allow __mcopy_atomic_hugetlb on userfaultfd
2189 +- * registered ranges.
2190 ++ * Check the vma is registered in uffd, this is
2191 ++ * required to enforce the VM_MAYWRITE check done at
2192 ++ * uffd registration time.
2193 + */
2194 + if (!dst_vma->vm_userfaultfd_ctx.ctx)
2195 + goto out_unlock;
2196 +@@ -275,7 +298,7 @@ retry:
2197 +
2198 + cond_resched();
2199 +
2200 +- if (unlikely(err == -EFAULT)) {
2201 ++ if (unlikely(err == -ENOENT)) {
2202 + up_read(&dst_mm->mmap_sem);
2203 + BUG_ON(!page);
2204 +
2205 +@@ -381,7 +404,17 @@ static __always_inline ssize_t mfill_atomic_pte(struct mm_struct *dst_mm,
2206 + {
2207 + ssize_t err;
2208 +
2209 +- if (vma_is_anonymous(dst_vma)) {
2210 ++ /*
2211 ++ * The normal page fault path for a shmem will invoke the
2212 ++ * fault, fill the hole in the file and COW it right away. The
2213 ++ * result generates plain anonymous memory. So when we are
2214 ++ * asked to fill an hole in a MAP_PRIVATE shmem mapping, we'll
2215 ++ * generate anonymous memory directly without actually filling
2216 ++ * the hole. For the MAP_PRIVATE case the robustness check
2217 ++ * only happens in the pagetable (to verify it's still none)
2218 ++ * and not in the radix tree.
2219 ++ */
2220 ++ if (!(dst_vma->vm_flags & VM_SHARED)) {
2221 + if (!zeropage)
2222 + err = mcopy_atomic_pte(dst_mm, dst_pmd, dst_vma,
2223 + dst_addr, src_addr, page);
2224 +@@ -440,13 +473,9 @@ retry:
2225 + if (!dst_vma)
2226 + goto out_unlock;
2227 + /*
2228 +- * Be strict and only allow __mcopy_atomic on userfaultfd
2229 +- * registered ranges to prevent userland errors going
2230 +- * unnoticed. As far as the VM consistency is concerned, it
2231 +- * would be perfectly safe to remove this check, but there's
2232 +- * no useful usage for __mcopy_atomic ouside of userfaultfd
2233 +- * registered ranges. This is after all why these are ioctls
2234 +- * belonging to the userfaultfd and not syscalls.
2235 ++ * Check the vma is registered in uffd, this is required to
2236 ++ * enforce the VM_MAYWRITE check done at uffd registration
2237 ++ * time.
2238 + */
2239 + if (!dst_vma->vm_userfaultfd_ctx.ctx)
2240 + goto out_unlock;
2241 +@@ -480,7 +509,8 @@ retry:
2242 + * dst_vma.
2243 + */
2244 + err = -ENOMEM;
2245 +- if (vma_is_anonymous(dst_vma) && unlikely(anon_vma_prepare(dst_vma)))
2246 ++ if (!(dst_vma->vm_flags & VM_SHARED) &&
2247 ++ unlikely(anon_vma_prepare(dst_vma)))
2248 + goto out_unlock;
2249 +
2250 + while (src_addr < src_start + len) {
2251 +@@ -521,7 +551,7 @@ retry:
2252 + src_addr, &page, zeropage);
2253 + cond_resched();
2254 +
2255 +- if (unlikely(err == -EFAULT)) {
2256 ++ if (unlikely(err == -ENOENT)) {
2257 + void *page_kaddr;
2258 +
2259 + up_read(&dst_mm->mmap_sem);
2260 +diff --git a/mm/vmstat.c b/mm/vmstat.c
2261 +index 527ae727d547..6389e876c7a7 100644
2262 +--- a/mm/vmstat.c
2263 ++++ b/mm/vmstat.c
2264 +@@ -1500,6 +1500,10 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
2265 + if (is_zone_first_populated(pgdat, zone)) {
2266 + seq_printf(m, "\n per-node stats");
2267 + for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) {
2268 ++ /* Skip hidden vmstat items. */
2269 ++ if (*vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
2270 ++ NR_VM_NUMA_STAT_ITEMS] == '\0')
2271 ++ continue;
2272 + seq_printf(m, "\n %-12s %lu",
2273 + vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
2274 + NR_VM_NUMA_STAT_ITEMS],
2275 +diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
2276 +index 72eee34092ae..fabc299cb875 100644
2277 +--- a/net/ipv4/ip_tunnel.c
2278 ++++ b/net/ipv4/ip_tunnel.c
2279 +@@ -261,8 +261,8 @@ static struct net_device *__ip_tunnel_create(struct net *net,
2280 + } else {
2281 + if (strlen(ops->kind) > (IFNAMSIZ - 3))
2282 + goto failed;
2283 +- strlcpy(name, ops->kind, IFNAMSIZ);
2284 +- strncat(name, "%d", 2);
2285 ++ strcpy(name, ops->kind);
2286 ++ strcat(name, "%d");
2287 + }
2288 +
2289 + ASSERT_RTNL();
2290 +diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
2291 +index be3d9e3183dc..959c9aea3d1a 100644
2292 +--- a/net/tipc/subscr.c
2293 ++++ b/net/tipc/subscr.c
2294 +@@ -375,7 +375,7 @@ int tipc_topsrv_start(struct net *net)
2295 + topsrv->tipc_conn_new = tipc_subscrb_connect_cb;
2296 + topsrv->tipc_conn_release = tipc_subscrb_release_cb;
2297 +
2298 +- strncpy(topsrv->name, name, strlen(name) + 1);
2299 ++ strscpy(topsrv->name, name, sizeof(topsrv->name));
2300 + tn->topsrv = topsrv;
2301 + atomic_set(&tn->subscription_count, 0);
2302 +
2303 +diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
2304 +index c6ebf4239e64..8d5357053f86 100644
2305 +--- a/scripts/Makefile.extrawarn
2306 ++++ b/scripts/Makefile.extrawarn
2307 +@@ -11,6 +11,8 @@
2308 + # are not supported by all versions of the compiler
2309 + # ==========================================================================
2310 +
2311 ++KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
2312 ++
2313 + ifeq ("$(origin W)", "command line")
2314 + export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
2315 + endif
2316 +@@ -26,6 +28,7 @@ warning-1 += -Wold-style-definition
2317 + warning-1 += $(call cc-option, -Wmissing-include-dirs)
2318 + warning-1 += $(call cc-option, -Wunused-but-set-variable)
2319 + warning-1 += $(call cc-option, -Wunused-const-variable)
2320 ++warning-1 += $(call cc-option, -Wpacked-not-aligned)
2321 + warning-1 += $(call cc-disable-warning, missing-field-initializers)
2322 + warning-1 += $(call cc-disable-warning, sign-compare)
2323 +
2324 +diff --git a/scripts/unifdef.c b/scripts/unifdef.c
2325 +index 7493c0ee51cc..db00e3e30a59 100644
2326 +--- a/scripts/unifdef.c
2327 ++++ b/scripts/unifdef.c
2328 +@@ -395,7 +395,7 @@ usage(void)
2329 + * When we have processed a group that starts off with a known-false
2330 + * #if/#elif sequence (which has therefore been deleted) followed by a
2331 + * #elif that we don't understand and therefore must keep, we edit the
2332 +- * latter into a #if to keep the nesting correct. We use strncpy() to
2333 ++ * latter into a #if to keep the nesting correct. We use memcpy() to
2334 + * overwrite the 4 byte token "elif" with "if " without a '\0' byte.
2335 + *
2336 + * When we find a true #elif in a group, the following block will
2337 +@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); }
2338 + static void Itrue (void) { Ftrue(); ignoreon(); }
2339 + static void Ifalse(void) { Ffalse(); ignoreon(); }
2340 + /* modify this line */
2341 +-static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); }
2342 ++static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); }
2343 + static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); }
2344 + static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); }
2345 + static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }
2346 +diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
2347 +index cedf13b64803..2f18b1cdc2cd 100644
2348 +--- a/sound/pci/trident/trident.c
2349 ++++ b/sound/pci/trident/trident.c
2350 +@@ -123,7 +123,7 @@ static int snd_trident_probe(struct pci_dev *pci,
2351 + } else {
2352 + strcpy(card->shortname, "Trident ");
2353 + }
2354 +- strcat(card->shortname, card->driver);
2355 ++ strcat(card->shortname, str);
2356 + sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
2357 + card->shortname, trident->port, trident->irq);
2358 +
2359 +diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
2360 +index 697872d8308e..8b7abbd69116 100644
2361 +--- a/sound/x86/intel_hdmi_audio.c
2362 ++++ b/sound/x86/intel_hdmi_audio.c
2363 +@@ -1839,7 +1839,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
2364 + /* setup private data which can be retrieved when required */
2365 + pcm->private_data = ctx;
2366 + pcm->info_flags = 0;
2367 +- strncpy(pcm->name, card->shortname, strlen(card->shortname));
2368 ++ strlcpy(pcm->name, card->shortname, strlen(card->shortname));
2369 + /* setup the ops for playabck */
2370 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops);
2371 +