Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.19/0141-4.19.42-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


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