Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.19 commit in: /
Date: Fri, 10 May 2019 19:40:25
Message-Id: 1557517207.85602c336bfa5919a66fc97856a7f452614f5349.mpagano@gentoo
1 commit: 85602c336bfa5919a66fc97856a7f452614f5349
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 10 19:40:07 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri May 10 19:40:07 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=85602c33
7
8 Linux patch 4.19.42
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1041_linux-4.19.42.patch | 4659 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4663 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index ba19d17..9a195d3 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -207,6 +207,10 @@ Patch: 1040_linux-4.19.41.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.19.41
23
24 +Patch: 1041_linux-4.19.42.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.19.42
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/1041_linux-4.19.42.patch b/1041_linux-4.19.42.patch
33 new file mode 100644
34 index 0000000..ad6da18
35 --- /dev/null
36 +++ b/1041_linux-4.19.42.patch
37 @@ -0,0 +1,4659 @@
38 +diff --git a/Makefile b/Makefile
39 +index ba3b8504b689..914d69b9e3fd 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 19
46 +-SUBLEVEL = 41
47 ++SUBLEVEL = 42
48 + EXTRAVERSION =
49 + NAME = "People's Front"
50 +
51 +diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
52 +index fd1e722f3821..c7e30a6ed56e 100644
53 +--- a/arch/arm64/include/asm/futex.h
54 ++++ b/arch/arm64/include/asm/futex.h
55 +@@ -23,26 +23,34 @@
56 +
57 + #include <asm/errno.h>
58 +
59 ++#define FUTEX_MAX_LOOPS 128 /* What's the largest number you can think of? */
60 ++
61 + #define __futex_atomic_op(insn, ret, oldval, uaddr, tmp, oparg) \
62 + do { \
63 ++ unsigned int loops = FUTEX_MAX_LOOPS; \
64 ++ \
65 + uaccess_enable(); \
66 + asm volatile( \
67 + " prfm pstl1strm, %2\n" \
68 + "1: ldxr %w1, %2\n" \
69 + insn "\n" \
70 + "2: stlxr %w0, %w3, %2\n" \
71 +-" cbnz %w0, 1b\n" \
72 +-" dmb ish\n" \
73 ++" cbz %w0, 3f\n" \
74 ++" sub %w4, %w4, %w0\n" \
75 ++" cbnz %w4, 1b\n" \
76 ++" mov %w0, %w7\n" \
77 + "3:\n" \
78 ++" dmb ish\n" \
79 + " .pushsection .fixup,\"ax\"\n" \
80 + " .align 2\n" \
81 +-"4: mov %w0, %w5\n" \
82 ++"4: mov %w0, %w6\n" \
83 + " b 3b\n" \
84 + " .popsection\n" \
85 + _ASM_EXTABLE(1b, 4b) \
86 + _ASM_EXTABLE(2b, 4b) \
87 +- : "=&r" (ret), "=&r" (oldval), "+Q" (*uaddr), "=&r" (tmp) \
88 +- : "r" (oparg), "Ir" (-EFAULT) \
89 ++ : "=&r" (ret), "=&r" (oldval), "+Q" (*uaddr), "=&r" (tmp), \
90 ++ "+r" (loops) \
91 ++ : "r" (oparg), "Ir" (-EFAULT), "Ir" (-EAGAIN) \
92 + : "memory"); \
93 + uaccess_disable(); \
94 + } while (0)
95 +@@ -57,23 +65,23 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr)
96 +
97 + switch (op) {
98 + case FUTEX_OP_SET:
99 +- __futex_atomic_op("mov %w3, %w4",
100 ++ __futex_atomic_op("mov %w3, %w5",
101 + ret, oldval, uaddr, tmp, oparg);
102 + break;
103 + case FUTEX_OP_ADD:
104 +- __futex_atomic_op("add %w3, %w1, %w4",
105 ++ __futex_atomic_op("add %w3, %w1, %w5",
106 + ret, oldval, uaddr, tmp, oparg);
107 + break;
108 + case FUTEX_OP_OR:
109 +- __futex_atomic_op("orr %w3, %w1, %w4",
110 ++ __futex_atomic_op("orr %w3, %w1, %w5",
111 + ret, oldval, uaddr, tmp, oparg);
112 + break;
113 + case FUTEX_OP_ANDN:
114 +- __futex_atomic_op("and %w3, %w1, %w4",
115 ++ __futex_atomic_op("and %w3, %w1, %w5",
116 + ret, oldval, uaddr, tmp, ~oparg);
117 + break;
118 + case FUTEX_OP_XOR:
119 +- __futex_atomic_op("eor %w3, %w1, %w4",
120 ++ __futex_atomic_op("eor %w3, %w1, %w5",
121 + ret, oldval, uaddr, tmp, oparg);
122 + break;
123 + default:
124 +@@ -93,6 +101,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
125 + u32 oldval, u32 newval)
126 + {
127 + int ret = 0;
128 ++ unsigned int loops = FUTEX_MAX_LOOPS;
129 + u32 val, tmp;
130 + u32 __user *uaddr;
131 +
132 +@@ -104,20 +113,24 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
133 + asm volatile("// futex_atomic_cmpxchg_inatomic\n"
134 + " prfm pstl1strm, %2\n"
135 + "1: ldxr %w1, %2\n"
136 +-" sub %w3, %w1, %w4\n"
137 +-" cbnz %w3, 3f\n"
138 +-"2: stlxr %w3, %w5, %2\n"
139 +-" cbnz %w3, 1b\n"
140 +-" dmb ish\n"
141 ++" sub %w3, %w1, %w5\n"
142 ++" cbnz %w3, 4f\n"
143 ++"2: stlxr %w3, %w6, %2\n"
144 ++" cbz %w3, 3f\n"
145 ++" sub %w4, %w4, %w3\n"
146 ++" cbnz %w4, 1b\n"
147 ++" mov %w0, %w8\n"
148 + "3:\n"
149 ++" dmb ish\n"
150 ++"4:\n"
151 + " .pushsection .fixup,\"ax\"\n"
152 +-"4: mov %w0, %w6\n"
153 +-" b 3b\n"
154 ++"5: mov %w0, %w7\n"
155 ++" b 4b\n"
156 + " .popsection\n"
157 +- _ASM_EXTABLE(1b, 4b)
158 +- _ASM_EXTABLE(2b, 4b)
159 +- : "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp)
160 +- : "r" (oldval), "r" (newval), "Ir" (-EFAULT)
161 ++ _ASM_EXTABLE(1b, 5b)
162 ++ _ASM_EXTABLE(2b, 5b)
163 ++ : "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp), "+r" (loops)
164 ++ : "r" (oldval), "r" (newval), "Ir" (-EFAULT), "Ir" (-EAGAIN)
165 + : "memory");
166 + uaccess_disable();
167 +
168 +diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
169 +index eb6c0d582626..2c1e30ca7ee4 100644
170 +--- a/arch/mips/kernel/kgdb.c
171 ++++ b/arch/mips/kernel/kgdb.c
172 +@@ -33,6 +33,7 @@
173 + #include <asm/processor.h>
174 + #include <asm/sigcontext.h>
175 + #include <linux/uaccess.h>
176 ++#include <asm/irq_regs.h>
177 +
178 + static struct hard_trap_info {
179 + unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
180 +@@ -214,7 +215,7 @@ static void kgdb_call_nmi_hook(void *ignored)
181 + old_fs = get_fs();
182 + set_fs(get_ds());
183 +
184 +- kgdb_nmicallback(raw_smp_processor_id(), NULL);
185 ++ kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
186 +
187 + set_fs(old_fs);
188 + }
189 +diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
190 +index 3dd204d1dd19..f9958ad4d335 100644
191 +--- a/arch/x86/events/intel/core.c
192 ++++ b/arch/x86/events/intel/core.c
193 +@@ -3068,7 +3068,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
194 + return ret;
195 +
196 + if (event->attr.precise_ip) {
197 +- if (!event->attr.freq) {
198 ++ if (!(event->attr.freq || event->attr.wakeup_events)) {
199 + event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
200 + if (!(event->attr.sample_type &
201 + ~intel_pmu_large_pebs_flags(event)))
202 +@@ -3447,6 +3447,12 @@ static void intel_pmu_cpu_starting(int cpu)
203 +
204 + cpuc->lbr_sel = NULL;
205 +
206 ++ if (x86_pmu.flags & PMU_FL_TFA) {
207 ++ WARN_ON_ONCE(cpuc->tfa_shadow);
208 ++ cpuc->tfa_shadow = ~0ULL;
209 ++ intel_set_tfa(cpuc, false);
210 ++ }
211 ++
212 + if (x86_pmu.version > 1)
213 + flip_smm_bit(&x86_pmu.attr_freeze_on_smi);
214 +
215 +diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
216 +index 23752dc99b00..dd64f586679e 100644
217 +--- a/drivers/block/virtio_blk.c
218 ++++ b/drivers/block/virtio_blk.c
219 +@@ -446,6 +446,8 @@ static int init_vq(struct virtio_blk *vblk)
220 + if (err)
221 + num_vqs = 1;
222 +
223 ++ num_vqs = min_t(unsigned int, nr_cpu_ids, num_vqs);
224 ++
225 + vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
226 + if (!vblk->vqs)
227 + return -ENOMEM;
228 +diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
229 +index 6628ffa31383..4d4f6d842c31 100644
230 +--- a/drivers/clk/meson/gxbb.c
231 ++++ b/drivers/clk/meson/gxbb.c
232 +@@ -1571,6 +1571,7 @@ static struct clk_regmap gxbb_vdec_1_div = {
233 + .offset = HHI_VDEC_CLK_CNTL,
234 + .shift = 0,
235 + .width = 7,
236 ++ .flags = CLK_DIVIDER_ROUND_CLOSEST,
237 + },
238 + .hw.init = &(struct clk_init_data){
239 + .name = "vdec_1_div",
240 +@@ -1616,6 +1617,7 @@ static struct clk_regmap gxbb_vdec_hevc_div = {
241 + .offset = HHI_VDEC2_CLK_CNTL,
242 + .shift = 16,
243 + .width = 7,
244 ++ .flags = CLK_DIVIDER_ROUND_CLOSEST,
245 + },
246 + .hw.init = &(struct clk_init_data){
247 + .name = "vdec_hevc_div",
248 +diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c
249 +index 75491fc841a6..0df16eb1eb3c 100644
250 +--- a/drivers/cpufreq/armada-37xx-cpufreq.c
251 ++++ b/drivers/cpufreq/armada-37xx-cpufreq.c
252 +@@ -359,11 +359,11 @@ static int __init armada37xx_cpufreq_driver_init(void)
253 + struct armada_37xx_dvfs *dvfs;
254 + struct platform_device *pdev;
255 + unsigned long freq;
256 +- unsigned int cur_frequency;
257 ++ unsigned int cur_frequency, base_frequency;
258 + struct regmap *nb_pm_base, *avs_base;
259 + struct device *cpu_dev;
260 + int load_lvl, ret;
261 +- struct clk *clk;
262 ++ struct clk *clk, *parent;
263 +
264 + nb_pm_base =
265 + syscon_regmap_lookup_by_compatible("marvell,armada-3700-nb-pm");
266 +@@ -399,6 +399,22 @@ static int __init armada37xx_cpufreq_driver_init(void)
267 + return PTR_ERR(clk);
268 + }
269 +
270 ++ parent = clk_get_parent(clk);
271 ++ if (IS_ERR(parent)) {
272 ++ dev_err(cpu_dev, "Cannot get parent clock for CPU0\n");
273 ++ clk_put(clk);
274 ++ return PTR_ERR(parent);
275 ++ }
276 ++
277 ++ /* Get parent CPU frequency */
278 ++ base_frequency = clk_get_rate(parent);
279 ++
280 ++ if (!base_frequency) {
281 ++ dev_err(cpu_dev, "Failed to get parent clock rate for CPU\n");
282 ++ clk_put(clk);
283 ++ return -EINVAL;
284 ++ }
285 ++
286 + /* Get nominal (current) CPU frequency */
287 + cur_frequency = clk_get_rate(clk);
288 + if (!cur_frequency) {
289 +@@ -431,7 +447,7 @@ static int __init armada37xx_cpufreq_driver_init(void)
290 + for (load_lvl = ARMADA_37XX_DVFS_LOAD_0; load_lvl < LOAD_LEVEL_NR;
291 + load_lvl++) {
292 + unsigned long u_volt = avs_map[dvfs->avs[load_lvl]] * 1000;
293 +- freq = cur_frequency / dvfs->divider[load_lvl];
294 ++ freq = base_frequency / dvfs->divider[load_lvl];
295 + ret = dev_pm_opp_add(cpu_dev, freq, u_volt);
296 + if (ret)
297 + goto remove_opp;
298 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
299 +index 2b8b892eb846..76ee2de43ea6 100644
300 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
301 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
302 +@@ -4028,6 +4028,7 @@ static void handle_cursor_update(struct drm_plane *plane,
303 + amdgpu_crtc->cursor_width = plane->state->crtc_w;
304 + amdgpu_crtc->cursor_height = plane->state->crtc_h;
305 +
306 ++ memset(&attributes, 0, sizeof(attributes));
307 + attributes.address.high_part = upper_32_bits(address);
308 + attributes.address.low_part = lower_32_bits(address);
309 + attributes.width = plane->state->crtc_w;
310 +diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
311 +index 643f5edd68fe..62444a3a5742 100644
312 +--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
313 ++++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
314 +@@ -1473,7 +1473,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
315 + if (IS_ERR(regmap))
316 + ret = PTR_ERR(regmap);
317 + if (ret) {
318 +- ret = PTR_ERR(regmap);
319 + dev_err(dev,
320 + "Failed to get system configuration registers: %d\n",
321 + ret);
322 +@@ -1509,6 +1508,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
323 + of_node_put(remote);
324 +
325 + hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
326 ++ of_node_put(i2c_np);
327 + if (!hdmi->ddc_adpt) {
328 + dev_err(dev, "Failed to get ddc i2c adapter by node\n");
329 + return -EINVAL;
330 +diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
331 +index 340383150fb9..ebf9c96d43ee 100644
332 +--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
333 ++++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
334 +@@ -175,6 +175,7 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
335 + REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
336 + hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
337 + hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
338 ++ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
339 + hdmi4_core_disable(core);
340 + return 0;
341 + }
342 +@@ -182,16 +183,24 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
343 + if (err)
344 + return err;
345 +
346 ++ /*
347 ++ * Initialize CEC clock divider: CEC needs 2MHz clock hence
348 ++ * set the divider to 24 to get 48/24=2MHz clock
349 ++ */
350 ++ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
351 ++
352 + /* Clear TX FIFO */
353 + if (!hdmi_cec_clear_tx_fifo(adap)) {
354 + pr_err("cec-%s: could not clear TX FIFO\n", adap->name);
355 +- return -EIO;
356 ++ err = -EIO;
357 ++ goto err_disable_clk;
358 + }
359 +
360 + /* Clear RX FIFO */
361 + if (!hdmi_cec_clear_rx_fifo(adap)) {
362 + pr_err("cec-%s: could not clear RX FIFO\n", adap->name);
363 +- return -EIO;
364 ++ err = -EIO;
365 ++ goto err_disable_clk;
366 + }
367 +
368 + /* Clear CEC interrupts */
369 +@@ -236,6 +245,12 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
370 + hdmi_write_reg(core->base, HDMI_CEC_INT_STATUS_1, temp);
371 + }
372 + return 0;
373 ++
374 ++err_disable_clk:
375 ++ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
376 ++ hdmi4_core_disable(core);
377 ++
378 ++ return err;
379 + }
380 +
381 + static int hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
382 +@@ -333,11 +348,8 @@ int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core,
383 + return ret;
384 + core->wp = wp;
385 +
386 +- /*
387 +- * Initialize CEC clock divider: CEC needs 2MHz clock hence
388 +- * set the devider to 24 to get 48/24=2MHz clock
389 +- */
390 +- REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
391 ++ /* Disable clock initially, hdmi_cec_adap_enable() manages it */
392 ++ REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
393 +
394 + ret = cec_register_adapter(core->adap, &pdev->dev);
395 + if (ret < 0) {
396 +diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
397 +index adcdf946c365..dfbcd1ad81a5 100644
398 +--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
399 ++++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
400 +@@ -217,7 +217,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
401 +
402 + err_unregister_gates:
403 + for (i = 0; i < CLK_NUM; i++)
404 +- if (clk_data->hws[i])
405 ++ if (!IS_ERR_OR_NULL(clk_data->hws[i]))
406 + clk_hw_unregister_gate(clk_data->hws[i]);
407 + clk_disable_unprepare(tcon_top->bus);
408 + err_assert_reset:
409 +@@ -235,7 +235,8 @@ static void sun8i_tcon_top_unbind(struct device *dev, struct device *master,
410 +
411 + of_clk_del_provider(dev->of_node);
412 + for (i = 0; i < CLK_NUM; i++)
413 +- clk_hw_unregister_gate(clk_data->hws[i]);
414 ++ if (clk_data->hws[i])
415 ++ clk_hw_unregister_gate(clk_data->hws[i]);
416 +
417 + clk_disable_unprepare(tcon_top->bus);
418 + reset_control_assert(tcon_top->rst);
419 +diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
420 +index 748a1c4172a6..8e923e70e594 100644
421 +--- a/drivers/hv/hv.c
422 ++++ b/drivers/hv/hv.c
423 +@@ -402,7 +402,6 @@ int hv_synic_cleanup(unsigned int cpu)
424 +
425 + clockevents_unbind_device(hv_cpu->clk_evt, cpu);
426 + hv_ce_shutdown(hv_cpu->clk_evt);
427 +- put_cpu_ptr(hv_cpu);
428 + }
429 +
430 + hv_get_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
431 +diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
432 +index 1cf6290d6435..70f2cb90adc5 100644
433 +--- a/drivers/hwtracing/intel_th/pci.c
434 ++++ b/drivers/hwtracing/intel_th/pci.c
435 +@@ -165,6 +165,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
436 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x34a6),
437 + .driver_data = (kernel_ulong_t)&intel_th_2x,
438 + },
439 ++ {
440 ++ /* Comet Lake */
441 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x02a6),
442 ++ .driver_data = (kernel_ulong_t)&intel_th_2x,
443 ++ },
444 + { 0 },
445 + };
446 +
447 +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
448 +index 902d12d6d88b..b12c8ff8ed66 100644
449 +--- a/drivers/infiniband/hw/hfi1/chip.c
450 ++++ b/drivers/infiniband/hw/hfi1/chip.c
451 +@@ -13388,7 +13388,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
452 + int total_contexts;
453 + int ret;
454 + unsigned ngroups;
455 +- int qos_rmt_count;
456 ++ int rmt_count;
457 + int user_rmt_reduced;
458 + u32 n_usr_ctxts;
459 + u32 send_contexts = chip_send_contexts(dd);
460 +@@ -13450,10 +13450,20 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
461 + n_usr_ctxts = rcv_contexts - total_contexts;
462 + }
463 +
464 +- /* each user context requires an entry in the RMT */
465 +- qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
466 +- if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
467 +- user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
468 ++ /*
469 ++ * The RMT entries are currently allocated as shown below:
470 ++ * 1. QOS (0 to 128 entries);
471 ++ * 2. FECN for PSM (num_user_contexts + num_vnic_contexts);
472 ++ * 3. VNIC (num_vnic_contexts).
473 ++ * It should be noted that PSM FECN oversubscribe num_vnic_contexts
474 ++ * entries of RMT because both VNIC and PSM could allocate any receive
475 ++ * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
476 ++ * and PSM FECN must reserve an RMT entry for each possible PSM receive
477 ++ * context.
478 ++ */
479 ++ rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
480 ++ if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
481 ++ user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
482 + dd_dev_err(dd,
483 + "RMT size is reducing the number of user receive contexts from %u to %d\n",
484 + n_usr_ctxts,
485 +@@ -14441,9 +14451,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
486 + u64 reg;
487 + int i, idx, regoff, regidx;
488 + u8 offset;
489 ++ u32 total_cnt;
490 +
491 + /* there needs to be enough room in the map table */
492 +- if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
493 ++ total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
494 ++ if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
495 + dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
496 + return;
497 + }
498 +@@ -14497,7 +14509,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
499 + /* add rule 1 */
500 + add_rsm_rule(dd, RSM_INS_FECN, &rrd);
501 +
502 +- rmt->used += dd->num_user_contexts;
503 ++ rmt->used += total_cnt;
504 + }
505 +
506 + /* Initialize RSM for VNIC */
507 +diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
508 +index 6f013a565353..770c78c65730 100644
509 +--- a/drivers/infiniband/hw/hfi1/rc.c
510 ++++ b/drivers/infiniband/hw/hfi1/rc.c
511 +@@ -2303,7 +2303,7 @@ send_last:
512 + update_ack_queue(qp, next);
513 + }
514 + e = &qp->s_ack_queue[qp->r_head_ack_queue];
515 +- if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
516 ++ if (e->rdma_sge.mr) {
517 + rvt_put_mr(e->rdma_sge.mr);
518 + e->rdma_sge.mr = NULL;
519 + }
520 +@@ -2377,7 +2377,7 @@ send_last:
521 + update_ack_queue(qp, next);
522 + }
523 + e = &qp->s_ack_queue[qp->r_head_ack_queue];
524 +- if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
525 ++ if (e->rdma_sge.mr) {
526 + rvt_put_mr(e->rdma_sge.mr);
527 + e->rdma_sge.mr = NULL;
528 + }
529 +diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c
530 +index f6faefed96e8..a73d388b7093 100644
531 +--- a/drivers/infiniband/hw/hns/hns_roce_hem.c
532 ++++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
533 +@@ -745,6 +745,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
534 + idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
535 + dma_offset = offset = idx_offset * table->obj_size;
536 + } else {
537 ++ u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
538 ++
539 + hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop);
540 + /* mtt mhop */
541 + i = mhop.l0_idx;
542 +@@ -756,8 +758,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
543 + hem_idx = i;
544 +
545 + hem = table->hem[hem_idx];
546 +- dma_offset = offset = (obj & (table->num_obj - 1)) *
547 +- table->obj_size % mhop.bt_chunk_size;
548 ++ dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
549 ++ mhop.bt_chunk_size;
550 + if (mhop.hop_num == 2)
551 + dma_offset = offset = 0;
552 + }
553 +diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
554 +index eb26a5f6fc58..41a538d23b80 100644
555 +--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
556 ++++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
557 +@@ -707,7 +707,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
558 + struct hns_roce_hem_table *table;
559 + dma_addr_t dma_handle;
560 + __le64 *mtts;
561 +- u32 s = start_index * sizeof(u64);
562 + u32 bt_page_size;
563 + u32 i;
564 +
565 +@@ -730,7 +729,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
566 + table = &hr_dev->mr_table.mtt_cqe_table;
567 +
568 + mtts = hns_roce_table_find(hr_dev, table,
569 +- mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
570 ++ mtt->first_seg +
571 ++ start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
572 + &dma_handle);
573 + if (!mtts)
574 + return -ENOMEM;
575 +diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
576 +index a5719899f49a..ed99f0a08dc4 100644
577 +--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
578 ++++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
579 +@@ -1123,6 +1123,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
580 + pvrdma_page_dir_cleanup(dev, &dev->cq_pdir);
581 + pvrdma_page_dir_cleanup(dev, &dev->async_pdir);
582 + pvrdma_free_slots(dev);
583 ++ dma_free_coherent(&pdev->dev, sizeof(*dev->dsr), dev->dsr,
584 ++ dev->dsrbase);
585 +
586 + iounmap(dev->regs);
587 + kfree(dev->sgid_tbl);
588 +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
589 +index be3801d43d48..3a1d30304f7e 100644
590 +--- a/drivers/iommu/amd_iommu_init.c
591 ++++ b/drivers/iommu/amd_iommu_init.c
592 +@@ -356,7 +356,7 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val)
593 + static void iommu_set_exclusion_range(struct amd_iommu *iommu)
594 + {
595 + u64 start = iommu->exclusion_start & PAGE_MASK;
596 +- u64 limit = (start + iommu->exclusion_length) & PAGE_MASK;
597 ++ u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK;
598 + u64 entry;
599 +
600 + if (!iommu->exclusion_start)
601 +diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
602 +index b7dd4e3c760d..6d690678c20e 100644
603 +--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
604 ++++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
605 +@@ -140,7 +140,7 @@ static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
606 + p->des0 |= cpu_to_le32(RDES0_OWN);
607 +
608 + bfsize1 = min(bfsize, BUF_SIZE_2KiB - 1);
609 +- p->des1 |= cpu_to_le32(bfsize & RDES1_BUFFER1_SIZE_MASK);
610 ++ p->des1 |= cpu_to_le32(bfsize1 & RDES1_BUFFER1_SIZE_MASK);
611 +
612 + if (mode == STMMAC_CHAIN_MODE)
613 + ndesc_rx_set_on_chain(p, end);
614 +diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
615 +index 9375fa705d82..67dec8860bf3 100644
616 +--- a/drivers/nvme/host/fc.c
617 ++++ b/drivers/nvme/host/fc.c
618 +@@ -1844,7 +1844,7 @@ nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx)
619 + memset(queue, 0, sizeof(*queue));
620 + queue->ctrl = ctrl;
621 + queue->qnum = idx;
622 +- atomic_set(&queue->csn, 1);
623 ++ atomic_set(&queue->csn, 0);
624 + queue->dev = ctrl->dev;
625 +
626 + if (idx > 0)
627 +@@ -1886,7 +1886,7 @@ nvme_fc_free_queue(struct nvme_fc_queue *queue)
628 + */
629 +
630 + queue->connection_id = 0;
631 +- atomic_set(&queue->csn, 1);
632 ++ atomic_set(&queue->csn, 0);
633 + }
634 +
635 + static void
636 +@@ -2182,7 +2182,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
637 + {
638 + struct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu;
639 + struct nvme_command *sqe = &cmdiu->sqe;
640 +- u32 csn;
641 + int ret, opstate;
642 +
643 + /*
644 +@@ -2197,8 +2196,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
645 +
646 + /* format the FC-NVME CMD IU and fcp_req */
647 + cmdiu->connection_id = cpu_to_be64(queue->connection_id);
648 +- csn = atomic_inc_return(&queue->csn);
649 +- cmdiu->csn = cpu_to_be32(csn);
650 + cmdiu->data_len = cpu_to_be32(data_len);
651 + switch (io_dir) {
652 + case NVMEFC_FCP_WRITE:
653 +@@ -2256,11 +2253,24 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
654 + if (!(op->flags & FCOP_FLAGS_AEN))
655 + blk_mq_start_request(op->rq);
656 +
657 ++ cmdiu->csn = cpu_to_be32(atomic_inc_return(&queue->csn));
658 + ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport,
659 + &ctrl->rport->remoteport,
660 + queue->lldd_handle, &op->fcp_req);
661 +
662 + if (ret) {
663 ++ /*
664 ++ * If the lld fails to send the command is there an issue with
665 ++ * the csn value? If the command that fails is the Connect,
666 ++ * no - as the connection won't be live. If it is a command
667 ++ * post-connect, it's possible a gap in csn may be created.
668 ++ * Does this matter? As Linux initiators don't send fused
669 ++ * commands, no. The gap would exist, but as there's nothing
670 ++ * that depends on csn order to be delivered on the target
671 ++ * side, it shouldn't hurt. It would be difficult for a
672 ++ * target to even detect the csn gap as it has no idea when the
673 ++ * cmd with the csn was supposed to arrive.
674 ++ */
675 + opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE);
676 + __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
677 +
678 +diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
679 +index eaec2d306481..c7039f52ad51 100644
680 +--- a/drivers/platform/x86/pmc_atom.c
681 ++++ b/drivers/platform/x86/pmc_atom.c
682 +@@ -396,7 +396,7 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
683 + * Some systems need one or more of their pmc_plt_clks to be
684 + * marked as critical.
685 + */
686 +-static const struct dmi_system_id critclk_systems[] __initconst = {
687 ++static const struct dmi_system_id critclk_systems[] = {
688 + {
689 + .ident = "MPL CEC1x",
690 + .matches = {
691 +diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
692 +index dab0d3f9bee1..e09c7f360dbd 100644
693 +--- a/drivers/scsi/csiostor/csio_scsi.c
694 ++++ b/drivers/scsi/csiostor/csio_scsi.c
695 +@@ -1713,8 +1713,11 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req)
696 + }
697 +
698 + out:
699 +- if (req->nsge > 0)
700 ++ if (req->nsge > 0) {
701 + scsi_dma_unmap(cmnd);
702 ++ if (req->dcopy && (host_status == DID_OK))
703 ++ host_status = csio_scsi_copy_to_sgl(hw, req);
704 ++ }
705 +
706 + cmnd->result = (((host_status) << 16) | scsi_status);
707 + cmnd->scsi_done(cmnd);
708 +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
709 +index a1551ab33616..e9ecc667e3fb 100644
710 +--- a/drivers/scsi/libsas/sas_expander.c
711 ++++ b/drivers/scsi/libsas/sas_expander.c
712 +@@ -48,17 +48,16 @@ static void smp_task_timedout(struct timer_list *t)
713 + unsigned long flags;
714 +
715 + spin_lock_irqsave(&task->task_state_lock, flags);
716 +- if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
717 ++ if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
718 + task->task_state_flags |= SAS_TASK_STATE_ABORTED;
719 ++ complete(&task->slow_task->completion);
720 ++ }
721 + spin_unlock_irqrestore(&task->task_state_lock, flags);
722 +-
723 +- complete(&task->slow_task->completion);
724 + }
725 +
726 + static void smp_task_done(struct sas_task *task)
727 + {
728 +- if (!del_timer(&task->slow_task->timer))
729 +- return;
730 ++ del_timer(&task->slow_task->timer);
731 + complete(&task->slow_task->completion);
732 + }
733 +
734 +diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
735 +index 1a6ed9b0a249..cb19b12e7211 100644
736 +--- a/drivers/scsi/lpfc/lpfc_attr.c
737 ++++ b/drivers/scsi/lpfc/lpfc_attr.c
738 +@@ -117,7 +117,7 @@ static ssize_t
739 + lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
740 + char *buf)
741 + {
742 +- return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
743 ++ return scnprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
744 + }
745 +
746 + /**
747 +@@ -137,9 +137,9 @@ lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
748 + struct lpfc_hba *phba = vport->phba;
749 +
750 + if (phba->hba_flag & HBA_FIP_SUPPORT)
751 +- return snprintf(buf, PAGE_SIZE, "1\n");
752 ++ return scnprintf(buf, PAGE_SIZE, "1\n");
753 + else
754 +- return snprintf(buf, PAGE_SIZE, "0\n");
755 ++ return scnprintf(buf, PAGE_SIZE, "0\n");
756 + }
757 +
758 + static ssize_t
759 +@@ -517,14 +517,15 @@ lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
760 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
761 + struct lpfc_hba *phba = vport->phba;
762 +
763 +- if (phba->cfg_enable_bg)
764 ++ if (phba->cfg_enable_bg) {
765 + if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
766 +- return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
767 ++ return scnprintf(buf, PAGE_SIZE,
768 ++ "BlockGuard Enabled\n");
769 + else
770 +- return snprintf(buf, PAGE_SIZE,
771 ++ return scnprintf(buf, PAGE_SIZE,
772 + "BlockGuard Not Supported\n");
773 +- else
774 +- return snprintf(buf, PAGE_SIZE,
775 ++ } else
776 ++ return scnprintf(buf, PAGE_SIZE,
777 + "BlockGuard Disabled\n");
778 + }
779 +
780 +@@ -536,7 +537,7 @@ lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr,
781 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
782 + struct lpfc_hba *phba = vport->phba;
783 +
784 +- return snprintf(buf, PAGE_SIZE, "%llu\n",
785 ++ return scnprintf(buf, PAGE_SIZE, "%llu\n",
786 + (unsigned long long)phba->bg_guard_err_cnt);
787 + }
788 +
789 +@@ -548,7 +549,7 @@ lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr,
790 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
791 + struct lpfc_hba *phba = vport->phba;
792 +
793 +- return snprintf(buf, PAGE_SIZE, "%llu\n",
794 ++ return scnprintf(buf, PAGE_SIZE, "%llu\n",
795 + (unsigned long long)phba->bg_apptag_err_cnt);
796 + }
797 +
798 +@@ -560,7 +561,7 @@ lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr,
799 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
800 + struct lpfc_hba *phba = vport->phba;
801 +
802 +- return snprintf(buf, PAGE_SIZE, "%llu\n",
803 ++ return scnprintf(buf, PAGE_SIZE, "%llu\n",
804 + (unsigned long long)phba->bg_reftag_err_cnt);
805 + }
806 +
807 +@@ -578,7 +579,7 @@ lpfc_info_show(struct device *dev, struct device_attribute *attr,
808 + {
809 + struct Scsi_Host *host = class_to_shost(dev);
810 +
811 +- return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
812 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", lpfc_info(host));
813 + }
814 +
815 + /**
816 +@@ -597,7 +598,7 @@ lpfc_serialnum_show(struct device *dev, struct device_attribute *attr,
817 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
818 + struct lpfc_hba *phba = vport->phba;
819 +
820 +- return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
821 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", phba->SerialNumber);
822 + }
823 +
824 + /**
825 +@@ -619,7 +620,7 @@ lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr,
826 + struct Scsi_Host *shost = class_to_shost(dev);
827 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
828 + struct lpfc_hba *phba = vport->phba;
829 +- return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
830 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->temp_sensor_support);
831 + }
832 +
833 + /**
834 +@@ -638,7 +639,7 @@ lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr,
835 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
836 + struct lpfc_hba *phba = vport->phba;
837 +
838 +- return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
839 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelDesc);
840 + }
841 +
842 + /**
843 +@@ -657,7 +658,7 @@ lpfc_modelname_show(struct device *dev, struct device_attribute *attr,
844 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
845 + struct lpfc_hba *phba = vport->phba;
846 +
847 +- return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
848 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelName);
849 + }
850 +
851 + /**
852 +@@ -676,7 +677,7 @@ lpfc_programtype_show(struct device *dev, struct device_attribute *attr,
853 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
854 + struct lpfc_hba *phba = vport->phba;
855 +
856 +- return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
857 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ProgramType);
858 + }
859 +
860 + /**
861 +@@ -694,7 +695,7 @@ lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf)
862 + struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
863 + struct lpfc_hba *phba = vport->phba;
864 +
865 +- return snprintf(buf, PAGE_SIZE, "%d\n",
866 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",
867 + (phba->sli.sli_flag & LPFC_MENLO_MAINT));
868 + }
869 +
870 +@@ -714,7 +715,7 @@ lpfc_vportnum_show(struct device *dev, struct device_attribute *attr,
871 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
872 + struct lpfc_hba *phba = vport->phba;
873 +
874 +- return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
875 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", phba->Port);
876 + }
877 +
878 + /**
879 +@@ -742,10 +743,10 @@ lpfc_fwrev_show(struct device *dev, struct device_attribute *attr,
880 + sli_family = phba->sli4_hba.pc_sli4_params.sli_family;
881 +
882 + if (phba->sli_rev < LPFC_SLI_REV4)
883 +- len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
884 ++ len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
885 + fwrev, phba->sli_rev);
886 + else
887 +- len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
888 ++ len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
889 + fwrev, phba->sli_rev, if_type, sli_family);
890 +
891 + return len;
892 +@@ -769,7 +770,7 @@ lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf)
893 + lpfc_vpd_t *vp = &phba->vpd;
894 +
895 + lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
896 +- return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
897 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", hdw);
898 + }
899 +
900 + /**
901 +@@ -790,10 +791,11 @@ lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr,
902 + char fwrev[FW_REV_STR_SIZE];
903 +
904 + if (phba->sli_rev < LPFC_SLI_REV4)
905 +- return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
906 ++ return scnprintf(buf, PAGE_SIZE, "%s\n",
907 ++ phba->OptionROMVersion);
908 +
909 + lpfc_decode_firmware_rev(phba, fwrev, 1);
910 +- return snprintf(buf, PAGE_SIZE, "%s\n", fwrev);
911 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", fwrev);
912 + }
913 +
914 + /**
915 +@@ -824,20 +826,20 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
916 + case LPFC_LINK_DOWN:
917 + case LPFC_HBA_ERROR:
918 + if (phba->hba_flag & LINK_DISABLED)
919 +- len += snprintf(buf + len, PAGE_SIZE-len,
920 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
921 + "Link Down - User disabled\n");
922 + else
923 +- len += snprintf(buf + len, PAGE_SIZE-len,
924 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
925 + "Link Down\n");
926 + break;
927 + case LPFC_LINK_UP:
928 + case LPFC_CLEAR_LA:
929 + case LPFC_HBA_READY:
930 +- len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
931 ++ len += scnprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
932 +
933 + switch (vport->port_state) {
934 + case LPFC_LOCAL_CFG_LINK:
935 +- len += snprintf(buf + len, PAGE_SIZE-len,
936 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
937 + "Configuring Link\n");
938 + break;
939 + case LPFC_FDISC:
940 +@@ -847,38 +849,40 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
941 + case LPFC_NS_QRY:
942 + case LPFC_BUILD_DISC_LIST:
943 + case LPFC_DISC_AUTH:
944 +- len += snprintf(buf + len, PAGE_SIZE - len,
945 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
946 + "Discovery\n");
947 + break;
948 + case LPFC_VPORT_READY:
949 +- len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
950 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
951 ++ "Ready\n");
952 + break;
953 +
954 + case LPFC_VPORT_FAILED:
955 +- len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
956 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
957 ++ "Failed\n");
958 + break;
959 +
960 + case LPFC_VPORT_UNKNOWN:
961 +- len += snprintf(buf + len, PAGE_SIZE - len,
962 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
963 + "Unknown\n");
964 + break;
965 + }
966 + if (phba->sli.sli_flag & LPFC_MENLO_MAINT)
967 +- len += snprintf(buf + len, PAGE_SIZE-len,
968 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
969 + " Menlo Maint Mode\n");
970 + else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
971 + if (vport->fc_flag & FC_PUBLIC_LOOP)
972 +- len += snprintf(buf + len, PAGE_SIZE-len,
973 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
974 + " Public Loop\n");
975 + else
976 +- len += snprintf(buf + len, PAGE_SIZE-len,
977 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
978 + " Private Loop\n");
979 + } else {
980 + if (vport->fc_flag & FC_FABRIC)
981 +- len += snprintf(buf + len, PAGE_SIZE-len,
982 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
983 + " Fabric\n");
984 + else
985 +- len += snprintf(buf + len, PAGE_SIZE-len,
986 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
987 + " Point-2-Point\n");
988 + }
989 + }
990 +@@ -903,15 +907,15 @@ lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr,
991 + struct lpfc_hba *phba = vport->phba;
992 +
993 + if (phba->sli_rev < LPFC_SLI_REV4)
994 +- return snprintf(buf, PAGE_SIZE, "fc\n");
995 ++ return scnprintf(buf, PAGE_SIZE, "fc\n");
996 +
997 + if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) {
998 + if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE)
999 +- return snprintf(buf, PAGE_SIZE, "fcoe\n");
1000 ++ return scnprintf(buf, PAGE_SIZE, "fcoe\n");
1001 + if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)
1002 +- return snprintf(buf, PAGE_SIZE, "fc\n");
1003 ++ return scnprintf(buf, PAGE_SIZE, "fc\n");
1004 + }
1005 +- return snprintf(buf, PAGE_SIZE, "unknown\n");
1006 ++ return scnprintf(buf, PAGE_SIZE, "unknown\n");
1007 + }
1008 +
1009 + /**
1010 +@@ -931,7 +935,7 @@ lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr,
1011 + struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
1012 + struct lpfc_hba *phba = vport->phba;
1013 +
1014 +- return snprintf(buf, PAGE_SIZE, "%d\n",
1015 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",
1016 + phba->sli4_hba.pc_sli4_params.oas_supported);
1017 + }
1018 +
1019 +@@ -989,7 +993,7 @@ lpfc_num_discovered_ports_show(struct device *dev,
1020 + struct Scsi_Host *shost = class_to_shost(dev);
1021 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1022 +
1023 +- return snprintf(buf, PAGE_SIZE, "%d\n",
1024 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",
1025 + vport->fc_map_cnt + vport->fc_unmap_cnt);
1026 + }
1027 +
1028 +@@ -1427,7 +1431,7 @@ lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr,
1029 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1030 + struct lpfc_hba *phba = vport->phba;
1031 +
1032 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
1033 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
1034 + }
1035 +
1036 + /**
1037 +@@ -1456,7 +1460,7 @@ lpfc_board_mode_show(struct device *dev, struct device_attribute *attr,
1038 + else
1039 + state = "online";
1040 +
1041 +- return snprintf(buf, PAGE_SIZE, "%s\n", state);
1042 ++ return scnprintf(buf, PAGE_SIZE, "%s\n", state);
1043 + }
1044 +
1045 + /**
1046 +@@ -1669,8 +1673,8 @@ lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr,
1047 + uint32_t cnt;
1048 +
1049 + if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
1050 +- return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1051 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1052 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
1053 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1054 + }
1055 +
1056 + /**
1057 +@@ -1697,8 +1701,8 @@ lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
1058 + uint32_t cnt, acnt;
1059 +
1060 + if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
1061 +- return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1062 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1063 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1064 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1065 + }
1066 +
1067 + /**
1068 +@@ -1725,8 +1729,8 @@ lpfc_max_xri_show(struct device *dev, struct device_attribute *attr,
1069 + uint32_t cnt;
1070 +
1071 + if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
1072 +- return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1073 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1074 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
1075 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1076 + }
1077 +
1078 + /**
1079 +@@ -1753,8 +1757,8 @@ lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
1080 + uint32_t cnt, acnt;
1081 +
1082 + if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
1083 +- return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1084 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1085 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1086 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1087 + }
1088 +
1089 + /**
1090 +@@ -1781,8 +1785,8 @@ lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr,
1091 + uint32_t cnt;
1092 +
1093 + if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
1094 +- return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
1095 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1096 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
1097 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1098 + }
1099 +
1100 + /**
1101 +@@ -1809,8 +1813,8 @@ lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
1102 + uint32_t cnt, acnt;
1103 +
1104 + if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
1105 +- return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1106 +- return snprintf(buf, PAGE_SIZE, "Unknown\n");
1107 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
1108 ++ return scnprintf(buf, PAGE_SIZE, "Unknown\n");
1109 + }
1110 +
1111 + /**
1112 +@@ -1835,10 +1839,10 @@ lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr,
1113 + struct lpfc_hba *phba = vport->phba;
1114 +
1115 + if (!(phba->max_vpi))
1116 +- return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
1117 ++ return scnprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
1118 + if (vport->port_type == LPFC_PHYSICAL_PORT)
1119 +- return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
1120 +- return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
1121 ++ return scnprintf(buf, PAGE_SIZE, "NPIV Physical\n");
1122 ++ return scnprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
1123 + }
1124 +
1125 + /**
1126 +@@ -1860,7 +1864,7 @@ lpfc_poll_show(struct device *dev, struct device_attribute *attr,
1127 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1128 + struct lpfc_hba *phba = vport->phba;
1129 +
1130 +- return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
1131 ++ return scnprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
1132 + }
1133 +
1134 + /**
1135 +@@ -1964,7 +1968,7 @@ lpfc_fips_level_show(struct device *dev, struct device_attribute *attr,
1136 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1137 + struct lpfc_hba *phba = vport->phba;
1138 +
1139 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
1140 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
1141 + }
1142 +
1143 + /**
1144 +@@ -1983,7 +1987,7 @@ lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr,
1145 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1146 + struct lpfc_hba *phba = vport->phba;
1147 +
1148 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
1149 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
1150 + }
1151 +
1152 + /**
1153 +@@ -2002,7 +2006,7 @@ lpfc_dss_show(struct device *dev, struct device_attribute *attr,
1154 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1155 + struct lpfc_hba *phba = vport->phba;
1156 +
1157 +- return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
1158 ++ return scnprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
1159 + (phba->cfg_enable_dss) ? "Enabled" : "Disabled",
1160 + (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ?
1161 + "" : "Not ");
1162 +@@ -2031,7 +2035,7 @@ lpfc_sriov_hw_max_virtfn_show(struct device *dev,
1163 + uint16_t max_nr_virtfn;
1164 +
1165 + max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
1166 +- return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
1167 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
1168 + }
1169 +
1170 + static inline bool lpfc_rangecheck(uint val, uint min, uint max)
1171 +@@ -2091,7 +2095,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1172 + struct Scsi_Host *shost = class_to_shost(dev);\
1173 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1174 + struct lpfc_hba *phba = vport->phba;\
1175 +- return snprintf(buf, PAGE_SIZE, "%d\n",\
1176 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",\
1177 + phba->cfg_##attr);\
1178 + }
1179 +
1180 +@@ -2119,7 +2123,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1181 + struct lpfc_hba *phba = vport->phba;\
1182 + uint val = 0;\
1183 + val = phba->cfg_##attr;\
1184 +- return snprintf(buf, PAGE_SIZE, "%#x\n",\
1185 ++ return scnprintf(buf, PAGE_SIZE, "%#x\n",\
1186 + phba->cfg_##attr);\
1187 + }
1188 +
1189 +@@ -2255,7 +2259,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1190 + { \
1191 + struct Scsi_Host *shost = class_to_shost(dev);\
1192 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1193 +- return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1194 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1195 + }
1196 +
1197 + /**
1198 +@@ -2280,7 +2284,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1199 + { \
1200 + struct Scsi_Host *shost = class_to_shost(dev);\
1201 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1202 +- return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1203 ++ return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1204 + }
1205 +
1206 + /**
1207 +@@ -2551,7 +2555,7 @@ lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr,
1208 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1209 + struct lpfc_hba *phba = vport->phba;
1210 +
1211 +- return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1212 ++ return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
1213 + (unsigned long long)phba->cfg_soft_wwpn);
1214 + }
1215 +
1216 +@@ -2648,7 +2652,7 @@ lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr,
1217 + {
1218 + struct Scsi_Host *shost = class_to_shost(dev);
1219 + struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1220 +- return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1221 ++ return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
1222 + (unsigned long long)phba->cfg_soft_wwnn);
1223 + }
1224 +
1225 +@@ -2714,7 +2718,7 @@ lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr,
1226 + struct Scsi_Host *shost = class_to_shost(dev);
1227 + struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1228 +
1229 +- return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1230 ++ return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
1231 + wwn_to_u64(phba->cfg_oas_tgt_wwpn));
1232 + }
1233 +
1234 +@@ -2782,7 +2786,7 @@ lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr,
1235 + struct Scsi_Host *shost = class_to_shost(dev);
1236 + struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1237 +
1238 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
1239 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
1240 + }
1241 +
1242 + /**
1243 +@@ -2845,7 +2849,7 @@ lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr,
1244 + struct Scsi_Host *shost = class_to_shost(dev);
1245 + struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1246 +
1247 +- return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1248 ++ return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
1249 + wwn_to_u64(phba->cfg_oas_vpt_wwpn));
1250 + }
1251 +
1252 +@@ -2916,7 +2920,7 @@ lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr,
1253 + struct Scsi_Host *shost = class_to_shost(dev);
1254 + struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1255 +
1256 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
1257 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
1258 + }
1259 +
1260 + /**
1261 +@@ -2980,7 +2984,7 @@ lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr,
1262 + if (!(phba->cfg_oas_flags & OAS_LUN_VALID))
1263 + return -EFAULT;
1264 +
1265 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
1266 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
1267 + }
1268 + static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO,
1269 + lpfc_oas_lun_status_show, NULL);
1270 +@@ -3132,7 +3136,7 @@ lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr,
1271 + if (oas_lun != NOT_OAS_ENABLED_LUN)
1272 + phba->cfg_oas_flags |= OAS_LUN_VALID;
1273 +
1274 +- len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
1275 ++ len += scnprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
1276 +
1277 + return len;
1278 + }
1279 +@@ -3266,7 +3270,7 @@ lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
1280 + struct Scsi_Host *shost = class_to_shost(dev);
1281 + struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
1282 +
1283 +- return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
1284 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
1285 + }
1286 +
1287 + static DEVICE_ATTR(iocb_hw, S_IRUGO,
1288 +@@ -3278,7 +3282,7 @@ lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf)
1289 + struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
1290 + struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
1291 +
1292 +- return snprintf(buf, PAGE_SIZE, "%d\n",
1293 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",
1294 + pring ? pring->txq_max : 0);
1295 + }
1296 +
1297 +@@ -3292,7 +3296,7 @@ lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr,
1298 + struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
1299 + struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
1300 +
1301 +- return snprintf(buf, PAGE_SIZE, "%d\n",
1302 ++ return scnprintf(buf, PAGE_SIZE, "%d\n",
1303 + pring ? pring->txcmplq_max : 0);
1304 + }
1305 +
1306 +@@ -3328,7 +3332,7 @@ lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
1307 + struct Scsi_Host *shost = class_to_shost(dev);
1308 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1309 +
1310 +- return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
1311 ++ return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
1312 + }
1313 +
1314 + /**
1315 +@@ -4830,19 +4834,19 @@ lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
1316 +
1317 + switch (phba->cfg_fcp_cpu_map) {
1318 + case 0:
1319 +- len += snprintf(buf + len, PAGE_SIZE-len,
1320 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
1321 + "fcp_cpu_map: No mapping (%d)\n",
1322 + phba->cfg_fcp_cpu_map);
1323 + return len;
1324 + case 1:
1325 +- len += snprintf(buf + len, PAGE_SIZE-len,
1326 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
1327 + "fcp_cpu_map: HBA centric mapping (%d): "
1328 + "%d online CPUs\n",
1329 + phba->cfg_fcp_cpu_map,
1330 + phba->sli4_hba.num_online_cpu);
1331 + break;
1332 + case 2:
1333 +- len += snprintf(buf + len, PAGE_SIZE-len,
1334 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
1335 + "fcp_cpu_map: Driver centric mapping (%d): "
1336 + "%d online CPUs\n",
1337 + phba->cfg_fcp_cpu_map,
1338 +@@ -4855,14 +4859,14 @@ lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
1339 +
1340 + /* margin should fit in this and the truncated message */
1341 + if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
1342 +- len += snprintf(buf + len, PAGE_SIZE-len,
1343 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
1344 + "CPU %02d io_chan %02d "
1345 + "physid %d coreid %d\n",
1346 + phba->sli4_hba.curr_disp_cpu,
1347 + cpup->channel_id, cpup->phys_id,
1348 + cpup->core_id);
1349 + else
1350 +- len += snprintf(buf + len, PAGE_SIZE-len,
1351 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
1352 + "CPU %02d io_chan %02d "
1353 + "physid %d coreid %d IRQ %d\n",
1354 + phba->sli4_hba.curr_disp_cpu,
1355 +@@ -4875,7 +4879,7 @@ lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr,
1356 + if (phba->sli4_hba.curr_disp_cpu <
1357 + phba->sli4_hba.num_present_cpu &&
1358 + (len >= (PAGE_SIZE - 64))) {
1359 +- len += snprintf(buf + len, PAGE_SIZE-len, "more...\n");
1360 ++ len += scnprintf(buf + len, PAGE_SIZE-len, "more...\n");
1361 + break;
1362 + }
1363 + }
1364 +@@ -6296,7 +6300,7 @@ lpfc_show_rport_##field (struct device *dev, \
1365 + { \
1366 + struct fc_rport *rport = transport_class_to_rport(dev); \
1367 + struct lpfc_rport_data *rdata = rport->hostdata; \
1368 +- return snprintf(buf, sz, format_string, \
1369 ++ return scnprintf(buf, sz, format_string, \
1370 + (rdata->target) ? cast rdata->target->field : 0); \
1371 + }
1372 +
1373 +diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
1374 +index 1cbdc892ff95..1a964e71582f 100644
1375 +--- a/drivers/scsi/lpfc/lpfc_ct.c
1376 ++++ b/drivers/scsi/lpfc/lpfc_ct.c
1377 +@@ -1220,7 +1220,7 @@ lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol,
1378 + * Name object. NPIV is not in play so this integer
1379 + * value is sufficient and unique per FC-ID.
1380 + */
1381 +- n = snprintf(symbol, size, "%d", vport->phba->brd_no);
1382 ++ n = scnprintf(symbol, size, "%d", vport->phba->brd_no);
1383 + return n;
1384 + }
1385 +
1386 +@@ -1234,26 +1234,26 @@ lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
1387 +
1388 + lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
1389 +
1390 +- n = snprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
1391 ++ n = scnprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
1392 + if (size < n)
1393 + return n;
1394 +
1395 +- n += snprintf(symbol + n, size - n, " FV%s", fwrev);
1396 ++ n += scnprintf(symbol + n, size - n, " FV%s", fwrev);
1397 + if (size < n)
1398 + return n;
1399 +
1400 +- n += snprintf(symbol + n, size - n, " DV%s.",
1401 ++ n += scnprintf(symbol + n, size - n, " DV%s.",
1402 + lpfc_release_version);
1403 + if (size < n)
1404 + return n;
1405 +
1406 +- n += snprintf(symbol + n, size - n, " HN:%s.",
1407 ++ n += scnprintf(symbol + n, size - n, " HN:%s.",
1408 + init_utsname()->nodename);
1409 + if (size < n)
1410 + return n;
1411 +
1412 + /* Note :- OS name is "Linux" */
1413 +- n += snprintf(symbol + n, size - n, " OS:%s\n",
1414 ++ n += scnprintf(symbol + n, size - n, " OS:%s\n",
1415 + init_utsname()->sysname);
1416 + return n;
1417 + }
1418 +diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
1419 +index ca6c3982548d..f1951c432766 100644
1420 +--- a/drivers/scsi/lpfc/lpfc_debugfs.c
1421 ++++ b/drivers/scsi/lpfc/lpfc_debugfs.c
1422 +@@ -170,7 +170,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
1423 + snprintf(buffer,
1424 + LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
1425 + dtp->seq_cnt, ms, dtp->fmt);
1426 +- len += snprintf(buf+len, size-len, buffer,
1427 ++ len += scnprintf(buf+len, size-len, buffer,
1428 + dtp->data1, dtp->data2, dtp->data3);
1429 + }
1430 + for (i = 0; i < index; i++) {
1431 +@@ -181,7 +181,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
1432 + snprintf(buffer,
1433 + LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
1434 + dtp->seq_cnt, ms, dtp->fmt);
1435 +- len += snprintf(buf+len, size-len, buffer,
1436 ++ len += scnprintf(buf+len, size-len, buffer,
1437 + dtp->data1, dtp->data2, dtp->data3);
1438 + }
1439 +
1440 +@@ -236,7 +236,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
1441 + snprintf(buffer,
1442 + LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
1443 + dtp->seq_cnt, ms, dtp->fmt);
1444 +- len += snprintf(buf+len, size-len, buffer,
1445 ++ len += scnprintf(buf+len, size-len, buffer,
1446 + dtp->data1, dtp->data2, dtp->data3);
1447 + }
1448 + for (i = 0; i < index; i++) {
1449 +@@ -247,7 +247,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
1450 + snprintf(buffer,
1451 + LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
1452 + dtp->seq_cnt, ms, dtp->fmt);
1453 +- len += snprintf(buf+len, size-len, buffer,
1454 ++ len += scnprintf(buf+len, size-len, buffer,
1455 + dtp->data1, dtp->data2, dtp->data3);
1456 + }
1457 +
1458 +@@ -307,7 +307,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
1459 +
1460 + i = lpfc_debugfs_last_hbq;
1461 +
1462 +- len += snprintf(buf+len, size-len, "HBQ %d Info\n", i);
1463 ++ len += scnprintf(buf+len, size-len, "HBQ %d Info\n", i);
1464 +
1465 + hbqs = &phba->hbqs[i];
1466 + posted = 0;
1467 +@@ -315,21 +315,21 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
1468 + posted++;
1469 +
1470 + hip = lpfc_hbq_defs[i];
1471 +- len += snprintf(buf+len, size-len,
1472 ++ len += scnprintf(buf+len, size-len,
1473 + "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
1474 + hip->hbq_index, hip->profile, hip->rn,
1475 + hip->buffer_count, hip->init_count, hip->add_count, posted);
1476 +
1477 + raw_index = phba->hbq_get[i];
1478 + getidx = le32_to_cpu(raw_index);
1479 +- len += snprintf(buf+len, size-len,
1480 ++ len += scnprintf(buf+len, size-len,
1481 + "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
1482 + hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
1483 + hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
1484 +
1485 + hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
1486 + for (j=0; j<hbqs->entry_count; j++) {
1487 +- len += snprintf(buf+len, size-len,
1488 ++ len += scnprintf(buf+len, size-len,
1489 + "%03d: %08x %04x %05x ", j,
1490 + le32_to_cpu(hbqe->bde.addrLow),
1491 + le32_to_cpu(hbqe->bde.tus.w),
1492 +@@ -341,14 +341,16 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
1493 + low = hbqs->hbqPutIdx - posted;
1494 + if (low >= 0) {
1495 + if ((j >= hbqs->hbqPutIdx) || (j < low)) {
1496 +- len += snprintf(buf+len, size-len, "Unused\n");
1497 ++ len += scnprintf(buf + len, size - len,
1498 ++ "Unused\n");
1499 + goto skipit;
1500 + }
1501 + }
1502 + else {
1503 + if ((j >= hbqs->hbqPutIdx) &&
1504 + (j < (hbqs->entry_count+low))) {
1505 +- len += snprintf(buf+len, size-len, "Unused\n");
1506 ++ len += scnprintf(buf + len, size - len,
1507 ++ "Unused\n");
1508 + goto skipit;
1509 + }
1510 + }
1511 +@@ -358,7 +360,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
1512 + hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
1513 + phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
1514 + if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
1515 +- len += snprintf(buf+len, size-len,
1516 ++ len += scnprintf(buf+len, size-len,
1517 + "Buf%d: %p %06x\n", i,
1518 + hbq_buf->dbuf.virt, hbq_buf->tag);
1519 + found = 1;
1520 +@@ -367,7 +369,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
1521 + i++;
1522 + }
1523 + if (!found) {
1524 +- len += snprintf(buf+len, size-len, "No DMAinfo?\n");
1525 ++ len += scnprintf(buf+len, size-len, "No DMAinfo?\n");
1526 + }
1527 + skipit:
1528 + hbqe++;
1529 +@@ -413,7 +415,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
1530 + off = 0;
1531 + spin_lock_irq(&phba->hbalock);
1532 +
1533 +- len += snprintf(buf+len, size-len, "HBA SLIM\n");
1534 ++ len += scnprintf(buf+len, size-len, "HBA SLIM\n");
1535 + lpfc_memcpy_from_slim(buffer,
1536 + phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024);
1537 +
1538 +@@ -427,7 +429,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
1539 +
1540 + i = 1024;
1541 + while (i > 0) {
1542 +- len += snprintf(buf+len, size-len,
1543 ++ len += scnprintf(buf+len, size-len,
1544 + "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
1545 + off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
1546 + *(ptr+5), *(ptr+6), *(ptr+7));
1547 +@@ -471,11 +473,11 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
1548 + off = 0;
1549 + spin_lock_irq(&phba->hbalock);
1550 +
1551 +- len += snprintf(buf+len, size-len, "SLIM Mailbox\n");
1552 ++ len += scnprintf(buf+len, size-len, "SLIM Mailbox\n");
1553 + ptr = (uint32_t *)phba->slim2p.virt;
1554 + i = sizeof(MAILBOX_t);
1555 + while (i > 0) {
1556 +- len += snprintf(buf+len, size-len,
1557 ++ len += scnprintf(buf+len, size-len,
1558 + "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
1559 + off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
1560 + *(ptr+5), *(ptr+6), *(ptr+7));
1561 +@@ -484,11 +486,11 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
1562 + off += (8 * sizeof(uint32_t));
1563 + }
1564 +
1565 +- len += snprintf(buf+len, size-len, "SLIM PCB\n");
1566 ++ len += scnprintf(buf+len, size-len, "SLIM PCB\n");
1567 + ptr = (uint32_t *)phba->pcb;
1568 + i = sizeof(PCB_t);
1569 + while (i > 0) {
1570 +- len += snprintf(buf+len, size-len,
1571 ++ len += scnprintf(buf+len, size-len,
1572 + "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
1573 + off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
1574 + *(ptr+5), *(ptr+6), *(ptr+7));
1575 +@@ -501,7 +503,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
1576 + for (i = 0; i < 4; i++) {
1577 + pgpp = &phba->port_gp[i];
1578 + pring = &psli->sli3_ring[i];
1579 +- len += snprintf(buf+len, size-len,
1580 ++ len += scnprintf(buf+len, size-len,
1581 + "Ring %d: CMD GetInx:%d "
1582 + "(Max:%d Next:%d "
1583 + "Local:%d flg:x%x) "
1584 +@@ -518,7 +520,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
1585 + word1 = readl(phba->CAregaddr);
1586 + word2 = readl(phba->HSregaddr);
1587 + word3 = readl(phba->HCregaddr);
1588 +- len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
1589 ++ len += scnprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
1590 + "HC:%08x\n", word0, word1, word2, word3);
1591 + }
1592 + spin_unlock_irq(&phba->hbalock);
1593 +@@ -557,12 +559,12 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
1594 + cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
1595 + outio = 0;
1596 +
1597 +- len += snprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
1598 ++ len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
1599 + spin_lock_irq(shost->host_lock);
1600 + list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
1601 + iocnt = 0;
1602 + if (!cnt) {
1603 +- len += snprintf(buf+len, size-len,
1604 ++ len += scnprintf(buf+len, size-len,
1605 + "Missing Nodelist Entries\n");
1606 + break;
1607 + }
1608 +@@ -600,62 +602,62 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
1609 + default:
1610 + statep = "UNKNOWN";
1611 + }
1612 +- len += snprintf(buf+len, size-len, "%s DID:x%06x ",
1613 ++ len += scnprintf(buf+len, size-len, "%s DID:x%06x ",
1614 + statep, ndlp->nlp_DID);
1615 +- len += snprintf(buf+len, size-len,
1616 ++ len += scnprintf(buf+len, size-len,
1617 + "WWPN x%llx ",
1618 + wwn_to_u64(ndlp->nlp_portname.u.wwn));
1619 +- len += snprintf(buf+len, size-len,
1620 ++ len += scnprintf(buf+len, size-len,
1621 + "WWNN x%llx ",
1622 + wwn_to_u64(ndlp->nlp_nodename.u.wwn));
1623 + if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
1624 +- len += snprintf(buf+len, size-len, "RPI:%03d ",
1625 ++ len += scnprintf(buf+len, size-len, "RPI:%03d ",
1626 + ndlp->nlp_rpi);
1627 + else
1628 +- len += snprintf(buf+len, size-len, "RPI:none ");
1629 +- len += snprintf(buf+len, size-len, "flag:x%08x ",
1630 ++ len += scnprintf(buf+len, size-len, "RPI:none ");
1631 ++ len += scnprintf(buf+len, size-len, "flag:x%08x ",
1632 + ndlp->nlp_flag);
1633 + if (!ndlp->nlp_type)
1634 +- len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
1635 ++ len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
1636 + if (ndlp->nlp_type & NLP_FC_NODE)
1637 +- len += snprintf(buf+len, size-len, "FC_NODE ");
1638 ++ len += scnprintf(buf+len, size-len, "FC_NODE ");
1639 + if (ndlp->nlp_type & NLP_FABRIC) {
1640 +- len += snprintf(buf+len, size-len, "FABRIC ");
1641 ++ len += scnprintf(buf+len, size-len, "FABRIC ");
1642 + iocnt = 0;
1643 + }
1644 + if (ndlp->nlp_type & NLP_FCP_TARGET)
1645 +- len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
1646 ++ len += scnprintf(buf+len, size-len, "FCP_TGT sid:%d ",
1647 + ndlp->nlp_sid);
1648 + if (ndlp->nlp_type & NLP_FCP_INITIATOR)
1649 +- len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
1650 ++ len += scnprintf(buf+len, size-len, "FCP_INITIATOR ");
1651 + if (ndlp->nlp_type & NLP_NVME_TARGET)
1652 +- len += snprintf(buf + len,
1653 ++ len += scnprintf(buf + len,
1654 + size - len, "NVME_TGT sid:%d ",
1655 + NLP_NO_SID);
1656 + if (ndlp->nlp_type & NLP_NVME_INITIATOR)
1657 +- len += snprintf(buf + len,
1658 ++ len += scnprintf(buf + len,
1659 + size - len, "NVME_INITIATOR ");
1660 +- len += snprintf(buf+len, size-len, "usgmap:%x ",
1661 ++ len += scnprintf(buf+len, size-len, "usgmap:%x ",
1662 + ndlp->nlp_usg_map);
1663 +- len += snprintf(buf+len, size-len, "refcnt:%x",
1664 ++ len += scnprintf(buf+len, size-len, "refcnt:%x",
1665 + kref_read(&ndlp->kref));
1666 + if (iocnt) {
1667 + i = atomic_read(&ndlp->cmd_pending);
1668 +- len += snprintf(buf + len, size - len,
1669 ++ len += scnprintf(buf + len, size - len,
1670 + " OutIO:x%x Qdepth x%x",
1671 + i, ndlp->cmd_qdepth);
1672 + outio += i;
1673 + }
1674 +- len += snprintf(buf+len, size-len, "\n");
1675 ++ len += scnprintf(buf+len, size-len, "\n");
1676 + }
1677 + spin_unlock_irq(shost->host_lock);
1678 +
1679 +- len += snprintf(buf + len, size - len,
1680 ++ len += scnprintf(buf + len, size - len,
1681 + "\nOutstanding IO x%x\n", outio);
1682 +
1683 + if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) {
1684 + tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
1685 +- len += snprintf(buf + len, size - len,
1686 ++ len += scnprintf(buf + len, size - len,
1687 + "\nNVME Targetport Entry ...\n");
1688 +
1689 + /* Port state is only one of two values for now. */
1690 +@@ -663,18 +665,18 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
1691 + statep = "REGISTERED";
1692 + else
1693 + statep = "INIT";
1694 +- len += snprintf(buf + len, size - len,
1695 ++ len += scnprintf(buf + len, size - len,
1696 + "TGT WWNN x%llx WWPN x%llx State %s\n",
1697 + wwn_to_u64(vport->fc_nodename.u.wwn),
1698 + wwn_to_u64(vport->fc_portname.u.wwn),
1699 + statep);
1700 +- len += snprintf(buf + len, size - len,
1701 ++ len += scnprintf(buf + len, size - len,
1702 + " Targetport DID x%06x\n",
1703 + phba->targetport->port_id);
1704 + goto out_exit;
1705 + }
1706 +
1707 +- len += snprintf(buf + len, size - len,
1708 ++ len += scnprintf(buf + len, size - len,
1709 + "\nNVME Lport/Rport Entries ...\n");
1710 +
1711 + localport = vport->localport;
1712 +@@ -689,11 +691,11 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
1713 + else
1714 + statep = "UNKNOWN ";
1715 +
1716 +- len += snprintf(buf + len, size - len,
1717 ++ len += scnprintf(buf + len, size - len,
1718 + "Lport DID x%06x PortState %s\n",
1719 + localport->port_id, statep);
1720 +
1721 +- len += snprintf(buf + len, size - len, "\tRport List:\n");
1722 ++ len += scnprintf(buf + len, size - len, "\tRport List:\n");
1723 + list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
1724 + /* local short-hand pointer. */
1725 + spin_lock(&phba->hbalock);
1726 +@@ -720,32 +722,32 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
1727 + }
1728 +
1729 + /* Tab in to show lport ownership. */
1730 +- len += snprintf(buf + len, size - len,
1731 ++ len += scnprintf(buf + len, size - len,
1732 + "\t%s Port ID:x%06x ",
1733 + statep, nrport->port_id);
1734 +- len += snprintf(buf + len, size - len, "WWPN x%llx ",
1735 ++ len += scnprintf(buf + len, size - len, "WWPN x%llx ",
1736 + nrport->port_name);
1737 +- len += snprintf(buf + len, size - len, "WWNN x%llx ",
1738 ++ len += scnprintf(buf + len, size - len, "WWNN x%llx ",
1739 + nrport->node_name);
1740 +
1741 + /* An NVME rport can have multiple roles. */
1742 + if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
1743 +- len += snprintf(buf + len, size - len,
1744 ++ len += scnprintf(buf + len, size - len,
1745 + "INITIATOR ");
1746 + if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
1747 +- len += snprintf(buf + len, size - len,
1748 ++ len += scnprintf(buf + len, size - len,
1749 + "TARGET ");
1750 + if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
1751 +- len += snprintf(buf + len, size - len,
1752 ++ len += scnprintf(buf + len, size - len,
1753 + "DISCSRVC ");
1754 + if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
1755 + FC_PORT_ROLE_NVME_TARGET |
1756 + FC_PORT_ROLE_NVME_DISCOVERY))
1757 +- len += snprintf(buf + len, size - len,
1758 ++ len += scnprintf(buf + len, size - len,
1759 + "UNKNOWN ROLE x%x",
1760 + nrport->port_role);
1761 + /* Terminate the string. */
1762 +- len += snprintf(buf + len, size - len, "\n");
1763 ++ len += scnprintf(buf + len, size - len, "\n");
1764 + }
1765 +
1766 + spin_unlock_irq(shost->host_lock);
1767 +@@ -784,35 +786,35 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1768 + if (!phba->targetport)
1769 + return len;
1770 + tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
1771 +- len += snprintf(buf + len, size - len,
1772 ++ len += scnprintf(buf + len, size - len,
1773 + "\nNVME Targetport Statistics\n");
1774 +
1775 +- len += snprintf(buf + len, size - len,
1776 ++ len += scnprintf(buf + len, size - len,
1777 + "LS: Rcv %08x Drop %08x Abort %08x\n",
1778 + atomic_read(&tgtp->rcv_ls_req_in),
1779 + atomic_read(&tgtp->rcv_ls_req_drop),
1780 + atomic_read(&tgtp->xmt_ls_abort));
1781 + if (atomic_read(&tgtp->rcv_ls_req_in) !=
1782 + atomic_read(&tgtp->rcv_ls_req_out)) {
1783 +- len += snprintf(buf + len, size - len,
1784 ++ len += scnprintf(buf + len, size - len,
1785 + "Rcv LS: in %08x != out %08x\n",
1786 + atomic_read(&tgtp->rcv_ls_req_in),
1787 + atomic_read(&tgtp->rcv_ls_req_out));
1788 + }
1789 +
1790 +- len += snprintf(buf + len, size - len,
1791 ++ len += scnprintf(buf + len, size - len,
1792 + "LS: Xmt %08x Drop %08x Cmpl %08x\n",
1793 + atomic_read(&tgtp->xmt_ls_rsp),
1794 + atomic_read(&tgtp->xmt_ls_drop),
1795 + atomic_read(&tgtp->xmt_ls_rsp_cmpl));
1796 +
1797 +- len += snprintf(buf + len, size - len,
1798 ++ len += scnprintf(buf + len, size - len,
1799 + "LS: RSP Abort %08x xb %08x Err %08x\n",
1800 + atomic_read(&tgtp->xmt_ls_rsp_aborted),
1801 + atomic_read(&tgtp->xmt_ls_rsp_xb_set),
1802 + atomic_read(&tgtp->xmt_ls_rsp_error));
1803 +
1804 +- len += snprintf(buf + len, size - len,
1805 ++ len += scnprintf(buf + len, size - len,
1806 + "FCP: Rcv %08x Defer %08x Release %08x "
1807 + "Drop %08x\n",
1808 + atomic_read(&tgtp->rcv_fcp_cmd_in),
1809 +@@ -822,13 +824,13 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1810 +
1811 + if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
1812 + atomic_read(&tgtp->rcv_fcp_cmd_out)) {
1813 +- len += snprintf(buf + len, size - len,
1814 ++ len += scnprintf(buf + len, size - len,
1815 + "Rcv FCP: in %08x != out %08x\n",
1816 + atomic_read(&tgtp->rcv_fcp_cmd_in),
1817 + atomic_read(&tgtp->rcv_fcp_cmd_out));
1818 + }
1819 +
1820 +- len += snprintf(buf + len, size - len,
1821 ++ len += scnprintf(buf + len, size - len,
1822 + "FCP Rsp: read %08x readrsp %08x "
1823 + "write %08x rsp %08x\n",
1824 + atomic_read(&tgtp->xmt_fcp_read),
1825 +@@ -836,31 +838,31 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1826 + atomic_read(&tgtp->xmt_fcp_write),
1827 + atomic_read(&tgtp->xmt_fcp_rsp));
1828 +
1829 +- len += snprintf(buf + len, size - len,
1830 ++ len += scnprintf(buf + len, size - len,
1831 + "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
1832 + atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
1833 + atomic_read(&tgtp->xmt_fcp_rsp_error),
1834 + atomic_read(&tgtp->xmt_fcp_rsp_drop));
1835 +
1836 +- len += snprintf(buf + len, size - len,
1837 ++ len += scnprintf(buf + len, size - len,
1838 + "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
1839 + atomic_read(&tgtp->xmt_fcp_rsp_aborted),
1840 + atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
1841 + atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
1842 +
1843 +- len += snprintf(buf + len, size - len,
1844 ++ len += scnprintf(buf + len, size - len,
1845 + "ABORT: Xmt %08x Cmpl %08x\n",
1846 + atomic_read(&tgtp->xmt_fcp_abort),
1847 + atomic_read(&tgtp->xmt_fcp_abort_cmpl));
1848 +
1849 +- len += snprintf(buf + len, size - len,
1850 ++ len += scnprintf(buf + len, size - len,
1851 + "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
1852 + atomic_read(&tgtp->xmt_abort_sol),
1853 + atomic_read(&tgtp->xmt_abort_unsol),
1854 + atomic_read(&tgtp->xmt_abort_rsp),
1855 + atomic_read(&tgtp->xmt_abort_rsp_error));
1856 +
1857 +- len += snprintf(buf + len, size - len, "\n");
1858 ++ len += scnprintf(buf + len, size - len, "\n");
1859 +
1860 + cnt = 0;
1861 + spin_lock(&phba->sli4_hba.abts_nvme_buf_list_lock);
1862 +@@ -871,7 +873,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1863 + }
1864 + spin_unlock(&phba->sli4_hba.abts_nvme_buf_list_lock);
1865 + if (cnt) {
1866 +- len += snprintf(buf + len, size - len,
1867 ++ len += scnprintf(buf + len, size - len,
1868 + "ABORT: %d ctx entries\n", cnt);
1869 + spin_lock(&phba->sli4_hba.abts_nvme_buf_list_lock);
1870 + list_for_each_entry_safe(ctxp, next_ctxp,
1871 +@@ -879,7 +881,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1872 + list) {
1873 + if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ))
1874 + break;
1875 +- len += snprintf(buf + len, size - len,
1876 ++ len += scnprintf(buf + len, size - len,
1877 + "Entry: oxid %x state %x "
1878 + "flag %x\n",
1879 + ctxp->oxid, ctxp->state,
1880 +@@ -893,7 +895,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1881 + tot += atomic_read(&tgtp->xmt_fcp_release);
1882 + tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
1883 +
1884 +- len += snprintf(buf + len, size - len,
1885 ++ len += scnprintf(buf + len, size - len,
1886 + "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
1887 + "CTX Outstanding %08llx\n",
1888 + phba->sli4_hba.nvmet_xri_cnt,
1889 +@@ -911,10 +913,10 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1890 + if (!lport)
1891 + return len;
1892 +
1893 +- len += snprintf(buf + len, size - len,
1894 ++ len += scnprintf(buf + len, size - len,
1895 + "\nNVME Lport Statistics\n");
1896 +
1897 +- len += snprintf(buf + len, size - len,
1898 ++ len += scnprintf(buf + len, size - len,
1899 + "LS: Xmt %016x Cmpl %016x\n",
1900 + atomic_read(&lport->fc4NvmeLsRequests),
1901 + atomic_read(&lport->fc4NvmeLsCmpls));
1902 +@@ -938,20 +940,20 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1903 + if (i >= 32)
1904 + continue;
1905 +
1906 +- len += snprintf(buf + len, PAGE_SIZE - len,
1907 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
1908 + "FCP (%d): Rd %016llx Wr %016llx "
1909 + "IO %016llx ",
1910 + i, data1, data2, data3);
1911 +- len += snprintf(buf + len, PAGE_SIZE - len,
1912 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
1913 + "Cmpl %016llx OutIO %016llx\n",
1914 + tot, ((data1 + data2 + data3) - tot));
1915 + }
1916 +- len += snprintf(buf + len, PAGE_SIZE - len,
1917 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
1918 + "Total FCP Cmpl %016llx Issue %016llx "
1919 + "OutIO %016llx\n",
1920 + totin, totout, totout - totin);
1921 +
1922 +- len += snprintf(buf + len, size - len,
1923 ++ len += scnprintf(buf + len, size - len,
1924 + "LS Xmt Err: Abrt %08x Err %08x "
1925 + "Cmpl Err: xb %08x Err %08x\n",
1926 + atomic_read(&lport->xmt_ls_abort),
1927 +@@ -959,7 +961,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1928 + atomic_read(&lport->cmpl_ls_xb),
1929 + atomic_read(&lport->cmpl_ls_err));
1930 +
1931 +- len += snprintf(buf + len, size - len,
1932 ++ len += scnprintf(buf + len, size - len,
1933 + "FCP Xmt Err: noxri %06x nondlp %06x "
1934 + "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
1935 + atomic_read(&lport->xmt_fcp_noxri),
1936 +@@ -969,7 +971,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1937 + atomic_read(&lport->xmt_fcp_err),
1938 + atomic_read(&lport->xmt_fcp_abort));
1939 +
1940 +- len += snprintf(buf + len, size - len,
1941 ++ len += scnprintf(buf + len, size - len,
1942 + "FCP Cmpl Err: xb %08x Err %08x\n",
1943 + atomic_read(&lport->cmpl_fcp_xb),
1944 + atomic_read(&lport->cmpl_fcp_err));
1945 +@@ -1001,58 +1003,58 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
1946 +
1947 + if (phba->nvmet_support == 0) {
1948 + /* NVME Initiator */
1949 +- len += snprintf(buf + len, PAGE_SIZE - len,
1950 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
1951 + "ktime %s: Total Samples: %lld\n",
1952 + (phba->ktime_on ? "Enabled" : "Disabled"),
1953 + phba->ktime_data_samples);
1954 + if (phba->ktime_data_samples == 0)
1955 + return len;
1956 +
1957 +- len += snprintf(
1958 ++ len += scnprintf(
1959 + buf + len, PAGE_SIZE - len,
1960 + "Segment 1: Last NVME Cmd cmpl "
1961 + "done -to- Start of next NVME cnd (in driver)\n");
1962 +- len += snprintf(
1963 ++ len += scnprintf(
1964 + buf + len, PAGE_SIZE - len,
1965 + "avg:%08lld min:%08lld max %08lld\n",
1966 + div_u64(phba->ktime_seg1_total,
1967 + phba->ktime_data_samples),
1968 + phba->ktime_seg1_min,
1969 + phba->ktime_seg1_max);
1970 +- len += snprintf(
1971 ++ len += scnprintf(
1972 + buf + len, PAGE_SIZE - len,
1973 + "Segment 2: Driver start of NVME cmd "
1974 + "-to- Firmware WQ doorbell\n");
1975 +- len += snprintf(
1976 ++ len += scnprintf(
1977 + buf + len, PAGE_SIZE - len,
1978 + "avg:%08lld min:%08lld max %08lld\n",
1979 + div_u64(phba->ktime_seg2_total,
1980 + phba->ktime_data_samples),
1981 + phba->ktime_seg2_min,
1982 + phba->ktime_seg2_max);
1983 +- len += snprintf(
1984 ++ len += scnprintf(
1985 + buf + len, PAGE_SIZE - len,
1986 + "Segment 3: Firmware WQ doorbell -to- "
1987 + "MSI-X ISR cmpl\n");
1988 +- len += snprintf(
1989 ++ len += scnprintf(
1990 + buf + len, PAGE_SIZE - len,
1991 + "avg:%08lld min:%08lld max %08lld\n",
1992 + div_u64(phba->ktime_seg3_total,
1993 + phba->ktime_data_samples),
1994 + phba->ktime_seg3_min,
1995 + phba->ktime_seg3_max);
1996 +- len += snprintf(
1997 ++ len += scnprintf(
1998 + buf + len, PAGE_SIZE - len,
1999 + "Segment 4: MSI-X ISR cmpl -to- "
2000 + "NVME cmpl done\n");
2001 +- len += snprintf(
2002 ++ len += scnprintf(
2003 + buf + len, PAGE_SIZE - len,
2004 + "avg:%08lld min:%08lld max %08lld\n",
2005 + div_u64(phba->ktime_seg4_total,
2006 + phba->ktime_data_samples),
2007 + phba->ktime_seg4_min,
2008 + phba->ktime_seg4_max);
2009 +- len += snprintf(
2010 ++ len += scnprintf(
2011 + buf + len, PAGE_SIZE - len,
2012 + "Total IO avg time: %08lld\n",
2013 + div_u64(phba->ktime_seg1_total +
2014 +@@ -1064,7 +1066,7 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
2015 + }
2016 +
2017 + /* NVME Target */
2018 +- len += snprintf(buf + len, PAGE_SIZE-len,
2019 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2020 + "ktime %s: Total Samples: %lld %lld\n",
2021 + (phba->ktime_on ? "Enabled" : "Disabled"),
2022 + phba->ktime_data_samples,
2023 +@@ -1072,46 +1074,46 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
2024 + if (phba->ktime_data_samples == 0)
2025 + return len;
2026 +
2027 +- len += snprintf(buf + len, PAGE_SIZE-len,
2028 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2029 + "Segment 1: MSI-X ISR Rcv cmd -to- "
2030 + "cmd pass to NVME Layer\n");
2031 +- len += snprintf(buf + len, PAGE_SIZE-len,
2032 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2033 + "avg:%08lld min:%08lld max %08lld\n",
2034 + div_u64(phba->ktime_seg1_total,
2035 + phba->ktime_data_samples),
2036 + phba->ktime_seg1_min,
2037 + phba->ktime_seg1_max);
2038 +- len += snprintf(buf + len, PAGE_SIZE-len,
2039 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2040 + "Segment 2: cmd pass to NVME Layer- "
2041 + "-to- Driver rcv cmd OP (action)\n");
2042 +- len += snprintf(buf + len, PAGE_SIZE-len,
2043 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2044 + "avg:%08lld min:%08lld max %08lld\n",
2045 + div_u64(phba->ktime_seg2_total,
2046 + phba->ktime_data_samples),
2047 + phba->ktime_seg2_min,
2048 + phba->ktime_seg2_max);
2049 +- len += snprintf(buf + len, PAGE_SIZE-len,
2050 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2051 + "Segment 3: Driver rcv cmd OP -to- "
2052 + "Firmware WQ doorbell: cmd\n");
2053 +- len += snprintf(buf + len, PAGE_SIZE-len,
2054 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2055 + "avg:%08lld min:%08lld max %08lld\n",
2056 + div_u64(phba->ktime_seg3_total,
2057 + phba->ktime_data_samples),
2058 + phba->ktime_seg3_min,
2059 + phba->ktime_seg3_max);
2060 +- len += snprintf(buf + len, PAGE_SIZE-len,
2061 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2062 + "Segment 4: Firmware WQ doorbell: cmd "
2063 + "-to- MSI-X ISR for cmd cmpl\n");
2064 +- len += snprintf(buf + len, PAGE_SIZE-len,
2065 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2066 + "avg:%08lld min:%08lld max %08lld\n",
2067 + div_u64(phba->ktime_seg4_total,
2068 + phba->ktime_data_samples),
2069 + phba->ktime_seg4_min,
2070 + phba->ktime_seg4_max);
2071 +- len += snprintf(buf + len, PAGE_SIZE-len,
2072 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2073 + "Segment 5: MSI-X ISR for cmd cmpl "
2074 + "-to- NVME layer passed cmd done\n");
2075 +- len += snprintf(buf + len, PAGE_SIZE-len,
2076 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2077 + "avg:%08lld min:%08lld max %08lld\n",
2078 + div_u64(phba->ktime_seg5_total,
2079 + phba->ktime_data_samples),
2080 +@@ -1119,10 +1121,10 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
2081 + phba->ktime_seg5_max);
2082 +
2083 + if (phba->ktime_status_samples == 0) {
2084 +- len += snprintf(buf + len, PAGE_SIZE-len,
2085 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2086 + "Total: cmd received by MSI-X ISR "
2087 + "-to- cmd completed on wire\n");
2088 +- len += snprintf(buf + len, PAGE_SIZE-len,
2089 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2090 + "avg:%08lld min:%08lld "
2091 + "max %08lld\n",
2092 + div_u64(phba->ktime_seg10_total,
2093 +@@ -1132,46 +1134,46 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
2094 + return len;
2095 + }
2096 +
2097 +- len += snprintf(buf + len, PAGE_SIZE-len,
2098 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2099 + "Segment 6: NVME layer passed cmd done "
2100 + "-to- Driver rcv rsp status OP\n");
2101 +- len += snprintf(buf + len, PAGE_SIZE-len,
2102 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2103 + "avg:%08lld min:%08lld max %08lld\n",
2104 + div_u64(phba->ktime_seg6_total,
2105 + phba->ktime_status_samples),
2106 + phba->ktime_seg6_min,
2107 + phba->ktime_seg6_max);
2108 +- len += snprintf(buf + len, PAGE_SIZE-len,
2109 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2110 + "Segment 7: Driver rcv rsp status OP "
2111 + "-to- Firmware WQ doorbell: status\n");
2112 +- len += snprintf(buf + len, PAGE_SIZE-len,
2113 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2114 + "avg:%08lld min:%08lld max %08lld\n",
2115 + div_u64(phba->ktime_seg7_total,
2116 + phba->ktime_status_samples),
2117 + phba->ktime_seg7_min,
2118 + phba->ktime_seg7_max);
2119 +- len += snprintf(buf + len, PAGE_SIZE-len,
2120 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2121 + "Segment 8: Firmware WQ doorbell: status"
2122 + " -to- MSI-X ISR for status cmpl\n");
2123 +- len += snprintf(buf + len, PAGE_SIZE-len,
2124 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2125 + "avg:%08lld min:%08lld max %08lld\n",
2126 + div_u64(phba->ktime_seg8_total,
2127 + phba->ktime_status_samples),
2128 + phba->ktime_seg8_min,
2129 + phba->ktime_seg8_max);
2130 +- len += snprintf(buf + len, PAGE_SIZE-len,
2131 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2132 + "Segment 9: MSI-X ISR for status cmpl "
2133 + "-to- NVME layer passed status done\n");
2134 +- len += snprintf(buf + len, PAGE_SIZE-len,
2135 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2136 + "avg:%08lld min:%08lld max %08lld\n",
2137 + div_u64(phba->ktime_seg9_total,
2138 + phba->ktime_status_samples),
2139 + phba->ktime_seg9_min,
2140 + phba->ktime_seg9_max);
2141 +- len += snprintf(buf + len, PAGE_SIZE-len,
2142 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2143 + "Total: cmd received by MSI-X ISR -to- "
2144 + "cmd completed on wire\n");
2145 +- len += snprintf(buf + len, PAGE_SIZE-len,
2146 ++ len += scnprintf(buf + len, PAGE_SIZE-len,
2147 + "avg:%08lld min:%08lld max %08lld\n",
2148 + div_u64(phba->ktime_seg10_total,
2149 + phba->ktime_status_samples),
2150 +@@ -1206,7 +1208,7 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
2151 + (phba->nvmeio_trc_size - 1);
2152 + skip = phba->nvmeio_trc_output_idx;
2153 +
2154 +- len += snprintf(buf + len, size - len,
2155 ++ len += scnprintf(buf + len, size - len,
2156 + "%s IO Trace %s: next_idx %d skip %d size %d\n",
2157 + (phba->nvmet_support ? "NVME" : "NVMET"),
2158 + (state ? "Enabled" : "Disabled"),
2159 +@@ -1228,18 +1230,18 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
2160 + if (!dtp->fmt)
2161 + continue;
2162 +
2163 +- len += snprintf(buf + len, size - len, dtp->fmt,
2164 ++ len += scnprintf(buf + len, size - len, dtp->fmt,
2165 + dtp->data1, dtp->data2, dtp->data3);
2166 +
2167 + if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
2168 + phba->nvmeio_trc_output_idx = 0;
2169 +- len += snprintf(buf + len, size - len,
2170 ++ len += scnprintf(buf + len, size - len,
2171 + "Trace Complete\n");
2172 + goto out;
2173 + }
2174 +
2175 + if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
2176 +- len += snprintf(buf + len, size - len,
2177 ++ len += scnprintf(buf + len, size - len,
2178 + "Trace Continue (%d of %d)\n",
2179 + phba->nvmeio_trc_output_idx,
2180 + phba->nvmeio_trc_size);
2181 +@@ -1257,18 +1259,18 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
2182 + if (!dtp->fmt)
2183 + continue;
2184 +
2185 +- len += snprintf(buf + len, size - len, dtp->fmt,
2186 ++ len += scnprintf(buf + len, size - len, dtp->fmt,
2187 + dtp->data1, dtp->data2, dtp->data3);
2188 +
2189 + if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
2190 + phba->nvmeio_trc_output_idx = 0;
2191 +- len += snprintf(buf + len, size - len,
2192 ++ len += scnprintf(buf + len, size - len,
2193 + "Trace Complete\n");
2194 + goto out;
2195 + }
2196 +
2197 + if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
2198 +- len += snprintf(buf + len, size - len,
2199 ++ len += scnprintf(buf + len, size - len,
2200 + "Trace Continue (%d of %d)\n",
2201 + phba->nvmeio_trc_output_idx,
2202 + phba->nvmeio_trc_size);
2203 +@@ -1276,7 +1278,7 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
2204 + }
2205 + }
2206 +
2207 +- len += snprintf(buf + len, size - len,
2208 ++ len += scnprintf(buf + len, size - len,
2209 + "Trace Done\n");
2210 + out:
2211 + return len;
2212 +@@ -1308,39 +1310,39 @@ lpfc_debugfs_cpucheck_data(struct lpfc_vport *vport, char *buf, int size)
2213 +
2214 + if (phba->nvmet_support == 0) {
2215 + /* NVME Initiator */
2216 +- len += snprintf(buf + len, PAGE_SIZE - len,
2217 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2218 + "CPUcheck %s\n",
2219 + (phba->cpucheck_on & LPFC_CHECK_NVME_IO ?
2220 + "Enabled" : "Disabled"));
2221 + for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
2222 + if (i >= LPFC_CHECK_CPU_CNT)
2223 + break;
2224 +- len += snprintf(buf + len, PAGE_SIZE - len,
2225 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2226 + "%02d: xmit x%08x cmpl x%08x\n",
2227 + i, phba->cpucheck_xmt_io[i],
2228 + phba->cpucheck_cmpl_io[i]);
2229 + tot_xmt += phba->cpucheck_xmt_io[i];
2230 + tot_cmpl += phba->cpucheck_cmpl_io[i];
2231 + }
2232 +- len += snprintf(buf + len, PAGE_SIZE - len,
2233 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2234 + "tot:xmit x%08x cmpl x%08x\n",
2235 + tot_xmt, tot_cmpl);
2236 + return len;
2237 + }
2238 +
2239 + /* NVME Target */
2240 +- len += snprintf(buf + len, PAGE_SIZE - len,
2241 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2242 + "CPUcheck %s ",
2243 + (phba->cpucheck_on & LPFC_CHECK_NVMET_IO ?
2244 + "IO Enabled - " : "IO Disabled - "));
2245 +- len += snprintf(buf + len, PAGE_SIZE - len,
2246 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2247 + "%s\n",
2248 + (phba->cpucheck_on & LPFC_CHECK_NVMET_RCV ?
2249 + "Rcv Enabled\n" : "Rcv Disabled\n"));
2250 + for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
2251 + if (i >= LPFC_CHECK_CPU_CNT)
2252 + break;
2253 +- len += snprintf(buf + len, PAGE_SIZE - len,
2254 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2255 + "%02d: xmit x%08x ccmpl x%08x "
2256 + "cmpl x%08x rcv x%08x\n",
2257 + i, phba->cpucheck_xmt_io[i],
2258 +@@ -1352,7 +1354,7 @@ lpfc_debugfs_cpucheck_data(struct lpfc_vport *vport, char *buf, int size)
2259 + tot_cmpl += phba->cpucheck_cmpl_io[i];
2260 + tot_ccmpl += phba->cpucheck_ccmpl_io[i];
2261 + }
2262 +- len += snprintf(buf + len, PAGE_SIZE - len,
2263 ++ len += scnprintf(buf + len, PAGE_SIZE - len,
2264 + "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
2265 + tot_xmt, tot_ccmpl, tot_cmpl, tot_rcv);
2266 + return len;
2267 +@@ -1797,28 +1799,29 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
2268 + int cnt = 0;
2269 +
2270 + if (dent == phba->debug_writeGuard)
2271 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
2272 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
2273 + else if (dent == phba->debug_writeApp)
2274 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
2275 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
2276 + else if (dent == phba->debug_writeRef)
2277 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
2278 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
2279 + else if (dent == phba->debug_readGuard)
2280 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
2281 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
2282 + else if (dent == phba->debug_readApp)
2283 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
2284 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
2285 + else if (dent == phba->debug_readRef)
2286 +- cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
2287 ++ cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
2288 + else if (dent == phba->debug_InjErrNPortID)
2289 +- cnt = snprintf(cbuf, 32, "0x%06x\n", phba->lpfc_injerr_nportid);
2290 ++ cnt = scnprintf(cbuf, 32, "0x%06x\n",
2291 ++ phba->lpfc_injerr_nportid);
2292 + else if (dent == phba->debug_InjErrWWPN) {
2293 + memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
2294 + tmp = cpu_to_be64(tmp);
2295 +- cnt = snprintf(cbuf, 32, "0x%016llx\n", tmp);
2296 ++ cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
2297 + } else if (dent == phba->debug_InjErrLBA) {
2298 + if (phba->lpfc_injerr_lba == (sector_t)(-1))
2299 +- cnt = snprintf(cbuf, 32, "off\n");
2300 ++ cnt = scnprintf(cbuf, 32, "off\n");
2301 + else
2302 +- cnt = snprintf(cbuf, 32, "0x%llx\n",
2303 ++ cnt = scnprintf(cbuf, 32, "0x%llx\n",
2304 + (uint64_t) phba->lpfc_injerr_lba);
2305 + } else
2306 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2307 +@@ -2624,17 +2627,17 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
2308 + switch (count) {
2309 + case SIZE_U8: /* byte (8 bits) */
2310 + pci_read_config_byte(pdev, where, &u8val);
2311 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2312 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2313 + "%03x: %02x\n", where, u8val);
2314 + break;
2315 + case SIZE_U16: /* word (16 bits) */
2316 + pci_read_config_word(pdev, where, &u16val);
2317 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2318 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2319 + "%03x: %04x\n", where, u16val);
2320 + break;
2321 + case SIZE_U32: /* double word (32 bits) */
2322 + pci_read_config_dword(pdev, where, &u32val);
2323 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2324 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2325 + "%03x: %08x\n", where, u32val);
2326 + break;
2327 + case LPFC_PCI_CFG_BROWSE: /* browse all */
2328 +@@ -2654,25 +2657,25 @@ pcicfg_browse:
2329 + offset = offset_label;
2330 +
2331 + /* Read PCI config space */
2332 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2333 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2334 + "%03x: ", offset_label);
2335 + while (index > 0) {
2336 + pci_read_config_dword(pdev, offset, &u32val);
2337 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2338 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2339 + "%08x ", u32val);
2340 + offset += sizeof(uint32_t);
2341 + if (offset >= LPFC_PCI_CFG_SIZE) {
2342 +- len += snprintf(pbuffer+len,
2343 ++ len += scnprintf(pbuffer+len,
2344 + LPFC_PCI_CFG_SIZE-len, "\n");
2345 + break;
2346 + }
2347 + index -= sizeof(uint32_t);
2348 + if (!index)
2349 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2350 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2351 + "\n");
2352 + else if (!(index % (8 * sizeof(uint32_t)))) {
2353 + offset_label += (8 * sizeof(uint32_t));
2354 +- len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2355 ++ len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
2356 + "\n%03x: ", offset_label);
2357 + }
2358 + }
2359 +@@ -2943,7 +2946,7 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
2360 + if (acc_range == SINGLE_WORD) {
2361 + offset_run = offset;
2362 + u32val = readl(mem_mapped_bar + offset_run);
2363 +- len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2364 ++ len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2365 + "%05x: %08x\n", offset_run, u32val);
2366 + } else
2367 + goto baracc_browse;
2368 +@@ -2957,35 +2960,35 @@ baracc_browse:
2369 + offset_run = offset_label;
2370 +
2371 + /* Read PCI bar memory mapped space */
2372 +- len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2373 ++ len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2374 + "%05x: ", offset_label);
2375 + index = LPFC_PCI_BAR_RD_SIZE;
2376 + while (index > 0) {
2377 + u32val = readl(mem_mapped_bar + offset_run);
2378 +- len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2379 ++ len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
2380 + "%08x ", u32val);
2381 + offset_run += sizeof(uint32_t);
2382 + if (acc_range == LPFC_PCI_BAR_BROWSE) {
2383 + if (offset_run >= bar_size) {
2384 +- len += snprintf(pbuffer+len,
2385 ++ len += scnprintf(pbuffer+len,
2386 + LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
2387 + break;
2388 + }
2389 + } else {
2390 + if (offset_run >= offset +
2391 + (acc_range * sizeof(uint32_t))) {
2392 +- len += snprintf(pbuffer+len,
2393 ++ len += scnprintf(pbuffer+len,
2394 + LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
2395 + break;
2396 + }
2397 + }
2398 + index -= sizeof(uint32_t);
2399 + if (!index)
2400 +- len += snprintf(pbuffer+len,
2401 ++ len += scnprintf(pbuffer+len,
2402 + LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
2403 + else if (!(index % (8 * sizeof(uint32_t)))) {
2404 + offset_label += (8 * sizeof(uint32_t));
2405 +- len += snprintf(pbuffer+len,
2406 ++ len += scnprintf(pbuffer+len,
2407 + LPFC_PCI_BAR_RD_BUF_SIZE-len,
2408 + "\n%05x: ", offset_label);
2409 + }
2410 +@@ -3158,19 +3161,19 @@ __lpfc_idiag_print_wq(struct lpfc_queue *qp, char *wqtype,
2411 + if (!qp)
2412 + return len;
2413 +
2414 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2415 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2416 + "\t\t%s WQ info: ", wqtype);
2417 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2418 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2419 + "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
2420 + qp->assoc_qid, qp->q_cnt_1,
2421 + (unsigned long long)qp->q_cnt_4);
2422 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2423 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2424 + "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
2425 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
2426 + qp->queue_id, qp->entry_count,
2427 + qp->entry_size, qp->host_index,
2428 + qp->hba_index, qp->entry_repost);
2429 +- len += snprintf(pbuffer + len,
2430 ++ len += scnprintf(pbuffer + len,
2431 + LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
2432 + return len;
2433 + }
2434 +@@ -3208,21 +3211,21 @@ __lpfc_idiag_print_cq(struct lpfc_queue *qp, char *cqtype,
2435 + if (!qp)
2436 + return len;
2437 +
2438 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2439 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2440 + "\t%s CQ info: ", cqtype);
2441 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2442 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2443 + "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
2444 + "xabt:x%x wq:x%llx]\n",
2445 + qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
2446 + qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
2447 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2448 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2449 + "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
2450 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
2451 + qp->queue_id, qp->entry_count,
2452 + qp->entry_size, qp->host_index,
2453 + qp->hba_index, qp->entry_repost);
2454 +
2455 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
2456 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
2457 +
2458 + return len;
2459 + }
2460 +@@ -3234,19 +3237,19 @@ __lpfc_idiag_print_rqpair(struct lpfc_queue *qp, struct lpfc_queue *datqp,
2461 + if (!qp || !datqp)
2462 + return len;
2463 +
2464 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2465 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2466 + "\t\t%s RQ info: ", rqtype);
2467 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2468 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2469 + "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
2470 + "posted:x%x rcv:x%llx]\n",
2471 + qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
2472 + qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
2473 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2474 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2475 + "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
2476 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
2477 + qp->queue_id, qp->entry_count, qp->entry_size,
2478 + qp->host_index, qp->hba_index, qp->entry_repost);
2479 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2480 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2481 + "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
2482 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
2483 + datqp->queue_id, datqp->entry_count,
2484 +@@ -3331,17 +3334,17 @@ __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
2485 + if (!qp)
2486 + return len;
2487 +
2488 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2489 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2490 + "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
2491 + "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
2492 + eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3,
2493 + (unsigned long long)qp->q_cnt_4, qp->q_mode);
2494 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2495 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2496 + "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
2497 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
2498 + qp->queue_id, qp->entry_count, qp->entry_size,
2499 + qp->host_index, qp->hba_index, qp->entry_repost);
2500 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
2501 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
2502 +
2503 + return len;
2504 + }
2505 +@@ -3399,7 +3402,7 @@ lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
2506 + if (phba->cfg_fof == 0)
2507 + phba->lpfc_idiag_last_eq = 0;
2508 +
2509 +- len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2510 ++ len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
2511 + "EQ %d out of %d HBA EQs\n",
2512 + x, phba->io_channel_irqs);
2513 +
2514 +@@ -3512,7 +3515,7 @@ fof:
2515 + return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
2516 +
2517 + too_big:
2518 +- len += snprintf(pbuffer + len,
2519 ++ len += scnprintf(pbuffer + len,
2520 + LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
2521 + out:
2522 + spin_unlock_irq(&phba->hbalock);
2523 +@@ -3568,22 +3571,22 @@ lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
2524 + return 0;
2525 +
2526 + esize = pque->entry_size;
2527 +- len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2528 ++ len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2529 + "QE-INDEX[%04d]:\n", index);
2530 +
2531 + offset = 0;
2532 + pentry = pque->qe[index].address;
2533 + while (esize > 0) {
2534 +- len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2535 ++ len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2536 + "%08x ", *pentry);
2537 + pentry++;
2538 + offset += sizeof(uint32_t);
2539 + esize -= sizeof(uint32_t);
2540 + if (esize > 0 && !(offset % (4 * sizeof(uint32_t))))
2541 +- len += snprintf(pbuffer+len,
2542 ++ len += scnprintf(pbuffer+len,
2543 + LPFC_QUE_ACC_BUF_SIZE-len, "\n");
2544 + }
2545 +- len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
2546 ++ len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
2547 +
2548 + return len;
2549 + }
2550 +@@ -3989,27 +3992,27 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
2551 +
2552 + switch (drbregid) {
2553 + case LPFC_DRB_EQ:
2554 +- len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
2555 ++ len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
2556 + "EQ-DRB-REG: 0x%08x\n",
2557 + readl(phba->sli4_hba.EQDBregaddr));
2558 + break;
2559 + case LPFC_DRB_CQ:
2560 +- len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
2561 ++ len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
2562 + "CQ-DRB-REG: 0x%08x\n",
2563 + readl(phba->sli4_hba.CQDBregaddr));
2564 + break;
2565 + case LPFC_DRB_MQ:
2566 +- len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2567 ++ len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2568 + "MQ-DRB-REG: 0x%08x\n",
2569 + readl(phba->sli4_hba.MQDBregaddr));
2570 + break;
2571 + case LPFC_DRB_WQ:
2572 +- len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2573 ++ len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2574 + "WQ-DRB-REG: 0x%08x\n",
2575 + readl(phba->sli4_hba.WQDBregaddr));
2576 + break;
2577 + case LPFC_DRB_RQ:
2578 +- len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2579 ++ len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2580 + "RQ-DRB-REG: 0x%08x\n",
2581 + readl(phba->sli4_hba.RQDBregaddr));
2582 + break;
2583 +@@ -4199,37 +4202,37 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
2584 +
2585 + switch (ctlregid) {
2586 + case LPFC_CTL_PORT_SEM:
2587 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2588 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2589 + "Port SemReg: 0x%08x\n",
2590 + readl(phba->sli4_hba.conf_regs_memmap_p +
2591 + LPFC_CTL_PORT_SEM_OFFSET));
2592 + break;
2593 + case LPFC_CTL_PORT_STA:
2594 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2595 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2596 + "Port StaReg: 0x%08x\n",
2597 + readl(phba->sli4_hba.conf_regs_memmap_p +
2598 + LPFC_CTL_PORT_STA_OFFSET));
2599 + break;
2600 + case LPFC_CTL_PORT_CTL:
2601 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2602 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2603 + "Port CtlReg: 0x%08x\n",
2604 + readl(phba->sli4_hba.conf_regs_memmap_p +
2605 + LPFC_CTL_PORT_CTL_OFFSET));
2606 + break;
2607 + case LPFC_CTL_PORT_ER1:
2608 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2609 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2610 + "Port Er1Reg: 0x%08x\n",
2611 + readl(phba->sli4_hba.conf_regs_memmap_p +
2612 + LPFC_CTL_PORT_ER1_OFFSET));
2613 + break;
2614 + case LPFC_CTL_PORT_ER2:
2615 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2616 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2617 + "Port Er2Reg: 0x%08x\n",
2618 + readl(phba->sli4_hba.conf_regs_memmap_p +
2619 + LPFC_CTL_PORT_ER2_OFFSET));
2620 + break;
2621 + case LPFC_CTL_PDEV_CTL:
2622 +- len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2623 ++ len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2624 + "PDev CtlReg: 0x%08x\n",
2625 + readl(phba->sli4_hba.conf_regs_memmap_p +
2626 + LPFC_CTL_PDEV_CTL_OFFSET));
2627 +@@ -4422,13 +4425,13 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
2628 + mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
2629 + mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
2630 +
2631 +- len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2632 ++ len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2633 + "mbx_dump_map: 0x%08x\n", mbx_dump_map);
2634 +- len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2635 ++ len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2636 + "mbx_dump_cnt: %04d\n", mbx_dump_cnt);
2637 +- len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2638 ++ len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2639 + "mbx_word_cnt: %04d\n", mbx_word_cnt);
2640 +- len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2641 ++ len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
2642 + "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
2643 +
2644 + return len;
2645 +@@ -4577,35 +4580,35 @@ lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len)
2646 + {
2647 + uint16_t ext_cnt, ext_size;
2648 +
2649 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2650 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2651 + "\nAvailable Extents Information:\n");
2652 +
2653 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2654 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2655 + "\tPort Available VPI extents: ");
2656 + lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI,
2657 + &ext_cnt, &ext_size);
2658 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2659 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2660 + "Count %3d, Size %3d\n", ext_cnt, ext_size);
2661 +
2662 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2663 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2664 + "\tPort Available VFI extents: ");
2665 + lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI,
2666 + &ext_cnt, &ext_size);
2667 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2668 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2669 + "Count %3d, Size %3d\n", ext_cnt, ext_size);
2670 +
2671 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2672 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2673 + "\tPort Available RPI extents: ");
2674 + lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI,
2675 + &ext_cnt, &ext_size);
2676 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2677 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2678 + "Count %3d, Size %3d\n", ext_cnt, ext_size);
2679 +
2680 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2681 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2682 + "\tPort Available XRI extents: ");
2683 + lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI,
2684 + &ext_cnt, &ext_size);
2685 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2686 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2687 + "Count %3d, Size %3d\n", ext_cnt, ext_size);
2688 +
2689 + return len;
2690 +@@ -4629,55 +4632,55 @@ lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len)
2691 + uint16_t ext_cnt, ext_size;
2692 + int rc;
2693 +
2694 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2695 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2696 + "\nAllocated Extents Information:\n");
2697 +
2698 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2699 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2700 + "\tHost Allocated VPI extents: ");
2701 + rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI,
2702 + &ext_cnt, &ext_size);
2703 + if (!rc)
2704 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2705 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2706 + "Port %d Extent %3d, Size %3d\n",
2707 + phba->brd_no, ext_cnt, ext_size);
2708 + else
2709 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2710 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2711 + "N/A\n");
2712 +
2713 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2714 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2715 + "\tHost Allocated VFI extents: ");
2716 + rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI,
2717 + &ext_cnt, &ext_size);
2718 + if (!rc)
2719 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2720 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2721 + "Port %d Extent %3d, Size %3d\n",
2722 + phba->brd_no, ext_cnt, ext_size);
2723 + else
2724 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2725 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2726 + "N/A\n");
2727 +
2728 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2729 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2730 + "\tHost Allocated RPI extents: ");
2731 + rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI,
2732 + &ext_cnt, &ext_size);
2733 + if (!rc)
2734 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2735 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2736 + "Port %d Extent %3d, Size %3d\n",
2737 + phba->brd_no, ext_cnt, ext_size);
2738 + else
2739 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2740 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2741 + "N/A\n");
2742 +
2743 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2744 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2745 + "\tHost Allocated XRI extents: ");
2746 + rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI,
2747 + &ext_cnt, &ext_size);
2748 + if (!rc)
2749 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2750 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2751 + "Port %d Extent %3d, Size %3d\n",
2752 + phba->brd_no, ext_cnt, ext_size);
2753 + else
2754 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2755 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2756 + "N/A\n");
2757 +
2758 + return len;
2759 +@@ -4701,49 +4704,49 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
2760 + struct lpfc_rsrc_blks *rsrc_blks;
2761 + int index;
2762 +
2763 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2764 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2765 + "\nDriver Extents Information:\n");
2766 +
2767 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2768 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2769 + "\tVPI extents:\n");
2770 + index = 0;
2771 + list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) {
2772 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2773 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2774 + "\t\tBlock %3d: Start %4d, Count %4d\n",
2775 + index, rsrc_blks->rsrc_start,
2776 + rsrc_blks->rsrc_size);
2777 + index++;
2778 + }
2779 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2780 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2781 + "\tVFI extents:\n");
2782 + index = 0;
2783 + list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list,
2784 + list) {
2785 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2786 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2787 + "\t\tBlock %3d: Start %4d, Count %4d\n",
2788 + index, rsrc_blks->rsrc_start,
2789 + rsrc_blks->rsrc_size);
2790 + index++;
2791 + }
2792 +
2793 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2794 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2795 + "\tRPI extents:\n");
2796 + index = 0;
2797 + list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list,
2798 + list) {
2799 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2800 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2801 + "\t\tBlock %3d: Start %4d, Count %4d\n",
2802 + index, rsrc_blks->rsrc_start,
2803 + rsrc_blks->rsrc_size);
2804 + index++;
2805 + }
2806 +
2807 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2808 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2809 + "\tXRI extents:\n");
2810 + index = 0;
2811 + list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list,
2812 + list) {
2813 +- len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2814 ++ len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
2815 + "\t\tBlock %3d: Start %4d, Count %4d\n",
2816 + index, rsrc_blks->rsrc_start,
2817 + rsrc_blks->rsrc_size);
2818 +@@ -5137,11 +5140,11 @@ lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
2819 + if (i != 0)
2820 + pr_err("%s\n", line_buf);
2821 + len = 0;
2822 +- len += snprintf(line_buf+len,
2823 ++ len += scnprintf(line_buf+len,
2824 + LPFC_MBX_ACC_LBUF_SZ-len,
2825 + "%03d: ", i);
2826 + }
2827 +- len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
2828 ++ len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
2829 + "%08x ", (uint32_t)*pword);
2830 + pword++;
2831 + }
2832 +@@ -5204,11 +5207,11 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
2833 + pr_err("%s\n", line_buf);
2834 + len = 0;
2835 + memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
2836 +- len += snprintf(line_buf+len,
2837 ++ len += scnprintf(line_buf+len,
2838 + LPFC_MBX_ACC_LBUF_SZ-len,
2839 + "%03d: ", i);
2840 + }
2841 +- len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
2842 ++ len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
2843 + "%08x ",
2844 + ((uint32_t)*pword) & 0xffffffff);
2845 + pword++;
2846 +@@ -5227,18 +5230,18 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
2847 + pr_err("%s\n", line_buf);
2848 + len = 0;
2849 + memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
2850 +- len += snprintf(line_buf+len,
2851 ++ len += scnprintf(line_buf+len,
2852 + LPFC_MBX_ACC_LBUF_SZ-len,
2853 + "%03d: ", i);
2854 + }
2855 + for (j = 0; j < 4; j++) {
2856 +- len += snprintf(line_buf+len,
2857 ++ len += scnprintf(line_buf+len,
2858 + LPFC_MBX_ACC_LBUF_SZ-len,
2859 + "%02x",
2860 + ((uint8_t)*pbyte) & 0xff);
2861 + pbyte++;
2862 + }
2863 +- len += snprintf(line_buf+len,
2864 ++ len += scnprintf(line_buf+len,
2865 + LPFC_MBX_ACC_LBUF_SZ-len, " ");
2866 + }
2867 + if ((i - 1) % 8)
2868 +diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
2869 +index 30efc7bf91bd..824de3e410ca 100644
2870 +--- a/drivers/scsi/lpfc/lpfc_debugfs.h
2871 ++++ b/drivers/scsi/lpfc/lpfc_debugfs.h
2872 +@@ -342,7 +342,7 @@ lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
2873 + pword = q->qe[idx].address;
2874 +
2875 + len = 0;
2876 +- len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
2877 ++ len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
2878 + if (qe_word_cnt > 8)
2879 + printk(KERN_ERR "%s\n", line_buf);
2880 +
2881 +@@ -353,11 +353,11 @@ lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
2882 + if (qe_word_cnt > 8) {
2883 + len = 0;
2884 + memset(line_buf, 0, LPFC_LBUF_SZ);
2885 +- len += snprintf(line_buf+len, LPFC_LBUF_SZ-len,
2886 ++ len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len,
2887 + "%03d: ", i);
2888 + }
2889 + }
2890 +- len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
2891 ++ len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
2892 + ((uint32_t)*pword) & 0xffffffff);
2893 + pword++;
2894 + }
2895 +diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
2896 +index 4888b999e82f..f8f4d3ea67f3 100644
2897 +--- a/drivers/scsi/qla2xxx/qla_attr.c
2898 ++++ b/drivers/scsi/qla2xxx/qla_attr.c
2899 +@@ -345,7 +345,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
2900 + }
2901 +
2902 + ha->optrom_region_start = start;
2903 +- ha->optrom_region_size = start + size;
2904 ++ ha->optrom_region_size = size;
2905 +
2906 + ha->optrom_state = QLA_SREADING;
2907 + ha->optrom_buffer = vmalloc(ha->optrom_region_size);
2908 +@@ -418,7 +418,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
2909 + }
2910 +
2911 + ha->optrom_region_start = start;
2912 +- ha->optrom_region_size = start + size;
2913 ++ ha->optrom_region_size = size;
2914 +
2915 + ha->optrom_state = QLA_SWRITING;
2916 + ha->optrom_buffer = vmalloc(ha->optrom_region_size);
2917 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
2918 +index d2888b30a8a3..a8c67cd17625 100644
2919 +--- a/drivers/scsi/qla2xxx/qla_target.c
2920 ++++ b/drivers/scsi/qla2xxx/qla_target.c
2921 +@@ -981,6 +981,8 @@ void qlt_free_session_done(struct work_struct *work)
2922 + sess->send_els_logo);
2923 +
2924 + if (!IS_SW_RESV_ADDR(sess->d_id)) {
2925 ++ qla2x00_mark_device_lost(vha, sess, 0, 0);
2926 ++
2927 + if (sess->send_els_logo) {
2928 + qlt_port_logo_t logo;
2929 +
2930 +@@ -1161,8 +1163,6 @@ void qlt_unreg_sess(struct fc_port *sess)
2931 + if (sess->se_sess)
2932 + vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
2933 +
2934 +- qla2x00_mark_device_lost(vha, sess, 0, 0);
2935 +-
2936 + sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
2937 + sess->disc_state = DSC_DELETE_PEND;
2938 + sess->last_rscn_gen = sess->rscn_gen;
2939 +diff --git a/drivers/soc/sunxi/Kconfig b/drivers/soc/sunxi/Kconfig
2940 +index 353b07e40176..e84eb4e59f58 100644
2941 +--- a/drivers/soc/sunxi/Kconfig
2942 ++++ b/drivers/soc/sunxi/Kconfig
2943 +@@ -4,6 +4,7 @@
2944 + config SUNXI_SRAM
2945 + bool
2946 + default ARCH_SUNXI
2947 ++ select REGMAP_MMIO
2948 + help
2949 + Say y here to enable the SRAM controller support. This
2950 + device is responsible on mapping the SRAM in the sunXi SoCs
2951 +diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
2952 +index 0529e5628c24..ae5c0285a942 100644
2953 +--- a/drivers/staging/greybus/power_supply.c
2954 ++++ b/drivers/staging/greybus/power_supply.c
2955 +@@ -520,7 +520,7 @@ static int gb_power_supply_prop_descriptors_get(struct gb_power_supply *gbpsy)
2956 +
2957 + op = gb_operation_create(connection,
2958 + GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
2959 +- sizeof(req), sizeof(*resp) + props_count *
2960 ++ sizeof(*req), sizeof(*resp) + props_count *
2961 + sizeof(struct gb_power_supply_props_desc),
2962 + GFP_KERNEL);
2963 + if (!op)
2964 +diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
2965 +index 4569838f27a0..0b48677fa958 100644
2966 +--- a/drivers/staging/most/cdev/cdev.c
2967 ++++ b/drivers/staging/most/cdev/cdev.c
2968 +@@ -546,7 +546,7 @@ static void __exit mod_exit(void)
2969 + destroy_cdev(c);
2970 + destroy_channel(c);
2971 + }
2972 +- unregister_chrdev_region(comp.devno, 1);
2973 ++ unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE);
2974 + ida_destroy(&comp.minor_id);
2975 + class_destroy(comp.class);
2976 + }
2977 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
2978 +index 32da5a4182ac..5b442bc68a76 100644
2979 +--- a/drivers/usb/class/cdc-acm.c
2980 ++++ b/drivers/usb/class/cdc-acm.c
2981 +@@ -470,12 +470,12 @@ static void acm_read_bulk_callback(struct urb *urb)
2982 + struct acm *acm = rb->instance;
2983 + unsigned long flags;
2984 + int status = urb->status;
2985 ++ bool stopped = false;
2986 ++ bool stalled = false;
2987 +
2988 + dev_vdbg(&acm->data->dev, "got urb %d, len %d, status %d\n",
2989 + rb->index, urb->actual_length, status);
2990 +
2991 +- set_bit(rb->index, &acm->read_urbs_free);
2992 +-
2993 + if (!acm->dev) {
2994 + dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__);
2995 + return;
2996 +@@ -488,15 +488,16 @@ static void acm_read_bulk_callback(struct urb *urb)
2997 + break;
2998 + case -EPIPE:
2999 + set_bit(EVENT_RX_STALL, &acm->flags);
3000 +- schedule_work(&acm->work);
3001 +- return;
3002 ++ stalled = true;
3003 ++ break;
3004 + case -ENOENT:
3005 + case -ECONNRESET:
3006 + case -ESHUTDOWN:
3007 + dev_dbg(&acm->data->dev,
3008 + "%s - urb shutting down with status: %d\n",
3009 + __func__, status);
3010 +- return;
3011 ++ stopped = true;
3012 ++ break;
3013 + default:
3014 + dev_dbg(&acm->data->dev,
3015 + "%s - nonzero urb status received: %d\n",
3016 +@@ -505,10 +506,24 @@ static void acm_read_bulk_callback(struct urb *urb)
3017 + }
3018 +
3019 + /*
3020 +- * Unthrottle may run on another CPU which needs to see events
3021 +- * in the same order. Submission has an implict barrier
3022 ++ * Make sure URB processing is done before marking as free to avoid
3023 ++ * racing with unthrottle() on another CPU. Matches the barriers
3024 ++ * implied by the test_and_clear_bit() in acm_submit_read_urb().
3025 + */
3026 + smp_mb__before_atomic();
3027 ++ set_bit(rb->index, &acm->read_urbs_free);
3028 ++ /*
3029 ++ * Make sure URB is marked as free before checking the throttled flag
3030 ++ * to avoid racing with unthrottle() on another CPU. Matches the
3031 ++ * smp_mb() in unthrottle().
3032 ++ */
3033 ++ smp_mb__after_atomic();
3034 ++
3035 ++ if (stopped || stalled) {
3036 ++ if (stalled)
3037 ++ schedule_work(&acm->work);
3038 ++ return;
3039 ++ }
3040 +
3041 + /* throttle device if requested by tty */
3042 + spin_lock_irqsave(&acm->read_lock, flags);
3043 +@@ -842,6 +857,9 @@ static void acm_tty_unthrottle(struct tty_struct *tty)
3044 + acm->throttle_req = 0;
3045 + spin_unlock_irq(&acm->read_lock);
3046 +
3047 ++ /* Matches the smp_mb__after_atomic() in acm_read_bulk_callback(). */
3048 ++ smp_mb();
3049 ++
3050 + if (was_throttled)
3051 + acm_submit_read_urbs(acm, GFP_KERNEL);
3052 + }
3053 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
3054 +index fec97465ccac..4d5c7dda8f54 100644
3055 +--- a/drivers/usb/dwc3/core.c
3056 ++++ b/drivers/usb/dwc3/core.c
3057 +@@ -1214,7 +1214,7 @@ static void dwc3_get_properties(struct dwc3 *dwc)
3058 + u8 tx_max_burst_prd;
3059 +
3060 + /* default to highest possible threshold */
3061 +- lpm_nyet_threshold = 0xff;
3062 ++ lpm_nyet_threshold = 0xf;
3063 +
3064 + /* default to -3.5dB de-emphasis */
3065 + tx_de_emphasis = 1;
3066 +diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
3067 +index ad08895e78f9..c3dae7d5cb6e 100644
3068 +--- a/drivers/usb/musb/Kconfig
3069 ++++ b/drivers/usb/musb/Kconfig
3070 +@@ -66,7 +66,7 @@ config USB_MUSB_SUNXI
3071 + depends on NOP_USB_XCEIV
3072 + depends on PHY_SUN4I_USB
3073 + depends on EXTCON
3074 +- depends on GENERIC_PHY
3075 ++ select GENERIC_PHY
3076 + select SUNXI_SRAM
3077 +
3078 + config USB_MUSB_DAVINCI
3079 +diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
3080 +index 96036f87b1de..087e5f1656f8 100644
3081 +--- a/drivers/usb/serial/f81232.c
3082 ++++ b/drivers/usb/serial/f81232.c
3083 +@@ -556,9 +556,12 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
3084 +
3085 + static void f81232_close(struct usb_serial_port *port)
3086 + {
3087 ++ struct f81232_private *port_priv = usb_get_serial_port_data(port);
3088 ++
3089 + f81232_port_disable(port);
3090 + usb_serial_generic_close(port);
3091 + usb_kill_urb(port->interrupt_in_urb);
3092 ++ flush_work(&port_priv->interrupt_work);
3093 + }
3094 +
3095 + static void f81232_dtr_rts(struct usb_serial_port *port, int on)
3096 +@@ -652,6 +655,40 @@ static int f81232_port_remove(struct usb_serial_port *port)
3097 + return 0;
3098 + }
3099 +
3100 ++static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
3101 ++{
3102 ++ struct usb_serial_port *port = serial->port[0];
3103 ++ struct f81232_private *port_priv = usb_get_serial_port_data(port);
3104 ++ int i;
3105 ++
3106 ++ for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
3107 ++ usb_kill_urb(port->read_urbs[i]);
3108 ++
3109 ++ usb_kill_urb(port->interrupt_in_urb);
3110 ++
3111 ++ if (port_priv)
3112 ++ flush_work(&port_priv->interrupt_work);
3113 ++
3114 ++ return 0;
3115 ++}
3116 ++
3117 ++static int f81232_resume(struct usb_serial *serial)
3118 ++{
3119 ++ struct usb_serial_port *port = serial->port[0];
3120 ++ int result;
3121 ++
3122 ++ if (tty_port_initialized(&port->port)) {
3123 ++ result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
3124 ++ if (result) {
3125 ++ dev_err(&port->dev, "submit interrupt urb failed: %d\n",
3126 ++ result);
3127 ++ return result;
3128 ++ }
3129 ++ }
3130 ++
3131 ++ return usb_serial_generic_resume(serial);
3132 ++}
3133 ++
3134 + static struct usb_serial_driver f81232_device = {
3135 + .driver = {
3136 + .owner = THIS_MODULE,
3137 +@@ -675,6 +712,8 @@ static struct usb_serial_driver f81232_device = {
3138 + .read_int_callback = f81232_read_int_callback,
3139 + .port_probe = f81232_port_probe,
3140 + .port_remove = f81232_port_remove,
3141 ++ .suspend = f81232_suspend,
3142 ++ .resume = f81232_resume,
3143 + };
3144 +
3145 + static struct usb_serial_driver * const serial_drivers[] = {
3146 +diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
3147 +index 101ebac43c87..59d82b45e758 100644
3148 +--- a/drivers/usb/storage/scsiglue.c
3149 ++++ b/drivers/usb/storage/scsiglue.c
3150 +@@ -65,6 +65,7 @@ static const char* host_info(struct Scsi_Host *host)
3151 + static int slave_alloc (struct scsi_device *sdev)
3152 + {
3153 + struct us_data *us = host_to_us(sdev->host);
3154 ++ int maxp;
3155 +
3156 + /*
3157 + * Set the INQUIRY transfer length to 36. We don't use any of
3158 +@@ -74,20 +75,17 @@ static int slave_alloc (struct scsi_device *sdev)
3159 + sdev->inquiry_len = 36;
3160 +
3161 + /*
3162 +- * USB has unusual DMA-alignment requirements: Although the
3163 +- * starting address of each scatter-gather element doesn't matter,
3164 +- * the length of each element except the last must be divisible
3165 +- * by the Bulk maxpacket value. There's currently no way to
3166 +- * express this by block-layer constraints, so we'll cop out
3167 +- * and simply require addresses to be aligned at 512-byte
3168 +- * boundaries. This is okay since most block I/O involves
3169 +- * hardware sectors that are multiples of 512 bytes in length,
3170 +- * and since host controllers up through USB 2.0 have maxpacket
3171 +- * values no larger than 512.
3172 +- *
3173 +- * But it doesn't suffice for Wireless USB, where Bulk maxpacket
3174 +- * values can be as large as 2048. To make that work properly
3175 +- * will require changes to the block layer.
3176 ++ * USB has unusual scatter-gather requirements: the length of each
3177 ++ * scatterlist element except the last must be divisible by the
3178 ++ * Bulk maxpacket value. Fortunately this value is always a
3179 ++ * power of 2. Inform the block layer about this requirement.
3180 ++ */
3181 ++ maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0);
3182 ++ blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
3183 ++
3184 ++ /*
3185 ++ * Some host controllers may have alignment requirements.
3186 ++ * We'll play it safe by requiring 512-byte alignment always.
3187 + */
3188 + blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
3189 +
3190 +diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
3191 +index 1f7b401c4d04..5b1d09367475 100644
3192 +--- a/drivers/usb/storage/uas.c
3193 ++++ b/drivers/usb/storage/uas.c
3194 +@@ -796,24 +796,33 @@ static int uas_slave_alloc(struct scsi_device *sdev)
3195 + {
3196 + struct uas_dev_info *devinfo =
3197 + (struct uas_dev_info *)sdev->host->hostdata;
3198 ++ int maxp;
3199 +
3200 + sdev->hostdata = devinfo;
3201 +
3202 + /*
3203 +- * USB has unusual DMA-alignment requirements: Although the
3204 +- * starting address of each scatter-gather element doesn't matter,
3205 +- * the length of each element except the last must be divisible
3206 +- * by the Bulk maxpacket value. There's currently no way to
3207 +- * express this by block-layer constraints, so we'll cop out
3208 +- * and simply require addresses to be aligned at 512-byte
3209 +- * boundaries. This is okay since most block I/O involves
3210 +- * hardware sectors that are multiples of 512 bytes in length,
3211 +- * and since host controllers up through USB 2.0 have maxpacket
3212 +- * values no larger than 512.
3213 ++ * We have two requirements here. We must satisfy the requirements
3214 ++ * of the physical HC and the demands of the protocol, as we
3215 ++ * definitely want no additional memory allocation in this path
3216 ++ * ruling out using bounce buffers.
3217 + *
3218 +- * But it doesn't suffice for Wireless USB, where Bulk maxpacket
3219 +- * values can be as large as 2048. To make that work properly
3220 +- * will require changes to the block layer.
3221 ++ * For a transmission on USB to continue we must never send
3222 ++ * a package that is smaller than maxpacket. Hence the length of each
3223 ++ * scatterlist element except the last must be divisible by the
3224 ++ * Bulk maxpacket value.
3225 ++ * If the HC does not ensure that through SG,
3226 ++ * the upper layer must do that. We must assume nothing
3227 ++ * about the capabilities off the HC, so we use the most
3228 ++ * pessimistic requirement.
3229 ++ */
3230 ++
3231 ++ maxp = usb_maxpacket(devinfo->udev, devinfo->data_in_pipe, 0);
3232 ++ blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
3233 ++
3234 ++ /*
3235 ++ * The protocol has no requirements on alignment in the strict sense.
3236 ++ * Controllers may or may not have alignment restrictions.
3237 ++ * As this is not exported, we use an extremely conservative guess.
3238 + */
3239 + blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
3240 +
3241 +diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
3242 +index 465a6f5142cc..45b04bc91f24 100644
3243 +--- a/drivers/virtio/virtio_pci_common.c
3244 ++++ b/drivers/virtio/virtio_pci_common.c
3245 +@@ -255,9 +255,11 @@ void vp_del_vqs(struct virtio_device *vdev)
3246 + for (i = 0; i < vp_dev->msix_used_vectors; ++i)
3247 + free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev);
3248 +
3249 +- for (i = 0; i < vp_dev->msix_vectors; i++)
3250 +- if (vp_dev->msix_affinity_masks[i])
3251 +- free_cpumask_var(vp_dev->msix_affinity_masks[i]);
3252 ++ if (vp_dev->msix_affinity_masks) {
3253 ++ for (i = 0; i < vp_dev->msix_vectors; i++)
3254 ++ if (vp_dev->msix_affinity_masks[i])
3255 ++ free_cpumask_var(vp_dev->msix_affinity_masks[i]);
3256 ++ }
3257 +
3258 + if (vp_dev->msix_enabled) {
3259 + /* Disable the vector used for configuration */
3260 +diff --git a/include/linux/kernel.h b/include/linux/kernel.h
3261 +index d6aac75b51ba..3d83ebb302cf 100644
3262 +--- a/include/linux/kernel.h
3263 ++++ b/include/linux/kernel.h
3264 +@@ -73,8 +73,8 @@
3265 +
3266 + #define u64_to_user_ptr(x) ( \
3267 + { \
3268 +- typecheck(u64, x); \
3269 +- (void __user *)(uintptr_t)x; \
3270 ++ typecheck(u64, (x)); \
3271 ++ (void __user *)(uintptr_t)(x); \
3272 + } \
3273 + )
3274 +
3275 +diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
3276 +index 1dfb75057580..cc2d0c3b475b 100644
3277 +--- a/include/net/bluetooth/hci_core.h
3278 ++++ b/include/net/bluetooth/hci_core.h
3279 +@@ -182,6 +182,9 @@ struct adv_info {
3280 +
3281 + #define HCI_MAX_SHORT_NAME_LENGTH 10
3282 +
3283 ++/* Min encryption key size to match with SMP */
3284 ++#define HCI_MIN_ENC_KEY_SIZE 7
3285 ++
3286 + /* Default LE RPA expiry time, 15 minutes */
3287 + #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
3288 +
3289 +diff --git a/kernel/events/core.c b/kernel/events/core.c
3290 +index 87bd96399d1c..171b83ebed4a 100644
3291 +--- a/kernel/events/core.c
3292 ++++ b/kernel/events/core.c
3293 +@@ -2007,8 +2007,8 @@ event_sched_out(struct perf_event *event,
3294 + event->pmu->del(event, 0);
3295 + event->oncpu = -1;
3296 +
3297 +- if (event->pending_disable) {
3298 +- event->pending_disable = 0;
3299 ++ if (READ_ONCE(event->pending_disable) >= 0) {
3300 ++ WRITE_ONCE(event->pending_disable, -1);
3301 + state = PERF_EVENT_STATE_OFF;
3302 + }
3303 + perf_event_set_state(event, state);
3304 +@@ -2196,7 +2196,8 @@ EXPORT_SYMBOL_GPL(perf_event_disable);
3305 +
3306 + void perf_event_disable_inatomic(struct perf_event *event)
3307 + {
3308 +- event->pending_disable = 1;
3309 ++ WRITE_ONCE(event->pending_disable, smp_processor_id());
3310 ++ /* can fail, see perf_pending_event_disable() */
3311 + irq_work_queue(&event->pending);
3312 + }
3313 +
3314 +@@ -5803,10 +5804,45 @@ void perf_event_wakeup(struct perf_event *event)
3315 + }
3316 + }
3317 +
3318 ++static void perf_pending_event_disable(struct perf_event *event)
3319 ++{
3320 ++ int cpu = READ_ONCE(event->pending_disable);
3321 ++
3322 ++ if (cpu < 0)
3323 ++ return;
3324 ++
3325 ++ if (cpu == smp_processor_id()) {
3326 ++ WRITE_ONCE(event->pending_disable, -1);
3327 ++ perf_event_disable_local(event);
3328 ++ return;
3329 ++ }
3330 ++
3331 ++ /*
3332 ++ * CPU-A CPU-B
3333 ++ *
3334 ++ * perf_event_disable_inatomic()
3335 ++ * @pending_disable = CPU-A;
3336 ++ * irq_work_queue();
3337 ++ *
3338 ++ * sched-out
3339 ++ * @pending_disable = -1;
3340 ++ *
3341 ++ * sched-in
3342 ++ * perf_event_disable_inatomic()
3343 ++ * @pending_disable = CPU-B;
3344 ++ * irq_work_queue(); // FAILS
3345 ++ *
3346 ++ * irq_work_run()
3347 ++ * perf_pending_event()
3348 ++ *
3349 ++ * But the event runs on CPU-B and wants disabling there.
3350 ++ */
3351 ++ irq_work_queue_on(&event->pending, cpu);
3352 ++}
3353 ++
3354 + static void perf_pending_event(struct irq_work *entry)
3355 + {
3356 +- struct perf_event *event = container_of(entry,
3357 +- struct perf_event, pending);
3358 ++ struct perf_event *event = container_of(entry, struct perf_event, pending);
3359 + int rctx;
3360 +
3361 + rctx = perf_swevent_get_recursion_context();
3362 +@@ -5815,10 +5851,7 @@ static void perf_pending_event(struct irq_work *entry)
3363 + * and we won't recurse 'further'.
3364 + */
3365 +
3366 +- if (event->pending_disable) {
3367 +- event->pending_disable = 0;
3368 +- perf_event_disable_local(event);
3369 +- }
3370 ++ perf_pending_event_disable(event);
3371 +
3372 + if (event->pending_wakeup) {
3373 + event->pending_wakeup = 0;
3374 +@@ -9969,6 +10002,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
3375 +
3376 +
3377 + init_waitqueue_head(&event->waitq);
3378 ++ event->pending_disable = -1;
3379 + init_irq_work(&event->pending, perf_pending_event);
3380 +
3381 + mutex_init(&event->mmap_mutex);
3382 +diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
3383 +index 474b2ccdbe69..99c7f199f2d4 100644
3384 +--- a/kernel/events/ring_buffer.c
3385 ++++ b/kernel/events/ring_buffer.c
3386 +@@ -393,7 +393,7 @@ void *perf_aux_output_begin(struct perf_output_handle *handle,
3387 + * store that will be enabled on successful return
3388 + */
3389 + if (!handle->size) { /* A, matches D */
3390 +- event->pending_disable = 1;
3391 ++ event->pending_disable = smp_processor_id();
3392 + perf_output_wakeup(handle);
3393 + local_set(&rb->aux_nest, 0);
3394 + goto err_put;
3395 +@@ -471,7 +471,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
3396 +
3397 + if (wakeup) {
3398 + if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED)
3399 +- handle->event->pending_disable = 1;
3400 ++ handle->event->pending_disable = smp_processor_id();
3401 + perf_output_wakeup(handle);
3402 + }
3403 +
3404 +diff --git a/kernel/futex.c b/kernel/futex.c
3405 +index 5a26d843a015..afdc5eadce6e 100644
3406 +--- a/kernel/futex.c
3407 ++++ b/kernel/futex.c
3408 +@@ -1306,13 +1306,15 @@ static int lookup_pi_state(u32 __user *uaddr, u32 uval,
3409 +
3410 + static int lock_pi_update_atomic(u32 __user *uaddr, u32 uval, u32 newval)
3411 + {
3412 ++ int err;
3413 + u32 uninitialized_var(curval);
3414 +
3415 + if (unlikely(should_fail_futex(true)))
3416 + return -EFAULT;
3417 +
3418 +- if (unlikely(cmpxchg_futex_value_locked(&curval, uaddr, uval, newval)))
3419 +- return -EFAULT;
3420 ++ err = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
3421 ++ if (unlikely(err))
3422 ++ return err;
3423 +
3424 + /* If user space value changed, let the caller retry */
3425 + return curval != uval ? -EAGAIN : 0;
3426 +@@ -1498,10 +1500,8 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_
3427 + if (unlikely(should_fail_futex(true)))
3428 + ret = -EFAULT;
3429 +
3430 +- if (cmpxchg_futex_value_locked(&curval, uaddr, uval, newval)) {
3431 +- ret = -EFAULT;
3432 +-
3433 +- } else if (curval != uval) {
3434 ++ ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
3435 ++ if (!ret && (curval != uval)) {
3436 + /*
3437 + * If a unconditional UNLOCK_PI operation (user space did not
3438 + * try the TID->0 transition) raced with a waiter setting the
3439 +@@ -1696,32 +1696,32 @@ retry_private:
3440 + double_lock_hb(hb1, hb2);
3441 + op_ret = futex_atomic_op_inuser(op, uaddr2);
3442 + if (unlikely(op_ret < 0)) {
3443 +-
3444 + double_unlock_hb(hb1, hb2);
3445 +
3446 +-#ifndef CONFIG_MMU
3447 +- /*
3448 +- * we don't get EFAULT from MMU faults if we don't have an MMU,
3449 +- * but we might get them from range checking
3450 +- */
3451 +- ret = op_ret;
3452 +- goto out_put_keys;
3453 +-#endif
3454 +-
3455 +- if (unlikely(op_ret != -EFAULT)) {
3456 ++ if (!IS_ENABLED(CONFIG_MMU) ||
3457 ++ unlikely(op_ret != -EFAULT && op_ret != -EAGAIN)) {
3458 ++ /*
3459 ++ * we don't get EFAULT from MMU faults if we don't have
3460 ++ * an MMU, but we might get them from range checking
3461 ++ */
3462 + ret = op_ret;
3463 + goto out_put_keys;
3464 + }
3465 +
3466 +- ret = fault_in_user_writeable(uaddr2);
3467 +- if (ret)
3468 +- goto out_put_keys;
3469 ++ if (op_ret == -EFAULT) {
3470 ++ ret = fault_in_user_writeable(uaddr2);
3471 ++ if (ret)
3472 ++ goto out_put_keys;
3473 ++ }
3474 +
3475 +- if (!(flags & FLAGS_SHARED))
3476 ++ if (!(flags & FLAGS_SHARED)) {
3477 ++ cond_resched();
3478 + goto retry_private;
3479 ++ }
3480 +
3481 + put_futex_key(&key2);
3482 + put_futex_key(&key1);
3483 ++ cond_resched();
3484 + goto retry;
3485 + }
3486 +
3487 +@@ -2346,7 +2346,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
3488 + u32 uval, uninitialized_var(curval), newval;
3489 + struct task_struct *oldowner, *newowner;
3490 + u32 newtid;
3491 +- int ret;
3492 ++ int ret, err = 0;
3493 +
3494 + lockdep_assert_held(q->lock_ptr);
3495 +
3496 +@@ -2417,14 +2417,17 @@ retry:
3497 + if (!pi_state->owner)
3498 + newtid |= FUTEX_OWNER_DIED;
3499 +
3500 +- if (get_futex_value_locked(&uval, uaddr))
3501 +- goto handle_fault;
3502 ++ err = get_futex_value_locked(&uval, uaddr);
3503 ++ if (err)
3504 ++ goto handle_err;
3505 +
3506 + for (;;) {
3507 + newval = (uval & FUTEX_OWNER_DIED) | newtid;
3508 +
3509 +- if (cmpxchg_futex_value_locked(&curval, uaddr, uval, newval))
3510 +- goto handle_fault;
3511 ++ err = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
3512 ++ if (err)
3513 ++ goto handle_err;
3514 ++
3515 + if (curval == uval)
3516 + break;
3517 + uval = curval;
3518 +@@ -2452,23 +2455,37 @@ retry:
3519 + return 0;
3520 +
3521 + /*
3522 +- * To handle the page fault we need to drop the locks here. That gives
3523 +- * the other task (either the highest priority waiter itself or the
3524 +- * task which stole the rtmutex) the chance to try the fixup of the
3525 +- * pi_state. So once we are back from handling the fault we need to
3526 +- * check the pi_state after reacquiring the locks and before trying to
3527 +- * do another fixup. When the fixup has been done already we simply
3528 +- * return.
3529 ++ * In order to reschedule or handle a page fault, we need to drop the
3530 ++ * locks here. In the case of a fault, this gives the other task
3531 ++ * (either the highest priority waiter itself or the task which stole
3532 ++ * the rtmutex) the chance to try the fixup of the pi_state. So once we
3533 ++ * are back from handling the fault we need to check the pi_state after
3534 ++ * reacquiring the locks and before trying to do another fixup. When
3535 ++ * the fixup has been done already we simply return.
3536 + *
3537 + * Note: we hold both hb->lock and pi_mutex->wait_lock. We can safely
3538 + * drop hb->lock since the caller owns the hb -> futex_q relation.
3539 + * Dropping the pi_mutex->wait_lock requires the state revalidate.
3540 + */
3541 +-handle_fault:
3542 ++handle_err:
3543 + raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
3544 + spin_unlock(q->lock_ptr);
3545 +
3546 +- ret = fault_in_user_writeable(uaddr);
3547 ++ switch (err) {
3548 ++ case -EFAULT:
3549 ++ ret = fault_in_user_writeable(uaddr);
3550 ++ break;
3551 ++
3552 ++ case -EAGAIN:
3553 ++ cond_resched();
3554 ++ ret = 0;
3555 ++ break;
3556 ++
3557 ++ default:
3558 ++ WARN_ON_ONCE(1);
3559 ++ ret = err;
3560 ++ break;
3561 ++ }
3562 +
3563 + spin_lock(q->lock_ptr);
3564 + raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
3565 +@@ -3037,10 +3054,8 @@ retry:
3566 + * A unconditional UNLOCK_PI op raced against a waiter
3567 + * setting the FUTEX_WAITERS bit. Try again.
3568 + */
3569 +- if (ret == -EAGAIN) {
3570 +- put_futex_key(&key);
3571 +- goto retry;
3572 +- }
3573 ++ if (ret == -EAGAIN)
3574 ++ goto pi_retry;
3575 + /*
3576 + * wake_futex_pi has detected invalid state. Tell user
3577 + * space.
3578 +@@ -3055,9 +3070,19 @@ retry:
3579 + * preserve the WAITERS bit not the OWNER_DIED one. We are the
3580 + * owner.
3581 + */
3582 +- if (cmpxchg_futex_value_locked(&curval, uaddr, uval, 0)) {
3583 ++ if ((ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, 0))) {
3584 + spin_unlock(&hb->lock);
3585 +- goto pi_faulted;
3586 ++ switch (ret) {
3587 ++ case -EFAULT:
3588 ++ goto pi_faulted;
3589 ++
3590 ++ case -EAGAIN:
3591 ++ goto pi_retry;
3592 ++
3593 ++ default:
3594 ++ WARN_ON_ONCE(1);
3595 ++ goto out_putkey;
3596 ++ }
3597 + }
3598 +
3599 + /*
3600 +@@ -3071,6 +3096,11 @@ out_putkey:
3601 + put_futex_key(&key);
3602 + return ret;
3603 +
3604 ++pi_retry:
3605 ++ put_futex_key(&key);
3606 ++ cond_resched();
3607 ++ goto retry;
3608 ++
3609 + pi_faulted:
3610 + put_futex_key(&key);
3611 +
3612 +@@ -3431,6 +3461,7 @@ err_unlock:
3613 + int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi)
3614 + {
3615 + u32 uval, uninitialized_var(nval), mval;
3616 ++ int err;
3617 +
3618 + /* Futex address must be 32bit aligned */
3619 + if ((((unsigned long)uaddr) % sizeof(*uaddr)) != 0)
3620 +@@ -3440,42 +3471,57 @@ retry:
3621 + if (get_user(uval, uaddr))
3622 + return -1;
3623 +
3624 +- if ((uval & FUTEX_TID_MASK) == task_pid_vnr(curr)) {
3625 +- /*
3626 +- * Ok, this dying thread is truly holding a futex
3627 +- * of interest. Set the OWNER_DIED bit atomically
3628 +- * via cmpxchg, and if the value had FUTEX_WAITERS
3629 +- * set, wake up a waiter (if any). (We have to do a
3630 +- * futex_wake() even if OWNER_DIED is already set -
3631 +- * to handle the rare but possible case of recursive
3632 +- * thread-death.) The rest of the cleanup is done in
3633 +- * userspace.
3634 +- */
3635 +- mval = (uval & FUTEX_WAITERS) | FUTEX_OWNER_DIED;
3636 +- /*
3637 +- * We are not holding a lock here, but we want to have
3638 +- * the pagefault_disable/enable() protection because
3639 +- * we want to handle the fault gracefully. If the
3640 +- * access fails we try to fault in the futex with R/W
3641 +- * verification via get_user_pages. get_user() above
3642 +- * does not guarantee R/W access. If that fails we
3643 +- * give up and leave the futex locked.
3644 +- */
3645 +- if (cmpxchg_futex_value_locked(&nval, uaddr, uval, mval)) {
3646 ++ if ((uval & FUTEX_TID_MASK) != task_pid_vnr(curr))
3647 ++ return 0;
3648 ++
3649 ++ /*
3650 ++ * Ok, this dying thread is truly holding a futex
3651 ++ * of interest. Set the OWNER_DIED bit atomically
3652 ++ * via cmpxchg, and if the value had FUTEX_WAITERS
3653 ++ * set, wake up a waiter (if any). (We have to do a
3654 ++ * futex_wake() even if OWNER_DIED is already set -
3655 ++ * to handle the rare but possible case of recursive
3656 ++ * thread-death.) The rest of the cleanup is done in
3657 ++ * userspace.
3658 ++ */
3659 ++ mval = (uval & FUTEX_WAITERS) | FUTEX_OWNER_DIED;
3660 ++
3661 ++ /*
3662 ++ * We are not holding a lock here, but we want to have
3663 ++ * the pagefault_disable/enable() protection because
3664 ++ * we want to handle the fault gracefully. If the
3665 ++ * access fails we try to fault in the futex with R/W
3666 ++ * verification via get_user_pages. get_user() above
3667 ++ * does not guarantee R/W access. If that fails we
3668 ++ * give up and leave the futex locked.
3669 ++ */
3670 ++ if ((err = cmpxchg_futex_value_locked(&nval, uaddr, uval, mval))) {
3671 ++ switch (err) {
3672 ++ case -EFAULT:
3673 + if (fault_in_user_writeable(uaddr))
3674 + return -1;
3675 + goto retry;
3676 +- }
3677 +- if (nval != uval)
3678 ++
3679 ++ case -EAGAIN:
3680 ++ cond_resched();
3681 + goto retry;
3682 +
3683 +- /*
3684 +- * Wake robust non-PI futexes here. The wakeup of
3685 +- * PI futexes happens in exit_pi_state():
3686 +- */
3687 +- if (!pi && (uval & FUTEX_WAITERS))
3688 +- futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
3689 ++ default:
3690 ++ WARN_ON_ONCE(1);
3691 ++ return err;
3692 ++ }
3693 + }
3694 ++
3695 ++ if (nval != uval)
3696 ++ goto retry;
3697 ++
3698 ++ /*
3699 ++ * Wake robust non-PI futexes here. The wakeup of
3700 ++ * PI futexes happens in exit_pi_state():
3701 ++ */
3702 ++ if (!pi && (uval & FUTEX_WAITERS))
3703 ++ futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
3704 ++
3705 + return 0;
3706 + }
3707 +
3708 +diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
3709 +index 5c0ba5ca5930..cd4f9f3e8345 100644
3710 +--- a/kernel/irq/manage.c
3711 ++++ b/kernel/irq/manage.c
3712 +@@ -356,8 +356,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
3713 + desc->affinity_notify = notify;
3714 + raw_spin_unlock_irqrestore(&desc->lock, flags);
3715 +
3716 +- if (old_notify)
3717 ++ if (old_notify) {
3718 ++ cancel_work_sync(&old_notify->work);
3719 + kref_put(&old_notify->kref, old_notify->release);
3720 ++ }
3721 +
3722 + return 0;
3723 + }
3724 +diff --git a/lib/ubsan.c b/lib/ubsan.c
3725 +index e4162f59a81c..1e9e2ab25539 100644
3726 +--- a/lib/ubsan.c
3727 ++++ b/lib/ubsan.c
3728 +@@ -86,11 +86,13 @@ static bool is_inline_int(struct type_descriptor *type)
3729 + return bits <= inline_bits;
3730 + }
3731 +
3732 +-static s_max get_signed_val(struct type_descriptor *type, unsigned long val)
3733 ++static s_max get_signed_val(struct type_descriptor *type, void *val)
3734 + {
3735 + if (is_inline_int(type)) {
3736 + unsigned extra_bits = sizeof(s_max)*8 - type_bit_width(type);
3737 +- return ((s_max)val) << extra_bits >> extra_bits;
3738 ++ unsigned long ulong_val = (unsigned long)val;
3739 ++
3740 ++ return ((s_max)ulong_val) << extra_bits >> extra_bits;
3741 + }
3742 +
3743 + if (type_bit_width(type) == 64)
3744 +@@ -99,15 +101,15 @@ static s_max get_signed_val(struct type_descriptor *type, unsigned long val)
3745 + return *(s_max *)val;
3746 + }
3747 +
3748 +-static bool val_is_negative(struct type_descriptor *type, unsigned long val)
3749 ++static bool val_is_negative(struct type_descriptor *type, void *val)
3750 + {
3751 + return type_is_signed(type) && get_signed_val(type, val) < 0;
3752 + }
3753 +
3754 +-static u_max get_unsigned_val(struct type_descriptor *type, unsigned long val)
3755 ++static u_max get_unsigned_val(struct type_descriptor *type, void *val)
3756 + {
3757 + if (is_inline_int(type))
3758 +- return val;
3759 ++ return (unsigned long)val;
3760 +
3761 + if (type_bit_width(type) == 64)
3762 + return *(u64 *)val;
3763 +@@ -116,7 +118,7 @@ static u_max get_unsigned_val(struct type_descriptor *type, unsigned long val)
3764 + }
3765 +
3766 + static void val_to_string(char *str, size_t size, struct type_descriptor *type,
3767 +- unsigned long value)
3768 ++ void *value)
3769 + {
3770 + if (type_is_int(type)) {
3771 + if (type_bit_width(type) == 128) {
3772 +@@ -163,8 +165,8 @@ static void ubsan_epilogue(unsigned long *flags)
3773 + current->in_ubsan--;
3774 + }
3775 +
3776 +-static void handle_overflow(struct overflow_data *data, unsigned long lhs,
3777 +- unsigned long rhs, char op)
3778 ++static void handle_overflow(struct overflow_data *data, void *lhs,
3779 ++ void *rhs, char op)
3780 + {
3781 +
3782 + struct type_descriptor *type = data->type;
3783 +@@ -191,8 +193,7 @@ static void handle_overflow(struct overflow_data *data, unsigned long lhs,
3784 + }
3785 +
3786 + void __ubsan_handle_add_overflow(struct overflow_data *data,
3787 +- unsigned long lhs,
3788 +- unsigned long rhs)
3789 ++ void *lhs, void *rhs)
3790 + {
3791 +
3792 + handle_overflow(data, lhs, rhs, '+');
3793 +@@ -200,23 +201,21 @@ void __ubsan_handle_add_overflow(struct overflow_data *data,
3794 + EXPORT_SYMBOL(__ubsan_handle_add_overflow);
3795 +
3796 + void __ubsan_handle_sub_overflow(struct overflow_data *data,
3797 +- unsigned long lhs,
3798 +- unsigned long rhs)
3799 ++ void *lhs, void *rhs)
3800 + {
3801 + handle_overflow(data, lhs, rhs, '-');
3802 + }
3803 + EXPORT_SYMBOL(__ubsan_handle_sub_overflow);
3804 +
3805 + void __ubsan_handle_mul_overflow(struct overflow_data *data,
3806 +- unsigned long lhs,
3807 +- unsigned long rhs)
3808 ++ void *lhs, void *rhs)
3809 + {
3810 + handle_overflow(data, lhs, rhs, '*');
3811 + }
3812 + EXPORT_SYMBOL(__ubsan_handle_mul_overflow);
3813 +
3814 + void __ubsan_handle_negate_overflow(struct overflow_data *data,
3815 +- unsigned long old_val)
3816 ++ void *old_val)
3817 + {
3818 + unsigned long flags;
3819 + char old_val_str[VALUE_LENGTH];
3820 +@@ -237,8 +236,7 @@ EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
3821 +
3822 +
3823 + void __ubsan_handle_divrem_overflow(struct overflow_data *data,
3824 +- unsigned long lhs,
3825 +- unsigned long rhs)
3826 ++ void *lhs, void *rhs)
3827 + {
3828 + unsigned long flags;
3829 + char rhs_val_str[VALUE_LENGTH];
3830 +@@ -323,7 +321,7 @@ static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
3831 + }
3832 +
3833 + void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
3834 +- unsigned long ptr)
3835 ++ void *ptr)
3836 + {
3837 + struct type_mismatch_data_common common_data = {
3838 + .location = &data->location,
3839 +@@ -332,12 +330,12 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
3840 + .type_check_kind = data->type_check_kind
3841 + };
3842 +
3843 +- ubsan_type_mismatch_common(&common_data, ptr);
3844 ++ ubsan_type_mismatch_common(&common_data, (unsigned long)ptr);
3845 + }
3846 + EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
3847 +
3848 + void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
3849 +- unsigned long ptr)
3850 ++ void *ptr)
3851 + {
3852 +
3853 + struct type_mismatch_data_common common_data = {
3854 +@@ -347,12 +345,12 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
3855 + .type_check_kind = data->type_check_kind
3856 + };
3857 +
3858 +- ubsan_type_mismatch_common(&common_data, ptr);
3859 ++ ubsan_type_mismatch_common(&common_data, (unsigned long)ptr);
3860 + }
3861 + EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
3862 +
3863 + void __ubsan_handle_vla_bound_not_positive(struct vla_bound_data *data,
3864 +- unsigned long bound)
3865 ++ void *bound)
3866 + {
3867 + unsigned long flags;
3868 + char bound_str[VALUE_LENGTH];
3869 +@@ -369,8 +367,7 @@ void __ubsan_handle_vla_bound_not_positive(struct vla_bound_data *data,
3870 + }
3871 + EXPORT_SYMBOL(__ubsan_handle_vla_bound_not_positive);
3872 +
3873 +-void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data,
3874 +- unsigned long index)
3875 ++void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index)
3876 + {
3877 + unsigned long flags;
3878 + char index_str[VALUE_LENGTH];
3879 +@@ -388,7 +385,7 @@ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data,
3880 + EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
3881 +
3882 + void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
3883 +- unsigned long lhs, unsigned long rhs)
3884 ++ void *lhs, void *rhs)
3885 + {
3886 + unsigned long flags;
3887 + struct type_descriptor *rhs_type = data->rhs_type;
3888 +@@ -439,7 +436,7 @@ void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
3889 + EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
3890 +
3891 + void __ubsan_handle_load_invalid_value(struct invalid_value_data *data,
3892 +- unsigned long val)
3893 ++ void *val)
3894 + {
3895 + unsigned long flags;
3896 + char val_str[VALUE_LENGTH];
3897 +diff --git a/mm/slab.c b/mm/slab.c
3898 +index b8e0ec74330f..018d32496e8d 100644
3899 +--- a/mm/slab.c
3900 ++++ b/mm/slab.c
3901 +@@ -4305,7 +4305,8 @@ static void show_symbol(struct seq_file *m, unsigned long address)
3902 +
3903 + static int leaks_show(struct seq_file *m, void *p)
3904 + {
3905 +- struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
3906 ++ struct kmem_cache *cachep = list_entry(p, struct kmem_cache,
3907 ++ root_caches_node);
3908 + struct page *page;
3909 + struct kmem_cache_node *n;
3910 + const char *name;
3911 +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
3912 +index bd4978ce8c45..3cf0764d5793 100644
3913 +--- a/net/bluetooth/hci_conn.c
3914 ++++ b/net/bluetooth/hci_conn.c
3915 +@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
3916 + !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
3917 + return 0;
3918 +
3919 ++ /* The minimum encryption key size needs to be enforced by the
3920 ++ * host stack before establishing any L2CAP connections. The
3921 ++ * specification in theory allows a minimum of 1, but to align
3922 ++ * BR/EDR and LE transports, a minimum of 7 is chosen.
3923 ++ */
3924 ++ if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
3925 ++ return 0;
3926 ++
3927 + return 1;
3928 + }
3929 +
3930 +diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
3931 +index 1eaac01f85de..7f36fa73ffee 100644
3932 +--- a/net/bluetooth/hidp/sock.c
3933 ++++ b/net/bluetooth/hidp/sock.c
3934 +@@ -76,6 +76,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
3935 + sockfd_put(csock);
3936 + return err;
3937 + }
3938 ++ ca.name[sizeof(ca.name)-1] = 0;
3939 +
3940 + err = hidp_connection_add(&ca, csock, isock);
3941 + if (!err && copy_to_user(argp, &ca, sizeof(ca)))
3942 +diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
3943 +index bd6226bde45f..17e0101081ef 100644
3944 +--- a/sound/soc/codecs/cs35l35.c
3945 ++++ b/sound/soc/codecs/cs35l35.c
3946 +@@ -1634,6 +1634,16 @@ err:
3947 + return ret;
3948 + }
3949 +
3950 ++static int cs35l35_i2c_remove(struct i2c_client *i2c_client)
3951 ++{
3952 ++ struct cs35l35_private *cs35l35 = i2c_get_clientdata(i2c_client);
3953 ++
3954 ++ regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies);
3955 ++ gpiod_set_value_cansleep(cs35l35->reset_gpio, 0);
3956 ++
3957 ++ return 0;
3958 ++}
3959 ++
3960 + static const struct of_device_id cs35l35_of_match[] = {
3961 + {.compatible = "cirrus,cs35l35"},
3962 + {},
3963 +@@ -1654,6 +1664,7 @@ static struct i2c_driver cs35l35_i2c_driver = {
3964 + },
3965 + .id_table = cs35l35_id,
3966 + .probe = cs35l35_i2c_probe,
3967 ++ .remove = cs35l35_i2c_remove,
3968 + };
3969 +
3970 + module_i2c_driver(cs35l35_i2c_driver);
3971 +diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
3972 +index 3c266eeb89bf..007ce9f48e44 100644
3973 +--- a/sound/soc/codecs/cs4270.c
3974 ++++ b/sound/soc/codecs/cs4270.c
3975 +@@ -642,6 +642,7 @@ static const struct regmap_config cs4270_regmap = {
3976 + .reg_defaults = cs4270_reg_defaults,
3977 + .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
3978 + .cache_type = REGCACHE_RBTREE,
3979 ++ .write_flag_mask = CS4270_I2C_INCR,
3980 +
3981 + .readable_reg = cs4270_reg_is_readable,
3982 + .volatile_reg = cs4270_reg_is_volatile,
3983 +diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
3984 +index e5b6769b9797..d5f73c837281 100644
3985 +--- a/sound/soc/codecs/hdmi-codec.c
3986 ++++ b/sound/soc/codecs/hdmi-codec.c
3987 +@@ -529,73 +529,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai,
3988 + {
3989 + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
3990 + struct hdmi_codec_daifmt cf = { 0 };
3991 +- int ret = 0;
3992 +
3993 + dev_dbg(dai->dev, "%s()\n", __func__);
3994 +
3995 +- if (dai->id == DAI_ID_SPDIF) {
3996 +- cf.fmt = HDMI_SPDIF;
3997 +- } else {
3998 +- switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3999 +- case SND_SOC_DAIFMT_CBM_CFM:
4000 +- cf.bit_clk_master = 1;
4001 +- cf.frame_clk_master = 1;
4002 +- break;
4003 +- case SND_SOC_DAIFMT_CBS_CFM:
4004 +- cf.frame_clk_master = 1;
4005 +- break;
4006 +- case SND_SOC_DAIFMT_CBM_CFS:
4007 +- cf.bit_clk_master = 1;
4008 +- break;
4009 +- case SND_SOC_DAIFMT_CBS_CFS:
4010 +- break;
4011 +- default:
4012 +- return -EINVAL;
4013 +- }
4014 ++ if (dai->id == DAI_ID_SPDIF)
4015 ++ return 0;
4016 ++
4017 ++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
4018 ++ case SND_SOC_DAIFMT_CBM_CFM:
4019 ++ cf.bit_clk_master = 1;
4020 ++ cf.frame_clk_master = 1;
4021 ++ break;
4022 ++ case SND_SOC_DAIFMT_CBS_CFM:
4023 ++ cf.frame_clk_master = 1;
4024 ++ break;
4025 ++ case SND_SOC_DAIFMT_CBM_CFS:
4026 ++ cf.bit_clk_master = 1;
4027 ++ break;
4028 ++ case SND_SOC_DAIFMT_CBS_CFS:
4029 ++ break;
4030 ++ default:
4031 ++ return -EINVAL;
4032 ++ }
4033 +
4034 +- switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
4035 +- case SND_SOC_DAIFMT_NB_NF:
4036 +- break;
4037 +- case SND_SOC_DAIFMT_NB_IF:
4038 +- cf.frame_clk_inv = 1;
4039 +- break;
4040 +- case SND_SOC_DAIFMT_IB_NF:
4041 +- cf.bit_clk_inv = 1;
4042 +- break;
4043 +- case SND_SOC_DAIFMT_IB_IF:
4044 +- cf.frame_clk_inv = 1;
4045 +- cf.bit_clk_inv = 1;
4046 +- break;
4047 +- }
4048 ++ switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
4049 ++ case SND_SOC_DAIFMT_NB_NF:
4050 ++ break;
4051 ++ case SND_SOC_DAIFMT_NB_IF:
4052 ++ cf.frame_clk_inv = 1;
4053 ++ break;
4054 ++ case SND_SOC_DAIFMT_IB_NF:
4055 ++ cf.bit_clk_inv = 1;
4056 ++ break;
4057 ++ case SND_SOC_DAIFMT_IB_IF:
4058 ++ cf.frame_clk_inv = 1;
4059 ++ cf.bit_clk_inv = 1;
4060 ++ break;
4061 ++ }
4062 +
4063 +- switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
4064 +- case SND_SOC_DAIFMT_I2S:
4065 +- cf.fmt = HDMI_I2S;
4066 +- break;
4067 +- case SND_SOC_DAIFMT_DSP_A:
4068 +- cf.fmt = HDMI_DSP_A;
4069 +- break;
4070 +- case SND_SOC_DAIFMT_DSP_B:
4071 +- cf.fmt = HDMI_DSP_B;
4072 +- break;
4073 +- case SND_SOC_DAIFMT_RIGHT_J:
4074 +- cf.fmt = HDMI_RIGHT_J;
4075 +- break;
4076 +- case SND_SOC_DAIFMT_LEFT_J:
4077 +- cf.fmt = HDMI_LEFT_J;
4078 +- break;
4079 +- case SND_SOC_DAIFMT_AC97:
4080 +- cf.fmt = HDMI_AC97;
4081 +- break;
4082 +- default:
4083 +- dev_err(dai->dev, "Invalid DAI interface format\n");
4084 +- return -EINVAL;
4085 +- }
4086 ++ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
4087 ++ case SND_SOC_DAIFMT_I2S:
4088 ++ cf.fmt = HDMI_I2S;
4089 ++ break;
4090 ++ case SND_SOC_DAIFMT_DSP_A:
4091 ++ cf.fmt = HDMI_DSP_A;
4092 ++ break;
4093 ++ case SND_SOC_DAIFMT_DSP_B:
4094 ++ cf.fmt = HDMI_DSP_B;
4095 ++ break;
4096 ++ case SND_SOC_DAIFMT_RIGHT_J:
4097 ++ cf.fmt = HDMI_RIGHT_J;
4098 ++ break;
4099 ++ case SND_SOC_DAIFMT_LEFT_J:
4100 ++ cf.fmt = HDMI_LEFT_J;
4101 ++ break;
4102 ++ case SND_SOC_DAIFMT_AC97:
4103 ++ cf.fmt = HDMI_AC97;
4104 ++ break;
4105 ++ default:
4106 ++ dev_err(dai->dev, "Invalid DAI interface format\n");
4107 ++ return -EINVAL;
4108 + }
4109 +
4110 + hcp->daifmt[dai->id] = cf;
4111 +
4112 +- return ret;
4113 ++ return 0;
4114 + }
4115 +
4116 + static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
4117 +@@ -792,8 +790,10 @@ static int hdmi_codec_probe(struct platform_device *pdev)
4118 + i++;
4119 + }
4120 +
4121 +- if (hcd->spdif)
4122 ++ if (hcd->spdif) {
4123 + hcp->daidrv[i] = hdmi_spdif_dai;
4124 ++ hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF;
4125 ++ }
4126 +
4127 + dev_set_drvdata(dev, hcp);
4128 +
4129 +diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
4130 +index bfd74b86c9d2..645aa0794123 100644
4131 +--- a/sound/soc/codecs/nau8810.c
4132 ++++ b/sound/soc/codecs/nau8810.c
4133 +@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = {
4134 + SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
4135 + NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0],
4136 + ARRAY_SIZE(nau8810_mono_mixer_controls)),
4137 +- SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
4138 ++ SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
4139 + NAU8810_DAC_EN_SFT, 0),
4140 +- SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
4141 ++ SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
4142 + NAU8810_ADC_EN_SFT, 0),
4143 + SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
4144 + NAU8810_NSPK_EN_SFT, 0, NULL, 0),
4145 +diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
4146 +index 468d5143e2c4..663a208c2f78 100644
4147 +--- a/sound/soc/codecs/nau8824.c
4148 ++++ b/sound/soc/codecs/nau8824.c
4149 +@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = {
4150 + SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
4151 + NAU8824_ADCR_EN_SFT, 0),
4152 +
4153 +- SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
4154 +- SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
4155 ++ SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
4156 ++ SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
4157 +
4158 + SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
4159 + NAU8824_DACL_EN_SFT, 0),
4160 +@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap)
4161 + }
4162 + }
4163 +
4164 ++static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
4165 ++{
4166 ++ struct snd_soc_dapm_context *dapm = nau8824->dapm;
4167 ++ const char *prefix = dapm->component->name_prefix;
4168 ++ char prefixed_pin[80];
4169 ++
4170 ++ if (prefix) {
4171 ++ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
4172 ++ prefix, pin);
4173 ++ snd_soc_dapm_disable_pin(dapm, prefixed_pin);
4174 ++ } else {
4175 ++ snd_soc_dapm_disable_pin(dapm, pin);
4176 ++ }
4177 ++}
4178 ++
4179 ++static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
4180 ++{
4181 ++ struct snd_soc_dapm_context *dapm = nau8824->dapm;
4182 ++ const char *prefix = dapm->component->name_prefix;
4183 ++ char prefixed_pin[80];
4184 ++
4185 ++ if (prefix) {
4186 ++ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
4187 ++ prefix, pin);
4188 ++ snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
4189 ++ } else {
4190 ++ snd_soc_dapm_force_enable_pin(dapm, pin);
4191 ++ }
4192 ++}
4193 ++
4194 + static void nau8824_eject_jack(struct nau8824 *nau8824)
4195 + {
4196 + struct snd_soc_dapm_context *dapm = nau8824->dapm;
4197 +@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
4198 + /* Clear all interruption status */
4199 + nau8824_int_status_clear_all(regmap);
4200 +
4201 +- snd_soc_dapm_disable_pin(dapm, "SAR");
4202 +- snd_soc_dapm_disable_pin(dapm, "MICBIAS");
4203 ++ nau8824_dapm_disable_pin(nau8824, "SAR");
4204 ++ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
4205 + snd_soc_dapm_sync(dapm);
4206 +
4207 + /* Enable the insertion interruption, disable the ejection
4208 +@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
4209 + struct regmap *regmap = nau8824->regmap;
4210 + int adc_value, event = 0, event_mask = 0;
4211 +
4212 +- snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
4213 +- snd_soc_dapm_force_enable_pin(dapm, "SAR");
4214 ++ nau8824_dapm_enable_pin(nau8824, "MICBIAS");
4215 ++ nau8824_dapm_enable_pin(nau8824, "SAR");
4216 + snd_soc_dapm_sync(dapm);
4217 +
4218 + msleep(100);
4219 +@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
4220 + if (adc_value < HEADSET_SARADC_THD) {
4221 + event |= SND_JACK_HEADPHONE;
4222 +
4223 +- snd_soc_dapm_disable_pin(dapm, "SAR");
4224 +- snd_soc_dapm_disable_pin(dapm, "MICBIAS");
4225 ++ nau8824_dapm_disable_pin(nau8824, "SAR");
4226 ++ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
4227 + snd_soc_dapm_sync(dapm);
4228 + } else {
4229 + event |= SND_JACK_HEADSET;
4230 +diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
4231 +index 79ebcc239786..6f5dac09cede 100644
4232 +--- a/sound/soc/codecs/rt5682.c
4233 ++++ b/sound/soc/codecs/rt5682.c
4234 +@@ -1196,7 +1196,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
4235 + struct snd_soc_component *component =
4236 + snd_soc_dapm_to_component(w->dapm);
4237 + struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
4238 +- int ref, val, reg, sft, mask, idx = -EINVAL;
4239 ++ int ref, val, reg, idx = -EINVAL;
4240 + static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
4241 + static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48};
4242 +
4243 +@@ -1210,15 +1210,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
4244 +
4245 + idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f));
4246 +
4247 +- if (w->shift == RT5682_PWR_ADC_S1F_BIT) {
4248 ++ if (w->shift == RT5682_PWR_ADC_S1F_BIT)
4249 + reg = RT5682_PLL_TRACK_3;
4250 +- sft = RT5682_ADC_OSR_SFT;
4251 +- mask = RT5682_ADC_OSR_MASK;
4252 +- } else {
4253 ++ else
4254 + reg = RT5682_PLL_TRACK_2;
4255 +- sft = RT5682_DAC_OSR_SFT;
4256 +- mask = RT5682_DAC_OSR_MASK;
4257 +- }
4258 +
4259 + snd_soc_component_update_bits(component, reg,
4260 + RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT);
4261 +@@ -1230,7 +1225,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
4262 + }
4263 +
4264 + snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1,
4265 +- mask, idx << sft);
4266 ++ RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK,
4267 ++ (idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT));
4268 +
4269 + return 0;
4270 + }
4271 +diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
4272 +index f03195d2ab2e..45d9f4a09044 100644
4273 +--- a/sound/soc/codecs/tlv320aic32x4.c
4274 ++++ b/sound/soc/codecs/tlv320aic32x4.c
4275 +@@ -462,6 +462,8 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
4276 + SND_SOC_DAPM_INPUT("IN2_R"),
4277 + SND_SOC_DAPM_INPUT("IN3_L"),
4278 + SND_SOC_DAPM_INPUT("IN3_R"),
4279 ++ SND_SOC_DAPM_INPUT("CM_L"),
4280 ++ SND_SOC_DAPM_INPUT("CM_R"),
4281 + };
4282 +
4283 + static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
4284 +diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
4285 +index 6a271e6e6b8f..6c0a3dad44b8 100644
4286 +--- a/sound/soc/codecs/tlv320aic3x.c
4287 ++++ b/sound/soc/codecs/tlv320aic3x.c
4288 +@@ -1599,7 +1599,6 @@ static int aic3x_probe(struct snd_soc_component *component)
4289 + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
4290 + int ret, i;
4291 +
4292 +- INIT_LIST_HEAD(&aic3x->list);
4293 + aic3x->component = component;
4294 +
4295 + for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
4296 +@@ -1682,7 +1681,6 @@ static void aic3x_remove(struct snd_soc_component *component)
4297 + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
4298 + int i;
4299 +
4300 +- list_del(&aic3x->list);
4301 + for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
4302 + regulator_unregister_notifier(aic3x->supplies[i].consumer,
4303 + &aic3x->disable_nb[i].nb);
4304 +@@ -1880,6 +1878,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
4305 + if (ret != 0)
4306 + goto err_gpio;
4307 +
4308 ++ INIT_LIST_HEAD(&aic3x->list);
4309 + list_add(&aic3x->list, &reset_list);
4310 +
4311 + return 0;
4312 +@@ -1896,6 +1895,8 @@ static int aic3x_i2c_remove(struct i2c_client *client)
4313 + {
4314 + struct aic3x_priv *aic3x = i2c_get_clientdata(client);
4315 +
4316 ++ list_del(&aic3x->list);
4317 ++
4318 + if (gpio_is_valid(aic3x->gpio_reset) &&
4319 + !aic3x_is_shared_reset(aic3x)) {
4320 + gpio_set_value(aic3x->gpio_reset, 0);
4321 +diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
4322 +index a651fed62a27..ee85056a8577 100644
4323 +--- a/sound/soc/codecs/wm_adsp.c
4324 ++++ b/sound/soc/codecs/wm_adsp.c
4325 +@@ -3819,11 +3819,13 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
4326 + struct regmap *regmap = dsp->regmap;
4327 + int ret = 0;
4328 +
4329 ++ mutex_lock(&dsp->pwr_lock);
4330 ++
4331 + ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val);
4332 + if (ret) {
4333 + adsp_err(dsp,
4334 + "Failed to read Region Lock Ctrl register: %d\n", ret);
4335 +- return IRQ_HANDLED;
4336 ++ goto error;
4337 + }
4338 +
4339 + if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
4340 +@@ -3842,7 +3844,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
4341 + adsp_err(dsp,
4342 + "Failed to read Bus Err Addr register: %d\n",
4343 + ret);
4344 +- return IRQ_HANDLED;
4345 ++ goto error;
4346 + }
4347 +
4348 + adsp_err(dsp, "bus error address = 0x%x\n",
4349 +@@ -3855,7 +3857,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
4350 + adsp_err(dsp,
4351 + "Failed to read Pmem Xmem Err Addr register: %d\n",
4352 + ret);
4353 +- return IRQ_HANDLED;
4354 ++ goto error;
4355 + }
4356 +
4357 + adsp_err(dsp, "xmem error address = 0x%x\n",
4358 +@@ -3868,6 +3870,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
4359 + regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL,
4360 + ADSP2_CTRL_ERR_EINT, ADSP2_CTRL_ERR_EINT);
4361 +
4362 ++error:
4363 ++ mutex_unlock(&dsp->pwr_lock);
4364 ++
4365 + return IRQ_HANDLED;
4366 + }
4367 + EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);
4368 +diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
4369 +index a892b37eab7c..b8a03f58ac8c 100644
4370 +--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
4371 ++++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
4372 +@@ -406,7 +406,7 @@ static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
4373 + };
4374 +
4375 + static const unsigned int dmic_2ch[] = {
4376 +- 4,
4377 ++ 2,
4378 + };
4379 +
4380 + static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
4381 +diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
4382 +index 11041aedea31..6cfcc1042989 100644
4383 +--- a/sound/soc/intel/common/sst-firmware.c
4384 ++++ b/sound/soc/intel/common/sst-firmware.c
4385 +@@ -1251,11 +1251,15 @@ struct sst_dsp *sst_dsp_new(struct device *dev,
4386 + goto irq_err;
4387 +
4388 + err = sst_dma_new(sst);
4389 +- if (err)
4390 +- dev_warn(dev, "sst_dma_new failed %d\n", err);
4391 ++ if (err) {
4392 ++ dev_err(dev, "sst_dma_new failed %d\n", err);
4393 ++ goto dma_err;
4394 ++ }
4395 +
4396 + return sst;
4397 +
4398 ++dma_err:
4399 ++ free_irq(sst->irq, sst);
4400 + irq_err:
4401 + if (sst->ops->free)
4402 + sst->ops->free(sst);
4403 +diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
4404 +index 823e39103edd..6b2c8c6e7a00 100644
4405 +--- a/sound/soc/intel/skylake/skl-pcm.c
4406 ++++ b/sound/soc/intel/skylake/skl-pcm.c
4407 +@@ -180,6 +180,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
4408 + struct hdac_stream *hstream;
4409 + struct hdac_ext_stream *stream;
4410 + struct hdac_ext_link *link;
4411 ++ unsigned char stream_tag;
4412 +
4413 + hstream = snd_hdac_get_stream(bus, params->stream,
4414 + params->link_dma_id + 1);
4415 +@@ -198,10 +199,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
4416 +
4417 + snd_hdac_ext_link_stream_setup(stream, format_val);
4418 +
4419 +- list_for_each_entry(link, &bus->hlink_list, list) {
4420 +- if (link->index == params->link_index)
4421 +- snd_hdac_ext_link_set_stream_id(link,
4422 +- hstream->stream_tag);
4423 ++ stream_tag = hstream->stream_tag;
4424 ++ if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
4425 ++ list_for_each_entry(link, &bus->hlink_list, list) {
4426 ++ if (link->index == params->link_index)
4427 ++ snd_hdac_ext_link_set_stream_id(link,
4428 ++ stream_tag);
4429 ++ }
4430 + }
4431 +
4432 + stream->link_prepared = 1;
4433 +@@ -640,6 +644,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
4434 + struct hdac_ext_stream *link_dev =
4435 + snd_soc_dai_get_dma_data(dai, substream);
4436 + struct hdac_ext_link *link;
4437 ++ unsigned char stream_tag;
4438 +
4439 + dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
4440 +
4441 +@@ -649,7 +654,11 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
4442 + if (!link)
4443 + return -EINVAL;
4444 +
4445 +- snd_hdac_ext_link_clear_stream_id(link, hdac_stream(link_dev)->stream_tag);
4446 ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
4447 ++ stream_tag = hdac_stream(link_dev)->stream_tag;
4448 ++ snd_hdac_ext_link_clear_stream_id(link, stream_tag);
4449 ++ }
4450 ++
4451 + snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
4452 + return 0;
4453 + }
4454 +diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c
4455 +index 400e29edb1c9..8a2e3bbce3a1 100644
4456 +--- a/sound/soc/rockchip/rockchip_pdm.c
4457 ++++ b/sound/soc/rockchip/rockchip_pdm.c
4458 +@@ -208,7 +208,9 @@ static int rockchip_pdm_set_fmt(struct snd_soc_dai *cpu_dai,
4459 + return -EINVAL;
4460 + }
4461 +
4462 ++ pm_runtime_get_sync(cpu_dai->dev);
4463 + regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val);
4464 ++ pm_runtime_put(cpu_dai->dev);
4465 +
4466 + return 0;
4467 + }
4468 +diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
4469 +index e7b371b07230..45c6d7396785 100644
4470 +--- a/sound/soc/samsung/odroid.c
4471 ++++ b/sound/soc/samsung/odroid.c
4472 +@@ -64,11 +64,11 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream,
4473 + return ret;
4474 +
4475 + /*
4476 +- * We add 1 to the rclk_freq value in order to avoid too low clock
4477 ++ * We add 2 to the rclk_freq value in order to avoid too low clock
4478 + * frequency values due to the EPLL output frequency not being exact
4479 + * multiple of the audio sampling rate.
4480 + */
4481 +- rclk_freq = params_rate(params) * rfs + 1;
4482 ++ rclk_freq = params_rate(params) * rfs + 2;
4483 +
4484 + ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
4485 + if (ret < 0)
4486 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
4487 +index 9b78fb3daa7b..2257b1b0151c 100644
4488 +--- a/sound/soc/soc-dapm.c
4489 ++++ b/sound/soc/soc-dapm.c
4490 +@@ -3847,6 +3847,10 @@ snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
4491 + int count;
4492 +
4493 + devm_kfree(card->dev, (void *)*private_value);
4494 ++
4495 ++ if (!w_param_text)
4496 ++ return;
4497 ++
4498 + for (count = 0 ; count < num_params; count++)
4499 + devm_kfree(card->dev, (void *)w_param_text[count]);
4500 + devm_kfree(card->dev, w_param_text);
4501 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
4502 +index e8b98bfd4cf1..33060af18b5a 100644
4503 +--- a/sound/soc/soc-pcm.c
4504 ++++ b/sound/soc/soc-pcm.c
4505 +@@ -957,10 +957,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
4506 + codec_params = *params;
4507 +
4508 + /* fixup params based on TDM slot masks */
4509 +- if (codec_dai->tx_mask)
4510 ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
4511 ++ codec_dai->tx_mask)
4512 + soc_pcm_codec_params_fixup(&codec_params,
4513 + codec_dai->tx_mask);
4514 +- if (codec_dai->rx_mask)
4515 ++
4516 ++ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
4517 ++ codec_dai->rx_mask)
4518 + soc_pcm_codec_params_fixup(&codec_params,
4519 + codec_dai->rx_mask);
4520 +
4521 +diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
4522 +index 706ff005234f..24948b95eb19 100644
4523 +--- a/sound/soc/stm/stm32_adfsdm.c
4524 ++++ b/sound/soc/stm/stm32_adfsdm.c
4525 +@@ -9,6 +9,7 @@
4526 +
4527 + #include <linux/clk.h>
4528 + #include <linux/module.h>
4529 ++#include <linux/mutex.h>
4530 + #include <linux/platform_device.h>
4531 + #include <linux/slab.h>
4532 +
4533 +@@ -37,6 +38,8 @@ struct stm32_adfsdm_priv {
4534 + /* PCM buffer */
4535 + unsigned char *pcm_buff;
4536 + unsigned int pos;
4537 ++
4538 ++ struct mutex lock; /* protect against race condition on iio state */
4539 + };
4540 +
4541 + static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = {
4542 +@@ -62,10 +65,12 @@ static void stm32_adfsdm_shutdown(struct snd_pcm_substream *substream,
4543 + {
4544 + struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
4545 +
4546 ++ mutex_lock(&priv->lock);
4547 + if (priv->iio_active) {
4548 + iio_channel_stop_all_cb(priv->iio_cb);
4549 + priv->iio_active = false;
4550 + }
4551 ++ mutex_unlock(&priv->lock);
4552 + }
4553 +
4554 + static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
4555 +@@ -74,13 +79,19 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
4556 + struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
4557 + int ret;
4558 +
4559 ++ mutex_lock(&priv->lock);
4560 ++ if (priv->iio_active) {
4561 ++ iio_channel_stop_all_cb(priv->iio_cb);
4562 ++ priv->iio_active = false;
4563 ++ }
4564 ++
4565 + ret = iio_write_channel_attribute(priv->iio_ch,
4566 + substream->runtime->rate, 0,
4567 + IIO_CHAN_INFO_SAMP_FREQ);
4568 + if (ret < 0) {
4569 + dev_err(dai->dev, "%s: Failed to set %d sampling rate\n",
4570 + __func__, substream->runtime->rate);
4571 +- return ret;
4572 ++ goto out;
4573 + }
4574 +
4575 + if (!priv->iio_active) {
4576 +@@ -92,6 +103,9 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
4577 + __func__, ret);
4578 + }
4579 +
4580 ++out:
4581 ++ mutex_unlock(&priv->lock);
4582 ++
4583 + return ret;
4584 + }
4585 +
4586 +@@ -290,6 +304,7 @@ MODULE_DEVICE_TABLE(of, stm32_adfsdm_of_match);
4587 + static int stm32_adfsdm_probe(struct platform_device *pdev)
4588 + {
4589 + struct stm32_adfsdm_priv *priv;
4590 ++ struct snd_soc_component *component;
4591 + int ret;
4592 +
4593 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
4594 +@@ -298,6 +313,7 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
4595 +
4596 + priv->dev = &pdev->dev;
4597 + priv->dai_drv = stm32_adfsdm_dai;
4598 ++ mutex_init(&priv->lock);
4599 +
4600 + dev_set_drvdata(&pdev->dev, priv);
4601 +
4602 +@@ -316,9 +332,15 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
4603 + if (IS_ERR(priv->iio_cb))
4604 + return PTR_ERR(priv->iio_cb);
4605 +
4606 +- ret = devm_snd_soc_register_component(&pdev->dev,
4607 +- &stm32_adfsdm_soc_platform,
4608 +- NULL, 0);
4609 ++ component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
4610 ++ if (!component)
4611 ++ return -ENOMEM;
4612 ++#ifdef CONFIG_DEBUG_FS
4613 ++ component->debugfs_prefix = "pcm";
4614 ++#endif
4615 ++
4616 ++ ret = snd_soc_add_component(&pdev->dev, component,
4617 ++ &stm32_adfsdm_soc_platform, NULL, 0);
4618 + if (ret < 0)
4619 + dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
4620 + __func__);
4621 +@@ -326,12 +348,20 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
4622 + return ret;
4623 + }
4624 +
4625 ++static int stm32_adfsdm_remove(struct platform_device *pdev)
4626 ++{
4627 ++ snd_soc_unregister_component(&pdev->dev);
4628 ++
4629 ++ return 0;
4630 ++}
4631 ++
4632 + static struct platform_driver stm32_adfsdm_driver = {
4633 + .driver = {
4634 + .name = STM32_ADFSDM_DRV_NAME,
4635 + .of_match_table = stm32_adfsdm_of_match,
4636 + },
4637 + .probe = stm32_adfsdm_probe,
4638 ++ .remove = stm32_adfsdm_remove,
4639 + };
4640 +
4641 + module_platform_driver(stm32_adfsdm_driver);
4642 +diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
4643 +index 85c4b6d8e89d..2fb2b914e78b 100644
4644 +--- a/sound/soc/stm/stm32_sai_sub.c
4645 ++++ b/sound/soc/stm/stm32_sai_sub.c
4646 +@@ -96,7 +96,7 @@
4647 + * @slot_mask: rx or tx active slots mask. set at init or at runtime
4648 + * @data_size: PCM data width. corresponds to PCM substream width.
4649 + * @spdif_frm_cnt: S/PDIF playback frame counter
4650 +- * @snd_aes_iec958: iec958 data
4651 ++ * @iec958: iec958 data
4652 + * @ctrl_lock: control lock
4653 + */
4654 + struct stm32_sai_sub_data {
4655 +@@ -498,6 +498,14 @@ static int stm32_sai_startup(struct snd_pcm_substream *substream,
4656 +
4657 + sai->substream = substream;
4658 +
4659 ++ if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
4660 ++ snd_pcm_hw_constraint_mask64(substream->runtime,
4661 ++ SNDRV_PCM_HW_PARAM_FORMAT,
4662 ++ SNDRV_PCM_FMTBIT_S32_LE);
4663 ++ snd_pcm_hw_constraint_single(substream->runtime,
4664 ++ SNDRV_PCM_HW_PARAM_CHANNELS, 2);
4665 ++ }
4666 ++
4667 + ret = clk_prepare_enable(sai->sai_ck);
4668 + if (ret < 0) {
4669 + dev_err(cpu_dai->dev, "Failed to enable clock: %d\n", ret);
4670 +@@ -888,11 +896,12 @@ static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
4671 + struct snd_soc_dai *cpu_dai)
4672 + {
4673 + struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
4674 ++ struct snd_kcontrol_new knew = iec958_ctls;
4675 +
4676 + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
4677 + dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__);
4678 +- return snd_ctl_add(rtd->pcm->card,
4679 +- snd_ctl_new1(&iec958_ctls, sai));
4680 ++ knew.device = rtd->pcm->device;
4681 ++ return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai));
4682 + }
4683 +
4684 + return 0;
4685 +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
4686 +index 550f17611bd7..ef152daccc33 100644
4687 +--- a/tools/objtool/check.c
4688 ++++ b/tools/objtool/check.c
4689 +@@ -165,6 +165,7 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func,
4690 + "fortify_panic",
4691 + "usercopy_abort",
4692 + "machine_real_restart",
4693 ++ "rewind_stack_do_exit",
4694 + };
4695 +
4696 + if (func->bind == STB_WEAK)