]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.0-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 May 2019 17:02:08 +0000 (19:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 May 2019 17:02:08 +0000 (19:02 +0200)
added patches:
acpi-lpss-use-acpi_lpss_-instead-of-acpi_subsys_-functions-for-hibernate.patch
bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
bluetooth-fix-not-initializing-l2cap-tx_credits.patch
bluetooth-hci_bcm-fix-empty-regulator-supplies-for-intel-macs.patch
bluetooth-hidp-fix-buffer-overflow.patch
cpufreq-armada-37xx-fix-frequency-calculation-for-opp.patch
iio-adc-qcom-spmi-adc5-fix-of-based-module-autoloading.patch
scsi-lpfc-change-snprintf-to-scnprintf-for-possible-overflow.patch
scsi-qla2xxx-fix-device-staying-in-blocked-state.patch
scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs-routines.patch
soc-sunxi-fix-missing-dependency-on-regmap_mmio.patch
uas-fix-alignment-of-scatter-gather-segments.patch

13 files changed:
queue-5.0/acpi-lpss-use-acpi_lpss_-instead-of-acpi_subsys_-functions-for-hibernate.patch [new file with mode: 0644]
queue-5.0/bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch [new file with mode: 0644]
queue-5.0/bluetooth-fix-not-initializing-l2cap-tx_credits.patch [new file with mode: 0644]
queue-5.0/bluetooth-hci_bcm-fix-empty-regulator-supplies-for-intel-macs.patch [new file with mode: 0644]
queue-5.0/bluetooth-hidp-fix-buffer-overflow.patch [new file with mode: 0644]
queue-5.0/cpufreq-armada-37xx-fix-frequency-calculation-for-opp.patch [new file with mode: 0644]
queue-5.0/iio-adc-qcom-spmi-adc5-fix-of-based-module-autoloading.patch [new file with mode: 0644]
queue-5.0/scsi-lpfc-change-snprintf-to-scnprintf-for-possible-overflow.patch [new file with mode: 0644]
queue-5.0/scsi-qla2xxx-fix-device-staying-in-blocked-state.patch [new file with mode: 0644]
queue-5.0/scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs-routines.patch [new file with mode: 0644]
queue-5.0/series
queue-5.0/soc-sunxi-fix-missing-dependency-on-regmap_mmio.patch [new file with mode: 0644]
queue-5.0/uas-fix-alignment-of-scatter-gather-segments.patch [new file with mode: 0644]

diff --git a/queue-5.0/acpi-lpss-use-acpi_lpss_-instead-of-acpi_subsys_-functions-for-hibernate.patch b/queue-5.0/acpi-lpss-use-acpi_lpss_-instead-of-acpi_subsys_-functions-for-hibernate.patch
new file mode 100644 (file)
index 0000000..3d8f861
--- /dev/null
@@ -0,0 +1,50 @@
+From c8afd03486c26accdda4846e5561aa3f8e862a9d Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Thu, 18 Apr 2019 13:39:33 +0200
+Subject: ACPI / LPSS: Use acpi_lpss_* instead of acpi_subsys_* functions for hibernate
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit c8afd03486c26accdda4846e5561aa3f8e862a9d upstream.
+
+Commit 48402cee6889 ("ACPI / LPSS: Resume BYT/CHT I2C controllers from
+resume_noirq") makes acpi_lpss_{suspend_late,resume_early}() bail early
+on BYT/CHT as resume_from_noirq is set.
+
+This means that on resume from hibernate dw_i2c_plat_resume() doesn't get
+called by the restore_early callback, acpi_lpss_resume_early(). Instead it
+should be called by the restore_noirq callback matching how things are done
+when resume_from_noirq is set and we are doing a regular resume.
+
+Change the restore_noirq callback to acpi_lpss_resume_noirq so that
+dw_i2c_plat_resume() gets properly called when resume_from_noirq is set
+and we are resuming from hibernate.
+
+Likewise also change the poweroff_noirq callback so that
+dw_i2c_plat_suspend gets called properly.
+
+Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202139
+Fixes: 48402cee6889 ("ACPI / LPSS: Resume BYT/CHT I2C controllers from resume_noirq")
+Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/acpi_lpss.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/acpi/acpi_lpss.c
++++ b/drivers/acpi/acpi_lpss.c
+@@ -1142,8 +1142,8 @@ static struct dev_pm_domain acpi_lpss_pm
+               .thaw_noirq = acpi_subsys_thaw_noirq,
+               .poweroff = acpi_subsys_suspend,
+               .poweroff_late = acpi_lpss_suspend_late,
+-              .poweroff_noirq = acpi_subsys_suspend_noirq,
+-              .restore_noirq = acpi_subsys_resume_noirq,
++              .poweroff_noirq = acpi_lpss_suspend_noirq,
++              .restore_noirq = acpi_lpss_resume_noirq,
+               .restore_early = acpi_lpss_resume_early,
+ #endif
+               .runtime_suspend = acpi_lpss_runtime_suspend,
diff --git a/queue-5.0/bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch b/queue-5.0/bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
new file mode 100644 (file)
index 0000000..c7e5bf0
--- /dev/null
@@ -0,0 +1,52 @@
+From d5bb334a8e171b262e48f378bd2096c0ea458265 Mon Sep 17 00:00:00 2001
+From: Marcel Holtmann <marcel@holtmann.org>
+Date: Wed, 24 Apr 2019 22:19:17 +0200
+Subject: Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
+
+From: Marcel Holtmann <marcel@holtmann.org>
+
+commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream.
+
+The minimum encryption key size for LE connections is 56 bits and to
+align LE with BR/EDR, enforce 56 bits of minimum encryption key size for
+BR/EDR connections as well.
+
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/net/bluetooth/hci_core.h |    3 +++
+ net/bluetooth/hci_conn.c         |    8 ++++++++
+ 2 files changed, 11 insertions(+)
+
+--- a/include/net/bluetooth/hci_core.h
++++ b/include/net/bluetooth/hci_core.h
+@@ -190,6 +190,9 @@ struct adv_info {
+ #define HCI_MAX_SHORT_NAME_LENGTH     10
++/* Min encryption key size to match with SMP */
++#define HCI_MIN_ENC_KEY_SIZE          7
++
+ /* Default LE RPA expiry time, 15 minutes */
+ #define HCI_DEFAULT_RPA_TIMEOUT               (15 * 60)
+--- a/net/bluetooth/hci_conn.c
++++ b/net/bluetooth/hci_conn.c
+@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_
+           !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+               return 0;
++      /* The minimum encryption key size needs to be enforced by the
++       * host stack before establishing any L2CAP connections. The
++       * specification in theory allows a minimum of 1, but to align
++       * BR/EDR and LE transports, a minimum of 7 is chosen.
++       */
++      if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
++              return 0;
++
+       return 1;
+ }
diff --git a/queue-5.0/bluetooth-fix-not-initializing-l2cap-tx_credits.patch b/queue-5.0/bluetooth-fix-not-initializing-l2cap-tx_credits.patch
new file mode 100644 (file)
index 0000000..2a5d200
--- /dev/null
@@ -0,0 +1,62 @@
+From ba8f5289f706aed94cc95b15cc5b89e22062f61f Mon Sep 17 00:00:00 2001
+From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Date: Thu, 14 Mar 2019 15:43:37 +0200
+Subject: Bluetooth: Fix not initializing L2CAP tx_credits
+
+From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+
+commit ba8f5289f706aed94cc95b15cc5b89e22062f61f upstream.
+
+l2cap_le_flowctl_init was reseting the tx_credits which works only for
+outgoing connection since that set the tx_credits on the response, for
+incoming connections that was not the case which leaves the channel
+without any credits causing it to be suspended.
+
+Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Cc: stable@vger.kernel.org # 4.20+
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/bluetooth/l2cap_core.c |    9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+--- a/net/bluetooth/l2cap_core.c
++++ b/net/bluetooth/l2cap_core.c
+@@ -510,12 +510,12 @@ void l2cap_chan_set_defaults(struct l2ca
+ }
+ EXPORT_SYMBOL_GPL(l2cap_chan_set_defaults);
+-static void l2cap_le_flowctl_init(struct l2cap_chan *chan)
++static void l2cap_le_flowctl_init(struct l2cap_chan *chan, u16 tx_credits)
+ {
+       chan->sdu = NULL;
+       chan->sdu_last_frag = NULL;
+       chan->sdu_len = 0;
+-      chan->tx_credits = 0;
++      chan->tx_credits = tx_credits;
+       /* Derive MPS from connection MTU to stop HCI fragmentation */
+       chan->mps = min_t(u16, chan->imtu, chan->conn->mtu - L2CAP_HDR_SIZE);
+       /* Give enough credits for a full packet */
+@@ -1281,7 +1281,7 @@ static void l2cap_le_connect(struct l2ca
+       if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags))
+               return;
+-      l2cap_le_flowctl_init(chan);
++      l2cap_le_flowctl_init(chan, 0);
+       req.psm     = chan->psm;
+       req.scid    = cpu_to_le16(chan->scid);
+@@ -5531,11 +5531,10 @@ static int l2cap_le_connect_req(struct l
+       chan->dcid = scid;
+       chan->omtu = mtu;
+       chan->remote_mps = mps;
+-      chan->tx_credits = __le16_to_cpu(req->credits);
+       __l2cap_chan_add(conn, chan);
+-      l2cap_le_flowctl_init(chan);
++      l2cap_le_flowctl_init(chan, __le16_to_cpu(req->credits));
+       dcid = chan->scid;
+       credits = chan->rx_credits;
diff --git a/queue-5.0/bluetooth-hci_bcm-fix-empty-regulator-supplies-for-intel-macs.patch b/queue-5.0/bluetooth-hci_bcm-fix-empty-regulator-supplies-for-intel-macs.patch
new file mode 100644 (file)
index 0000000..cef8cbf
--- /dev/null
@@ -0,0 +1,69 @@
+From 62611abc8f37d00e3b0cff0eb2d72fa92b05fd27 Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Mon, 1 Apr 2019 11:43:12 +0800
+Subject: Bluetooth: hci_bcm: Fix empty regulator supplies for Intel Macs
+
+From: Chen-Yu Tsai <wens@csie.org>
+
+commit 62611abc8f37d00e3b0cff0eb2d72fa92b05fd27 upstream.
+
+The code path for Macs goes through bcm_apple_get_resources(), which
+skips over the code that sets up the regulator supplies. As a result,
+the call to regulator_bulk_enable() / regulator_bulk_disable() results
+in a NULL pointer dereference.
+
+This was reported on the kernel.org Bugzilla, bug 202963.
+
+Unbreak Broadcom Bluetooth support on Intel Macs by checking if the
+supplies were set up before enabling or disabling them.
+
+The same does not need to be done for the clocks, as the common clock
+framework API checks for NULL pointers.
+
+Fixes: 75d11676dccb ("Bluetooth: hci_bcm: Add support for regulator supplies")
+Cc: <stable@vger.kernel.org> # 5.0.x
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+Tested-by: Imre Kaloz <kaloz@openwrt.org>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/bluetooth/hci_bcm.c |   20 ++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
+
+--- a/drivers/bluetooth/hci_bcm.c
++++ b/drivers/bluetooth/hci_bcm.c
+@@ -228,9 +228,15 @@ static int bcm_gpio_set_power(struct bcm
+       int err;
+       if (powered && !dev->res_enabled) {
+-              err = regulator_bulk_enable(BCM_NUM_SUPPLIES, dev->supplies);
+-              if (err)
+-                      return err;
++              /* Intel Macs use bcm_apple_get_resources() and don't
++               * have regulator supplies configured.
++               */
++              if (dev->supplies[0].supply) {
++                      err = regulator_bulk_enable(BCM_NUM_SUPPLIES,
++                                                  dev->supplies);
++                      if (err)
++                              return err;
++              }
+               /* LPO clock needs to be 32.768 kHz */
+               err = clk_set_rate(dev->lpo_clk, 32768);
+@@ -259,7 +265,13 @@ static int bcm_gpio_set_power(struct bcm
+       if (!powered && dev->res_enabled) {
+               clk_disable_unprepare(dev->txco_clk);
+               clk_disable_unprepare(dev->lpo_clk);
+-              regulator_bulk_disable(BCM_NUM_SUPPLIES, dev->supplies);
++
++              /* Intel Macs use bcm_apple_get_resources() and don't
++               * have regulator supplies configured.
++               */
++              if (dev->supplies[0].supply)
++                      regulator_bulk_disable(BCM_NUM_SUPPLIES,
++                                             dev->supplies);
+       }
+       /* wait for device to power on and come out of reset */
diff --git a/queue-5.0/bluetooth-hidp-fix-buffer-overflow.patch b/queue-5.0/bluetooth-hidp-fix-buffer-overflow.patch
new file mode 100644 (file)
index 0000000..77c1a8d
--- /dev/null
@@ -0,0 +1,34 @@
+From a1616a5ac99ede5d605047a9012481ce7ff18b16 Mon Sep 17 00:00:00 2001
+From: Young Xiao <YangX92@hotmail.com>
+Date: Fri, 12 Apr 2019 15:24:30 +0800
+Subject: Bluetooth: hidp: fix buffer overflow
+
+From: Young Xiao <YangX92@hotmail.com>
+
+commit a1616a5ac99ede5d605047a9012481ce7ff18b16 upstream.
+
+Struct ca is copied from userspace. It is not checked whether the "name"
+field is NULL terminated, which allows local users to obtain potentially
+sensitive information from kernel stack memory, via a HIDPCONNADD command.
+
+This vulnerability is similar to CVE-2011-1079.
+
+Signed-off-by: Young Xiao <YangX92@hotmail.com>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/bluetooth/hidp/sock.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/net/bluetooth/hidp/sock.c
++++ b/net/bluetooth/hidp/sock.c
+@@ -75,6 +75,7 @@ static int do_hidp_sock_ioctl(struct soc
+                       sockfd_put(csock);
+                       return err;
+               }
++              ca.name[sizeof(ca.name)-1] = 0;
+               err = hidp_connection_add(&ca, csock, isock);
+               if (!err && copy_to_user(argp, &ca, sizeof(ca)))
diff --git a/queue-5.0/cpufreq-armada-37xx-fix-frequency-calculation-for-opp.patch b/queue-5.0/cpufreq-armada-37xx-fix-frequency-calculation-for-opp.patch
new file mode 100644 (file)
index 0000000..47d9dbe
--- /dev/null
@@ -0,0 +1,75 @@
+From 8db82563451f976597ab7b282ec655e4390a4088 Mon Sep 17 00:00:00 2001
+From: Gregory CLEMENT <gregory.clement@bootlin.com>
+Date: Fri, 8 Mar 2019 17:47:10 +0100
+Subject: cpufreq: armada-37xx: fix frequency calculation for opp
+
+From: Gregory CLEMENT <gregory.clement@bootlin.com>
+
+commit 8db82563451f976597ab7b282ec655e4390a4088 upstream.
+
+The frequency calculation was based on the current(max) frequency of the
+CPU. However for low frequency, the value used was already the parent
+frequency divided by a factor of 2.
+
+Instead of using this frequency, this fix directly get the frequency from
+the parent clock.
+
+Fixes: 92ce45fb875d ("cpufreq: Add DVFS support for Armada 37xx")
+Cc: <stable@vger.kernel.org>
+Reported-by: Christian Neubert <christian.neubert.86@gmail.com>
+Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
+Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/cpufreq/armada-37xx-cpufreq.c |   22 +++++++++++++++++++---
+ 1 file changed, 19 insertions(+), 3 deletions(-)
+
+--- a/drivers/cpufreq/armada-37xx-cpufreq.c
++++ b/drivers/cpufreq/armada-37xx-cpufreq.c
+@@ -359,11 +359,11 @@ static int __init armada37xx_cpufreq_dri
+       struct armada_37xx_dvfs *dvfs;
+       struct platform_device *pdev;
+       unsigned long freq;
+-      unsigned int cur_frequency;
++      unsigned int cur_frequency, base_frequency;
+       struct regmap *nb_pm_base, *avs_base;
+       struct device *cpu_dev;
+       int load_lvl, ret;
+-      struct clk *clk;
++      struct clk *clk, *parent;
+       nb_pm_base =
+               syscon_regmap_lookup_by_compatible("marvell,armada-3700-nb-pm");
+@@ -399,6 +399,22 @@ static int __init armada37xx_cpufreq_dri
+               return PTR_ERR(clk);
+       }
++      parent = clk_get_parent(clk);
++      if (IS_ERR(parent)) {
++              dev_err(cpu_dev, "Cannot get parent clock for CPU0\n");
++              clk_put(clk);
++              return PTR_ERR(parent);
++      }
++
++      /* Get parent CPU frequency */
++      base_frequency =  clk_get_rate(parent);
++
++      if (!base_frequency) {
++              dev_err(cpu_dev, "Failed to get parent clock rate for CPU\n");
++              clk_put(clk);
++              return -EINVAL;
++      }
++
+       /* Get nominal (current) CPU frequency */
+       cur_frequency = clk_get_rate(clk);
+       if (!cur_frequency) {
+@@ -431,7 +447,7 @@ static int __init armada37xx_cpufreq_dri
+       for (load_lvl = ARMADA_37XX_DVFS_LOAD_0; load_lvl < LOAD_LEVEL_NR;
+            load_lvl++) {
+               unsigned long u_volt = avs_map[dvfs->avs[load_lvl]] * 1000;
+-              freq = cur_frequency / dvfs->divider[load_lvl];
++              freq = base_frequency / dvfs->divider[load_lvl];
+               ret = dev_pm_opp_add(cpu_dev, freq, u_volt);
+               if (ret)
+                       goto remove_opp;
diff --git a/queue-5.0/iio-adc-qcom-spmi-adc5-fix-of-based-module-autoloading.patch b/queue-5.0/iio-adc-qcom-spmi-adc5-fix-of-based-module-autoloading.patch
new file mode 100644 (file)
index 0000000..857ec2b
--- /dev/null
@@ -0,0 +1,33 @@
+From 447ccb4e0834a9f9f0dd5643e421c7f1a1649e6a Mon Sep 17 00:00:00 2001
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+Date: Tue, 16 Apr 2019 16:49:27 -0700
+Subject: iio: adc: qcom-spmi-adc5: Fix of-based module autoloading
+
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+
+commit 447ccb4e0834a9f9f0dd5643e421c7f1a1649e6a upstream.
+
+The of_device_id table needs to be registered as module alias in order
+for automatic module loading to pick the kernel module based on the
+DeviceTree compatible. So add MODULE_DEVICE_TABLE() to make this happen.
+
+Fixes: e13d757279bb ("iio: adc: Add QCOM SPMI PMIC5 ADC driver")
+Cc: stable@vger.kernel.org
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/iio/adc/qcom-spmi-adc5.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/iio/adc/qcom-spmi-adc5.c
++++ b/drivers/iio/adc/qcom-spmi-adc5.c
+@@ -664,6 +664,7 @@ static const struct of_device_id adc5_ma
+       },
+       { }
+ };
++MODULE_DEVICE_TABLE(of, adc5_match_table);
+ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
+ {
diff --git a/queue-5.0/scsi-lpfc-change-snprintf-to-scnprintf-for-possible-overflow.patch b/queue-5.0/scsi-lpfc-change-snprintf-to-scnprintf-for-possible-overflow.patch
new file mode 100644 (file)
index 0000000..7afea84
--- /dev/null
@@ -0,0 +1,2250 @@
+From e7f7b6f38a44697428f5a2e7c606de028df2b0e3 Mon Sep 17 00:00:00 2001
+From: Silvio Cesare <silvio.cesare@gmail.com>
+Date: Thu, 21 Mar 2019 09:44:32 -0700
+Subject: scsi: lpfc: change snprintf to scnprintf for possible overflow
+
+From: Silvio Cesare <silvio.cesare@gmail.com>
+
+commit e7f7b6f38a44697428f5a2e7c606de028df2b0e3 upstream.
+
+Change snprintf to scnprintf. There are generally two cases where using
+snprintf causes problems.
+
+1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
+In this case, if snprintf would have written more characters than what the
+buffer size (SIZE) is, then size will end up larger than SIZE. In later
+uses of snprintf, SIZE - size will result in a negative number, leading
+to problems. Note that size might already be too large by using
+size = snprintf before the code reaches a case of size += snprintf.
+
+2) If size is ultimately used as a length parameter for a copy back to user
+space, then it will potentially allow for a buffer overflow and information
+disclosure when size is greater than SIZE. When the size is used to index
+the buffer directly, we can have memory corruption. This also means when
+size = snprintf... is used, it may also cause problems since size may become
+large.  Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
+configuration.
+
+The solution to these issues is to use scnprintf which returns the number of
+characters actually written to the buffer, so the size variable will never
+exceed SIZE.
+
+Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
+Signed-off-by: Willy Tarreau <w@1wt.eu>
+Signed-off-by: James Smart <james.smart@broadcom.com>
+Cc: Dick Kennedy <dick.kennedy@broadcom.com>
+Cc: Dan Carpenter <dan.carpenter@oracle.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Will Deacon <will.deacon@arm.com>
+Cc: Greg KH <greg@kroah.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/lpfc/lpfc_attr.c    |  192 ++++++++--------
+ drivers/scsi/lpfc/lpfc_ct.c      |   12 -
+ drivers/scsi/lpfc/lpfc_debugfs.c |  455 +++++++++++++++++++--------------------
+ drivers/scsi/lpfc/lpfc_debugfs.h |    6 
+ 4 files changed, 336 insertions(+), 329 deletions(-)
+
+--- a/drivers/scsi/lpfc/lpfc_attr.c
++++ b/drivers/scsi/lpfc/lpfc_attr.c
+@@ -117,7 +117,7 @@ static ssize_t
+ lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
+                      char *buf)
+ {
+-      return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
++      return scnprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
+ }
+ /**
+@@ -137,9 +137,9 @@ lpfc_enable_fip_show(struct device *dev,
+       struct lpfc_hba   *phba = vport->phba;
+       if (phba->hba_flag & HBA_FIP_SUPPORT)
+-              return snprintf(buf, PAGE_SIZE, "1\n");
++              return scnprintf(buf, PAGE_SIZE, "1\n");
+       else
+-              return snprintf(buf, PAGE_SIZE, "0\n");
++              return scnprintf(buf, PAGE_SIZE, "0\n");
+ }
+ static ssize_t
+@@ -517,14 +517,15 @@ lpfc_bg_info_show(struct device *dev, st
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      if (phba->cfg_enable_bg)
++      if (phba->cfg_enable_bg) {
+               if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
+-                      return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
++                      return scnprintf(buf, PAGE_SIZE,
++                                      "BlockGuard Enabled\n");
+               else
+-                      return snprintf(buf, PAGE_SIZE,
++                      return scnprintf(buf, PAGE_SIZE,
+                                       "BlockGuard Not Supported\n");
+-      else
+-                      return snprintf(buf, PAGE_SIZE,
++      } else
++              return scnprintf(buf, PAGE_SIZE,
+                                       "BlockGuard Disabled\n");
+ }
+@@ -536,7 +537,7 @@ lpfc_bg_guard_err_show(struct device *de
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%llu\n",
++      return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                       (unsigned long long)phba->bg_guard_err_cnt);
+ }
+@@ -548,7 +549,7 @@ lpfc_bg_apptag_err_show(struct device *d
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%llu\n",
++      return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                       (unsigned long long)phba->bg_apptag_err_cnt);
+ }
+@@ -560,7 +561,7 @@ lpfc_bg_reftag_err_show(struct device *d
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%llu\n",
++      return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                       (unsigned long long)phba->bg_reftag_err_cnt);
+ }
+@@ -578,7 +579,7 @@ lpfc_info_show(struct device *dev, struc
+ {
+       struct Scsi_Host *host = class_to_shost(dev);
+-      return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
++      return scnprintf(buf, PAGE_SIZE, "%s\n", lpfc_info(host));
+ }
+ /**
+@@ -597,7 +598,7 @@ lpfc_serialnum_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", phba->SerialNumber);
+ }
+ /**
+@@ -619,7 +620,7 @@ lpfc_temp_sensor_show(struct device *dev
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->temp_sensor_support);
+ }
+ /**
+@@ -638,7 +639,7 @@ lpfc_modeldesc_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelDesc);
+ }
+ /**
+@@ -657,7 +658,7 @@ lpfc_modelname_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelName);
+ }
+ /**
+@@ -676,7 +677,7 @@ lpfc_programtype_show(struct device *dev
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ProgramType);
+ }
+ /**
+@@ -694,7 +695,7 @@ lpfc_mlomgmt_show(struct device *dev, st
+       struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n",
++      return scnprintf(buf, PAGE_SIZE, "%d\n",
+               (phba->sli.sli_flag & LPFC_MENLO_MAINT));
+ }
+@@ -714,7 +715,7 @@ lpfc_vportnum_show(struct device *dev, s
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", phba->Port);
+ }
+ /**
+@@ -742,10 +743,10 @@ lpfc_fwrev_show(struct device *dev, stru
+       sli_family = phba->sli4_hba.pc_sli4_params.sli_family;
+       if (phba->sli_rev < LPFC_SLI_REV4)
+-              len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
++              len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d\n",
+                              fwrev, phba->sli_rev);
+       else
+-              len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
++              len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n",
+                              fwrev, phba->sli_rev, if_type, sli_family);
+       return len;
+@@ -769,7 +770,7 @@ lpfc_hdw_show(struct device *dev, struct
+       lpfc_vpd_t *vp = &phba->vpd;
+       lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
+-      return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", hdw);
+ }
+ /**
+@@ -790,10 +791,11 @@ lpfc_option_rom_version_show(struct devi
+       char fwrev[FW_REV_STR_SIZE];
+       if (phba->sli_rev < LPFC_SLI_REV4)
+-              return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
++              return scnprintf(buf, PAGE_SIZE, "%s\n",
++                              phba->OptionROMVersion);
+       lpfc_decode_firmware_rev(phba, fwrev, 1);
+-      return snprintf(buf, PAGE_SIZE, "%s\n", fwrev);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", fwrev);
+ }
+ /**
+@@ -824,20 +826,20 @@ lpfc_link_state_show(struct device *dev,
+       case LPFC_LINK_DOWN:
+       case LPFC_HBA_ERROR:
+               if (phba->hba_flag & LINK_DISABLED)
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "Link Down - User disabled\n");
+               else
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "Link Down\n");
+               break;
+       case LPFC_LINK_UP:
+       case LPFC_CLEAR_LA:
+       case LPFC_HBA_READY:
+-              len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
++              len += scnprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
+               switch (vport->port_state) {
+               case LPFC_LOCAL_CFG_LINK:
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                                       "Configuring Link\n");
+                       break;
+               case LPFC_FDISC:
+@@ -847,38 +849,40 @@ lpfc_link_state_show(struct device *dev,
+               case LPFC_NS_QRY:
+               case LPFC_BUILD_DISC_LIST:
+               case LPFC_DISC_AUTH:
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                                       "Discovery\n");
+                       break;
+               case LPFC_VPORT_READY:
+-                      len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
++                                      "Ready\n");
+                       break;
+               case LPFC_VPORT_FAILED:
+-                      len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
++                                      "Failed\n");
+                       break;
+               case LPFC_VPORT_UNKNOWN:
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                                       "Unknown\n");
+                       break;
+               }
+               if (phba->sli.sli_flag & LPFC_MENLO_MAINT)
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                                       "   Menlo Maint Mode\n");
+               else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
+                       if (vport->fc_flag & FC_PUBLIC_LOOP)
+-                              len += snprintf(buf + len, PAGE_SIZE-len,
++                              len += scnprintf(buf + len, PAGE_SIZE-len,
+                                               "   Public Loop\n");
+                       else
+-                              len += snprintf(buf + len, PAGE_SIZE-len,
++                              len += scnprintf(buf + len, PAGE_SIZE-len,
+                                               "   Private Loop\n");
+               } else {
+                       if (vport->fc_flag & FC_FABRIC)
+-                              len += snprintf(buf + len, PAGE_SIZE-len,
++                              len += scnprintf(buf + len, PAGE_SIZE-len,
+                                               "   Fabric\n");
+                       else
+-                              len += snprintf(buf + len, PAGE_SIZE-len,
++                              len += scnprintf(buf + len, PAGE_SIZE-len,
+                                               "   Point-2-Point\n");
+               }
+       }
+@@ -890,28 +894,28 @@ lpfc_link_state_show(struct device *dev,
+               struct lpfc_trunk_link link = phba->trunk_link;
+               if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba))
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "Trunk port 0: Link %s %s\n",
+                               (link.link0.state == LPFC_LINK_UP) ?
+                                "Up" : "Down. ",
+                               trunk_errmsg[link.link0.fault]);
+               if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba))
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "Trunk port 1: Link %s %s\n",
+                               (link.link1.state == LPFC_LINK_UP) ?
+                                "Up" : "Down. ",
+                               trunk_errmsg[link.link1.fault]);
+               if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba))
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "Trunk port 2: Link %s %s\n",
+                               (link.link2.state == LPFC_LINK_UP) ?
+                                "Up" : "Down. ",
+                               trunk_errmsg[link.link2.fault]);
+               if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba))
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "Trunk port 3: Link %s %s\n",
+                               (link.link3.state == LPFC_LINK_UP) ?
+                                "Up" : "Down. ",
+@@ -939,15 +943,15 @@ lpfc_sli4_protocol_show(struct device *d
+       struct lpfc_hba *phba = vport->phba;
+       if (phba->sli_rev < LPFC_SLI_REV4)
+-              return snprintf(buf, PAGE_SIZE, "fc\n");
++              return scnprintf(buf, PAGE_SIZE, "fc\n");
+       if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) {
+               if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE)
+-                      return snprintf(buf, PAGE_SIZE, "fcoe\n");
++                      return scnprintf(buf, PAGE_SIZE, "fcoe\n");
+               if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)
+-                      return snprintf(buf, PAGE_SIZE, "fc\n");
++                      return scnprintf(buf, PAGE_SIZE, "fc\n");
+       }
+-      return snprintf(buf, PAGE_SIZE, "unknown\n");
++      return scnprintf(buf, PAGE_SIZE, "unknown\n");
+ }
+ /**
+@@ -967,7 +971,7 @@ lpfc_oas_supported_show(struct device *d
+       struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+       struct lpfc_hba *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n",
++      return scnprintf(buf, PAGE_SIZE, "%d\n",
+                       phba->sli4_hba.pc_sli4_params.oas_supported);
+ }
+@@ -1025,7 +1029,7 @@ lpfc_num_discovered_ports_show(struct de
+       struct Scsi_Host  *shost = class_to_shost(dev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+-      return snprintf(buf, PAGE_SIZE, "%d\n",
++      return scnprintf(buf, PAGE_SIZE, "%d\n",
+                       vport->fc_map_cnt + vport->fc_unmap_cnt);
+ }
+@@ -1539,7 +1543,7 @@ lpfc_nport_evt_cnt_show(struct device *d
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
+ }
+ int
+@@ -1628,7 +1632,7 @@ lpfc_board_mode_show(struct device *dev,
+       else
+               state = "online";
+-      return snprintf(buf, PAGE_SIZE, "%s\n", state);
++      return scnprintf(buf, PAGE_SIZE, "%s\n", state);
+ }
+ /**
+@@ -1854,8 +1858,8 @@ lpfc_max_rpi_show(struct device *dev, st
+       uint32_t cnt;
+       if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -1882,8 +1886,8 @@ lpfc_used_rpi_show(struct device *dev, s
+       uint32_t cnt, acnt;
+       if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -1910,8 +1914,8 @@ lpfc_max_xri_show(struct device *dev, st
+       uint32_t cnt;
+       if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -1938,8 +1942,8 @@ lpfc_used_xri_show(struct device *dev, s
+       uint32_t cnt, acnt;
+       if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -1966,8 +1970,8 @@ lpfc_max_vpi_show(struct device *dev, st
+       uint32_t cnt;
+       if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", cnt);
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -1994,8 +1998,8 @@ lpfc_used_vpi_show(struct device *dev, s
+       uint32_t cnt, acnt;
+       if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
+-              return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
+-      return snprintf(buf, PAGE_SIZE, "Unknown\n");
++              return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
++      return scnprintf(buf, PAGE_SIZE, "Unknown\n");
+ }
+ /**
+@@ -2020,10 +2024,10 @@ lpfc_npiv_info_show(struct device *dev,
+       struct lpfc_hba   *phba = vport->phba;
+       if (!(phba->max_vpi))
+-              return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
++              return scnprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
+       if (vport->port_type == LPFC_PHYSICAL_PORT)
+-              return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
+-      return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
++              return scnprintf(buf, PAGE_SIZE, "NPIV Physical\n");
++      return scnprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
+ }
+ /**
+@@ -2045,7 +2049,7 @@ lpfc_poll_show(struct device *dev, struc
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
++      return scnprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
+ }
+ /**
+@@ -2149,7 +2153,7 @@ lpfc_fips_level_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
+ }
+ /**
+@@ -2168,7 +2172,7 @@ lpfc_fips_rev_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
+ }
+ /**
+@@ -2187,7 +2191,7 @@ lpfc_dss_show(struct device *dev, struct
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
++      return scnprintf(buf, PAGE_SIZE, "%s - %sOperational\n",
+                       (phba->cfg_enable_dss) ? "Enabled" : "Disabled",
+                       (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ?
+                               "" : "Not ");
+@@ -2216,7 +2220,7 @@ lpfc_sriov_hw_max_virtfn_show(struct dev
+       uint16_t max_nr_virtfn;
+       max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba);
+-      return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
+ }
+ static inline bool lpfc_rangecheck(uint val, uint min, uint max)
+@@ -2276,7 +2280,7 @@ lpfc_##attr##_show(struct device *dev, s
+       struct Scsi_Host  *shost = class_to_shost(dev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+       struct lpfc_hba   *phba = vport->phba;\
+-      return snprintf(buf, PAGE_SIZE, "%d\n",\
++      return scnprintf(buf, PAGE_SIZE, "%d\n",\
+                       phba->cfg_##attr);\
+ }
+@@ -2304,7 +2308,7 @@ lpfc_##attr##_show(struct device *dev, s
+       struct lpfc_hba   *phba = vport->phba;\
+       uint val = 0;\
+       val = phba->cfg_##attr;\
+-      return snprintf(buf, PAGE_SIZE, "%#x\n",\
++      return scnprintf(buf, PAGE_SIZE, "%#x\n",\
+                       phba->cfg_##attr);\
+ }
+@@ -2440,7 +2444,7 @@ lpfc_##attr##_show(struct device *dev, s
+ { \
+       struct Scsi_Host  *shost = class_to_shost(dev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+-      return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
++      return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
+ }
+ /**
+@@ -2465,7 +2469,7 @@ lpfc_##attr##_show(struct device *dev, s
+ { \
+       struct Scsi_Host  *shost = class_to_shost(dev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+-      return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
++      return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
+ }
+ /**
+@@ -2736,7 +2740,7 @@ lpfc_soft_wwpn_show(struct device *dev,
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+-      return snprintf(buf, PAGE_SIZE, "0x%llx\n",
++      return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
+                       (unsigned long long)phba->cfg_soft_wwpn);
+ }
+@@ -2833,7 +2837,7 @@ lpfc_soft_wwnn_show(struct device *dev,
+ {
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "0x%llx\n",
++      return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
+                       (unsigned long long)phba->cfg_soft_wwnn);
+ }
+@@ -2899,7 +2903,7 @@ lpfc_oas_tgt_show(struct device *dev, st
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "0x%llx\n",
++      return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
+                       wwn_to_u64(phba->cfg_oas_tgt_wwpn));
+ }
+@@ -2967,7 +2971,7 @@ lpfc_oas_priority_show(struct device *de
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority);
+ }
+ /**
+@@ -3030,7 +3034,7 @@ lpfc_oas_vpt_show(struct device *dev, st
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "0x%llx\n",
++      return scnprintf(buf, PAGE_SIZE, "0x%llx\n",
+                       wwn_to_u64(phba->cfg_oas_vpt_wwpn));
+ }
+@@ -3101,7 +3105,7 @@ lpfc_oas_lun_state_show(struct device *d
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state);
+ }
+ /**
+@@ -3165,7 +3169,7 @@ lpfc_oas_lun_status_show(struct device *
+       if (!(phba->cfg_oas_flags & OAS_LUN_VALID))
+               return -EFAULT;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status);
+ }
+ static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO,
+                  lpfc_oas_lun_status_show, NULL);
+@@ -3317,7 +3321,7 @@ lpfc_oas_lun_show(struct device *dev, st
+       if (oas_lun != NOT_OAS_ENABLED_LUN)
+               phba->cfg_oas_flags |= OAS_LUN_VALID;
+-      len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
++      len += scnprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun);
+       return len;
+ }
+@@ -3451,7 +3455,7 @@ lpfc_iocb_hw_show(struct device *dev, st
+       struct Scsi_Host  *shost = class_to_shost(dev);
+       struct lpfc_hba   *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
++      return scnprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max);
+ }
+ static DEVICE_ATTR(iocb_hw, S_IRUGO,
+@@ -3463,7 +3467,7 @@ lpfc_txq_hw_show(struct device *dev, str
+       struct lpfc_hba   *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
+       struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
+-      return snprintf(buf, PAGE_SIZE, "%d\n",
++      return scnprintf(buf, PAGE_SIZE, "%d\n",
+                       pring ? pring->txq_max : 0);
+ }
+@@ -3477,7 +3481,7 @@ lpfc_txcmplq_hw_show(struct device *dev,
+       struct lpfc_hba   *phba = ((struct lpfc_vport *) shost->hostdata)->phba;
+       struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba);
+-      return snprintf(buf, PAGE_SIZE, "%d\n",
++      return scnprintf(buf, PAGE_SIZE, "%d\n",
+                       pring ? pring->txcmplq_max : 0);
+ }
+@@ -3513,7 +3517,7 @@ lpfc_nodev_tmo_show(struct device *dev,
+       struct Scsi_Host  *shost = class_to_shost(dev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+-      return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
++      return scnprintf(buf, PAGE_SIZE, "%d\n",        vport->cfg_devloss_tmo);
+ }
+ /**
+@@ -5016,19 +5020,19 @@ lpfc_fcp_cpu_map_show(struct device *dev
+       switch (phba->cfg_fcp_cpu_map) {
+       case 0:
+-              len += snprintf(buf + len, PAGE_SIZE-len,
++              len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "fcp_cpu_map: No mapping (%d)\n",
+                               phba->cfg_fcp_cpu_map);
+               return len;
+       case 1:
+-              len += snprintf(buf + len, PAGE_SIZE-len,
++              len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "fcp_cpu_map: HBA centric mapping (%d): "
+                               "%d online CPUs\n",
+                               phba->cfg_fcp_cpu_map,
+                               phba->sli4_hba.num_online_cpu);
+               break;
+       case 2:
+-              len += snprintf(buf + len, PAGE_SIZE-len,
++              len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "fcp_cpu_map: Driver centric mapping (%d): "
+                               "%d online CPUs\n",
+                               phba->cfg_fcp_cpu_map,
+@@ -5041,14 +5045,14 @@ lpfc_fcp_cpu_map_show(struct device *dev
+               /* margin should fit in this and the truncated message */
+               if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                                       "CPU %02d io_chan %02d "
+                                       "physid %d coreid %d\n",
+                                       phba->sli4_hba.curr_disp_cpu,
+                                       cpup->channel_id, cpup->phys_id,
+                                       cpup->core_id);
+               else
+-                      len += snprintf(buf + len, PAGE_SIZE-len,
++                      len += scnprintf(buf + len, PAGE_SIZE-len,
+                                       "CPU %02d io_chan %02d "
+                                       "physid %d coreid %d IRQ %d\n",
+                                       phba->sli4_hba.curr_disp_cpu,
+@@ -5061,7 +5065,7 @@ lpfc_fcp_cpu_map_show(struct device *dev
+               if (phba->sli4_hba.curr_disp_cpu <
+                               phba->sli4_hba.num_present_cpu &&
+                               (len >= (PAGE_SIZE - 64))) {
+-                      len += snprintf(buf + len, PAGE_SIZE-len, "more...\n");
++                      len += scnprintf(buf + len, PAGE_SIZE-len, "more...\n");
+                       break;
+               }
+       }
+@@ -5586,10 +5590,10 @@ lpfc_sg_seg_cnt_show(struct device *dev,
+       struct lpfc_hba   *phba = vport->phba;
+       int len;
+-      len = snprintf(buf, PAGE_SIZE, "SGL sz: %d  total SGEs: %d\n",
++      len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d  total SGEs: %d\n",
+                      phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt);
+-      len += snprintf(buf + len, PAGE_SIZE, "Cfg: %d  SCSI: %d  NVME: %d\n",
++      len += scnprintf(buf + len, PAGE_SIZE, "Cfg: %d  SCSI: %d  NVME: %d\n",
+                       phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt,
+                       phba->cfg_nvme_seg_cnt);
+       return len;
+@@ -6586,7 +6590,7 @@ lpfc_show_rport_##field (struct device *
+ {                                                                     \
+       struct fc_rport *rport = transport_class_to_rport(dev);         \
+       struct lpfc_rport_data *rdata = rport->hostdata;                \
+-      return snprintf(buf, sz, format_string,                         \
++      return scnprintf(buf, sz, format_string,                        \
+               (rdata->target) ? cast rdata->target->field : 0);       \
+ }
+--- a/drivers/scsi/lpfc/lpfc_ct.c
++++ b/drivers/scsi/lpfc/lpfc_ct.c
+@@ -1430,7 +1430,7 @@ lpfc_vport_symbolic_port_name(struct lpf
+        * Name object.  NPIV is not in play so this integer
+        * value is sufficient and unique per FC-ID.
+        */
+-      n = snprintf(symbol, size, "%d", vport->phba->brd_no);
++      n = scnprintf(symbol, size, "%d", vport->phba->brd_no);
+       return n;
+ }
+@@ -1444,26 +1444,26 @@ lpfc_vport_symbolic_node_name(struct lpf
+       lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
+-      n = snprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
++      n = scnprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
+       if (size < n)
+               return n;
+-      n += snprintf(symbol + n, size - n, " FV%s", fwrev);
++      n += scnprintf(symbol + n, size - n, " FV%s", fwrev);
+       if (size < n)
+               return n;
+-      n += snprintf(symbol + n, size - n, " DV%s.",
++      n += scnprintf(symbol + n, size - n, " DV%s.",
+                     lpfc_release_version);
+       if (size < n)
+               return n;
+-      n += snprintf(symbol + n, size - n, " HN:%s.",
++      n += scnprintf(symbol + n, size - n, " HN:%s.",
+                     init_utsname()->nodename);
+       if (size < n)
+               return n;
+       /* Note :- OS name is "Linux" */
+-      n += snprintf(symbol + n, size - n, " OS:%s\n",
++      n += scnprintf(symbol + n, size - n, " OS:%s\n",
+                     init_utsname()->sysname);
+       return n;
+ }
+--- a/drivers/scsi/lpfc/lpfc_debugfs.c
++++ b/drivers/scsi/lpfc/lpfc_debugfs.c
+@@ -170,7 +170,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_v
+               snprintf(buffer,
+                       LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
+                       dtp->seq_cnt, ms, dtp->fmt);
+-              len +=  snprintf(buf+len, size-len, buffer,
++              len +=  scnprintf(buf+len, size-len, buffer,
+                       dtp->data1, dtp->data2, dtp->data3);
+       }
+       for (i = 0; i < index; i++) {
+@@ -181,7 +181,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_v
+               snprintf(buffer,
+                       LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
+                       dtp->seq_cnt, ms, dtp->fmt);
+-              len +=  snprintf(buf+len, size-len, buffer,
++              len +=  scnprintf(buf+len, size-len, buffer,
+                       dtp->data1, dtp->data2, dtp->data3);
+       }
+@@ -236,7 +236,7 @@ lpfc_debugfs_slow_ring_trc_data(struct l
+               snprintf(buffer,
+                       LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
+                       dtp->seq_cnt, ms, dtp->fmt);
+-              len +=  snprintf(buf+len, size-len, buffer,
++              len +=  scnprintf(buf+len, size-len, buffer,
+                       dtp->data1, dtp->data2, dtp->data3);
+       }
+       for (i = 0; i < index; i++) {
+@@ -247,7 +247,7 @@ lpfc_debugfs_slow_ring_trc_data(struct l
+               snprintf(buffer,
+                       LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
+                       dtp->seq_cnt, ms, dtp->fmt);
+-              len +=  snprintf(buf+len, size-len, buffer,
++              len +=  scnprintf(buf+len, size-len, buffer,
+                       dtp->data1, dtp->data2, dtp->data3);
+       }
+@@ -307,7 +307,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb
+       i = lpfc_debugfs_last_hbq;
+-      len +=  snprintf(buf+len, size-len, "HBQ %d Info\n", i);
++      len +=  scnprintf(buf+len, size-len, "HBQ %d Info\n", i);
+       hbqs =  &phba->hbqs[i];
+       posted = 0;
+@@ -315,21 +315,21 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb
+               posted++;
+       hip =  lpfc_hbq_defs[i];
+-      len +=  snprintf(buf+len, size-len,
++      len +=  scnprintf(buf+len, size-len,
+               "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
+               hip->hbq_index, hip->profile, hip->rn,
+               hip->buffer_count, hip->init_count, hip->add_count, posted);
+       raw_index = phba->hbq_get[i];
+       getidx = le32_to_cpu(raw_index);
+-      len +=  snprintf(buf+len, size-len,
++      len +=  scnprintf(buf+len, size-len,
+               "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
+               hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
+               hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
+       hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
+       for (j=0; j<hbqs->entry_count; j++) {
+-              len +=  snprintf(buf+len, size-len,
++              len +=  scnprintf(buf+len, size-len,
+                       "%03d: %08x %04x %05x ", j,
+                       le32_to_cpu(hbqe->bde.addrLow),
+                       le32_to_cpu(hbqe->bde.tus.w),
+@@ -341,14 +341,16 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb
+               low = hbqs->hbqPutIdx - posted;
+               if (low >= 0) {
+                       if ((j >= hbqs->hbqPutIdx) || (j < low)) {
+-                              len +=  snprintf(buf+len, size-len, "Unused\n");
++                              len +=  scnprintf(buf + len, size - len,
++                                              "Unused\n");
+                               goto skipit;
+                       }
+               }
+               else {
+                       if ((j >= hbqs->hbqPutIdx) &&
+                               (j < (hbqs->entry_count+low))) {
+-                              len +=  snprintf(buf+len, size-len, "Unused\n");
++                              len +=  scnprintf(buf + len, size - len,
++                                              "Unused\n");
+                               goto skipit;
+                       }
+               }
+@@ -358,7 +360,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb
+                       hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
+                       phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
+                       if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
+-                              len +=  snprintf(buf+len, size-len,
++                              len +=  scnprintf(buf+len, size-len,
+                                       "Buf%d: %p %06x\n", i,
+                                       hbq_buf->dbuf.virt, hbq_buf->tag);
+                               found = 1;
+@@ -367,7 +369,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb
+                       i++;
+               }
+               if (!found) {
+-                      len +=  snprintf(buf+len, size-len, "No DMAinfo?\n");
++                      len +=  scnprintf(buf+len, size-len, "No DMAinfo?\n");
+               }
+ skipit:
+               hbqe++;
+@@ -413,7 +415,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpf
+       off = 0;
+       spin_lock_irq(&phba->hbalock);
+-      len +=  snprintf(buf+len, size-len, "HBA SLIM\n");
++      len +=  scnprintf(buf+len, size-len, "HBA SLIM\n");
+       lpfc_memcpy_from_slim(buffer,
+               phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024);
+@@ -427,7 +429,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpf
+       i = 1024;
+       while (i > 0) {
+-              len +=  snprintf(buf+len, size-len,
++              len +=  scnprintf(buf+len, size-len,
+               "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
+               off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
+               *(ptr+5), *(ptr+6), *(ptr+7));
+@@ -471,11 +473,11 @@ lpfc_debugfs_dumpHostSlim_data(struct lp
+       off = 0;
+       spin_lock_irq(&phba->hbalock);
+-      len +=  snprintf(buf+len, size-len, "SLIM Mailbox\n");
++      len +=  scnprintf(buf+len, size-len, "SLIM Mailbox\n");
+       ptr = (uint32_t *)phba->slim2p.virt;
+       i = sizeof(MAILBOX_t);
+       while (i > 0) {
+-              len +=  snprintf(buf+len, size-len,
++              len +=  scnprintf(buf+len, size-len,
+               "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
+               off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
+               *(ptr+5), *(ptr+6), *(ptr+7));
+@@ -484,11 +486,11 @@ lpfc_debugfs_dumpHostSlim_data(struct lp
+               off += (8 * sizeof(uint32_t));
+       }
+-      len +=  snprintf(buf+len, size-len, "SLIM PCB\n");
++      len +=  scnprintf(buf+len, size-len, "SLIM PCB\n");
+       ptr = (uint32_t *)phba->pcb;
+       i = sizeof(PCB_t);
+       while (i > 0) {
+-              len +=  snprintf(buf+len, size-len,
++              len +=  scnprintf(buf+len, size-len,
+               "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
+               off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
+               *(ptr+5), *(ptr+6), *(ptr+7));
+@@ -501,7 +503,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lp
+               for (i = 0; i < 4; i++) {
+                       pgpp = &phba->port_gp[i];
+                       pring = &psli->sli3_ring[i];
+-                      len +=  snprintf(buf+len, size-len,
++                      len +=  scnprintf(buf+len, size-len,
+                                        "Ring %d: CMD GetInx:%d "
+                                        "(Max:%d Next:%d "
+                                        "Local:%d flg:x%x)  "
+@@ -518,7 +520,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lp
+               word1 = readl(phba->CAregaddr);
+               word2 = readl(phba->HSregaddr);
+               word3 = readl(phba->HCregaddr);
+-              len +=  snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
++              len +=  scnprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
+                                "HC:%08x\n", word0, word1, word2, word3);
+       }
+       spin_unlock_irq(&phba->hbalock);
+@@ -556,12 +558,12 @@ lpfc_debugfs_nodelist_data(struct lpfc_v
+       cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
+       outio = 0;
+-      len += snprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
++      len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
+       spin_lock_irq(shost->host_lock);
+       list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
+               iocnt = 0;
+               if (!cnt) {
+-                      len +=  snprintf(buf+len, size-len,
++                      len +=  scnprintf(buf+len, size-len,
+                               "Missing Nodelist Entries\n");
+                       break;
+               }
+@@ -599,63 +601,63 @@ lpfc_debugfs_nodelist_data(struct lpfc_v
+               default:
+                       statep = "UNKNOWN";
+               }
+-              len += snprintf(buf+len, size-len, "%s DID:x%06x ",
++              len += scnprintf(buf+len, size-len, "%s DID:x%06x ",
+                               statep, ndlp->nlp_DID);
+-              len += snprintf(buf+len, size-len,
++              len += scnprintf(buf+len, size-len,
+                               "WWPN x%llx ",
+                               wwn_to_u64(ndlp->nlp_portname.u.wwn));
+-              len += snprintf(buf+len, size-len,
++              len += scnprintf(buf+len, size-len,
+                               "WWNN x%llx ",
+                               wwn_to_u64(ndlp->nlp_nodename.u.wwn));
+               if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
+-                      len += snprintf(buf+len, size-len, "RPI:%03d ",
++                      len += scnprintf(buf+len, size-len, "RPI:%03d ",
+                                       ndlp->nlp_rpi);
+               else
+-                      len += snprintf(buf+len, size-len, "RPI:none ");
+-              len +=  snprintf(buf+len, size-len, "flag:x%08x ",
++                      len += scnprintf(buf+len, size-len, "RPI:none ");
++              len +=  scnprintf(buf+len, size-len, "flag:x%08x ",
+                       ndlp->nlp_flag);
+               if (!ndlp->nlp_type)
+-                      len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
++                      len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
+               if (ndlp->nlp_type & NLP_FC_NODE)
+-                      len += snprintf(buf+len, size-len, "FC_NODE ");
++                      len += scnprintf(buf+len, size-len, "FC_NODE ");
+               if (ndlp->nlp_type & NLP_FABRIC) {
+-                      len += snprintf(buf+len, size-len, "FABRIC ");
++                      len += scnprintf(buf+len, size-len, "FABRIC ");
+                       iocnt = 0;
+               }
+               if (ndlp->nlp_type & NLP_FCP_TARGET)
+-                      len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
++                      len += scnprintf(buf+len, size-len, "FCP_TGT sid:%d ",
+                               ndlp->nlp_sid);
+               if (ndlp->nlp_type & NLP_FCP_INITIATOR)
+-                      len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
++                      len += scnprintf(buf+len, size-len, "FCP_INITIATOR ");
+               if (ndlp->nlp_type & NLP_NVME_TARGET)
+-                      len += snprintf(buf + len,
++                      len += scnprintf(buf + len,
+                                       size - len, "NVME_TGT sid:%d ",
+                                       NLP_NO_SID);
+               if (ndlp->nlp_type & NLP_NVME_INITIATOR)
+-                      len += snprintf(buf + len,
++                      len += scnprintf(buf + len,
+                                       size - len, "NVME_INITIATOR ");
+-              len += snprintf(buf+len, size-len, "usgmap:%x ",
++              len += scnprintf(buf+len, size-len, "usgmap:%x ",
+                       ndlp->nlp_usg_map);
+-              len += snprintf(buf+len, size-len, "refcnt:%x",
++              len += scnprintf(buf+len, size-len, "refcnt:%x",
+                       kref_read(&ndlp->kref));
+               if (iocnt) {
+                       i = atomic_read(&ndlp->cmd_pending);
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       " OutIO:x%x Qdepth x%x",
+                                       i, ndlp->cmd_qdepth);
+                       outio += i;
+               }
+-              len += snprintf(buf + len, size - len, "defer:%x ",
++              len += scnprintf(buf + len, size - len, "defer:%x ",
+                       ndlp->nlp_defer_did);
+-              len +=  snprintf(buf+len, size-len, "\n");
++              len +=  scnprintf(buf+len, size-len, "\n");
+       }
+       spin_unlock_irq(shost->host_lock);
+-      len += snprintf(buf + len, size - len,
++      len += scnprintf(buf + len, size - len,
+                       "\nOutstanding IO x%x\n",  outio);
+       if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) {
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "\nNVME Targetport Entry ...\n");
+               /* Port state is only one of two values for now. */
+@@ -663,18 +665,18 @@ lpfc_debugfs_nodelist_data(struct lpfc_v
+                       statep = "REGISTERED";
+               else
+                       statep = "INIT";
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "TGT WWNN x%llx WWPN x%llx State %s\n",
+                               wwn_to_u64(vport->fc_nodename.u.wwn),
+                               wwn_to_u64(vport->fc_portname.u.wwn),
+                               statep);
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "    Targetport DID x%06x\n",
+                               phba->targetport->port_id);
+               goto out_exit;
+       }
+-      len += snprintf(buf + len, size - len,
++      len += scnprintf(buf + len, size - len,
+                               "\nNVME Lport/Rport Entries ...\n");
+       localport = vport->localport;
+@@ -689,11 +691,11 @@ lpfc_debugfs_nodelist_data(struct lpfc_v
+       else
+               statep = "UNKNOWN ";
+-      len += snprintf(buf + len, size - len,
++      len += scnprintf(buf + len, size - len,
+                       "Lport DID x%06x PortState %s\n",
+                       localport->port_id, statep);
+-      len += snprintf(buf + len, size - len, "\tRport List:\n");
++      len += scnprintf(buf + len, size - len, "\tRport List:\n");
+       list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
+               /* local short-hand pointer. */
+               spin_lock(&phba->hbalock);
+@@ -720,32 +722,32 @@ lpfc_debugfs_nodelist_data(struct lpfc_v
+               }
+               /* Tab in to show lport ownership. */
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "\t%s Port ID:x%06x ",
+                               statep, nrport->port_id);
+-              len += snprintf(buf + len, size - len, "WWPN x%llx ",
++              len += scnprintf(buf + len, size - len, "WWPN x%llx ",
+                               nrport->port_name);
+-              len += snprintf(buf + len, size - len, "WWNN x%llx ",
++              len += scnprintf(buf + len, size - len, "WWNN x%llx ",
+                               nrport->node_name);
+               /* An NVME rport can have multiple roles. */
+               if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
+-                      len +=  snprintf(buf + len, size - len,
++                      len +=  scnprintf(buf + len, size - len,
+                                        "INITIATOR ");
+               if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
+-                      len +=  snprintf(buf + len, size - len,
++                      len +=  scnprintf(buf + len, size - len,
+                                        "TARGET ");
+               if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
+-                      len +=  snprintf(buf + len, size - len,
++                      len +=  scnprintf(buf + len, size - len,
+                                        "DISCSRVC ");
+               if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
+                                         FC_PORT_ROLE_NVME_TARGET |
+                                         FC_PORT_ROLE_NVME_DISCOVERY))
+-                      len +=  snprintf(buf + len, size - len,
++                      len +=  scnprintf(buf + len, size - len,
+                                        "UNKNOWN ROLE x%x",
+                                        nrport->port_role);
+               /* Terminate the string. */
+-              len +=  snprintf(buf + len, size - len, "\n");
++              len +=  scnprintf(buf + len, size - len, "\n");
+       }
+       spin_unlock_irq(shost->host_lock);
+@@ -784,35 +786,35 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+               if (!phba->targetport)
+                       return len;
+               tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "\nNVME Targetport Statistics\n");
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "LS: Rcv %08x Drop %08x Abort %08x\n",
+                               atomic_read(&tgtp->rcv_ls_req_in),
+                               atomic_read(&tgtp->rcv_ls_req_drop),
+                               atomic_read(&tgtp->xmt_ls_abort));
+               if (atomic_read(&tgtp->rcv_ls_req_in) !=
+                   atomic_read(&tgtp->rcv_ls_req_out)) {
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Rcv LS: in %08x != out %08x\n",
+                                       atomic_read(&tgtp->rcv_ls_req_in),
+                                       atomic_read(&tgtp->rcv_ls_req_out));
+               }
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "LS: Xmt %08x Drop %08x Cmpl %08x\n",
+                               atomic_read(&tgtp->xmt_ls_rsp),
+                               atomic_read(&tgtp->xmt_ls_drop),
+                               atomic_read(&tgtp->xmt_ls_rsp_cmpl));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "LS: RSP Abort %08x xb %08x Err %08x\n",
+                               atomic_read(&tgtp->xmt_ls_rsp_aborted),
+                               atomic_read(&tgtp->xmt_ls_rsp_xb_set),
+                               atomic_read(&tgtp->xmt_ls_rsp_error));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP: Rcv %08x Defer %08x Release %08x "
+                               "Drop %08x\n",
+                               atomic_read(&tgtp->rcv_fcp_cmd_in),
+@@ -822,13 +824,13 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+               if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
+                   atomic_read(&tgtp->rcv_fcp_cmd_out)) {
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Rcv FCP: in %08x != out %08x\n",
+                                       atomic_read(&tgtp->rcv_fcp_cmd_in),
+                                       atomic_read(&tgtp->rcv_fcp_cmd_out));
+               }
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP Rsp: read %08x readrsp %08x "
+                               "write %08x rsp %08x\n",
+                               atomic_read(&tgtp->xmt_fcp_read),
+@@ -836,31 +838,31 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+                               atomic_read(&tgtp->xmt_fcp_write),
+                               atomic_read(&tgtp->xmt_fcp_rsp));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
+                               atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
+                               atomic_read(&tgtp->xmt_fcp_rsp_error),
+                               atomic_read(&tgtp->xmt_fcp_rsp_drop));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP Rsp Abort: %08x xb %08x xricqe  %08x\n",
+                               atomic_read(&tgtp->xmt_fcp_rsp_aborted),
+                               atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
+                               atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "ABORT: Xmt %08x Cmpl %08x\n",
+                               atomic_read(&tgtp->xmt_fcp_abort),
+                               atomic_read(&tgtp->xmt_fcp_abort_cmpl));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "ABORT: Sol %08x  Usol %08x Err %08x Cmpl %08x",
+                               atomic_read(&tgtp->xmt_abort_sol),
+                               atomic_read(&tgtp->xmt_abort_unsol),
+                               atomic_read(&tgtp->xmt_abort_rsp),
+                               atomic_read(&tgtp->xmt_abort_rsp_error));
+-              len +=  snprintf(buf + len, size - len, "\n");
++              len +=  scnprintf(buf + len, size - len, "\n");
+               cnt = 0;
+               spin_lock(&phba->sli4_hba.abts_nvme_buf_list_lock);
+@@ -871,7 +873,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+               }
+               spin_unlock(&phba->sli4_hba.abts_nvme_buf_list_lock);
+               if (cnt) {
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "ABORT: %d ctx entries\n", cnt);
+                       spin_lock(&phba->sli4_hba.abts_nvme_buf_list_lock);
+                       list_for_each_entry_safe(ctxp, next_ctxp,
+@@ -879,7 +881,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+                                   list) {
+                               if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ))
+                                       break;
+-                              len += snprintf(buf + len, size - len,
++                              len += scnprintf(buf + len, size - len,
+                                               "Entry: oxid %x state %x "
+                                               "flag %x\n",
+                                               ctxp->oxid, ctxp->state,
+@@ -893,7 +895,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+               tot += atomic_read(&tgtp->xmt_fcp_release);
+               tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "IO_CTX: %08x  WAIT: cur %08x tot %08x\n"
+                               "CTX Outstanding %08llx\n",
+                               phba->sli4_hba.nvmet_xri_cnt,
+@@ -911,10 +913,10 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+               if (!lport)
+                       return len;
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "\nNVME Lport Statistics\n");
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "LS: Xmt %016x Cmpl %016x\n",
+                               atomic_read(&lport->fc4NvmeLsRequests),
+                               atomic_read(&lport->fc4NvmeLsCmpls));
+@@ -938,20 +940,20 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+                       if (i >= 32)
+                               continue;
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                                       "FCP (%d): Rd %016llx Wr %016llx "
+                                       "IO %016llx ",
+                                       i, data1, data2, data3);
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                                       "Cmpl %016llx OutIO %016llx\n",
+                                       tot, ((data1 + data2 + data3) - tot));
+               }
+-              len += snprintf(buf + len, PAGE_SIZE - len,
++              len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "Total FCP Cmpl %016llx Issue %016llx "
+                               "OutIO %016llx\n",
+                               totin, totout, totout - totin);
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "LS Xmt Err: Abrt %08x Err %08x  "
+                               "Cmpl Err: xb %08x Err %08x\n",
+                               atomic_read(&lport->xmt_ls_abort),
+@@ -959,7 +961,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+                               atomic_read(&lport->cmpl_ls_xb),
+                               atomic_read(&lport->cmpl_ls_err));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP Xmt Err: noxri %06x nondlp %06x "
+                               "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
+                               atomic_read(&lport->xmt_fcp_noxri),
+@@ -969,7 +971,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_v
+                               atomic_read(&lport->xmt_fcp_err),
+                               atomic_read(&lport->xmt_fcp_abort));
+-              len += snprintf(buf + len, size - len,
++              len += scnprintf(buf + len, size - len,
+                               "FCP Cmpl Err: xb %08x Err %08x\n",
+                               atomic_read(&lport->cmpl_fcp_xb),
+                               atomic_read(&lport->cmpl_fcp_err));
+@@ -1001,58 +1003,58 @@ lpfc_debugfs_nvmektime_data(struct lpfc_
+       if (phba->nvmet_support == 0) {
+               /* NVME Initiator */
+-              len += snprintf(buf + len, PAGE_SIZE - len,
++              len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "ktime %s: Total Samples: %lld\n",
+                               (phba->ktime_on ?  "Enabled" : "Disabled"),
+                               phba->ktime_data_samples);
+               if (phba->ktime_data_samples == 0)
+                       return len;
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "Segment 1: Last NVME Cmd cmpl "
+                       "done -to- Start of next NVME cnd (in driver)\n");
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg1_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg1_min,
+                       phba->ktime_seg1_max);
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "Segment 2: Driver start of NVME cmd "
+                       "-to- Firmware WQ doorbell\n");
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg2_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg2_min,
+                       phba->ktime_seg2_max);
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "Segment 3: Firmware WQ doorbell -to- "
+                       "MSI-X ISR cmpl\n");
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg3_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg3_min,
+                       phba->ktime_seg3_max);
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "Segment 4: MSI-X ISR cmpl -to- "
+                       "NVME cmpl done\n");
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg4_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg4_min,
+                       phba->ktime_seg4_max);
+-              len += snprintf(
++              len += scnprintf(
+                       buf + len, PAGE_SIZE - len,
+                       "Total IO avg time: %08lld\n",
+                       div_u64(phba->ktime_seg1_total +
+@@ -1064,7 +1066,7 @@ lpfc_debugfs_nvmektime_data(struct lpfc_
+       }
+       /* NVME Target */
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "ktime %s: Total Samples: %lld %lld\n",
+                       (phba->ktime_on ? "Enabled" : "Disabled"),
+                       phba->ktime_data_samples,
+@@ -1072,46 +1074,46 @@ lpfc_debugfs_nvmektime_data(struct lpfc_
+       if (phba->ktime_data_samples == 0)
+               return len;
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 1: MSI-X ISR Rcv cmd -to- "
+                       "cmd pass to NVME Layer\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg1_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg1_min,
+                       phba->ktime_seg1_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 2: cmd pass to NVME Layer- "
+                       "-to- Driver rcv cmd OP (action)\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg2_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg2_min,
+                       phba->ktime_seg2_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 3: Driver rcv cmd OP -to- "
+                       "Firmware WQ doorbell: cmd\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg3_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg3_min,
+                       phba->ktime_seg3_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 4: Firmware WQ doorbell: cmd "
+                       "-to- MSI-X ISR for cmd cmpl\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg4_total,
+                               phba->ktime_data_samples),
+                       phba->ktime_seg4_min,
+                       phba->ktime_seg4_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 5: MSI-X ISR for cmd cmpl "
+                       "-to- NVME layer passed cmd done\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg5_total,
+                               phba->ktime_data_samples),
+@@ -1119,10 +1121,10 @@ lpfc_debugfs_nvmektime_data(struct lpfc_
+                       phba->ktime_seg5_max);
+       if (phba->ktime_status_samples == 0) {
+-              len += snprintf(buf + len, PAGE_SIZE-len,
++              len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "Total: cmd received by MSI-X ISR "
+                               "-to- cmd completed on wire\n");
+-              len += snprintf(buf + len, PAGE_SIZE-len,
++              len += scnprintf(buf + len, PAGE_SIZE-len,
+                               "avg:%08lld min:%08lld "
+                               "max %08lld\n",
+                               div_u64(phba->ktime_seg10_total,
+@@ -1132,46 +1134,46 @@ lpfc_debugfs_nvmektime_data(struct lpfc_
+               return len;
+       }
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 6: NVME layer passed cmd done "
+                       "-to- Driver rcv rsp status OP\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg6_total,
+                               phba->ktime_status_samples),
+                       phba->ktime_seg6_min,
+                       phba->ktime_seg6_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 7: Driver rcv rsp status OP "
+                       "-to- Firmware WQ doorbell: status\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg7_total,
+                               phba->ktime_status_samples),
+                       phba->ktime_seg7_min,
+                       phba->ktime_seg7_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 8: Firmware WQ doorbell: status"
+                       " -to- MSI-X ISR for status cmpl\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg8_total,
+                               phba->ktime_status_samples),
+                       phba->ktime_seg8_min,
+                       phba->ktime_seg8_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Segment 9: MSI-X ISR for status cmpl  "
+                       "-to- NVME layer passed status done\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg9_total,
+                               phba->ktime_status_samples),
+                       phba->ktime_seg9_min,
+                       phba->ktime_seg9_max);
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "Total: cmd received by MSI-X ISR -to- "
+                       "cmd completed on wire\n");
+-      len += snprintf(buf + len, PAGE_SIZE-len,
++      len += scnprintf(buf + len, PAGE_SIZE-len,
+                       "avg:%08lld min:%08lld max %08lld\n",
+                       div_u64(phba->ktime_seg10_total,
+                               phba->ktime_status_samples),
+@@ -1206,7 +1208,7 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc
+               (phba->nvmeio_trc_size - 1);
+       skip = phba->nvmeio_trc_output_idx;
+-      len += snprintf(buf + len, size - len,
++      len += scnprintf(buf + len, size - len,
+                       "%s IO Trace %s: next_idx %d skip %d size %d\n",
+                       (phba->nvmet_support ? "NVME" : "NVMET"),
+                       (state ? "Enabled" : "Disabled"),
+@@ -1228,18 +1230,18 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc
+               if (!dtp->fmt)
+                       continue;
+-              len +=  snprintf(buf + len, size - len, dtp->fmt,
++              len +=  scnprintf(buf + len, size - len, dtp->fmt,
+                       dtp->data1, dtp->data2, dtp->data3);
+               if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
+                       phba->nvmeio_trc_output_idx = 0;
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Trace Complete\n");
+                       goto out;
+               }
+               if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Trace Continue (%d of %d)\n",
+                                       phba->nvmeio_trc_output_idx,
+                                       phba->nvmeio_trc_size);
+@@ -1257,18 +1259,18 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc
+               if (!dtp->fmt)
+                       continue;
+-              len +=  snprintf(buf + len, size - len, dtp->fmt,
++              len +=  scnprintf(buf + len, size - len, dtp->fmt,
+                       dtp->data1, dtp->data2, dtp->data3);
+               if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
+                       phba->nvmeio_trc_output_idx = 0;
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Trace Complete\n");
+                       goto out;
+               }
+               if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
+-                      len += snprintf(buf + len, size - len,
++                      len += scnprintf(buf + len, size - len,
+                                       "Trace Continue (%d of %d)\n",
+                                       phba->nvmeio_trc_output_idx,
+                                       phba->nvmeio_trc_size);
+@@ -1276,7 +1278,7 @@ lpfc_debugfs_nvmeio_trc_data(struct lpfc
+               }
+       }
+-      len += snprintf(buf + len, size - len,
++      len += scnprintf(buf + len, size - len,
+                       "Trace Done\n");
+ out:
+       return len;
+@@ -1308,39 +1310,39 @@ lpfc_debugfs_cpucheck_data(struct lpfc_v
+       if (phba->nvmet_support == 0) {
+               /* NVME Initiator */
+-              len += snprintf(buf + len, PAGE_SIZE - len,
++              len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "CPUcheck %s\n",
+                               (phba->cpucheck_on & LPFC_CHECK_NVME_IO ?
+                                       "Enabled" : "Disabled"));
+               for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
+                       if (i >= LPFC_CHECK_CPU_CNT)
+                               break;
+-                      len += snprintf(buf + len, PAGE_SIZE - len,
++                      len += scnprintf(buf + len, PAGE_SIZE - len,
+                                       "%02d: xmit x%08x cmpl x%08x\n",
+                                       i, phba->cpucheck_xmt_io[i],
+                                       phba->cpucheck_cmpl_io[i]);
+                       tot_xmt += phba->cpucheck_xmt_io[i];
+                       tot_cmpl += phba->cpucheck_cmpl_io[i];
+               }
+-              len += snprintf(buf + len, PAGE_SIZE - len,
++              len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "tot:xmit x%08x cmpl x%08x\n",
+                               tot_xmt, tot_cmpl);
+               return len;
+       }
+       /* NVME Target */
+-      len += snprintf(buf + len, PAGE_SIZE - len,
++      len += scnprintf(buf + len, PAGE_SIZE - len,
+                       "CPUcheck %s ",
+                       (phba->cpucheck_on & LPFC_CHECK_NVMET_IO ?
+                               "IO Enabled - " : "IO Disabled - "));
+-      len += snprintf(buf + len, PAGE_SIZE - len,
++      len += scnprintf(buf + len, PAGE_SIZE - len,
+                       "%s\n",
+                       (phba->cpucheck_on & LPFC_CHECK_NVMET_RCV ?
+                               "Rcv Enabled\n" : "Rcv Disabled\n"));
+       for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
+               if (i >= LPFC_CHECK_CPU_CNT)
+                       break;
+-              len += snprintf(buf + len, PAGE_SIZE - len,
++              len += scnprintf(buf + len, PAGE_SIZE - len,
+                               "%02d: xmit x%08x ccmpl x%08x "
+                               "cmpl x%08x rcv x%08x\n",
+                               i, phba->cpucheck_xmt_io[i],
+@@ -1352,7 +1354,7 @@ lpfc_debugfs_cpucheck_data(struct lpfc_v
+               tot_cmpl += phba->cpucheck_cmpl_io[i];
+               tot_ccmpl += phba->cpucheck_ccmpl_io[i];
+       }
+-      len += snprintf(buf + len, PAGE_SIZE - len,
++      len += scnprintf(buf + len, PAGE_SIZE - len,
+                       "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
+                       tot_xmt, tot_ccmpl, tot_cmpl, tot_rcv);
+       return len;
+@@ -1797,28 +1799,29 @@ lpfc_debugfs_dif_err_read(struct file *f
+       int cnt = 0;
+       if (dent == phba->debug_writeGuard)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
+       else if (dent == phba->debug_writeApp)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
+       else if (dent == phba->debug_writeRef)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
+       else if (dent == phba->debug_readGuard)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
+       else if (dent == phba->debug_readApp)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
+       else if (dent == phba->debug_readRef)
+-              cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
++              cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
+       else if (dent == phba->debug_InjErrNPortID)
+-              cnt = snprintf(cbuf, 32, "0x%06x\n", phba->lpfc_injerr_nportid);
++              cnt = scnprintf(cbuf, 32, "0x%06x\n",
++                              phba->lpfc_injerr_nportid);
+       else if (dent == phba->debug_InjErrWWPN) {
+               memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
+               tmp = cpu_to_be64(tmp);
+-              cnt = snprintf(cbuf, 32, "0x%016llx\n", tmp);
++              cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
+       } else if (dent == phba->debug_InjErrLBA) {
+               if (phba->lpfc_injerr_lba == (sector_t)(-1))
+-                      cnt = snprintf(cbuf, 32, "off\n");
++                      cnt = scnprintf(cbuf, 32, "off\n");
+               else
+-                      cnt = snprintf(cbuf, 32, "0x%llx\n",
++                      cnt = scnprintf(cbuf, 32, "0x%llx\n",
+                                (uint64_t) phba->lpfc_injerr_lba);
+       } else
+               lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+@@ -2624,17 +2627,17 @@ lpfc_idiag_pcicfg_read(struct file *file
+       switch (count) {
+       case SIZE_U8: /* byte (8 bits) */
+               pci_read_config_byte(pdev, where, &u8val);
+-              len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                               "%03x: %02x\n", where, u8val);
+               break;
+       case SIZE_U16: /* word (16 bits) */
+               pci_read_config_word(pdev, where, &u16val);
+-              len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                               "%03x: %04x\n", where, u16val);
+               break;
+       case SIZE_U32: /* double word (32 bits) */
+               pci_read_config_dword(pdev, where, &u32val);
+-              len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                               "%03x: %08x\n", where, u32val);
+               break;
+       case LPFC_PCI_CFG_BROWSE: /* browse all */
+@@ -2654,25 +2657,25 @@ pcicfg_browse:
+       offset = offset_label;
+       /* Read PCI config space */
+-      len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                       "%03x: ", offset_label);
+       while (index > 0) {
+               pci_read_config_dword(pdev, offset, &u32val);
+-              len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                               "%08x ", u32val);
+               offset += sizeof(uint32_t);
+               if (offset >= LPFC_PCI_CFG_SIZE) {
+-                      len += snprintf(pbuffer+len,
++                      len += scnprintf(pbuffer+len,
+                                       LPFC_PCI_CFG_SIZE-len, "\n");
+                       break;
+               }
+               index -= sizeof(uint32_t);
+               if (!index)
+-                      len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++                      len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                                       "\n");
+               else if (!(index % (8 * sizeof(uint32_t)))) {
+                       offset_label += (8 * sizeof(uint32_t));
+-                      len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
++                      len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
+                                       "\n%03x: ", offset_label);
+               }
+       }
+@@ -2943,7 +2946,7 @@ lpfc_idiag_baracc_read(struct file *file
+       if (acc_range == SINGLE_WORD) {
+               offset_run = offset;
+               u32val = readl(mem_mapped_bar + offset_run);
+-              len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
+                               "%05x: %08x\n", offset_run, u32val);
+       } else
+               goto baracc_browse;
+@@ -2957,35 +2960,35 @@ baracc_browse:
+       offset_run = offset_label;
+       /* Read PCI bar memory mapped space */
+-      len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
+                       "%05x: ", offset_label);
+       index = LPFC_PCI_BAR_RD_SIZE;
+       while (index > 0) {
+               u32val = readl(mem_mapped_bar + offset_run);
+-              len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
+                               "%08x ", u32val);
+               offset_run += sizeof(uint32_t);
+               if (acc_range == LPFC_PCI_BAR_BROWSE) {
+                       if (offset_run >= bar_size) {
+-                              len += snprintf(pbuffer+len,
++                              len += scnprintf(pbuffer+len,
+                                       LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
+                               break;
+                       }
+               } else {
+                       if (offset_run >= offset +
+                           (acc_range * sizeof(uint32_t))) {
+-                              len += snprintf(pbuffer+len,
++                              len += scnprintf(pbuffer+len,
+                                       LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
+                               break;
+                       }
+               }
+               index -= sizeof(uint32_t);
+               if (!index)
+-                      len += snprintf(pbuffer+len,
++                      len += scnprintf(pbuffer+len,
+                                       LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
+               else if (!(index % (8 * sizeof(uint32_t)))) {
+                       offset_label += (8 * sizeof(uint32_t));
+-                      len += snprintf(pbuffer+len,
++                      len += scnprintf(pbuffer+len,
+                                       LPFC_PCI_BAR_RD_BUF_SIZE-len,
+                                       "\n%05x: ", offset_label);
+               }
+@@ -3158,19 +3161,19 @@ __lpfc_idiag_print_wq(struct lpfc_queue
+       if (!qp)
+               return len;
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t\t%s WQ info: ", wqtype);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
+                       qp->assoc_qid, qp->q_cnt_1,
+                       (unsigned long long)qp->q_cnt_4);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
+                       "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
+                       qp->queue_id, qp->entry_count,
+                       qp->entry_size, qp->host_index,
+                       qp->hba_index, qp->entry_repost);
+-      len +=  snprintf(pbuffer + len,
++      len +=  scnprintf(pbuffer + len,
+                       LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
+       return len;
+ }
+@@ -3208,21 +3211,21 @@ __lpfc_idiag_print_cq(struct lpfc_queue
+       if (!qp)
+               return len;
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t%s CQ info: ", cqtype);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
+                       "xabt:x%x wq:x%llx]\n",
+                       qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
+                       qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
+                       "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
+                       qp->queue_id, qp->entry_count,
+                       qp->entry_size, qp->host_index,
+                       qp->hba_index, qp->entry_repost);
+-      len +=  snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
++      len +=  scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
+       return len;
+ }
+@@ -3234,19 +3237,19 @@ __lpfc_idiag_print_rqpair(struct lpfc_qu
+       if (!qp || !datqp)
+               return len;
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t\t%s RQ info: ", rqtype);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
+                       "posted:x%x rcv:x%llx]\n",
+                       qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
+                       qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
+                       "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
+                       qp->queue_id, qp->entry_count, qp->entry_size,
+                       qp->host_index, qp->hba_index, qp->entry_repost);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
+                       "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
+                       datqp->queue_id, datqp->entry_count,
+@@ -3331,17 +3334,17 @@ __lpfc_idiag_print_eq(struct lpfc_queue
+       if (!qp)
+               return len;
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
+                       "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
+                       eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3,
+                       (unsigned long long)qp->q_cnt_4, qp->q_mode);
+-      len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++      len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                       "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
+                       "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
+                       qp->queue_id, qp->entry_count, qp->entry_size,
+                       qp->host_index, qp->hba_index, qp->entry_repost);
+-      len +=  snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
++      len +=  scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
+       return len;
+ }
+@@ -3399,7 +3402,7 @@ lpfc_idiag_queinfo_read(struct file *fil
+                       if (phba->cfg_fof == 0)
+                               phba->lpfc_idiag_last_eq = 0;
+-              len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
++              len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
+                                       "EQ %d out of %d HBA EQs\n",
+                                       x, phba->io_channel_irqs);
+@@ -3512,7 +3515,7 @@ fof:
+       return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+ too_big:
+-      len +=  snprintf(pbuffer + len,
++      len +=  scnprintf(pbuffer + len,
+               LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
+ out:
+       spin_unlock_irq(&phba->hbalock);
+@@ -3568,22 +3571,22 @@ lpfc_idiag_queacc_read_qe(char *pbuffer,
+               return 0;
+       esize = pque->entry_size;
+-      len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
+                       "QE-INDEX[%04d]:\n", index);
+       offset = 0;
+       pentry = pque->qe[index].address;
+       while (esize > 0) {
+-              len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
+                               "%08x ", *pentry);
+               pentry++;
+               offset += sizeof(uint32_t);
+               esize -= sizeof(uint32_t);
+               if (esize > 0 && !(offset % (4 * sizeof(uint32_t))))
+-                      len += snprintf(pbuffer+len,
++                      len += scnprintf(pbuffer+len,
+                                       LPFC_QUE_ACC_BUF_SIZE-len, "\n");
+       }
+-      len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
++      len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
+       return len;
+ }
+@@ -3989,27 +3992,27 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_h
+       switch (drbregid) {
+       case LPFC_DRB_EQ:
+-              len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
+                               "EQ-DRB-REG: 0x%08x\n",
+                               readl(phba->sli4_hba.EQDBregaddr));
+               break;
+       case LPFC_DRB_CQ:
+-              len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
++              len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
+                               "CQ-DRB-REG: 0x%08x\n",
+                               readl(phba->sli4_hba.CQDBregaddr));
+               break;
+       case LPFC_DRB_MQ:
+-              len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
+                               "MQ-DRB-REG:   0x%08x\n",
+                               readl(phba->sli4_hba.MQDBregaddr));
+               break;
+       case LPFC_DRB_WQ:
+-              len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
+                               "WQ-DRB-REG:   0x%08x\n",
+                               readl(phba->sli4_hba.WQDBregaddr));
+               break;
+       case LPFC_DRB_RQ:
+-              len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
+                               "RQ-DRB-REG:   0x%08x\n",
+                               readl(phba->sli4_hba.RQDBregaddr));
+               break;
+@@ -4199,37 +4202,37 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_h
+       switch (ctlregid) {
+       case LPFC_CTL_PORT_SEM:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "Port SemReg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PORT_SEM_OFFSET));
+               break;
+       case LPFC_CTL_PORT_STA:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "Port StaReg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PORT_STA_OFFSET));
+               break;
+       case LPFC_CTL_PORT_CTL:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "Port CtlReg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PORT_CTL_OFFSET));
+               break;
+       case LPFC_CTL_PORT_ER1:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "Port Er1Reg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PORT_ER1_OFFSET));
+               break;
+       case LPFC_CTL_PORT_ER2:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "Port Er2Reg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PORT_ER2_OFFSET));
+               break;
+       case LPFC_CTL_PDEV_CTL:
+-              len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
+                               "PDev CtlReg:   0x%08x\n",
+                               readl(phba->sli4_hba.conf_regs_memmap_p +
+                                     LPFC_CTL_PDEV_CTL_OFFSET));
+@@ -4422,13 +4425,13 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_
+       mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
+       mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
+-      len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
+                       "mbx_dump_map: 0x%08x\n", mbx_dump_map);
+-      len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
+                       "mbx_dump_cnt: %04d\n", mbx_dump_cnt);
+-      len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
+                       "mbx_word_cnt: %04d\n", mbx_word_cnt);
+-      len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
+                       "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
+       return len;
+@@ -4577,35 +4580,35 @@ lpfc_idiag_extacc_avail_get(struct lpfc_
+ {
+       uint16_t ext_cnt, ext_size;
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\nAvailable Extents Information:\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tPort Available VPI extents: ");
+       lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI,
+                                      &ext_cnt, &ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "Count %3d, Size %3d\n", ext_cnt, ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tPort Available VFI extents: ");
+       lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI,
+                                      &ext_cnt, &ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "Count %3d, Size %3d\n", ext_cnt, ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tPort Available RPI extents: ");
+       lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI,
+                                      &ext_cnt, &ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "Count %3d, Size %3d\n", ext_cnt, ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tPort Available XRI extents: ");
+       lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI,
+                                      &ext_cnt, &ext_size);
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "Count %3d, Size %3d\n", ext_cnt, ext_size);
+       return len;
+@@ -4629,55 +4632,55 @@ lpfc_idiag_extacc_alloc_get(struct lpfc_
+       uint16_t ext_cnt, ext_size;
+       int rc;
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\nAllocated Extents Information:\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tHost Allocated VPI extents: ");
+       rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI,
+                                           &ext_cnt, &ext_size);
+       if (!rc)
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "Port %d Extent %3d, Size %3d\n",
+                               phba->brd_no, ext_cnt, ext_size);
+       else
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "N/A\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tHost Allocated VFI extents: ");
+       rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI,
+                                           &ext_cnt, &ext_size);
+       if (!rc)
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "Port %d Extent %3d, Size %3d\n",
+                               phba->brd_no, ext_cnt, ext_size);
+       else
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "N/A\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tHost Allocated RPI extents: ");
+       rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI,
+                                           &ext_cnt, &ext_size);
+       if (!rc)
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "Port %d Extent %3d, Size %3d\n",
+                               phba->brd_no, ext_cnt, ext_size);
+       else
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "N/A\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tHost Allocated XRI extents: ");
+       rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI,
+                                           &ext_cnt, &ext_size);
+       if (!rc)
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "Port %d Extent %3d, Size %3d\n",
+                               phba->brd_no, ext_cnt, ext_size);
+       else
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "N/A\n");
+       return len;
+@@ -4701,49 +4704,49 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_
+       struct lpfc_rsrc_blks *rsrc_blks;
+       int index;
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\nDriver Extents Information:\n");
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tVPI extents:\n");
+       index = 0;
+       list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) {
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "\t\tBlock %3d: Start %4d, Count %4d\n",
+                               index, rsrc_blks->rsrc_start,
+                               rsrc_blks->rsrc_size);
+               index++;
+       }
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tVFI extents:\n");
+       index = 0;
+       list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list,
+                           list) {
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "\t\tBlock %3d: Start %4d, Count %4d\n",
+                               index, rsrc_blks->rsrc_start,
+                               rsrc_blks->rsrc_size);
+               index++;
+       }
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tRPI extents:\n");
+       index = 0;
+       list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list,
+                           list) {
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "\t\tBlock %3d: Start %4d, Count %4d\n",
+                               index, rsrc_blks->rsrc_start,
+                               rsrc_blks->rsrc_size);
+               index++;
+       }
+-      len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++      len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                       "\tXRI extents:\n");
+       index = 0;
+       list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list,
+                           list) {
+-              len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
++              len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
+                               "\t\tBlock %3d: Start %4d, Count %4d\n",
+                               index, rsrc_blks->rsrc_start,
+                               rsrc_blks->rsrc_size);
+@@ -5137,11 +5140,11 @@ lpfc_idiag_mbxacc_dump_bsg_mbox(struct l
+                               if (i != 0)
+                                       pr_err("%s\n", line_buf);
+                               len = 0;
+-                              len += snprintf(line_buf+len,
++                              len += scnprintf(line_buf+len,
+                                               LPFC_MBX_ACC_LBUF_SZ-len,
+                                               "%03d: ", i);
+                       }
+-                      len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
++                      len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
+                                       "%08x ", (uint32_t)*pword);
+                       pword++;
+               }
+@@ -5204,11 +5207,11 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct
+                                       pr_err("%s\n", line_buf);
+                               len = 0;
+                               memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
+-                              len += snprintf(line_buf+len,
++                              len += scnprintf(line_buf+len,
+                                               LPFC_MBX_ACC_LBUF_SZ-len,
+                                               "%03d: ", i);
+                       }
+-                      len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
++                      len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
+                                       "%08x ",
+                                       ((uint32_t)*pword) & 0xffffffff);
+                       pword++;
+@@ -5227,18 +5230,18 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct
+                                       pr_err("%s\n", line_buf);
+                               len = 0;
+                               memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
+-                              len += snprintf(line_buf+len,
++                              len += scnprintf(line_buf+len,
+                                               LPFC_MBX_ACC_LBUF_SZ-len,
+                                               "%03d: ", i);
+                       }
+                       for (j = 0; j < 4; j++) {
+-                              len += snprintf(line_buf+len,
++                              len += scnprintf(line_buf+len,
+                                               LPFC_MBX_ACC_LBUF_SZ-len,
+                                               "%02x",
+                                               ((uint8_t)*pbyte) & 0xff);
+                               pbyte++;
+                       }
+-                      len += snprintf(line_buf+len,
++                      len += scnprintf(line_buf+len,
+                                       LPFC_MBX_ACC_LBUF_SZ-len, " ");
+               }
+               if ((i - 1) % 8)
+--- a/drivers/scsi/lpfc/lpfc_debugfs.h
++++ b/drivers/scsi/lpfc/lpfc_debugfs.h
+@@ -342,7 +342,7 @@ lpfc_debug_dump_qe(struct lpfc_queue *q,
+       pword = q->qe[idx].address;
+       len = 0;
+-      len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
++      len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
+       if (qe_word_cnt > 8)
+               printk(KERN_ERR "%s\n", line_buf);
+@@ -353,11 +353,11 @@ lpfc_debug_dump_qe(struct lpfc_queue *q,
+                       if (qe_word_cnt > 8) {
+                               len = 0;
+                               memset(line_buf, 0, LPFC_LBUF_SZ);
+-                              len += snprintf(line_buf+len, LPFC_LBUF_SZ-len,
++                              len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len,
+                                               "%03d: ", i);
+                       }
+               }
+-              len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
++              len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
+                               ((uint32_t)*pword) & 0xffffffff);
+               pword++;
+       }
diff --git a/queue-5.0/scsi-qla2xxx-fix-device-staying-in-blocked-state.patch b/queue-5.0/scsi-qla2xxx-fix-device-staying-in-blocked-state.patch
new file mode 100644 (file)
index 0000000..8b187ae
--- /dev/null
@@ -0,0 +1,49 @@
+From 2137490f2147a8d0799b72b9a1023efb012d40c7 Mon Sep 17 00:00:00 2001
+From: Quinn Tran <qtran@marvell.com>
+Date: Tue, 23 Apr 2019 14:52:35 -0700
+Subject: scsi: qla2xxx: Fix device staying in blocked state
+
+From: Quinn Tran <qtran@marvell.com>
+
+commit 2137490f2147a8d0799b72b9a1023efb012d40c7 upstream.
+
+This patch fixes issue reported by some of the customers, who discovered
+that after cable pull scenario the devices disappear and path seems to
+remain in blocked state. Once the device reappears, driver does not seem to
+update path to online. This issue appears because of the defer flag
+creating race condition where the same session reappears.  This patch fixes
+this issue by indicating SCSI-ML of device lost when
+qlt_free_session_done() is called from qlt_unreg_sess().
+
+Fixes: 41dc529a4602a ("qla2xxx: Improve RSCN handling in driver")
+Signed-off-by: Quinn Tran <qtran@marvell.com>
+Cc: stable@vger.kernel.org #4.19
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Ewan D. Milne <emilne@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/qla2xxx/qla_target.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -977,6 +977,8 @@ void qlt_free_session_done(struct work_s
+               sess->send_els_logo);
+       if (!IS_SW_RESV_ADDR(sess->d_id)) {
++              qla2x00_mark_device_lost(vha, sess, 0, 0);
++
+               if (sess->send_els_logo) {
+                       qlt_port_logo_t logo;
+@@ -1157,8 +1159,6 @@ void qlt_unreg_sess(struct fc_port *sess
+       if (sess->se_sess)
+               vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
+-      qla2x00_mark_device_lost(vha, sess, 0, 0);
+-
+       sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
+       sess->disc_state = DSC_DELETE_PEND;
+       sess->last_rscn_gen = sess->rscn_gen;
diff --git a/queue-5.0/scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs-routines.patch b/queue-5.0/scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs-routines.patch
new file mode 100644 (file)
index 0000000..17f94fe
--- /dev/null
@@ -0,0 +1,45 @@
+From 5cbdae10bf11f96e30b4d14de7b08c8b490e903c Mon Sep 17 00:00:00 2001
+From: Andrew Vasquez <andrewv@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:25 -0700
+Subject: scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines
+
+From: Andrew Vasquez <andrewv@marvell.com>
+
+commit 5cbdae10bf11f96e30b4d14de7b08c8b490e903c upstream.
+
+Commit e6f77540c067 ("scsi: qla2xxx: Fix an integer overflow in sysfs
+code") incorrectly set 'optrom_region_size' to 'start+size', which can
+overflow option-rom boundaries when 'start' is non-zero.  Continue setting
+optrom_region_size to the proper adjusted value of 'size'.
+
+Fixes: e6f77540c067 ("scsi: qla2xxx: Fix an integer overflow in sysfs code")
+Cc: stable@vger.kernel.org
+Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/qla2xxx/qla_attr.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -364,7 +364,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+               }
+               ha->optrom_region_start = start;
+-              ha->optrom_region_size = start + size;
++              ha->optrom_region_size = size;
+               ha->optrom_state = QLA_SREADING;
+               ha->optrom_buffer = vmalloc(ha->optrom_region_size);
+@@ -437,7 +437,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+               }
+               ha->optrom_region_start = start;
+-              ha->optrom_region_size = start + size;
++              ha->optrom_region_size = size;
+               ha->optrom_state = QLA_SWRITING;
+               ha->optrom_buffer = vmalloc(ha->optrom_region_size);
index 6974090a44fa478590620bef5ab51b84e0823138..ee2836463de181793ecb2586b3ab11a77b763883 100644 (file)
@@ -77,3 +77,15 @@ usb-serial-f81232-fix-interrupt-worker-not-stop.patch
 usb-cdc-acm-fix-unthrottle-races.patch
 usb-storage-set-virt_boundary_mask-to-avoid-sg-overflows.patch
 intel_th-pci-add-comet-lake-support.patch
+iio-adc-qcom-spmi-adc5-fix-of-based-module-autoloading.patch
+cpufreq-armada-37xx-fix-frequency-calculation-for-opp.patch
+acpi-lpss-use-acpi_lpss_-instead-of-acpi_subsys_-functions-for-hibernate.patch
+soc-sunxi-fix-missing-dependency-on-regmap_mmio.patch
+scsi-lpfc-change-snprintf-to-scnprintf-for-possible-overflow.patch
+scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs-routines.patch
+scsi-qla2xxx-fix-device-staying-in-blocked-state.patch
+bluetooth-hidp-fix-buffer-overflow.patch
+bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
+bluetooth-fix-not-initializing-l2cap-tx_credits.patch
+bluetooth-hci_bcm-fix-empty-regulator-supplies-for-intel-macs.patch
+uas-fix-alignment-of-scatter-gather-segments.patch
diff --git a/queue-5.0/soc-sunxi-fix-missing-dependency-on-regmap_mmio.patch b/queue-5.0/soc-sunxi-fix-missing-dependency-on-regmap_mmio.patch
new file mode 100644 (file)
index 0000000..abe84cd
--- /dev/null
@@ -0,0 +1,67 @@
+From a84014e1db35d8e7af09878d0b4bf30804fb17d5 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Tue, 30 Apr 2019 09:59:37 -0500
+Subject: soc: sunxi: Fix missing dependency on REGMAP_MMIO
+
+From: Samuel Holland <samuel@sholland.org>
+
+commit a84014e1db35d8e7af09878d0b4bf30804fb17d5 upstream.
+
+When enabling ARCH_SUNXI from allnoconfig, SUNXI_SRAM is enabled, but
+not REGMAP_MMIO, so the kernel fails to link with an undefined reference
+to __devm_regmap_init_mmio_clk. Select REGMAP_MMIO, as suggested in
+drivers/base/regmap/Kconfig.
+
+This creates the following dependency loop:
+
+  drivers/of/Kconfig:68:                symbol OF_IRQ depends on IRQ_DOMAIN
+  kernel/irq/Kconfig:63:                symbol IRQ_DOMAIN is selected by REGMAP
+  drivers/base/regmap/Kconfig:7:        symbol REGMAP default is visible depending on REGMAP_MMIO
+  drivers/base/regmap/Kconfig:39:       symbol REGMAP_MMIO is selected by SUNXI_SRAM
+  drivers/soc/sunxi/Kconfig:4:          symbol SUNXI_SRAM is selected by USB_MUSB_SUNXI
+  drivers/usb/musb/Kconfig:63:          symbol USB_MUSB_SUNXI depends on GENERIC_PHY
+  drivers/phy/Kconfig:7:                symbol GENERIC_PHY is selected by PHY_BCM_NS_USB3
+  drivers/phy/broadcom/Kconfig:29:      symbol PHY_BCM_NS_USB3 depends on MDIO_BUS
+  drivers/net/phy/Kconfig:12:           symbol MDIO_BUS default is visible depending on PHYLIB
+  drivers/net/phy/Kconfig:181:          symbol PHYLIB is selected by ARC_EMAC_CORE
+  drivers/net/ethernet/arc/Kconfig:18:  symbol ARC_EMAC_CORE is selected by ARC_EMAC
+  drivers/net/ethernet/arc/Kconfig:24:  symbol ARC_EMAC depends on OF_IRQ
+
+To fix the circular dependency, make USB_MUSB_SUNXI select GENERIC_PHY
+instead of depending on it. This matches the use of GENERIC_PHY by all
+but two other drivers.
+
+Cc: <stable@vger.kernel.org> # 4.19
+Fixes: 5828729bebbb ("soc: sunxi: export a regmap for EMAC clock reg on A64")
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
+Signed-off-by: Bin Liu <b-liu@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/soc/sunxi/Kconfig |    1 +
+ drivers/usb/musb/Kconfig  |    2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/soc/sunxi/Kconfig
++++ b/drivers/soc/sunxi/Kconfig
+@@ -4,6 +4,7 @@
+ config SUNXI_SRAM
+       bool
+       default ARCH_SUNXI
++      select REGMAP_MMIO
+       help
+         Say y here to enable the SRAM controller support. This
+         device is responsible on mapping the SRAM in the sunXi SoCs
+--- a/drivers/usb/musb/Kconfig
++++ b/drivers/usb/musb/Kconfig
+@@ -66,7 +66,7 @@ config USB_MUSB_SUNXI
+       depends on NOP_USB_XCEIV
+       depends on PHY_SUN4I_USB
+       depends on EXTCON
+-      depends on GENERIC_PHY
++      select GENERIC_PHY
+       select SUNXI_SRAM
+ config USB_MUSB_DAVINCI
diff --git a/queue-5.0/uas-fix-alignment-of-scatter-gather-segments.patch b/queue-5.0/uas-fix-alignment-of-scatter-gather-segments.patch
new file mode 100644 (file)
index 0000000..d4f661a
--- /dev/null
@@ -0,0 +1,77 @@
+From 3ae62a42090f1ed48e2313ed256a1182a85fb575 Mon Sep 17 00:00:00 2001
+From: Oliver Neukum <oneukum@suse.com>
+Date: Tue, 30 Apr 2019 12:21:45 +0200
+Subject: UAS: fix alignment of scatter/gather segments
+
+From: Oliver Neukum <oneukum@suse.com>
+
+commit 3ae62a42090f1ed48e2313ed256a1182a85fb575 upstream.
+
+This is the UAS version of
+
+747668dbc061b3e62bc1982767a3a1f9815fcf0e
+usb-storage: Set virt_boundary_mask to avoid SG overflows
+
+We are not as likely to be vulnerable as storage, as it is unlikelier
+that UAS is run over a controller without native support for SG,
+but the issue exists.
+The issue has been existing since the inception of the driver.
+
+Fixes: 115bb1ffa54c ("USB: Add UAS driver")
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/storage/uas.c |   35 ++++++++++++++++++++++-------------
+ 1 file changed, 22 insertions(+), 13 deletions(-)
+
+--- a/drivers/usb/storage/uas.c
++++ b/drivers/usb/storage/uas.c
+@@ -796,24 +796,33 @@ static int uas_slave_alloc(struct scsi_d
+ {
+       struct uas_dev_info *devinfo =
+               (struct uas_dev_info *)sdev->host->hostdata;
++      int maxp;
+       sdev->hostdata = devinfo;
+       /*
+-       * USB has unusual DMA-alignment requirements: Although the
+-       * starting address of each scatter-gather element doesn't matter,
+-       * the length of each element except the last must be divisible
+-       * by the Bulk maxpacket value.  There's currently no way to
+-       * express this by block-layer constraints, so we'll cop out
+-       * and simply require addresses to be aligned at 512-byte
+-       * boundaries.  This is okay since most block I/O involves
+-       * hardware sectors that are multiples of 512 bytes in length,
+-       * and since host controllers up through USB 2.0 have maxpacket
+-       * values no larger than 512.
++       * We have two requirements here. We must satisfy the requirements
++       * of the physical HC and the demands of the protocol, as we
++       * definitely want no additional memory allocation in this path
++       * ruling out using bounce buffers.
+        *
+-       * But it doesn't suffice for Wireless USB, where Bulk maxpacket
+-       * values can be as large as 2048.  To make that work properly
+-       * will require changes to the block layer.
++       * For a transmission on USB to continue we must never send
++       * a package that is smaller than maxpacket. Hence the length of each
++         * scatterlist element except the last must be divisible by the
++         * Bulk maxpacket value.
++       * If the HC does not ensure that through SG,
++       * the upper layer must do that. We must assume nothing
++       * about the capabilities off the HC, so we use the most
++       * pessimistic requirement.
++       */
++
++      maxp = usb_maxpacket(devinfo->udev, devinfo->data_in_pipe, 0);
++      blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
++
++      /*
++       * The protocol has no requirements on alignment in the strict sense.
++       * Controllers may or may not have alignment restrictions.
++       * As this is not exported, we use an extremely conservative guess.
+        */
+       blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));