History

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi

Pull more SCSI updates from Martin Petersen: "Remaining updates for the 7.3 merge window. The only core change is enabling context analysis for the SCSI layer and UFS. The remaining changes are either bug fixes or hardening" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi: (26 commits) scsi: snic: Fix SCSI host leak on workqueue allocation failure scsi: MAINTAINERS: Update my email address scsi: MAINTAINERS: Leave the cumana_1 and oak drivers to the RISCPC maintainers scsi: leapraid: Standardize NCQ priority sysfs attributes scsi: leapraid: Serialize firmware log mmap with teardown scsi: leapraid: Balance host references for firmware log VMAs scsi: lpfc: Remove unnnecessary NULL check scsi: qla2xxx: Fix an loop timeout test scsi: qla2xxx: Fix an error code in qla_get_tmf() scsi: ibmvfc: Fix use of uninitialized rport in ibmvfc_do_work() scsi: core: Enable context analysis for hosts.o scsi: lpfc: Replace strlcat() with sysfs_emit_at() in the sysfs show functions scsi: lpfc: Replace strlcat() with seq_buf in the debugfs dump helpers scsi: lpfc: Replace strlcat() with seq_buf in lpfc_rx_monitor_report() scsi: lpfc: Replace strlcat() with scnprintf() in lpfc_vport_symbolic_node_name() scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info() scsi: core: Enable context analysis scsi: core: Protect host state changes with the host lock scsi: core: Add lock context annotations scsi: core: Pass the SCSI host pointer directly to scanning functions ...

Linus Torvalds committed 2 months ago

Commit 08dbfad2 parents cf72cbb 12e67eb36 files · +654 −643Browse files

Unified · Split

36 files
  1. .mailmap +3 −0
  2. Documentation/scsi/leapraid.rst +10 −4
  3. MAINTAINERS +2 −4
  4. drivers/scsi/Makefile +23 −0
  5. drivers/scsi/device_handler/Makefile +3 −0
  6. drivers/scsi/hosts.c +11 −8
  7. drivers/scsi/ibmvscsi/ibmvfc-core.c +1 −1
  8. drivers/scsi/leapraid/leapraid_app.c +10 −4
  9. drivers/scsi/leapraid/leapraid_func.c +1 −1
  10. drivers/scsi/leapraid/leapraid_func.h +2 −2
  11. drivers/scsi/leapraid/leapraid_os.c +57 −32
  12. drivers/scsi/libsas/sas_expander.c +78 −18
  13. drivers/scsi/libsas/sas_internal.h +1 −0
  14. drivers/scsi/lpfc/lpfc_attr.c +230 −325
  15. drivers/scsi/lpfc/lpfc_bsg.c +2 −4
  16. drivers/scsi/lpfc/lpfc_ct.c +5 −24
  17. drivers/scsi/lpfc/lpfc_debugfs.c +87 −115
  18. drivers/scsi/lpfc/lpfc_scsi.c +15 −34
  19. drivers/scsi/lpfc/lpfc_scsi.h +0 −3
  20. drivers/scsi/lpfc/lpfc_sli.c +24 −19
  21. drivers/scsi/megaraid/megaraid_sas_base.c +1 −1
  22. drivers/scsi/mpi3mr/mpi3mr_os.c +1 −1
  23. drivers/scsi/mpt3sas/mpt3sas_base.c +2 −0
  24. drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 −1
  25. drivers/scsi/qla2xxx/qla_init.c +2 −2
  26. drivers/scsi/qla2xxx/qla_nx2.c +1 −1
  27. drivers/scsi/qla4xxx/ql4_os.c +2 −4
  28. drivers/scsi/scsi_lib.c +1 −2
  29. drivers/scsi/scsi_scan.c +31 −21
  30. drivers/scsi/scsi_sysfs.c +4 −3
  31. drivers/scsi/snic/snic_main.c +1 −0
  32. drivers/ufs/core/Makefile +2 −0
  33. drivers/ufs/core/ufs-debugfs.c +6 −2
  34. drivers/ufs/core/ufshcd.c +15 −0
  35. drivers/ufs/host/Makefile +2 −0
  36. include/scsi/scsi_host.h +17 −7
.mailmap+3−0
@@ -577,6 +577,9 @@ Mark Brown <broonie@sirena.org.uk> · 576 unmodified lines
577577 Mark Starovoytov <mstarovo@pm.me> <mstarovoitov@marvell.com>
578578 Markus Schneider-Pargmann <msp@baylibre.com> <mpa@pengutronix.de>
579579 Mark Yao <markyao0591@gmail.com> <mark.yao@rock-chips.com>
580+Martin K. Petersen <mkp@kernel.org> <martin.petersen@oracle.com>
581+Martin K. Petersen <mkp@kernel.org> <mkp@mkp.net>
582+Martin K. Petersen <mkp@kernel.org> <mkp@linuxcare.com>
580583 Martin Kepplinger-Novakovic <martink@posteo.de> <martin.kepplinger-novakovic@ginzinger.com>
581584 Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> <martyna.szapar-mudlaw@intel.com>
582585 Mathieu Othacehe <othacehe@gnu.org> <m.othacehe@gmail.com>
Documentation/scsi/leapraid.rst+10−4
@@ -22,6 +22,7 @@ Supported devices · 21 unmodified lines
2222
2323 Features
2424 ========
25+
2526 - PCIe Gen4 x8 host interface
2627 - Support for SAS and SATA devices
2728 - RAID levels: 0, 1, 10, 5, 50, 6, 60
@@ -50,16 +51,20 @@ LeapRAID specific disk attributes · 22 unmodified lines
5051
5152 ::
5253
53− /sys/class/scsi_disk/host:bus:target:lun/device/sas_device_handle
54− /sys/class/scsi_disk/host:bus:target:lun/device/ncq_cmd_prio_enable
54+ /sys/block/<disk>/device/sas_device_handle
55+ /sys/block/<disk>/device/sas_ncq_prio_supported
56+ /sys/block/<disk>/device/sas_ncq_prio_enable
5557
5658 The read-only attribute "sas_device_handle" represents the disk's device
5759 handle, which is a unique identifier maintained by the firmware.
5860
59−This attribute "ncq_cmd_prio_enable" controls NCQ command priority. A value
61+The read-only attribute "sas_ncq_prio_supported" reports whether a SATA
62+device supports NCQ command priority.
63+
64+The attribute "sas_ncq_prio_enable" controls NCQ command priority. A value
6065 of 0 disables NCQ priority handling for RT-priority I/O. Writing 1 enables
6166 NCQ priority handling when the device reports support for the feature through
62−VPD page 0x89. Unsupported devices keep the effective state at 0.
67+VPD page 0x89. Writes to unsupported devices fail with an error.
6368
6469 LeapRAID module parameters
6570 ==========================
@@ -100,6 +105,7 @@ in io_uring poll mode. The default value is 0. · 34 unmodified lines
100105
101106 File Location
102107 =============
108+
103109 The driver source is located at:
104110
105111 ``drivers/scsi/leapraid/``
MAINTAINERS+2−4
@@ -18776,8 +18776,6 @@ L: linux-scsi@vger.kernel.org · 18775 unmodified lines
1877618776 S: Maintained
1877718777 F: Documentation/scsi/g_NCR5380.rst
1877818778 F: drivers/scsi/NCR5380.*
18779−F: drivers/scsi/arm/cumana_1.c
18780−F: drivers/scsi/arm/oak.c
1878118779 F: drivers/scsi/atari_scsi.*
1878218780 F: drivers/scsi/dmx3191d.c
1878318781 F: drivers/scsi/g_NCR5380.*
@@ -24571,7 +24569,7 @@ F: include/scsi/sg.h · 5787 unmodified lines
2457124569
2457224570 SCSI SUBSYSTEM
2457324571 M: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
24574−M: "Martin K. Petersen" <martin.petersen@oracle.com>
24572+M: "Martin K. Petersen" <mkp@kernel.org>
2457524573 L: linux-scsi@vger.kernel.org
2457624574 S: Maintained
2457724575 Q: https://patchwork.kernel.org/project/linux-scsi/list/
@@ -24601,7 +24599,7 @@ F: drivers/target/target_core_user.c · 23 unmodified lines
2460124599 F: include/uapi/linux/target_core_user.h
2460224600
2460324601 SCSI TARGET SUBSYSTEM
24604−M: "Martin K. Petersen" <martin.petersen@oracle.com>
24602+M: "Martin K. Petersen" <mkp@kernel.org>
2460524603 L: linux-scsi@vger.kernel.org
2460624604 L: target-devel@vger.kernel.org
2460724605 S: Supported
drivers/scsi/Makefile+23−0
@@ -14,6 +14,29 @@ · 13 unmodified lines
1414 # satisfy certain initialization assumptions in the SCSI layer.
1515 # *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
1616
17+CONTEXT_ANALYSIS_constants.o := y
18+CONTEXT_ANALYSIS_hosts.o := y
19+CONTEXT_ANALYSIS_scsi.o := y
20+CONTEXT_ANALYSIS_scsi_common.o := y
21+CONTEXT_ANALYSIS_scsi_devinfo.o := y
22+CONTEXT_ANALYSIS_scsi_dh.o := y
23+CONTEXT_ANALYSIS_scsi_error.o := y
24+CONTEXT_ANALYSIS_scsi_ioctl.o := y
25+CONTEXT_ANALYSIS_scsi_lib.o := y
26+CONTEXT_ANALYSIS_scsi_lib_dma.o := y
27+CONTEXT_ANALYSIS_scsi_logging.o := y
28+CONTEXT_ANALYSIS_scsi_netlink.o := y
29+CONTEXT_ANALYSIS_scsi_pm.o := y
30+CONTEXT_ANALYSIS_scsi_proc.o := y
31+CONTEXT_ANALYSIS_scsi_scan.o := y
32+CONTEXT_ANALYSIS_scsi_sysfs.o := y
33+CONTEXT_ANALYSIS_scsi_trace.o := y
34+CONTEXT_ANALYSIS_scsicam.o := y
35+CONTEXT_ANALYSIS_sd.o := y
36+CONTEXT_ANALYSIS_sd_dif.o := y
37+CONTEXT_ANALYSIS_sd_zbc.o := y
38+CONTEXT_ANALYSIS_sr.o := y
39+CONTEXT_ANALYSIS_sr_ioctl.o := y
1740
1841 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
1942
drivers/scsi/device_handler/Makefile+3−0
@@ -2,6 +2,9 @@ · 1 unmodified line
22 #
33 # SCSI Device Handler
44 #
5+
6+CONTEXT_ANALYSIS := y
7+
58 obj-$(CONFIG_SCSI_DH_RDAC) += scsi_dh_rdac.o
69 obj-$(CONFIG_SCSI_DH_HP_SW) += scsi_dh_hp_sw.o
710 obj-$(CONFIG_SCSI_DH_EMC) += scsi_dh_emc.o
drivers/scsi/hosts.c+11−8
@@ -73,8 +73,9 @@ static struct class shost_class = { · 72 unmodified lines
7373 * transition is illegal.
7474 **/
7575 int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
76+ __must_hold(shost->host_lock)
7677 {
77− enum scsi_host_state oldstate = shost->shost_state;
78+ enum scsi_host_state oldstate = READ_ONCE(shost->shost_state);
7879
7980 if (state == oldstate)
8081 return 0;
@@ -145,7 +146,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) · 64 unmodified lines
145146 }
146147 break;
147148 }
148− shost->shost_state = state;
149+ WRITE_ONCE(shost->shost_state, state);
149150 return 0;
150151
151152 illegal:
@@ -276,7 +277,8 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 124 unmodified lines
276277 if (error)
277278 goto out_disable_runtime_pm;
278279
279− scsi_host_set_state(shost, SHOST_RUNNING);
280+ scoped_guard(spinlock_irq, shost->host_lock)
281+ scsi_host_set_state(shost, SHOST_RUNNING);
280282 get_device(shost->shost_gendev.parent);
281283
282284 device_enable_async_suspend(&shost->shost_dev);
@@ -350,6 +352,7 @@ EXPORT_SYMBOL(scsi_add_host_with_dma); · 67 unmodified lines
350352 static void scsi_host_dev_release(struct device *dev)
351353 {
352354 struct Scsi_Host *shost = dev_to_shost(dev);
355+ enum scsi_host_state state = scsi_get_host_state(shost);
353356 struct device *parent = dev->parent;
354357
355358 /* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */
@@ -363,7 +366,7 @@ static void scsi_host_dev_release(struct device *dev) · 7 unmodified lines
363366 if (shost->work_q)
364367 destroy_workqueue(shost->work_q);
365368
366− if (shost->shost_state == SHOST_CREATED) {
369+ if (state == SHOST_CREATED) {
367370 /*
368371 * Free the shost_dev device name and remove the proc host dir
369372 * here if scsi_host_{alloc,put}() have been called but neither
@@ -379,7 +382,7 @@ static void scsi_host_dev_release(struct device *dev) · 9 unmodified lines
379382
380383 ida_free(&host_index_ida, shost->host_no);
381384
382− if (shost->shost_state != SHOST_CREATED)
385+ if (state != SHOST_CREATED)
383386 put_device(parent);
384387 kfree(shost);
385388 }
@@ -412,8 +415,8 @@ struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, int priv · 26 unmodified lines
412415 return NULL;
413416
414417 shost->host_lock = &shost->default_lock;
415− spin_lock_init(shost->host_lock);
416− shost->shost_state = SHOST_CREATED;
418+ scoped_guard(spinlock_init, shost->host_lock)
419+ shost->shost_state = SHOST_CREATED;
417420 INIT_LIST_HEAD(&shost->__devices);
418421 INIT_LIST_HEAD(&shost->__targets);
419422 INIT_LIST_HEAD(&shost->eh_abort_list);
@@ -600,7 +603,7 @@ EXPORT_SYMBOL(scsi_host_lookup); · 180 unmodified lines
600603 **/
601604 struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
602605 {
603− if ((shost->shost_state == SHOST_DEL) ||
606+ if (scsi_get_host_state(shost) == SHOST_DEL ||
604607 !get_device(&shost->shost_gendev))
605608 return NULL;
606609 return shost;
drivers/scsi/ibmvscsi/ibmvfc-core.c+1−1
@@ -6151,7 +6151,7 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) · 6150 unmodified lines
61516151 timer_delete_sync(&tgt->timer);
61526152 kref_put(&tgt->kref, ibmvfc_release_tgt);
61536153 return;
6154− } else if (rport && tgt->action == IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT) {
6154+ } else if (tgt->action == IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT) {
61556155 tgt_dbg(tgt, "Deleting NVMe rport with outstanding I/O\n");
61566156 nvme_rport = tgt->nvme_remote_port;
61576157 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT);
drivers/scsi/leapraid/leapraid_app.c+10−4
@@ -171,7 +171,8 @@ static int leapraid_ctl_validate_sge_offset(struct leapraid_adapter *adapter, · 170 unmodified lines
171171 return 0;
172172 }
173173
174−static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id)
174+static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id,
175+ bool track_mmap)
175176 {
176177 struct leapraid_adapter *adapter;
177178 struct Scsi_Host *shost;
@@ -184,6 +185,8 @@ static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id) · 6 unmodified lines
184185 shost = adapter->shost;
185186 if (!shost || !scsi_host_get(shost))
186187 break;
188+ if (track_mmap)
189+ atomic_inc(&adapter->fw_log_desc.mmap_refcnt);
187190 spin_unlock(&leapraid_adapter_lock);
188191 return adapter;
189192 }
@@ -589,7 +592,7 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd, · 399 unmodified lines
589592 return -EFAULT;
590593 }
591594
592− adapter = leapraid_ctl_lookup_adapter(ioctl_header.adapter_id);
595+ adapter = leapraid_ctl_lookup_adapter(ioctl_header.adapter_id, false);
593596 if (!adapter)
594597 return -EFAULT;
595598
@@ -697,6 +700,7 @@ static void leapraid_fw_mmap_open(struct vm_area_struct *vma) · 101 unmodified lines
697700 if (!adapter)
698701 return;
699702
703+ get_device(&adapter->shost->shost_gendev);
700704 atomic_inc(&adapter->fw_log_desc.mmap_refcnt);
701705 }
702706
@@ -727,7 +731,7 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma) · 24 unmodified lines
727731
728732 length = vma->vm_end - vma->vm_start;
729733
730− adapter = leapraid_ctl_lookup_adapter(adapter_id);
734+ adapter = leapraid_ctl_lookup_adapter(adapter_id, true);
731735 if (!adapter) {
732736 pr_err("%s: No adapter found!\n", __func__);
733737 return -EINVAL;
@@ -767,10 +771,12 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma) · 33 unmodified lines
767771 vma->vm_private_data = adapter;
768772 vma->vm_ops = &leapraid_fw_mmap_vm_ops;
769773 leapraid_fw_mmap_open(vma);
770− adapter = NULL;
771774
772775 rc = 0;
773776 out_put:
777+ if (adapter &&
778+ atomic_dec_and_test(&adapter->fw_log_desc.mmap_refcnt))
779+ wake_up(&adapter->fw_log_desc.mmap_waitq);
774780 leapraid_ctl_put_adapter(adapter);
775781 return rc;
776782 }
drivers/scsi/leapraid/leapraid_func.c+1−1
@@ -37,7 +37,7 @@ static noinline bool leapraid_shost_in_recovery(struct Scsi_Host *shost) · 36 unmodified lines
3737 {
3838 enum scsi_host_state state;
3939
40− state = READ_ONCE(shost->shost_state);
40+ state = scsi_get_host_state(shost);
4141 return state == SHOST_RECOVERY ||
4242 state == SHOST_CANCEL_RECOVERY ||
4343 state == SHOST_DEL_RECOVERY ||
drivers/scsi/leapraid/leapraid_func.h+2−2
@@ -1064,7 +1064,7 @@ struct leapraid_starget_priv { · 1063 unmodified lines
10641064 * @starget_priv: Associated target private data.
10651065 * @lun: Logical Unit Number.
10661066 * @flg: Flags.
1067− * @ncq_cmd_prio_enable: Enables NCQ command priority for RT I/O.
1067+ * @ncq_prio_enable: Enables NCQ command priority for RT I/O.
10681068 * @block: Block flag.
10691069 * @deleted: Deletion flag.
10701070 * @sep: SEP flag.
@@ -1073,7 +1073,7 @@ struct leapraid_sdev_priv { · 2 unmodified lines
10731073 struct leapraid_starget_priv *starget_priv;
10741074 unsigned int lun;
10751075 u32 flg;
1076− u8 ncq_cmd_prio_enable;
1076+ u8 ncq_prio_enable;
10771077 u8 block;
10781078 u8 deleted;
10791079 u8 sep;
drivers/scsi/leapraid/leapraid_os.c+57−32
@@ -808,7 +808,7 @@ static bool leapraid_should_queuecommand(struct leapraid_adapter *adapter, · 807 unmodified lines
808808 goto no_connect;
809809
810810 if (sdev_priv->block &&
811− scmd->device->host->shost_state == SHOST_RECOVERY &&
811+ scsi_get_host_state(scmd->device->host) == SHOST_RECOVERY &&
812812 scmd->cmnd[0] == TEST_UNIT_READY) {
813813 scsi_build_sense(scmd, 0, UNIT_ATTENTION,
814814 LEAPRAID_SCSI_ASC_POWER_ON_RESET,
@@ -859,7 +859,7 @@ static u32 build_scsiio_req_control(struct scsi_cmnd *scmd, · 44 unmodified lines
859859
860860 control |= LEAPRAID_SCSIIO_CTRL_SIMPLEQ;
861861
862− if (sdev_priv->ncq_cmd_prio_enable &&
862+ if (sdev_priv->ncq_prio_enable &&
863863 (IOPRIO_PRIO_CLASS(req_get_ioprio(scsi_cmd_to_rq(scmd))) ==
864864 IOPRIO_CLASS_RT))
865865 control |= LEAPRAID_SCSIIO_CTRL_CMDPRI;
@@ -1854,7 +1854,16 @@ static ssize_t sas_device_handle_show(struct device *dev, · 988 unmodified lines
18541854 sas_device_priv_data->starget_priv->hdl);
18551855 }
18561856
1857−static ssize_t ncq_cmd_prio_enable_show(struct device *dev,
1857+static ssize_t sas_ncq_prio_supported_show(struct device *dev,
1858+ struct device_attribute *attr,
1859+ char *buf)
1860+{
1861+ struct scsi_device *sdev = to_scsi_device(dev);
1862+
1863+ return sysfs_emit(buf, "%d\n", sas_ata_ncq_prio_supported(sdev));
1864+}
1865+
1866+static ssize_t sas_ncq_prio_enable_show(struct device *dev,
18581867 struct device_attribute *attr,
18591868 char *buf)
18601869 {
@@ -1867,19 +1876,16 @@ static ssize_t ncq_cmd_prio_enable_show(struct device *dev, · 6 unmodified lines
18671876 return -EINVAL;
18681877 }
18691878
1870− return sysfs_emit(buf, "%d\n",
1871− sas_device_priv_data->ncq_cmd_prio_enable);
1879+ return sysfs_emit(buf, "%d\n", sas_device_priv_data->ncq_prio_enable);
18721880 }
18731881
1874−static ssize_t ncq_cmd_prio_enable_store(struct device *dev,
1882+static ssize_t sas_ncq_prio_enable_store(struct device *dev,
18751883 struct device_attribute *attr,
18761884 const char *buf, size_t count)
18771885 {
18781886 struct scsi_device *sdev = to_scsi_device(dev);
18791887 struct leapraid_sdev_priv *sas_device_priv_data = sdev->hostdata;
1880− struct scsi_vpd *vpd_pg89;
1881− int ncq_cmd_prio_enable;
1882− bool ncq_supported;
1888+ bool enable;
18831889
18841890 if (!sas_device_priv_data) {
18851891 dev_err(&sdev->sdev_gendev,
@@ -1887,44 +1893,63 @@ static ssize_t ncq_cmd_prio_enable_store(struct device *dev, · 1 unmodified line
18871893 return -EINVAL;
18881894 }
18891895
1890− if (kstrtoint(buf, 0, &ncq_cmd_prio_enable))
1891− return -EINVAL;
1892−
1893− if (ncq_cmd_prio_enable != 0 && ncq_cmd_prio_enable != 1) {
1894− dev_err(&sdev->sdev_gendev,
1895− "%s: Invalid NCQ cmd prio %d (0/1 only)\n",
1896− __func__, ncq_cmd_prio_enable);
1896+ if (kstrtobool(buf, &enable))
18971897 return -EINVAL;
1898− }
18991898
1900− rcu_read_lock();
1901− vpd_pg89 = rcu_dereference(sdev->vpd_pg89);
1902− if (!vpd_pg89 || vpd_pg89->len < LEAPRAID_VPD_PG89_MIN_LEN) {
1903− rcu_read_unlock();
1899+ if (!sas_ata_ncq_prio_supported(sdev))
19041900 return -EINVAL;
1905− }
19061901
1907− ncq_supported = (vpd_pg89->data[LEAPRAID_VPD_PG89_NCQ_BYTE_IDX] >>
1908− LEAPRAID_VPD_PG89_NCQ_BIT_SHIFT) &
1909− LEAPRAID_VPD_PG89_NCQ_BIT_MASK;
1910− rcu_read_unlock();
1911− if (ncq_supported)
1912− sas_device_priv_data->ncq_cmd_prio_enable =
1913− ncq_cmd_prio_enable;
1902+ sas_device_priv_data->ncq_prio_enable = enable;
19141903 return count;
19151904 }
19161905
19171906 static DEVICE_ATTR_RO(sas_device_handle);
1907+static DEVICE_ATTR_RO(sas_ncq_prio_supported);
1908+static DEVICE_ATTR_RW(sas_ncq_prio_enable);
1909+
1910+static bool leapraid_sdev_is_sata(struct scsi_device *sdev)
1911+{
1912+ struct scsi_target *starget = sdev->sdev_target;
1913+ struct leapraid_starget_priv *starget_priv = starget->hostdata;
1914+ struct leapraid_sas_dev *sas_dev;
19181915
1919−static DEVICE_ATTR_RW(ncq_cmd_prio_enable);
1916+ if (!starget_priv)
1917+ return false;
1918+
1919+ sas_dev = starget_priv->sas_dev;
1920+ return sas_dev && (sas_dev->dev_info & LEAPRAID_DEVTYP_SATA_DEV);
1921+}
19201922
19211923 static struct attribute *leapraid_sdev_attrs[] = {
19221924 &dev_attr_sas_device_handle.attr,
1923− &dev_attr_ncq_cmd_prio_enable.attr,
1925+ &dev_attr_sas_ncq_prio_supported.attr,
1926+ &dev_attr_sas_ncq_prio_enable.attr,
19241927 NULL,
19251928 };
19261929
1927−ATTRIBUTE_GROUPS(leapraid_sdev);
1930+static umode_t leapraid_sdev_attr_is_visible(struct kobject *kobj,
1931+ struct attribute *attr, int i)
1932+{
1933+ struct device *dev = kobj_to_dev(kobj);
1934+ struct scsi_device *sdev = to_scsi_device(dev);
1935+
1936+ if (attr == &dev_attr_sas_ncq_prio_supported.attr ||
1937+ attr == &dev_attr_sas_ncq_prio_enable.attr)
1938+ if (!leapraid_sdev_is_sata(sdev))
1939+ return 0;
1940+
1941+ return attr->mode;
1942+}
1943+
1944+static const struct attribute_group leapraid_sdev_attr_group = {
1945+ .attrs = leapraid_sdev_attrs,
1946+ .is_visible = leapraid_sdev_attr_is_visible,
1947+};
1948+
1949+static const struct attribute_group *leapraid_sdev_groups[] = {
1950+ &leapraid_sdev_attr_group,
1951+ NULL,
1952+};
19281953
19291954 static struct scsi_host_template leapraid_driver_template = {
19301955 .module = THIS_MODULE,
drivers/scsi/libsas/sas_expander.c+78−18
@@ -345,11 +345,10 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, · 344 unmodified lines
345345 SAS_ADDR(phy->attached_sas_addr), type);
346346 }
347347
348−/* check if we have an existing attached ata device on this expander phy */
349−struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id)
348+/* Return the domain device attached to an expander phy */
349+struct domain_device *sas_ex_phy_to_dev(struct domain_device *ex_dev, int phy_id)
350350 {
351351 struct ex_phy *ex_phy = &ex_dev->ex_dev.ex_phy[phy_id];
352− struct domain_device *dev;
353352 struct sas_rphy *rphy;
354353
355354 if (!ex_phy->port)
@@ -359,7 +358,13 @@ struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id) · 3 unmodified lines
359358 if (!rphy)
360359 return NULL;
361360
362− dev = sas_find_dev_by_rphy(rphy);
361+ return sas_find_dev_by_rphy(rphy);
362+}
363+
364+/* Check if we have an existing attached ata device on this expander phy */
365+struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id)
366+{
367+ struct domain_device *dev = sas_ex_phy_to_dev(ex_dev, phy_id);
363368
364369 if (dev && dev_is_sata(dev))
365370 return dev;
@@ -1958,6 +1963,72 @@ static bool dev_type_flutter(enum sas_device_type new, enum sas_device_type old) · 1592 unmodified lines
19581963 return false;
19591964 }
19601965
1966+static void sas_rediscover_ex_phy(struct domain_device *dev, int phy_id,
1967+ bool last)
1968+{
1969+ struct expander_device *ex = &dev->ex_dev;
1970+ struct ex_phy *phy = &ex->ex_phy[phy_id];
1971+
1972+ phy->phy_change_count = -1;
1973+ ex->ex_change_count = -1;
1974+ sas_unregister_devs_sas_addr(dev, phy_id, last);
1975+ sas_discover_event(dev->port, DISCE_REVALIDATE_DOMAIN);
1976+}
1977+
1978+static bool sas_dev_is_flutter(struct domain_device *dev, int phy_id,
1979+ u8 *sas_addr, enum sas_device_type type)
1980+{
1981+ struct expander_device *ex = &dev->ex_dev;
1982+ struct ex_phy *phy = &ex->ex_phy[phy_id];
1983+ struct domain_device *child_dev;
1984+ char *action = "";
1985+ int res;
1986+
1987+ if (SAS_ADDR(sas_addr) != SAS_ADDR(phy->attached_sas_addr) ||
1988+ !dev_type_flutter(type, phy->attached_dev_type))
1989+ return false;
1990+
1991+ res = sas_ex_phy_discover(dev, phy_id);
1992+ if (res)
1993+ return false;
1994+
1995+ child_dev = sas_ex_phy_to_dev(dev, phy_id);
1996+ if (!child_dev)
1997+ goto out;
1998+
1999+ if (dev_is_sata(child_dev) &&
2000+ phy->attached_dev_type == SAS_SATA_PENDING) {
2001+ action = ", needs recovery";
2002+ goto out;
2003+ }
2004+
2005+ if (SAS_ADDR(child_dev->sas_addr) != SAS_ADDR(phy->attached_sas_addr)) {
2006+ pr_info("ex %016llx phy%02d sas_addr changed from %016llx to %016llx\n",
2007+ SAS_ADDR(dev->sas_addr), phy_id,
2008+ SAS_ADDR(child_dev->sas_addr),
2009+ SAS_ADDR(phy->attached_sas_addr));
2010+ /*
2011+ * Device unregistering relies on address matching. Restore
2012+ * attached_sas_addr back to the original address so that the old
2013+ * device can be unregistered later
2014+ */
2015+ memcpy(phy->attached_sas_addr, child_dev->sas_addr, SAS_ADDR_SIZE);
2016+ return false;
2017+ }
2018+
2019+ if (child_dev->linkrate != phy->linkrate) {
2020+ pr_info("ex %016llx phy%02d linkrate changed from %d to %d\n",
2021+ SAS_ADDR(dev->sas_addr), phy_id,
2022+ child_dev->linkrate, phy->linkrate);
2023+ return false;
2024+ }
2025+
2026+out:
2027+ pr_debug("ex %016llx phy%02d broadcast flutter%s\n",
2028+ SAS_ADDR(dev->sas_addr), phy_id, action);
2029+ return true;
2030+}
2031+
19612032 static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
19622033 bool last, int sibling)
19632034 {
@@ -2011,27 +2082,16 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, · 47 unmodified lines
20112082 if (res == 0)
20122083 sas_set_ex_phy(dev, phy_id, disc_resp);
20132084 goto out_free_resp;
2014− } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
2015− dev_type_flutter(type, phy->attached_dev_type)) {
2016− struct domain_device *ata_dev = sas_ex_to_ata(dev, phy_id);
2017− char *action = "";
2018−
2019− sas_ex_phy_discover(dev, phy_id);
2085+ }
20202086
2021− if (ata_dev && phy->attached_dev_type == SAS_SATA_PENDING)
2022− action = ", needs recovery";
2023− pr_debug("ex %016llx phy%02d broadcast flutter%s\n",
2024− SAS_ADDR(dev->sas_addr), phy_id, action);
2087+ if (sas_dev_is_flutter(dev, phy_id, sas_addr, type))
20252088 goto out_free_resp;
2026− }
20272089
20282090 /* we always have to delete the old device when we went here */
20292091 pr_info("ex %016llx phy%02d replace %016llx\n",
20302092 SAS_ADDR(dev->sas_addr), phy_id,
20312093 SAS_ADDR(phy->attached_sas_addr));
2032− sas_unregister_devs_sas_addr(dev, phy_id, last);
2033−
2034− res = sas_discover_new(dev, phy_id);
2094+ sas_rediscover_ex_phy(dev, phy_id, last);
20352095 out_free_resp:
20362096 kfree(disc_resp);
20372097 return res;
drivers/scsi/libsas/sas_internal.h+1−0
@@ -91,6 +91,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy); · 90 unmodified lines
9191
9292 void sas_device_set_phy(struct domain_device *dev, struct sas_port *port);
9393 struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
94+struct domain_device *sas_ex_phy_to_dev(struct domain_device *ex_dev, int phy_id);
9495 struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id);
9596 int sas_ex_phy_discover(struct domain_device *dev, int single);
9697 int sas_get_report_phy_sata(struct domain_device *dev, int phy_id,
drivers/scsi/lpfc/lpfc_attr.c+230−325
@@ -57,7 +57,6 @@ · 56 unmodified lines
5757 #define LPFC_MIN_DEVLOSS_TMO 1
5858 #define LPFC_MAX_DEVLOSS_TMO 255
5959
60−#define LPFC_MAX_INFO_TMP_LEN 100
6160 #define LPFC_INFO_MORE_STR "\nCould be more info...\n"
6261 /*
6362 * Write key size should be multiple of 4. If write key is changed
@@ -126,133 +125,121 @@ lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr, · 62 unmodified lines
126125 int len = 0;
127126 int cpu;
128127 u64 rcv, total;
129− char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
130128
131129 if (phba->cgn_i)
132130 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
133131
134− scnprintf(tmp, sizeof(tmp),
135− "Congestion Mgmt Info: E2Eattr %d Ver %d "
136− "CMF %d cnt %d\n",
137− phba->sli4_hba.pc_sli4_params.mi_cap,
138− cp ? cp->cgn_info_version : 0,
139− phba->sli4_hba.pc_sli4_params.cmf, phba->cmf_timer_cnt);
140−
141− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
142− goto buffer_done;
132+ len = strnlen(buf, PAGE_SIZE);
133+ len += sysfs_emit_at(buf, len,
134+ "Congestion Mgmt Info: E2Eattr %d Ver %d CMF %d cnt %d\n",
135+ phba->sli4_hba.pc_sli4_params.mi_cap,
136+ cp ? cp->cgn_info_version : 0,
137+ phba->sli4_hba.pc_sli4_params.cmf,
138+ phba->cmf_timer_cnt);
143139
144140 if (!phba->sli4_hba.pc_sli4_params.cmf)
145141 goto buffer_done;
146142
147143 switch (phba->cgn_init_reg_signal) {
148144 case EDC_CG_SIG_WARN_ONLY:
149− scnprintf(tmp, sizeof(tmp),
150− "Register: Init: Signal:WARN ");
145+ len += sysfs_emit_at(buf, len,
146+ "Register: Init: Signal:WARN ");
151147 break;
152148 case EDC_CG_SIG_WARN_ALARM:
153− scnprintf(tmp, sizeof(tmp),
154− "Register: Init: Signal:WARN|ALARM ");
149+ len += sysfs_emit_at(buf, len,
150+ "Register: Init: Signal:WARN|ALARM ");
155151 break;
156152 default:
157− scnprintf(tmp, sizeof(tmp),
158− "Register: Init: Signal:NONE ");
153+ len += sysfs_emit_at(buf, len,
154+ "Register: Init: Signal:NONE ");
159155 break;
160156 }
161− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
162− goto buffer_done;
163157
164158 switch (phba->cgn_init_reg_fpin) {
165159 case LPFC_CGN_FPIN_WARN:
166− scnprintf(tmp, sizeof(tmp),
167− "FPIN:WARN\n");
160+ len += sysfs_emit_at(buf, len, "FPIN:WARN\n");
168161 break;
169162 case LPFC_CGN_FPIN_ALARM:
170− scnprintf(tmp, sizeof(tmp),
171− "FPIN:ALARM\n");
163+ len += sysfs_emit_at(buf, len, "FPIN:ALARM\n");
172164 break;
173165 case LPFC_CGN_FPIN_BOTH:
174− scnprintf(tmp, sizeof(tmp),
175− "FPIN:WARN|ALARM\n");
166+ len += sysfs_emit_at(buf, len, "FPIN:WARN|ALARM\n");
176167 break;
177168 default:
178− scnprintf(tmp, sizeof(tmp),
179− "FPIN:NONE\n");
169+ len += sysfs_emit_at(buf, len, "FPIN:NONE\n");
180170 break;
181171 }
182− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
183− goto buffer_done;
184172
185173 switch (phba->cgn_reg_signal) {
186174 case EDC_CG_SIG_WARN_ONLY:
187− scnprintf(tmp, sizeof(tmp),
188− " Current: Signal:WARN ");
175+ len += sysfs_emit_at(buf, len,
176+ " Current: Signal:WARN ");
189177 break;
190178 case EDC_CG_SIG_WARN_ALARM:
191− scnprintf(tmp, sizeof(tmp),
192− " Current: Signal:WARN|ALARM ");
179+ len += sysfs_emit_at(buf, len,
180+ " Current: Signal:WARN|ALARM ");
193181 break;
194182 default:
195− scnprintf(tmp, sizeof(tmp),
196− " Current: Signal:NONE ");
183+ len += sysfs_emit_at(buf, len,
184+ " Current: Signal:NONE ");
197185 break;
198186 }
199− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
200− goto buffer_done;
201187
202188 switch (phba->cgn_reg_fpin) {
203189 case LPFC_CGN_FPIN_WARN:
204− scnprintf(tmp, sizeof(tmp),
205− "FPIN:WARN ACQEcnt:%d\n", phba->cgn_acqe_cnt);
190+ len += sysfs_emit_at(buf, len,
191+ "FPIN:WARN ACQEcnt:%d\n",
192+ phba->cgn_acqe_cnt);
206193 break;
207194 case LPFC_CGN_FPIN_ALARM:
208− scnprintf(tmp, sizeof(tmp),
209− "FPIN:ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);
195+ len += sysfs_emit_at(buf, len,
196+ "FPIN:ALARM ACQEcnt:%d\n",
197+ phba->cgn_acqe_cnt);
210198 break;
211199 case LPFC_CGN_FPIN_BOTH:
212− scnprintf(tmp, sizeof(tmp),
213− "FPIN:WARN|ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);
200+ len += sysfs_emit_at(buf, len,
201+ "FPIN:WARN|ALARM ACQEcnt:%d\n",
202+ phba->cgn_acqe_cnt);
214203 break;
215204 default:
216− scnprintf(tmp, sizeof(tmp),
217− "FPIN:NONE ACQEcnt:%d\n", phba->cgn_acqe_cnt);
205+ len += sysfs_emit_at(buf, len,
206+ "FPIN:NONE ACQEcnt:%d\n",
207+ phba->cgn_acqe_cnt);
218208 break;
219209 }
220− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
221− goto buffer_done;
222210
223211 if (phba->cmf_active_mode != phba->cgn_p.cgn_param_mode) {
224212 switch (phba->cmf_active_mode) {
225213 case LPFC_CFG_OFF:
226− scnprintf(tmp, sizeof(tmp), "Active: Mode:Off\n");
214+ len += sysfs_emit_at(buf, len, "Active: Mode:Off\n");
227215 break;
228216 case LPFC_CFG_MANAGED:
229− scnprintf(tmp, sizeof(tmp), "Active: Mode:Managed\n");
217+ len += sysfs_emit_at(buf, len,
218+ "Active: Mode:Managed\n");
230219 break;
231220 case LPFC_CFG_MONITOR:
232− scnprintf(tmp, sizeof(tmp), "Active: Mode:Monitor\n");
221+ len += sysfs_emit_at(buf, len,
222+ "Active: Mode:Monitor\n");
233223 break;
234224 default:
235− scnprintf(tmp, sizeof(tmp), "Active: Mode:Unknown\n");
225+ len += sysfs_emit_at(buf, len,
226+ "Active: Mode:Unknown\n");
236227 }
237− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
238− goto buffer_done;
239228 }
240229
241230 switch (phba->cgn_p.cgn_param_mode) {
242231 case LPFC_CFG_OFF:
243− scnprintf(tmp, sizeof(tmp), "Config: Mode:Off ");
232+ len += sysfs_emit_at(buf, len, "Config: Mode:Off ");
244233 break;
245234 case LPFC_CFG_MANAGED:
246− scnprintf(tmp, sizeof(tmp), "Config: Mode:Managed ");
235+ len += sysfs_emit_at(buf, len, "Config: Mode:Managed ");
247236 break;
248237 case LPFC_CFG_MONITOR:
249− scnprintf(tmp, sizeof(tmp), "Config: Mode:Monitor ");
238+ len += sysfs_emit_at(buf, len, "Config: Mode:Monitor ");
250239 break;
251240 default:
252− scnprintf(tmp, sizeof(tmp), "Config: Mode:Unknown ");
241+ len += sysfs_emit_at(buf, len, "Config: Mode:Unknown ");
253242 }
254− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
255− goto buffer_done;
256243
257244 total = 0;
258245 rcv = 0;
@@ -262,24 +249,18 @@ lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr, · 3 unmodified lines
262249 rcv += atomic64_read(&cgs->rcv_bytes);
263250 }
264251
265− scnprintf(tmp, sizeof(tmp),
266− "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",
267− atomic_read(&phba->cmf_busy),
268− phba->cmf_active_info, rcv, total);
269− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
270− goto buffer_done;
252+ len += sysfs_emit_at(buf, len,
253+ "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",
254+ atomic_read(&phba->cmf_busy),
255+ phba->cmf_active_info, rcv, total);
271256
272− scnprintf(tmp, sizeof(tmp),
273− "Port_speed:%d Link_byte_cnt:%ld "
274− "Max_byte_per_interval:%ld\n",
275− lpfc_sli_port_speed_get(phba),
276− (unsigned long)phba->cmf_link_byte_count,
277− (unsigned long)phba->cmf_max_bytes_per_interval);
278− strlcat(buf, tmp, PAGE_SIZE);
257+ len += sysfs_emit_at(buf, len,
258+ "Port_speed:%d Link_byte_cnt:%ld Max_byte_per_interval:%ld\n",
259+ lpfc_sli_port_speed_get(phba),
260+ (unsigned long)phba->cmf_link_byte_count,
261+ (unsigned long)phba->cmf_max_bytes_per_interval);
279262
280263 buffer_done:
281− len = strnlen(buf, PAGE_SIZE);
282−
283264 if (unlikely(len >= (PAGE_SIZE - 1))) {
284265 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
285266 "6312 Catching potential buffer "
@@ -480,17 +461,19 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 194 unmodified lines
480461 char *statep;
481462 int i;
482463 int len = 0;
483− char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
484464
485465 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
486− len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
466+ len = sysfs_emit(buf, "NVME Disabled\n");
487467 return len;
488468 }
469+
470+ len = strnlen(buf, PAGE_SIZE);
471+
489472 if (phba->nvmet_support) {
490473 if (!phba->targetport) {
491− len = scnprintf(buf, PAGE_SIZE,
492− "NVME Target: x%llx is not allocated\n",
493− wwn_to_u64(vport->fc_portname.u.wwn));
474+ len = sysfs_emit(buf,
475+ "NVME Target: x%llx is not allocated\n",
476+ wwn_to_u64(vport->fc_portname.u.wwn));
494477 return len;
495478 }
496479 /* Port state is only one of two values for now. */
@@ -498,167 +481,131 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 1 unmodified line
498481 statep = "REGISTERED";
499482 else
500483 statep = "INIT";
501− scnprintf(tmp, sizeof(tmp),
502− "NVME Target Enabled State %s\n",
503− statep);
504− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
505− goto buffer_done;
506−
507− scnprintf(tmp, sizeof(tmp),
508− "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
509− "NVME Target: lpfc",
510− phba->brd_no,
511− wwn_to_u64(vport->fc_portname.u.wwn),
512− wwn_to_u64(vport->fc_nodename.u.wwn),
513− phba->targetport->port_id);
514− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
515− goto buffer_done;
516−
517− if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE)
518− >= PAGE_SIZE)
519− goto buffer_done;
484+ len += sysfs_emit_at(buf, len,
485+ "NVME Target Enabled State %s\n",
486+ statep);
487+
488+ len += sysfs_emit_at(buf, len,
489+ "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
490+ "NVME Target: lpfc",
491+ phba->brd_no,
492+ wwn_to_u64(vport->fc_portname.u.wwn),
493+ wwn_to_u64(vport->fc_nodename.u.wwn),
494+ phba->targetport->port_id);
495+
496+ len += sysfs_emit_at(buf, len, "\nNVME Target: Statistics\n");
520497
521498 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
522− scnprintf(tmp, sizeof(tmp),
523− "LS: Rcv %08x Drop %08x Abort %08x\n",
524− atomic_read(&tgtp->rcv_ls_req_in),
525− atomic_read(&tgtp->rcv_ls_req_drop),
526− atomic_read(&tgtp->xmt_ls_abort));
527− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
528− goto buffer_done;
499+ len += sysfs_emit_at(buf, len,
500+ "LS: Rcv %08x Drop %08x Abort %08x\n",
501+ atomic_read(&tgtp->rcv_ls_req_in),
502+ atomic_read(&tgtp->rcv_ls_req_drop),
503+ atomic_read(&tgtp->xmt_ls_abort));
529504
530505 if (atomic_read(&tgtp->rcv_ls_req_in) !=
531506 atomic_read(&tgtp->rcv_ls_req_out)) {
532− scnprintf(tmp, sizeof(tmp),
533− "Rcv LS: in %08x != out %08x\n",
534− atomic_read(&tgtp->rcv_ls_req_in),
535− atomic_read(&tgtp->rcv_ls_req_out));
536− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
537− goto buffer_done;
507+ len += sysfs_emit_at(buf, len,
508+ "Rcv LS: in %08x != out %08x\n",
509+ atomic_read(&tgtp->rcv_ls_req_in),
510+ atomic_read(&tgtp->rcv_ls_req_out));
538511 }
539512
540− scnprintf(tmp, sizeof(tmp),
541− "LS: Xmt %08x Drop %08x Cmpl %08x\n",
542− atomic_read(&tgtp->xmt_ls_rsp),
543− atomic_read(&tgtp->xmt_ls_drop),
544− atomic_read(&tgtp->xmt_ls_rsp_cmpl));
545− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
546− goto buffer_done;
547−
548− scnprintf(tmp, sizeof(tmp),
549− "LS: RSP Abort %08x xb %08x Err %08x\n",
550− atomic_read(&tgtp->xmt_ls_rsp_aborted),
551− atomic_read(&tgtp->xmt_ls_rsp_xb_set),
552− atomic_read(&tgtp->xmt_ls_rsp_error));
553− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
554− goto buffer_done;
555−
556− scnprintf(tmp, sizeof(tmp),
557− "FCP: Rcv %08x Defer %08x Release %08x "
558− "Drop %08x\n",
559− atomic_read(&tgtp->rcv_fcp_cmd_in),
560− atomic_read(&tgtp->rcv_fcp_cmd_defer),
561− atomic_read(&tgtp->xmt_fcp_release),
562− atomic_read(&tgtp->rcv_fcp_cmd_drop));
563− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
564− goto buffer_done;
513+ len += sysfs_emit_at(buf, len,
514+ "LS: Xmt %08x Drop %08x Cmpl %08x\n",
515+ atomic_read(&tgtp->xmt_ls_rsp),
516+ atomic_read(&tgtp->xmt_ls_drop),
517+ atomic_read(&tgtp->xmt_ls_rsp_cmpl));
518+
519+ len += sysfs_emit_at(buf, len,
520+ "LS: RSP Abort %08x xb %08x Err %08x\n",
521+ atomic_read(&tgtp->xmt_ls_rsp_aborted),
522+ atomic_read(&tgtp->xmt_ls_rsp_xb_set),
523+ atomic_read(&tgtp->xmt_ls_rsp_error));
524+
525+ len += sysfs_emit_at(buf, len,
526+ "FCP: Rcv %08x Defer %08x Release %08x Drop %08x\n",
527+ atomic_read(&tgtp->rcv_fcp_cmd_in),
528+ atomic_read(&tgtp->rcv_fcp_cmd_defer),
529+ atomic_read(&tgtp->xmt_fcp_release),
530+ atomic_read(&tgtp->rcv_fcp_cmd_drop));
565531
566532 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
567533 atomic_read(&tgtp->rcv_fcp_cmd_out)) {
568− scnprintf(tmp, sizeof(tmp),
569− "Rcv FCP: in %08x != out %08x\n",
570− atomic_read(&tgtp->rcv_fcp_cmd_in),
571− atomic_read(&tgtp->rcv_fcp_cmd_out));
572− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
573− goto buffer_done;
534+ len += sysfs_emit_at(buf, len,
535+ "Rcv FCP: in %08x != out %08x\n",
536+ atomic_read(&tgtp->rcv_fcp_cmd_in),
537+ atomic_read(&tgtp->rcv_fcp_cmd_out));
574538 }
575539
576− scnprintf(tmp, sizeof(tmp),
577− "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "
578− "drop %08x\n",
579− atomic_read(&tgtp->xmt_fcp_read),
580− atomic_read(&tgtp->xmt_fcp_read_rsp),
581− atomic_read(&tgtp->xmt_fcp_write),
582− atomic_read(&tgtp->xmt_fcp_rsp),
583− atomic_read(&tgtp->xmt_fcp_drop));
584− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
585− goto buffer_done;
586−
587− scnprintf(tmp, sizeof(tmp),
588− "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
589− atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
590− atomic_read(&tgtp->xmt_fcp_rsp_error),
591− atomic_read(&tgtp->xmt_fcp_rsp_drop));
592− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
593− goto buffer_done;
594−
595− scnprintf(tmp, sizeof(tmp),
596− "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
597− atomic_read(&tgtp->xmt_fcp_rsp_aborted),
598− atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
599− atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
600− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
601− goto buffer_done;
602−
603− scnprintf(tmp, sizeof(tmp),
604− "ABORT: Xmt %08x Cmpl %08x\n",
605− atomic_read(&tgtp->xmt_fcp_abort),
606− atomic_read(&tgtp->xmt_fcp_abort_cmpl));
607− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
608− goto buffer_done;
609−
610− scnprintf(tmp, sizeof(tmp),
611− "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",
612− atomic_read(&tgtp->xmt_abort_sol),
613− atomic_read(&tgtp->xmt_abort_unsol),
614− atomic_read(&tgtp->xmt_abort_rsp),
615− atomic_read(&tgtp->xmt_abort_rsp_error));
616− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
617− goto buffer_done;
618−
619− scnprintf(tmp, sizeof(tmp),
620− "DELAY: ctx %08x fod %08x wqfull %08x\n",
621− atomic_read(&tgtp->defer_ctx),
622− atomic_read(&tgtp->defer_fod),
623− atomic_read(&tgtp->defer_wqfull));
624− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
625− goto buffer_done;
540+ len += sysfs_emit_at(buf, len,
541+ "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x drop %08x\n",
542+ atomic_read(&tgtp->xmt_fcp_read),
543+ atomic_read(&tgtp->xmt_fcp_read_rsp),
544+ atomic_read(&tgtp->xmt_fcp_write),
545+ atomic_read(&tgtp->xmt_fcp_rsp),
546+ atomic_read(&tgtp->xmt_fcp_drop));
547+
548+ len += sysfs_emit_at(buf, len,
549+ "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
550+ atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
551+ atomic_read(&tgtp->xmt_fcp_rsp_error),
552+ atomic_read(&tgtp->xmt_fcp_rsp_drop));
553+
554+ len += sysfs_emit_at(buf, len,
555+ "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
556+ atomic_read(&tgtp->xmt_fcp_rsp_aborted),
557+ atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
558+ atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
559+
560+ len += sysfs_emit_at(buf, len,
561+ "ABORT: Xmt %08x Cmpl %08x\n",
562+ atomic_read(&tgtp->xmt_fcp_abort),
563+ atomic_read(&tgtp->xmt_fcp_abort_cmpl));
564+
565+ len += sysfs_emit_at(buf, len,
566+ "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",
567+ atomic_read(&tgtp->xmt_abort_sol),
568+ atomic_read(&tgtp->xmt_abort_unsol),
569+ atomic_read(&tgtp->xmt_abort_rsp),
570+ atomic_read(&tgtp->xmt_abort_rsp_error));
571+
572+ len += sysfs_emit_at(buf, len,
573+ "DELAY: ctx %08x fod %08x wqfull %08x\n",
574+ atomic_read(&tgtp->defer_ctx),
575+ atomic_read(&tgtp->defer_fod),
576+ atomic_read(&tgtp->defer_wqfull));
626577
627578 /* Calculate outstanding IOs */
628579 tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);
629580 tot += atomic_read(&tgtp->xmt_fcp_release);
630581 tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
631582
632− scnprintf(tmp, sizeof(tmp),
633− "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
634− "CTX Outstanding %08llx\n\n",
635− phba->sli4_hba.nvmet_xri_cnt,
636− phba->sli4_hba.nvmet_io_wait_cnt,
637− phba->sli4_hba.nvmet_io_wait_total,
638− tot);
639− strlcat(buf, tmp, PAGE_SIZE);
583+ len += sysfs_emit_at(buf, len,
584+ "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
585+ "CTX Outstanding %08llx\n\n",
586+ phba->sli4_hba.nvmet_xri_cnt,
587+ phba->sli4_hba.nvmet_io_wait_cnt,
588+ phba->sli4_hba.nvmet_io_wait_total,
589+ tot);
640590 goto buffer_done;
641591 }
642592
643593 localport = vport->localport;
644594 if (!localport) {
645− len = scnprintf(buf, PAGE_SIZE,
646− "NVME Initiator x%llx is not allocated\n",
647− wwn_to_u64(vport->fc_portname.u.wwn));
595+ len = sysfs_emit(buf,
596+ "NVME Initiator x%llx is not allocated\n",
597+ wwn_to_u64(vport->fc_portname.u.wwn));
648598 return len;
649599 }
650600 lport = (struct lpfc_nvme_lport *)localport->private;
651− if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE)
652− goto buffer_done;
601+ len += sysfs_emit_at(buf, len, "\nNVME Initiator Enabled\n");
653602
654− scnprintf(tmp, sizeof(tmp),
655− "XRI Dist lpfc%d Total %d IO %d ELS %d\n",
656− phba->brd_no,
657− phba->sli4_hba.max_cfg_param.max_xri,
658− phba->sli4_hba.io_xri_max,
659− lpfc_sli4_get_els_iocb_cnt(phba));
660− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
661− goto buffer_done;
603+ len += sysfs_emit_at(buf, len,
604+ "XRI Dist lpfc%d Total %d IO %d ELS %d\n",
605+ phba->brd_no,
606+ phba->sli4_hba.max_cfg_param.max_xri,
607+ phba->sli4_hba.io_xri_max,
608+ lpfc_sli4_get_els_iocb_cnt(phba));
662609
663610 /* Port state is only one of two values for now. */
664611 if (localport->port_id)
@@ -666,15 +613,13 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 1 unmodified line
666613 else
667614 statep = "UNKNOWN ";
668615
669− scnprintf(tmp, sizeof(tmp),
670− "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
671− "NVME LPORT lpfc",
672− phba->brd_no,
673− wwn_to_u64(vport->fc_portname.u.wwn),
674− wwn_to_u64(vport->fc_nodename.u.wwn),
675− localport->port_id, statep);
676− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
677− goto buffer_done;
616+ len += sysfs_emit_at(buf, len,
617+ "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
618+ "NVME LPORT lpfc",
619+ phba->brd_no,
620+ wwn_to_u64(vport->fc_portname.u.wwn),
621+ wwn_to_u64(vport->fc_nodename.u.wwn),
622+ localport->port_id, statep);
678623
679624 spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
680625
@@ -702,77 +647,55 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 21 unmodified lines
702647 }
703648
704649 /* Tab in to show lport ownership. */
705− if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE)
706− goto unlock_buf_done;
707− if (phba->brd_no >= 10) {
708− if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE)
709− goto unlock_buf_done;
710− }
650+ len += sysfs_emit_at(buf, len, "NVME RPORT ");
651+ if (phba->brd_no >= 10)
652+ len += sysfs_emit_at(buf, len, " ");
711653
712− scnprintf(tmp, sizeof(tmp), "WWPN x%llx ",
713− nrport->port_name);
714− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
715− goto unlock_buf_done;
654+ len += sysfs_emit_at(buf, len, "WWPN x%llx ",
655+ nrport->port_name);
716656
717− scnprintf(tmp, sizeof(tmp), "WWNN x%llx ",
718− nrport->node_name);
719− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
720− goto unlock_buf_done;
657+ len += sysfs_emit_at(buf, len, "WWNN x%llx ",
658+ nrport->node_name);
721659
722− scnprintf(tmp, sizeof(tmp), "DID x%06x ",
723− nrport->port_id);
724− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
725− goto unlock_buf_done;
660+ len += sysfs_emit_at(buf, len, "DID x%06x ",
661+ nrport->port_id);
726662
727663 /* An NVME rport can have multiple roles. */
728− if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) {
729− if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE)
730− goto unlock_buf_done;
731− }
732− if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) {
733− if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE)
734− goto unlock_buf_done;
735− }
736− if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) {
737− if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE)
738− goto unlock_buf_done;
739− }
664+ if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
665+ len += sysfs_emit_at(buf, len, "INITIATOR ");
666+ if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
667+ len += sysfs_emit_at(buf, len, "TARGET ");
668+ if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
669+ len += sysfs_emit_at(buf, len, "DISCSRVC ");
740670 if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
741671 FC_PORT_ROLE_NVME_TARGET |
742− FC_PORT_ROLE_NVME_DISCOVERY)) {
743− scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x",
744− nrport->port_role);
745− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
746− goto unlock_buf_done;
747− }
672+ FC_PORT_ROLE_NVME_DISCOVERY))
673+ len += sysfs_emit_at(buf, len, "UNKNOWN ROLE x%x",
674+ nrport->port_role);
675+
676+ len += sysfs_emit_at(buf, len, "%s\n", statep);
748677
749− scnprintf(tmp, sizeof(tmp), "%s\n", statep);
750− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
751− goto unlock_buf_done;
678+ if (len >= PAGE_SIZE - 1)
679+ break;
752680 }
753681 spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
754682
755683 if (!lport)
756684 goto buffer_done;
757685
758− if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE)
759− goto buffer_done;
686+ len += sysfs_emit_at(buf, len, "\nNVME Statistics\n");
760687
761− scnprintf(tmp, sizeof(tmp),
762− "LS: Xmt %010x Cmpl %010x Abort %08x\n",
763− atomic_read(&lport->fc4NvmeLsRequests),
764− atomic_read(&lport->fc4NvmeLsCmpls),
765− atomic_read(&lport->xmt_ls_abort));
766− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
767− goto buffer_done;
688+ len += sysfs_emit_at(buf, len,
689+ "LS: Xmt %010x Cmpl %010x Abort %08x\n",
690+ atomic_read(&lport->fc4NvmeLsRequests),
691+ atomic_read(&lport->fc4NvmeLsCmpls),
692+ atomic_read(&lport->xmt_ls_abort));
768693
769− scnprintf(tmp, sizeof(tmp),
770− "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
771− atomic_read(&lport->xmt_ls_err),
772− atomic_read(&lport->cmpl_ls_xb),
773− atomic_read(&lport->cmpl_ls_err));
774− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
775− goto buffer_done;
694+ len += sysfs_emit_at(buf, len,
695+ "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
696+ atomic_read(&lport->xmt_ls_err),
697+ atomic_read(&lport->cmpl_ls_xb),
698+ atomic_read(&lport->cmpl_ls_err));
776699
777700 totin = 0;
778701 totout = 0;
@@ -785,40 +708,25 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 6 unmodified lines
785708 data3 = cstat->control_requests;
786709 totout += (data1 + data2 + data3);
787710 }
788− scnprintf(tmp, sizeof(tmp),
789− "Total FCP Cmpl %016llx Issue %016llx "
790− "OutIO %016llx\n",
791− totin, totout, totout - totin);
792− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
793− goto buffer_done;
794−
795− scnprintf(tmp, sizeof(tmp),
796− "\tabort %08x noxri %08x nondlp %08x qdepth %08x "
797− "wqerr %08x err %08x\n",
798− atomic_read(&lport->xmt_fcp_abort),
799− atomic_read(&lport->xmt_fcp_noxri),
800− atomic_read(&lport->xmt_fcp_bad_ndlp),
801− atomic_read(&lport->xmt_fcp_qdepth),
802− atomic_read(&lport->xmt_fcp_wqerr),
803− atomic_read(&lport->xmt_fcp_err));
804− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
805− goto buffer_done;
806−
807− scnprintf(tmp, sizeof(tmp),
808− "FCP CMPL: xb %08x Err %08x\n",
809− atomic_read(&lport->cmpl_fcp_xb),
810− atomic_read(&lport->cmpl_fcp_err));
811− strlcat(buf, tmp, PAGE_SIZE);
812−
813− /* host_lock is already unlocked. */
814− goto buffer_done;
815−
816− unlock_buf_done:
817− spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
711+ len += sysfs_emit_at(buf, len,
712+ "Total FCP Cmpl %016llx Issue %016llx OutIO %016llx\n",
713+ totin, totout, totout - totin);
714+
715+ len += sysfs_emit_at(buf, len,
716+ "\tabort %08x noxri %08x nondlp %08x qdepth %08x wqerr %08x err %08x\n",
717+ atomic_read(&lport->xmt_fcp_abort),
718+ atomic_read(&lport->xmt_fcp_noxri),
719+ atomic_read(&lport->xmt_fcp_bad_ndlp),
720+ atomic_read(&lport->xmt_fcp_qdepth),
721+ atomic_read(&lport->xmt_fcp_wqerr),
722+ atomic_read(&lport->xmt_fcp_err));
723+
724+ len += sysfs_emit_at(buf, len,
725+ "FCP CMPL: xb %08x Err %08x\n",
726+ atomic_read(&lport->cmpl_fcp_xb),
727+ atomic_read(&lport->cmpl_fcp_err));
818728
819729 buffer_done:
820− len = strnlen(buf, PAGE_SIZE);
821−
822730 if (unlikely(len >= (PAGE_SIZE - 1))) {
823731 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,
824732 "6314 Catching potential buffer "
@@ -844,13 +752,12 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, · 19 unmodified lines
844752 u64 data1, data2, data3;
845753 u64 tot, totin, totout;
846754 int i;
847− char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
848755
849756 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
850757 (phba->sli_rev != LPFC_SLI_REV4))
851758 return 0;
852759
853− scnprintf(buf, PAGE_SIZE, "SCSI HDWQ Statistics\n");
760+ len = sysfs_emit(buf, "SCSI HDWQ Statistics\n");
854761
855762 totin = 0;
856763 totout = 0;
@@ -863,22 +770,20 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, · 6 unmodified lines
863770 data3 = cstat->control_requests;
864771 totout += (data1 + data2 + data3);
865772
866− scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "
867− "IO %016llx ", i, data1, data2, data3);
868− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
869− goto buffer_done;
773+ len += sysfs_emit_at(buf, len,
774+ "HDWQ (%d): Rd %016llx Wr %016llx IO %016llx ",
775+ i, data1, data2, data3);
870776
871− scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",
872− tot, ((data1 + data2 + data3) - tot));
873− if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
874− goto buffer_done;
875− }
876− scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx "
877− "OutIO %016llx\n", totin, totout, totout - totin);
878− strlcat(buf, tmp, PAGE_SIZE);
777+ len += sysfs_emit_at(buf, len,
778+ "Cmpl %016llx OutIO %016llx\n",
779+ tot, ((data1 + data2 + data3) - tot));
879780
880−buffer_done:
881− len = strnlen(buf, PAGE_SIZE);
781+ if (len >= PAGE_SIZE - 1)
782+ break;
783+ }
784+ len += sysfs_emit_at(buf, len,
785+ "Total FCP Cmpl %016llx Issue %016llx OutIO %016llx\n",
786+ totin, totout, totout - totin);
882787
883788 return len;
884789 }
drivers/scsi/lpfc/lpfc_bsg.c+2−4
@@ -1329,10 +1329,8 @@ lpfc_bsg_hba_get_event(struct bsg_job *job) · 1328 unmodified lines
13291329 else
13301330 bsg_reply->reply_payload_rcv_len = 0;
13311331
1332− if (evt_dat) {
1333− kfree(evt_dat->data);
1334− kfree(evt_dat);
1335− }
1332+ kfree(evt_dat->data);
1333+ kfree(evt_dat);
13361334
13371335 spin_lock_irqsave(&phba->ct_ev_lock, flags);
13381336 lpfc_bsg_event_unref(evt);
drivers/scsi/lpfc/lpfc_ct.c+5−24
@@ -1823,34 +1823,15 @@ lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, · 1822 unmodified lines
18231823 size_t size)
18241824 {
18251825 char fwrev[FW_REV_STR_SIZE] = {0};
1826− char tmp[MAXHOSTNAMELEN] = {0};
1827−
1828− memset(symbol, 0, size);
1829−
1830− scnprintf(tmp, sizeof(tmp), "Emulex %s", vport->phba->ModelName);
1831− if (strlcat(symbol, tmp, size) >= size)
1832− goto buffer_done;
18331826
18341827 lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
1835− scnprintf(tmp, sizeof(tmp), " FV%s", fwrev);
1836− if (strlcat(symbol, tmp, size) >= size)
1837− goto buffer_done;
1838−
1839− scnprintf(tmp, sizeof(tmp), " DV%s", lpfc_release_version);
1840− if (strlcat(symbol, tmp, size) >= size)
1841− goto buffer_done;
1842−
1843− scnprintf(tmp, sizeof(tmp), " HN:%s", vport->phba->os_host_name);
1844− if (strlcat(symbol, tmp, size) >= size)
1845− goto buffer_done;
18461828
1829+ memset(symbol, 0, size);
18471830 /* Note :- OS name is "Linux" */
1848− scnprintf(tmp, sizeof(tmp), " OS:%s", init_utsname()->sysname);
1849− strlcat(symbol, tmp, size);
1850−
1851−buffer_done:
1852− return strnlen(symbol, size);
1853−
1831+ return scnprintf(symbol, size, "Emulex %s FV%s DV%s HN:%s OS:%s",
1832+ vport->phba->ModelName, fwrev,
1833+ lpfc_release_version, vport->phba->os_host_name,
1834+ init_utsname()->sysname);
18541835 }
18551836
18561837 static uint32_t
drivers/scsi/lpfc/lpfc_debugfs.c+87−115
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include <linux/idr.h>
2828 #include <linux/interrupt.h>
2929 #include <linux/kthread.h>
30+#include <linux/seq_buf.h>
3031 #include <linux/slab.h>
3132 #include <linux/pci.h>
3233 #include <linux/spinlock.h>
@@ -462,7 +463,8 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 429 unmodified lines
462463 struct lpfc_pvt_pool *pvt_pool;
463464 struct lpfc_pbl_pool *pbl_pool;
464465 u32 txcmplq_cnt;
465− char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0};
466+ size_t used;
467+ struct seq_buf s;
466468
467469 if (phba->sli_rev != LPFC_SLI_REV4)
468470 return 0;
@@ -475,6 +477,9 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 6 unmodified lines
475477 return i;
476478 }
477479
480+ used = strnlen(buf, size);
481+ seq_buf_init(&s, buf + used, size - used);
482+
478483 /*
479484 * Pbl: Current number of free XRIs in public pool
480485 * Pvt: Current number of free XRIs in private pool
@@ -484,10 +489,8 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 3 unmodified lines
484489 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
485490 * IO submission
486491 */
487− scnprintf(tmp, sizeof(tmp),
488− "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
489− if (strlcat(buf, tmp, size) >= size)
490− return strnlen(buf, size);
492+ seq_buf_printf(&s,
493+ "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
491494
492495 #ifdef LPFC_MXP_STAT
493496 /*
@@ -501,25 +504,17 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 7 unmodified lines
501504 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
502505 * other pbl_pool
503506 */
504− scnprintf(tmp, sizeof(tmp),
505− "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
506− if (strlcat(buf, tmp, size) >= size)
507− return strnlen(buf, size);
507+ seq_buf_printf(&s, "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
508508
509509 /*
510510 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
511511 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
512512 * sBusy: snapshot of Busy 15 sec after stat gets cleared
513513 */
514− scnprintf(tmp, sizeof(tmp),
515− " | sPbl sPvt sBusy");
516− if (strlcat(buf, tmp, size) >= size)
517− return strnlen(buf, size);
514+ seq_buf_printf(&s, " | sPbl sPvt sBusy");
518515 #endif
519516
520− scnprintf(tmp, sizeof(tmp), "\n");
521− if (strlcat(buf, tmp, size) >= size)
522− return strnlen(buf, size);
517+ seq_buf_printf(&s, "\n");
523518
524519 hwq_count = phba->cfg_hdw_queue;
525520 for (i = 0; i < hwq_count; i++) {
@@ -531,36 +526,32 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 5 unmodified lines
531526 pvt_pool = &multixri_pool->pvt_pool;
532527 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
533528
534− scnprintf(tmp, sizeof(tmp),
535− "%03d: %4d %4d %4d %4d | %10d %10d ",
536− i, pbl_pool->count, pvt_pool->count,
537− txcmplq_cnt, pvt_pool->high_watermark,
538− qp->empty_io_bufs, multixri_pool->pbl_empty_count);
539− if (strlcat(buf, tmp, size) >= size)
540− break;
529+ seq_buf_printf(&s,
530+ "%03d: %4d %4d %4d %4d | %10d %10d ",
531+ i, pbl_pool->count, pvt_pool->count,
532+ txcmplq_cnt, pvt_pool->high_watermark,
533+ qp->empty_io_bufs,
534+ multixri_pool->pbl_empty_count);
541535
542536 #ifdef LPFC_MXP_STAT
543− scnprintf(tmp, sizeof(tmp),
544− "%4d %10d %10d %10d %10d",
545− multixri_pool->stat_max_hwm,
546− multixri_pool->above_limit_count,
547− multixri_pool->below_limit_count,
548− multixri_pool->local_pbl_hit_count,
549− multixri_pool->other_pbl_hit_count);
550− if (strlcat(buf, tmp, size) >= size)
551− break;
552−
553− scnprintf(tmp, sizeof(tmp),
554− " | %4d %4d %5d",
555− multixri_pool->stat_pbl_count,
556− multixri_pool->stat_pvt_count,
557− multixri_pool->stat_busy_count);
558− if (strlcat(buf, tmp, size) >= size)
559− break;
537+ seq_buf_printf(&s,
538+ "%4d %10d %10d %10d %10d",
539+ multixri_pool->stat_max_hwm,
540+ multixri_pool->above_limit_count,
541+ multixri_pool->below_limit_count,
542+ multixri_pool->local_pbl_hit_count,
543+ multixri_pool->other_pbl_hit_count);
544+
545+ seq_buf_printf(&s,
546+ " | %4d %4d %5d",
547+ multixri_pool->stat_pbl_count,
548+ multixri_pool->stat_pvt_count,
549+ multixri_pool->stat_busy_count);
560550 #endif
561551
562− scnprintf(tmp, sizeof(tmp), "\n");
563− if (strlcat(buf, tmp, size) >= size)
552+ seq_buf_printf(&s, "\n");
553+
554+ if (seq_buf_has_overflowed(&s))
564555 break;
565556 }
566557 return strnlen(buf, size);
@@ -1261,13 +1252,14 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size) · 694 unmodified lines
12611252 u64 data1, data2, data3;
12621253 u64 tot, totin, totout;
12631254 int i;
1264− char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
1255+ struct seq_buf s;
12651256
12661257 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
12671258 (phba->sli_rev != LPFC_SLI_REV4))
12681259 return 0;
12691260
1270− scnprintf(buf, size, "SCSI HDWQ Statistics\n");
1261+ seq_buf_init(&s, buf, size);
1262+ seq_buf_printf(&s, "SCSI HDWQ Statistics\n");
12711263
12721264 totin = 0;
12731265 totout = 0;
@@ -1280,21 +1272,18 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size) · 6 unmodified lines
12801272 data3 = cstat->control_requests;
12811273 totout += (data1 + data2 + data3);
12821274
1283− scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "
1284− "IO %016llx ", i, data1, data2, data3);
1285− if (strlcat(buf, tmp, size) >= size)
1286− goto buffer_done;
1275+ seq_buf_printf(&s, "HDWQ (%d): Rd %016llx Wr %016llx IO %016llx ",
1276+ i, data1, data2, data3);
1277+
1278+ seq_buf_printf(&s, "Cmpl %016llx OutIO %016llx\n",
1279+ tot, ((data1 + data2 + data3) - tot));
12871280
1288− scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",
1289− tot, ((data1 + data2 + data3) - tot));
1290− if (strlcat(buf, tmp, size) >= size)
1291− goto buffer_done;
1281+ if (seq_buf_has_overflowed(&s))
1282+ break;
12921283 }
1293− scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx "
1294− "OutIO %016llx\n", totin, totout, totout - totin);
1295− strlcat(buf, tmp, size);
1284+ seq_buf_printf(&s, "Total FCP Cmpl %016llx Issue %016llx OutIO %016llx\n",
1285+ totin, totout, totout - totin);
12961286
1297−buffer_done:
12981287 len = strnlen(buf, size);
12991288
13001289 return len;
@@ -1704,28 +1693,23 @@ lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size) · 403 unmodified lines
17041693 uint32_t tot_xmt;
17051694 uint32_t tot_rcv;
17061695 uint32_t tot_cmpl;
1707− char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
1696+ size_t used = strnlen(buf, size);
1697+ struct seq_buf s;
17081698
1709− scnprintf(tmp, sizeof(tmp), "HDWQ Stats:\n\n");
1710− if (strlcat(buf, tmp, size) >= size)
1711− goto buffer_done;
1699+ seq_buf_init(&s, buf + used, size - used);
17121700
1713− scnprintf(tmp, sizeof(tmp), "(NVME Accounting: %s) ",
1714− (phba->hdwqstat_on &
1715− (LPFC_CHECK_NVME_IO | LPFC_CHECK_NVMET_IO) ?
1716− "Enabled" : "Disabled"));
1717− if (strlcat(buf, tmp, size) >= size)
1718− goto buffer_done;
1701+ seq_buf_printf(&s, "HDWQ Stats:\n\n");
17191702
1720− scnprintf(tmp, sizeof(tmp), "(SCSI Accounting: %s) ",
1721− (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ?
1722− "Enabled" : "Disabled"));
1723− if (strlcat(buf, tmp, size) >= size)
1724− goto buffer_done;
1703+ seq_buf_printf(&s, "(NVME Accounting: %s) ",
1704+ (phba->hdwqstat_on &
1705+ (LPFC_CHECK_NVME_IO | LPFC_CHECK_NVMET_IO) ?
1706+ "Enabled" : "Disabled"));
17251707
1726− scnprintf(tmp, sizeof(tmp), "\n\n");
1727− if (strlcat(buf, tmp, size) >= size)
1728− goto buffer_done;
1708+ seq_buf_printf(&s, "(SCSI Accounting: %s) ",
1709+ (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ?
1710+ "Enabled" : "Disabled"));
1711+
1712+ seq_buf_printf(&s, "\n\n");
17291713
17301714 for (i = 0; i < phba->cfg_hdw_queue; i++) {
17311715 tot_rcv = 0;
@@ -1744,62 +1728,50 @@ lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size) · 12 unmodified lines
17441728 !c_stat->rcv_io)
17451729 continue;
17461730
1747− if (!tot_xmt && !tot_cmpl && !tot_rcv) {
1748− /* Print HDWQ string only the first time */
1749− scnprintf(tmp, sizeof(tmp), "[HDWQ %d]:\t", i);
1750− if (strlcat(buf, tmp, size) >= size)
1751− goto buffer_done;
1752− }
1731+ /* Print HDWQ string only the first time */
1732+ if (!tot_xmt && !tot_cmpl && !tot_rcv)
1733+ seq_buf_printf(&s, "[HDWQ %d]:\t", i);
17531734
17541735 tot_xmt += c_stat->xmt_io;
17551736 tot_cmpl += c_stat->cmpl_io;
17561737 if (phba->nvmet_support)
17571738 tot_rcv += c_stat->rcv_io;
17581739
1759− scnprintf(tmp, sizeof(tmp), "| [CPU %d]: ", j);
1760− if (strlcat(buf, tmp, size) >= size)
1761− goto buffer_done;
1762−
1763− if (phba->nvmet_support) {
1764− scnprintf(tmp, sizeof(tmp),
1765− "XMT 0x%x CMPL 0x%x RCV 0x%x |",
1766− c_stat->xmt_io, c_stat->cmpl_io,
1767− c_stat->rcv_io);
1768− if (strlcat(buf, tmp, size) >= size)
1769− goto buffer_done;
1770− } else {
1771− scnprintf(tmp, sizeof(tmp),
1772− "XMT 0x%x CMPL 0x%x |",
1773− c_stat->xmt_io, c_stat->cmpl_io);
1774− if (strlcat(buf, tmp, size) >= size)
1775− goto buffer_done;
1776− }
1740+ seq_buf_printf(&s, "| [CPU %d]: ", j);
1741+
1742+ if (phba->nvmet_support)
1743+ seq_buf_printf(&s,
1744+ "XMT 0x%x CMPL 0x%x RCV 0x%x |",
1745+ c_stat->xmt_io, c_stat->cmpl_io,
1746+ c_stat->rcv_io);
1747+ else
1748+ seq_buf_printf(&s,
1749+ "XMT 0x%x CMPL 0x%x |",
1750+ c_stat->xmt_io, c_stat->cmpl_io);
1751+
1752+ if (seq_buf_has_overflowed(&s))
1753+ break;
17771754 }
17781755
1756+ if (seq_buf_has_overflowed(&s))
1757+ break;
1758+
17791759 /* Check if nothing to display */
17801760 if (!tot_xmt && !tot_cmpl && !tot_rcv)
17811761 continue;
17821762
1783− scnprintf(tmp, sizeof(tmp), "\t->\t[HDWQ Total: ");
1784− if (strlcat(buf, tmp, size) >= size)
1785− goto buffer_done;
1763+ seq_buf_printf(&s, "\t->\t[HDWQ Total: ");
17861764
1787− if (phba->nvmet_support) {
1788− scnprintf(tmp, sizeof(tmp),
1789− "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",
1790− tot_xmt, tot_cmpl, tot_rcv);
1791− if (strlcat(buf, tmp, size) >= size)
1792− goto buffer_done;
1793− } else {
1794− scnprintf(tmp, sizeof(tmp),
1795− "XMT 0x%x CMPL 0x%x]\n\n",
1796− tot_xmt, tot_cmpl);
1797− if (strlcat(buf, tmp, size) >= size)
1798− goto buffer_done;
1799− }
1765+ if (phba->nvmet_support)
1766+ seq_buf_printf(&s,
1767+ "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",
1768+ tot_xmt, tot_cmpl, tot_rcv);
1769+ else
1770+ seq_buf_printf(&s,
1771+ "XMT 0x%x CMPL 0x%x]\n\n",
1772+ tot_xmt, tot_cmpl);
18001773 }
18011774
1802−buffer_done:
18031775 len = strnlen(buf, size);
18041776 return len;
18051777 }
drivers/scsi/lpfc/lpfc_scsi.c+15−34
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 * included with this package. *
2222 *******************************************************************/
2323 #include <linux/pci.h>
24+#include <linux/seq_buf.h>
2425 #include <linux/slab.h>
2526 #include <linux/interrupt.h>
2627 #include <linux/export.h>
@@ -5103,57 +5104,37 @@ lpfc_info(struct Scsi_Host *host) · 5076 unmodified lines
51035104 struct lpfc_hba *phba = vport->phba;
51045105 int link_speed = 0;
51055106 static char lpfcinfobuf[384];
5106− char tmp[384] = {0};
5107+ struct seq_buf s;
51075108
51085109 memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
5110+ seq_buf_init(&s, lpfcinfobuf, sizeof(lpfcinfobuf));
51095111 if (phba && phba->pcidev){
51105112 /* Model Description */
5111− scnprintf(tmp, sizeof(tmp), phba->ModelDesc);
5112− if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5113− sizeof(lpfcinfobuf))
5114− goto buffer_done;
5113+ seq_buf_printf(&s, "%s", phba->ModelDesc);
51155114
51165115 /* PCI Info */
5117− scnprintf(tmp, sizeof(tmp),
5118− " on PCI bus %02x device %02x irq %d",
5119− phba->pcidev->bus->number, phba->pcidev->devfn,
5120− phba->pcidev->irq);
5121− if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5122− sizeof(lpfcinfobuf))
5123− goto buffer_done;
5116+ seq_buf_printf(&s, " on PCI bus %02x device %02x irq %d",
5117+ phba->pcidev->bus->number, phba->pcidev->devfn,
5118+ phba->pcidev->irq);
51245119
51255120 /* Port Number */
5126− if (phba->Port[0]) {
5127− scnprintf(tmp, sizeof(tmp), " port %s", phba->Port);
5128− if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5129− sizeof(lpfcinfobuf))
5130− goto buffer_done;
5131− }
5121+ if (phba->Port[0])
5122+ seq_buf_printf(&s, " port %s", phba->Port);
51325123
51335124 /* Link Speed */
51345125 link_speed = lpfc_sli_port_speed_get(phba);
5135− if (link_speed != 0) {
5136− scnprintf(tmp, sizeof(tmp),
5137− " Logical Link Speed: %d Mbps", link_speed);
5138− if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5139− sizeof(lpfcinfobuf))
5140− goto buffer_done;
5141− }
5126+ if (link_speed != 0)
5127+ seq_buf_printf(&s, " Logical Link Speed: %d Mbps",
5128+ link_speed);
51425129
51435130 /* Support for BSG ioctls */
5144− scnprintf(tmp, sizeof(tmp), " BSG");
5145− if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5146− sizeof(lpfcinfobuf))
5147− goto buffer_done;
5131+ seq_buf_printf(&s, " BSG");
51485132
51495133 /* PCI resettable */
5150− if (!lpfc_check_pci_resettable(phba)) {
5151− scnprintf(tmp, sizeof(tmp), " PCI resettable");
5152− strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf));
5153− }
5134+ if (!lpfc_check_pci_resettable(phba))
5135+ seq_buf_printf(&s, " PCI resettable");
51545136 }
51555137
5156−buffer_done:
51575138 return lpfcinfobuf;
51585139 }
51595140
drivers/scsi/lpfc/lpfc_scsi.h+0−3
@@ -158,6 +158,3 @@ struct fcp_cmnd32 { · 157 unmodified lines
158158
159159 #define TXRDY_PAYLOAD_LEN 12
160160
161−/* For sysfs/debugfs tmp string max len */
162−#define LPFC_MAX_SCSI_INFO_TMP_LEN 79
163−
drivers/scsi/lpfc/lpfc_sli.c+24−19
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/pci.h>
2626 #include <linux/interrupt.h>
2727 #include <linux/delay.h>
28+#include <linux/seq_buf.h>
2829 #include <linux/slab.h>
2930 #include <linux/lockdep.h>
3031 #include <linux/dmi.h>
@@ -8109,17 +8110,18 @@ u32 lpfc_rx_monitor_report(struct lpfc_hba *phba, · 8078 unmodified lines
81098110 u32 cnt = 0;
81108111 char tmp[DBG_LOG_STR_SZ] = {0};
81118112 bool log_to_kmsg = (!buf || !buf_len) ? true : false;
8113+ struct seq_buf s;
81128114
81138115 if (!log_to_kmsg) {
81148116 /* clear the buffer to be sure */
81158117 memset(buf, 0, buf_len);
81168118
8117− scnprintf(buf, buf_len, "\t%-16s%-16s%-16s%-16s%-8s%-8s%-8s"
8118− "%-8s%-8s%-8s%-16s\n",
8119− "MaxBPI", "Tot_Data_CMF",
8120− "Tot_Data_Cmd", "Tot_Data_Cmpl",
8121− "Lat(us)", "Avg_IO", "Max_IO", "Bsy",
8122− "IO_cnt", "Info", "BWutil(ms)");
8119+ seq_buf_init(&s, buf, buf_len);
8120+ seq_buf_printf(&s, "\t%-16s%-16s%-16s%-16s%-8s%-8s%-8s%-8s%-8s%-8s%-16s\n",
8121+ "MaxBPI", "Tot_Data_CMF",
8122+ "Tot_Data_Cmd", "Tot_Data_Cmpl",
8123+ "Lat(us)", "Avg_IO", "Max_IO", "Bsy",
8124+ "IO_cnt", "Info", "BWutil(ms)");
81238125 }
81248126
81258127 /* Needs to be _irq because record is called from timer interrupt
@@ -8131,24 +8133,27 @@ u32 lpfc_rx_monitor_report(struct lpfc_hba *phba, · 5 unmodified lines
81318133
81328134 /* Read out this entry's data. */
81338135 if (!log_to_kmsg) {
8134− /* If !log_to_kmsg, then store to buf. */
8136+ /*
8137+ * Drop a record whole if it does not fit, without
8138+ * consuming its ring entry.
8139+ */
81358140 scnprintf(tmp, sizeof(tmp),
8136− "%03d:\t%-16llu%-16llu%-16llu%-16llu%-8llu"
8137− "%-8llu%-8llu%-8u%-8u%-8u%u(%u)\n",
8138− *head_idx, entry->max_bytes_per_interval,
8139− entry->cmf_bytes, entry->total_bytes,
8140− entry->rcv_bytes, entry->avg_io_latency,
8141− entry->avg_io_size, entry->max_read_cnt,
8141+ "%03d:\t%-16llu%-16llu%-16llu%-16llu%-8llu%-8llu%-8llu%-8u%-8u%-8u%u(%u)\n",
8142+ *head_idx,
8143+ entry->max_bytes_per_interval,
8144+ entry->cmf_bytes,
8145+ entry->total_bytes,
8146+ entry->rcv_bytes,
8147+ entry->avg_io_latency,
8148+ entry->avg_io_size,
8149+ entry->max_read_cnt,
81428150 entry->cmf_busy, entry->io_cnt,
8143− entry->cmf_info, entry->timer_utilization,
8151+ entry->cmf_info,
8152+ entry->timer_utilization,
81448153 entry->timer_interval);
81458154
8146− /* Check for buffer overflow */
8147− if ((strlen(buf) + strlen(tmp)) >= buf_len)
8155+ if (seq_buf_puts(&s, tmp) < 0)
81488156 break;
8149−
8150− /* Append entry's data to buffer */
8151− strlcat(buf, tmp, buf_len);
81528157 } else {
81538158 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
81548159 "4410 %02u: MBPI %llu Xmit %llu "
drivers/scsi/megaraid/megaraid_sas_base.c+1−1
@@ -3072,7 +3072,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd) · 3071 unmodified lines
30723072
30733073 scmd_printk(KERN_INFO, scmd,
30743074 "SCSI host state: %d SCSI host busy: %d FW outstanding: %d\n",
3075− scmd->device->host->shost_state,
3075+ scsi_get_host_state(scmd->device->host),
30763076 scsi_host_busy(scmd->device->host),
30773077 atomic_read(&instance->fw_outstanding));
30783078 /*
drivers/scsi/mpi3mr/mpi3mr_os.c+1−1
@@ -5172,7 +5172,7 @@ static enum scsi_qc_status mpi3mr_qcmd(struct Scsi_Host *shost, · 5171 unmodified lines
51725172
51735173 /* Avoid error handling escalation when device is removed or blocked */
51745174
5175− if (scmd->device->host->shost_state == SHOST_RECOVERY &&
5175+ if (scsi_get_host_state(scmd->device->host) == SHOST_RECOVERY &&
51765176 scmd->cmnd[0] == TEST_UNIT_READY &&
51775177 (stgt_priv_data->dev_removed || (dev_handle == MPI3MR_INVALID_DEV_HANDLE))) {
51785178 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);
drivers/scsi/mpt3sas/mpt3sas_base.c+2−0
@@ -5870,6 +5870,8 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) · 5869 unmodified lines
58705870
58715871 if (ioc->pcie_sgl_dma_pool) {
58725872 for (i = 0; i < ioc->scsiio_depth; i++) {
5873+ if (!ioc->pcie_sg_lookup[i].pcie_sgl)
5874+ continue;
58735875 dma_pool_free(ioc->pcie_sgl_dma_pool,
58745876 ioc->pcie_sg_lookup[i].pcie_sgl,
58755877 ioc->pcie_sg_lookup[i].pcie_sgl_dma);
drivers/scsi/mpt3sas/mpt3sas_scsih.c+1−1
@@ -5472,7 +5472,7 @@ static enum scsi_qc_status scsih_qcmd(struct Scsi_Host *shost, · 5471 unmodified lines
54725472 * Avoid error handling escallation when device is disconnected
54735473 */
54745474 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) {
5475− if (scmd->device->host->shost_state == SHOST_RECOVERY &&
5475+ if (scsi_get_host_state(scmd->device->host) == SHOST_RECOVERY &&
54765476 scmd->cmnd[0] == TEST_UNIT_READY) {
54775477 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);
54785478 scsi_done(scmd);
drivers/scsi/qla2xxx/qla_init.c+2−2
@@ -2302,7 +2302,7 @@ int qla_get_tmf(struct tmf_arg *arg) · 2301 unmodified lines
23022302 if (TMF_NOT_READY(fcport)) {
23032303 ql_log(ql_log_warn, vha, 0x802c,
23042304 "Unable to acquire TM resource due to disruption.\n");
2305− rc = EIO;
2305+ rc = -EIO;
23062306 break;
23072307 }
23082308 if (ha->active_tmf < MAX_ACTIVE_TMF &&
@@ -9269,7 +9269,7 @@ static int qla29xx_process_rd_image(struct scsi_qla_host *vha, · 6960 unmodified lines
92699269 if (section == TIM) {
92709270 if (section_size > req->length * qla_req_entry_size(ha)) {
92719271 ql_log(ql_log_fatal, vha, 0x0098,
9272− "TIM section too large (0x%x bytes, ring 0x%lx bytes).\n",
9272+ "TIM section too large (0x%x bytes, ring 0x%zx bytes).\n",
92739273 section_size,
92749274 req->length * qla_req_entry_size(ha));
92759275 return QLA_FUNCTION_FAILED;
drivers/scsi/qla2xxx/qla_nx2.c+1−1
@@ -3507,7 +3507,7 @@ qla8044_poll_flash_status_reg(struct scsi_qla_host *vha) · 3506 unmodified lines
35073507 msleep(QLA8044_FLASH_STATUS_REG_POLL_DELAY);
35083508 }
35093509
3510− if (!retries)
3510+ if (retries == -1)
35113511 ret_val = QLA_FUNCTION_FAILED;
35123512
35133513 return ret_val;
drivers/scsi/qla4xxx/ql4_os.c+2−4
@@ -9411,11 +9411,9 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) · 9410 unmodified lines
94119411 * This routine finds that if reset host is called in EH
94129412 * scenario or from some application like sg_reset
94139413 **/
9414−static int qla4xxx_is_eh_active(struct Scsi_Host *shost)
9414+static bool qla4xxx_is_eh_active(struct Scsi_Host *shost)
94159415 {
9416− if (shost->shost_state == SHOST_RECOVERY)
9417− return 1;
9418− return 0;
9416+ return scsi_get_host_state(shost) == SHOST_RECOVERY;
94199417 }
94209418
94219419 /**
drivers/scsi/scsi_lib.c+1−2
@@ -1663,10 +1663,9 @@ static enum scsi_qc_status scsi_dispatch_cmd(struct scsi_cmnd *cmd) · 1662 unmodified lines
16631663 goto done;
16641664 }
16651665
1666− if (unlikely(host->shost_state == SHOST_DEL)) {
1666+ if (unlikely(scsi_get_host_state(host) == SHOST_DEL)) {
16671667 cmd->result = (DID_NO_CONNECT << 16);
16681668 goto done;
1669−
16701669 }
16711670
16721671 trace_scsi_dispatch_cmd_start(cmd);
drivers/scsi/scsi_scan.c+31−21
@@ -1169,6 +1169,7 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq, · 1168 unmodified lines
11691169
11701170 /**
11711171 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
1172+ * @shost: SCSI host pointer
11721173 * @starget: pointer to target device structure
11731174 * @lun: LUN of target device
11741175 * @bflagsp: store bflags here if not NULL
@@ -1188,17 +1189,18 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq, · 13 unmodified lines
11881189 * attached at the LUN
11891190 * - SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
11901191 **/
1191−static int scsi_probe_and_add_lun(struct scsi_target *starget,
1192+static int scsi_probe_and_add_lun(struct Scsi_Host *shost,
1193+ struct scsi_target *starget,
11921194 u64 lun, blist_flags_t *bflagsp,
11931195 struct scsi_device **sdevp,
11941196 enum scsi_scan_mode rescan,
11951197 void *hostdata)
1198+ __must_hold(&shost->scan_mutex)
11961199 {
11971200 struct scsi_device *sdev;
11981201 unsigned char *result;
11991202 blist_flags_t bflags;
12001203 int res = SCSI_SCAN_NO_RESPONSE, result_len = 256;
1201− struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
12021204
12031205 /*
12041206 * The rescan flag is used as an optimization, the first scan of a
@@ -1334,6 +1336,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, · 129 unmodified lines
13341336
13351337 /**
13361338 * scsi_sequential_lun_scan - sequentially scan a SCSI target
1339+ * @shost: SCSI host pointer
13371340 * @starget: pointer to target structure to scan
13381341 * @bflags: black/white list flag for LUN 0
13391342 * @scsi_level: Which version of the standard does this device adhere to
@@ -1346,13 +1349,14 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, · 6 unmodified lines
13461349 *
13471350 * Modifies sdevscan->lun.
13481351 **/
1349−static void scsi_sequential_lun_scan(struct scsi_target *starget,
1352+static void scsi_sequential_lun_scan(struct Scsi_Host *shost,
1353+ struct scsi_target *starget,
13501354 blist_flags_t bflags, int scsi_level,
13511355 enum scsi_scan_mode rescan)
1356+ __must_hold(&shost->scan_mutex)
13521357 {
13531358 uint max_dev_lun;
13541359 u64 sparse_lun, lun;
1355− struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
13561360
13571361 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget,
13581362 "scsi scan: Sequential scan\n"));
@@ -1412,14 +1416,15 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, · 53 unmodified lines
14121416 * sparse_lun.
14131417 */
14141418 for (lun = 1; lun < max_dev_lun; ++lun)
1415− if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan,
1416− NULL) != SCSI_SCAN_LUN_PRESENT) &&
1419+ if (scsi_probe_and_add_lun(shost, starget, lun, NULL, NULL,
1420+ rescan, NULL) != SCSI_SCAN_LUN_PRESENT &&
14171421 !sparse_lun)
14181422 return;
14191423 }
14201424
14211425 /**
14221426 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
1427+ * @shost: SCSI host pointer
14231428 * @starget: which target
14241429 * @bflags: Zero or a mix of BLIST_NOLUN, BLIST_REPORTLUN2, or BLIST_NOREPORTLUN
14251430 * @rescan: nonzero if we can skip code only needed on first scan
@@ -1438,8 +1443,10 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, · 12 unmodified lines
14381443 * 0: scan completed (or no memory, so further scanning is futile)
14391444 * 1: could not scan with REPORT LUN
14401445 **/
1441−static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags,
1442− enum scsi_scan_mode rescan)
1446+static int scsi_report_lun_scan(struct Scsi_Host *shost,
1447+ struct scsi_target *starget, blist_flags_t bflags,
1448+ enum scsi_scan_mode rescan)
1449+ __must_hold(&shost->scan_mutex)
14431450 {
14441451 unsigned char scsi_cmd[MAX_COMMAND_SIZE];
14451452 unsigned int length;
@@ -1448,7 +1455,6 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag · 2 unmodified lines
14481455 int result;
14491456 struct scsi_lun *lunp, *lun_data;
14501457 struct scsi_device *sdev;
1451− struct Scsi_Host *shost = dev_to_shost(&starget->dev);
14521458 struct scsi_failure failure_defs[] = {
14531459 {
14541460 .sense = UNIT_ATTENTION,
@@ -1594,7 +1600,7 @@ retry: · 139 unmodified lines
15941600 } else {
15951601 int res;
15961602
1597− res = scsi_probe_and_add_lun(starget,
1603+ res = scsi_probe_and_add_lun(shost, starget,
15981604 lun, NULL, NULL, rescan, NULL);
15991605 if (res == SCSI_SCAN_NO_RESPONSE) {
16001606 /*
@@ -1641,7 +1647,7 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, · 40 unmodified lines
16411647 scsi_complete_async_scans();
16421648
16431649 if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) {
1644− scsi_probe_and_add_lun(starget, lun, NULL, &sdev,
1650+ scsi_probe_and_add_lun(shost, starget, lun, NULL, &sdev,
16451651 SCSI_SCAN_RESCAN, hostdata);
16461652 scsi_autopm_put_host(shost);
16471653 }
@@ -1763,10 +1769,11 @@ unlock: · 115 unmodified lines
17631769 }
17641770 EXPORT_SYMBOL(scsi_rescan_device);
17651771
1766−static void __scsi_scan_target(struct device *parent, unsigned int channel,
1767− unsigned int id, u64 lun, enum scsi_scan_mode rescan)
1772+static void __scsi_scan_target(struct Scsi_Host *shost, struct device *parent,
1773+ unsigned int channel, unsigned int id, u64 lun,
1774+ enum scsi_scan_mode rescan)
1775+ __must_hold(&shost->scan_mutex)
17681776 {
1769− struct Scsi_Host *shost = dev_to_shost(parent);
17701777 blist_flags_t bflags = 0;
17711778 int res;
17721779 struct scsi_target *starget;
@@ -1786,7 +1793,8 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, · 13 unmodified lines
17861793 /*
17871794 * Scan for a specific host/chan/id/lun.
17881795 */
1789− scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL);
1796+ scsi_probe_and_add_lun(shost, starget, lun, NULL, NULL, rescan,
1797+ NULL);
17901798 goto out_reap;
17911799 }
17921800
@@ -1794,14 +1802,15 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, · 1 unmodified line
17941802 * Scan LUN 0, if there is some response, scan further. Ideally, we
17951803 * would not configure LUN 0 until all LUNs are scanned.
17961804 */
1797− res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);
1805+ res = scsi_probe_and_add_lun(shost, starget, 0, &bflags, NULL, rescan,
1806+ NULL);
17981807 if (res == SCSI_SCAN_LUN_PRESENT || res == SCSI_SCAN_TARGET_PRESENT) {
1799− if (scsi_report_lun_scan(starget, bflags, rescan) != 0)
1808+ if (scsi_report_lun_scan(shost, starget, bflags, rescan) != 0)
18001809 /*
18011810 * The REPORT LUN did not scan the target,
18021811 * do a sequential scan.
18031812 */
1804− scsi_sequential_lun_scan(starget, bflags,
1813+ scsi_sequential_lun_scan(shost, starget, bflags,
18051814 starget->scsi_level, rescan);
18061815 }
18071816
@@ -1851,7 +1860,7 @@ void scsi_scan_target(struct device *parent, unsigned int channel, · 43 unmodified lines
18511860 scsi_complete_async_scans();
18521861
18531862 if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) {
1854− __scsi_scan_target(parent, channel, id, lun, rescan);
1863+ __scsi_scan_target(shost, parent, channel, id, lun, rescan);
18551864 scsi_autopm_put_host(shost);
18561865 }
18571866 mutex_unlock(&shost->scan_mutex);
@@ -1861,6 +1870,7 @@ EXPORT_SYMBOL(scsi_scan_target); · 3 unmodified lines
18611870 static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
18621871 unsigned int id, u64 lun,
18631872 enum scsi_scan_mode rescan)
1873+ __must_hold(&shost->scan_mutex)
18641874 {
18651875 uint order_id;
18661876
@@ -1882,11 +1892,11 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, · 15 unmodified lines
18821892 order_id = shost->max_id - id - 1;
18831893 else
18841894 order_id = id;
1885− __scsi_scan_target(&shost->shost_gendev, channel,
1895+ __scsi_scan_target(shost, &shost->shost_gendev, channel,
18861896 order_id, lun, rescan);
18871897 }
18881898 else
1889− __scsi_scan_target(&shost->shost_gendev, channel,
1899+ __scsi_scan_target(shost, &shost->shost_gendev, channel,
18901900 id, lun, rescan);
18911901 }
18921902
drivers/scsi/scsi_sysfs.c+4−3
@@ -214,8 +214,9 @@ store_shost_state(struct device *dev, struct device_attribute *attr, · 213 unmodified lines
214214 if (!state)
215215 return -EINVAL;
216216
217− if (scsi_host_set_state(shost, state))
218− return -EINVAL;
217+ scoped_guard(spinlock_irq, shost->host_lock)
218+ if (scsi_host_set_state(shost, state))
219+ return -EINVAL;
219220 return count;
220221 }
221222
@@ -223,7 +224,7 @@ static ssize_t · 1 unmodified line
223224 show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
224225 {
225226 struct Scsi_Host *shost = class_to_shost(dev);
226− const char *name = scsi_host_state_name(shost->shost_state);
227+ const char *name = scsi_host_state_name(scsi_get_host_state(shost));
227228
228229 if (!name)
229230 return -EINVAL;
drivers/scsi/snic/snic_main.c+1−0
@@ -305,6 +305,7 @@ snic_add_host(struct Scsi_Host *shost, struct pci_dev *pdev) · 304 unmodified lines
305305 if (!shost->work_q) {
306306 SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
307307
308+ scsi_remove_host(shost);
308309 ret = -ENOMEM;
309310 }
310311
drivers/ufs/core/Makefile+2−0
@@ -1,5 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
22
3+CONTEXT_ANALYSIS := y
4+
35 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
46 ufshcd-core-y += ufshcd.o ufs-sysfs.o ufs-mcq.o ufs-txeq.o
57 ufshcd-core-$(CONFIG_RPMB) += ufs-rpmb.o
drivers/ufs/core/ufs-debugfs.c+6−2
@@ -65,8 +65,10 @@ static int ee_usr_mask_get(void *data, u64 *val) · 64 unmodified lines
6565 return 0;
6666 }
6767
68+token_context_lock(ufs_debugfs);
69+
6870 static int ufs_debugfs_get_user_access(struct ufs_hba *hba)
69−__acquires(&hba->host_sem)
71+ __cond_acquires(0, ufs_debugfs)
7072 {
7173 down(&hba->host_sem);
7274 if (!ufshcd_is_user_access_allowed(hba)) {
@@ -74,14 +76,16 @@ __acquires(&hba->host_sem) · 1 unmodified line
7476 return -EBUSY;
7577 }
7678 ufshcd_rpm_get_sync(hba);
79+ __acquire(ufs_debugfs);
7780 return 0;
7881 }
7982
8083 static void ufs_debugfs_put_user_access(struct ufs_hba *hba)
81−__releases(&hba->host_sem)
84+ __releases(ufs_debugfs)
8285 {
8386 ufshcd_rpm_put_sync(hba);
8487 up(&hba->host_sem);
88+ __release(ufs_debugfs);
8589 }
8690
8791 static int ee_usr_mask_set(void *data, u64 val)
drivers/ufs/core/ufshcd.c+15−0
@@ -1317,6 +1317,7 @@ static int ufshcd_wait_for_pending_cmds(struct ufs_hba *hba, · 1316 unmodified lines
13171317 break;
13181318 }
13191319
1320+ __set_current_state(TASK_UNINTERRUPTIBLE);
13201321 io_schedule_timeout(msecs_to_jiffies(20));
13211322 if (ktime_to_us(ktime_sub(ktime_get(), start)) >
13221323 wait_timeout_us) {
@@ -1353,6 +1354,8 @@ out: · 30 unmodified lines
13531354 * On failure, all acquired locks are released and the tagset is unquiesced.
13541355 */
13551356 int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us)
1357+ __cond_acquires(0, &hba->host->scan_mutex)
1358+ __cond_acquires(0, &hba->clk_scaling_lock)
13561359 {
13571360 int ret = 0;
13581361
@@ -1377,6 +1380,8 @@ int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us) · 18 unmodified lines
13771380 * This function resumes command submissions.
13781381 */
13791382 void ufshcd_resume_command_processing(struct ufs_hba *hba)
1383+ __releases(&hba->clk_scaling_lock)
1384+ __releases(&hba->host->scan_mutex)
13801385 {
13811386 up_write(&hba->clk_scaling_lock);
13821387 blk_mq_unquiesce_tagset(&hba->host->tag_set);
@@ -1446,6 +1451,9 @@ config_pwr_mode: · 63 unmodified lines
14461451 * Return: 0 upon success; -EBUSY upon timeout.
14471452 */
14481453 static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
1454+ __cond_acquires(0, &hba->host->scan_mutex)
1455+ __cond_acquires(0, &hba->wb_mutex)
1456+ __cond_acquires(0, &hba->clk_scaling_lock)
14491457 {
14501458 int ret = 0;
14511459 /*
@@ -1475,6 +1483,9 @@ out: · 23 unmodified lines
14751483 }
14761484
14771485 static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err)
1486+ __releases(&hba->clk_scaling_lock)
1487+ __releases(&hba->wb_mutex)
1488+ __releases(&hba->host->scan_mutex)
14781489 {
14791490 up_write(&hba->clk_scaling_lock);
14801491 mutex_unlock(&hba->wb_mutex);
@@ -3304,6 +3315,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 1823 unmodified lines
33043315 }
33053316
33063317 static void ufshcd_dev_man_lock(struct ufs_hba *hba)
3318+ __acquires(&hba->dev_cmd.lock)
3319+ __acquires_shared(&hba->clk_scaling_lock)
33073320 {
33083321 ufshcd_hold(hba);
33093322 mutex_lock(&hba->dev_cmd.lock);
@@ -3311,6 +3324,8 @@ static void ufshcd_dev_man_lock(struct ufs_hba *hba) · 1 unmodified line
33113324 }
33123325
33133326 static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
3327+ __releases_shared(&hba->clk_scaling_lock)
3328+ __releases(&hba->dev_cmd.lock)
33143329 {
33153330 up_read(&hba->clk_scaling_lock);
33163331 mutex_unlock(&hba->dev_cmd.lock);
drivers/ufs/host/Makefile+2−0
@@ -1,5 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
22
3+CONTEXT_ANALYSIS := y
4+
35 obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o
46 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o
57 obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o
include/scsi/scsi_host.h+17−7
@@ -2,6 +2,7 @@ · 1 unmodified line
22 #ifndef _SCSI_SCSI_HOST_H
33 #define _SCSI_SCSI_HOST_H
44
5+#include <linux/cleanup.h>
56 #include <linux/device.h>
67 #include <linux/list.h>
78 #include <linux/types.h>
@@ -727,7 +728,7 @@ struct Scsi_Host { · 719 unmodified lines
727728 unsigned int irq;
728729
729730
730− enum scsi_host_state shost_state;
731+ enum scsi_host_state shost_state __guarded_by(host_lock);
731732
732733 /* ldm bits */
733734 struct device shost_gendev, shost_dev;
@@ -788,11 +789,18 @@ static inline struct Scsi_Host *dev_to_shost(struct device *dev) · 54 unmodified lines
788789 return container_of(dev, struct Scsi_Host, shost_gendev);
789790 }
790791
792+static inline enum scsi_host_state scsi_get_host_state(struct Scsi_Host *shost)
793+{
794+ return context_unsafe(READ_ONCE(shost->shost_state));
795+}
796+
791797 static inline int scsi_host_in_recovery(struct Scsi_Host *shost)
792798 {
793− return shost->shost_state == SHOST_RECOVERY ||
794− shost->shost_state == SHOST_CANCEL_RECOVERY ||
795− shost->shost_state == SHOST_DEL_RECOVERY ||
799+ enum scsi_host_state state = scsi_get_host_state(shost);
800+
801+ return state == SHOST_RECOVERY ||
802+ state == SHOST_CANCEL_RECOVERY ||
803+ state == SHOST_DEL_RECOVERY ||
796804 shost->tmf_in_progress;
797805 }
798806
@@ -838,8 +846,9 @@ static inline struct device *scsi_get_device(struct Scsi_Host *shost) · 39 unmodified lines
838846 **/
839847 static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)
840848 {
841− return shost->shost_state == SHOST_RUNNING ||
842− shost->shost_state == SHOST_RECOVERY;
849+ enum scsi_host_state state = scsi_get_host_state(shost);
850+
851+ return state == SHOST_RUNNING || state == SHOST_RECOVERY;
843852 }
844853
845854 extern void scsi_unblock_requests(struct Scsi_Host *);
@@ -943,6 +952,7 @@ static inline unsigned char scsi_host_get_guard(struct Scsi_Host *shost) · 97 unmodified lines
943952 return shost->prot_guard_type;
944953 }
945954
946−extern int scsi_host_set_state(struct Scsi_Host *, enum scsi_host_state);
955+int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
956+ __must_hold(shost->host_lock);
947957
948958 #endif /* _SCSI_SCSI_HOST_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t