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
577Mark Starovoytov <mstarovo@pm.me> <mstarovoitov@marvell.com>577Mark Starovoytov <mstarovo@pm.me> <mstarovoitov@marvell.com>
578Markus Schneider-Pargmann <msp@baylibre.com> <mpa@pengutronix.de>578Markus Schneider-Pargmann <msp@baylibre.com> <mpa@pengutronix.de>
579Mark Yao <markyao0591@gmail.com> <mark.yao@rock-chips.com>579Mark Yao <markyao0591@gmail.com> <mark.yao@rock-chips.com>
580Martin K. Petersen <mkp@kernel.org> <martin.petersen@oracle.com>
581Martin K. Petersen <mkp@kernel.org> <mkp@mkp.net>
582Martin K. Petersen <mkp@kernel.org> <mkp@linuxcare.com>
580Martin Kepplinger-Novakovic <martink@posteo.de> <martin.kepplinger-novakovic@ginzinger.com>583Martin Kepplinger-Novakovic <martink@posteo.de> <martin.kepplinger-novakovic@ginzinger.com>
581Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> <martyna.szapar-mudlaw@intel.com>584Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com> <martyna.szapar-mudlaw@intel.com>
582Mathieu Othacehe <othacehe@gnu.org> <m.othacehe@gmail.com>585Mathieu Othacehe <othacehe@gnu.org> <m.othacehe@gmail.com>
Documentation/scsi/leapraid.rst+10−4
@@ -22,6 +22,7 @@ Supported devices · 21 unmodified lines
22 22
23Features23Features
24========24========
25
25- PCIe Gen4 x8 host interface26- PCIe Gen4 x8 host interface
26- Support for SAS and SATA devices27- Support for SAS and SATA devices
27- RAID levels: 0, 1, 10, 5, 50, 6, 6028- RAID levels: 0, 1, 10, 5, 50, 6, 60
@@ -50,16 +51,20 @@ LeapRAID specific disk attributes · 22 unmodified lines
50 51
51::52::
52 53
53 /sys/class/scsi_disk/host:bus:target:lun/device/sas_device_handle54 /sys/block/<disk>/device/sas_device_handle
54 /sys/class/scsi_disk/host:bus:target:lun/device/ncq_cmd_prio_enable55 /sys/block/<disk>/device/sas_ncq_prio_supported
56 /sys/block/<disk>/device/sas_ncq_prio_enable
55 57
56The read-only attribute "sas_device_handle" represents the disk's device58The read-only attribute "sas_device_handle" represents the disk's device
57handle, which is a unique identifier maintained by the firmware.59handle, which is a unique identifier maintained by the firmware.
58 60
59This attribute "ncq_cmd_prio_enable" controls NCQ command priority. A value61The read-only attribute "sas_ncq_prio_supported" reports whether a SATA
62device supports NCQ command priority.
63
64The attribute "sas_ncq_prio_enable" controls NCQ command priority. A value
60of 0 disables NCQ priority handling for RT-priority I/O. Writing 1 enables65of 0 disables NCQ priority handling for RT-priority I/O. Writing 1 enables
61NCQ priority handling when the device reports support for the feature through66NCQ priority handling when the device reports support for the feature through
62VPD page 0x89. Unsupported devices keep the effective state at 0.67VPD page 0x89. Writes to unsupported devices fail with an error.
63 68
64LeapRAID module parameters69LeapRAID module parameters
65==========================70==========================
@@ -100,6 +105,7 @@ in io_uring poll mode. The default value is 0. · 34 unmodified lines
100 105
101File Location106File Location
102=============107=============
108
103The driver source is located at:109The driver source is located at:
104 110
105``drivers/scsi/leapraid/``111``drivers/scsi/leapraid/``
MAINTAINERS+2−4
@@ -18776,8 +18776,6 @@ L: linux-scsi@vger.kernel.org · 18775 unmodified lines
18776S: Maintained18776S: Maintained
18777F: Documentation/scsi/g_NCR5380.rst18777F: Documentation/scsi/g_NCR5380.rst
18778F: drivers/scsi/NCR5380.*18778F: drivers/scsi/NCR5380.*
18779F: drivers/scsi/arm/cumana_1.c
18780F: drivers/scsi/arm/oak.c
18781F: drivers/scsi/atari_scsi.*18779F: drivers/scsi/atari_scsi.*
18782F: drivers/scsi/dmx3191d.c18780F: drivers/scsi/dmx3191d.c
18783F: drivers/scsi/g_NCR5380.*18781F: drivers/scsi/g_NCR5380.*
@@ -24571,7 +24569,7 @@ F: include/scsi/sg.h · 5787 unmodified lines
24571 24569
24572SCSI SUBSYSTEM24570SCSI SUBSYSTEM
24573M: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>24571M: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
24574M: "Martin K. Petersen" <martin.petersen@oracle.com>24572M: "Martin K. Petersen" <mkp@kernel.org>
24575L: linux-scsi@vger.kernel.org24573L: linux-scsi@vger.kernel.org
24576S: Maintained24574S: Maintained
24577Q: https://patchwork.kernel.org/project/linux-scsi/list/24575Q: https://patchwork.kernel.org/project/linux-scsi/list/
@@ -24601,7 +24599,7 @@ F: drivers/target/target_core_user.c · 23 unmodified lines
24601F: include/uapi/linux/target_core_user.h24599F: include/uapi/linux/target_core_user.h
24602 24600
24603SCSI TARGET SUBSYSTEM24601SCSI TARGET SUBSYSTEM
24604M: "Martin K. Petersen" <martin.petersen@oracle.com>24602M: "Martin K. Petersen" <mkp@kernel.org>
24605L: linux-scsi@vger.kernel.org24603L: linux-scsi@vger.kernel.org
24606L: target-devel@vger.kernel.org24604L: target-devel@vger.kernel.org
24607S: Supported24605S: Supported
drivers/scsi/Makefile+23−0
@@ -14,6 +14,29 @@ · 13 unmodified lines
14# satisfy certain initialization assumptions in the SCSI layer.14# satisfy certain initialization assumptions in the SCSI layer.
15# *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!15# *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
16 16
17CONTEXT_ANALYSIS_constants.o := y
18CONTEXT_ANALYSIS_hosts.o := y
19CONTEXT_ANALYSIS_scsi.o := y
20CONTEXT_ANALYSIS_scsi_common.o := y
21CONTEXT_ANALYSIS_scsi_devinfo.o := y
22CONTEXT_ANALYSIS_scsi_dh.o := y
23CONTEXT_ANALYSIS_scsi_error.o := y
24CONTEXT_ANALYSIS_scsi_ioctl.o := y
25CONTEXT_ANALYSIS_scsi_lib.o := y
26CONTEXT_ANALYSIS_scsi_lib_dma.o := y
27CONTEXT_ANALYSIS_scsi_logging.o := y
28CONTEXT_ANALYSIS_scsi_netlink.o := y
29CONTEXT_ANALYSIS_scsi_pm.o := y
30CONTEXT_ANALYSIS_scsi_proc.o := y
31CONTEXT_ANALYSIS_scsi_scan.o := y
32CONTEXT_ANALYSIS_scsi_sysfs.o := y
33CONTEXT_ANALYSIS_scsi_trace.o := y
34CONTEXT_ANALYSIS_scsicam.o := y
35CONTEXT_ANALYSIS_sd.o := y
36CONTEXT_ANALYSIS_sd_dif.o := y
37CONTEXT_ANALYSIS_sd_zbc.o := y
38CONTEXT_ANALYSIS_sr.o := y
39CONTEXT_ANALYSIS_sr_ioctl.o := y
17 40
18CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF41CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
19 42
drivers/scsi/device_handler/Makefile+3−0
@@ -2,6 +2,9 @@ · 1 unmodified line
2#2#
3# SCSI Device Handler3# SCSI Device Handler
4#4#
5
6CONTEXT_ANALYSIS := y
7
5obj-$(CONFIG_SCSI_DH_RDAC) += scsi_dh_rdac.o8obj-$(CONFIG_SCSI_DH_RDAC) += scsi_dh_rdac.o
6obj-$(CONFIG_SCSI_DH_HP_SW) += scsi_dh_hp_sw.o9obj-$(CONFIG_SCSI_DH_HP_SW) += scsi_dh_hp_sw.o
7obj-$(CONFIG_SCSI_DH_EMC) += scsi_dh_emc.o10obj-$(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
73 * transition is illegal.73 * transition is illegal.
74 **/74 **/
75int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)75int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
76 __must_hold(shost->host_lock)
76{77{
77 enum scsi_host_state oldstate = shost->shost_state;78 enum scsi_host_state oldstate = READ_ONCE(shost->shost_state);
78 79
79 if (state == oldstate)80 if (state == oldstate)
80 return 0;81 return 0;
@@ -145,7 +146,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) · 64 unmodified lines
145 }146 }
146 break;147 break;
147 }148 }
148 shost->shost_state = state;149 WRITE_ONCE(shost->shost_state, state);
149 return 0;150 return 0;
150 151
151 illegal:152 illegal:
@@ -276,7 +277,8 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 124 unmodified lines
276 if (error)277 if (error)
277 goto out_disable_runtime_pm;278 goto out_disable_runtime_pm;
278 279
279 scsi_host_set_state(shost, SHOST_RUNNING);280 scoped_guard(spinlock_irq, shost->host_lock)
281 scsi_host_set_state(shost, SHOST_RUNNING);
280 get_device(shost->shost_gendev.parent);282 get_device(shost->shost_gendev.parent);
281 283
282 device_enable_async_suspend(&shost->shost_dev);284 device_enable_async_suspend(&shost->shost_dev);
@@ -350,6 +352,7 @@ EXPORT_SYMBOL(scsi_add_host_with_dma); · 67 unmodified lines
350static void scsi_host_dev_release(struct device *dev)352static void scsi_host_dev_release(struct device *dev)
351{353{
352 struct Scsi_Host *shost = dev_to_shost(dev);354 struct Scsi_Host *shost = dev_to_shost(dev);
355 enum scsi_host_state state = scsi_get_host_state(shost);
353 struct device *parent = dev->parent;356 struct device *parent = dev->parent;
354 357
355 /* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */358 /* 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
363 if (shost->work_q)366 if (shost->work_q)
364 destroy_workqueue(shost->work_q);367 destroy_workqueue(shost->work_q);
365 368
366 if (shost->shost_state == SHOST_CREATED) {369 if (state == SHOST_CREATED) {
367 /*370 /*
368 * Free the shost_dev device name and remove the proc host dir371 * Free the shost_dev device name and remove the proc host dir
369 * here if scsi_host_{alloc,put}() have been called but neither372 * 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
379 382
380 ida_free(&host_index_ida, shost->host_no);383 ida_free(&host_index_ida, shost->host_no);
381 384
382 if (shost->shost_state != SHOST_CREATED)385 if (state != SHOST_CREATED)
383 put_device(parent);386 put_device(parent);
384 kfree(shost);387 kfree(shost);
385}388}
@@ -412,8 +415,8 @@ struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, int priv · 26 unmodified lines
412 return NULL;415 return NULL;
413 416
414 shost->host_lock = &shost->default_lock;417 shost->host_lock = &shost->default_lock;
415 spin_lock_init(shost->host_lock);418 scoped_guard(spinlock_init, shost->host_lock)
416 shost->shost_state = SHOST_CREATED;419 shost->shost_state = SHOST_CREATED;
417 INIT_LIST_HEAD(&shost->__devices);420 INIT_LIST_HEAD(&shost->__devices);
418 INIT_LIST_HEAD(&shost->__targets);421 INIT_LIST_HEAD(&shost->__targets);
419 INIT_LIST_HEAD(&shost->eh_abort_list);422 INIT_LIST_HEAD(&shost->eh_abort_list);
@@ -600,7 +603,7 @@ EXPORT_SYMBOL(scsi_host_lookup); · 180 unmodified lines
600 **/603 **/
601struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)604struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
602{605{
603 if ((shost->shost_state == SHOST_DEL) ||606 if (scsi_get_host_state(shost) == SHOST_DEL ||
604 !get_device(&shost->shost_gendev))607 !get_device(&shost->shost_gendev))
605 return NULL;608 return NULL;
606 return shost;609 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
6151 timer_delete_sync(&tgt->timer);6151 timer_delete_sync(&tgt->timer);
6152 kref_put(&tgt->kref, ibmvfc_release_tgt);6152 kref_put(&tgt->kref, ibmvfc_release_tgt);
6153 return;6153 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) {
6155 tgt_dbg(tgt, "Deleting NVMe rport with outstanding I/O\n");6155 tgt_dbg(tgt, "Deleting NVMe rport with outstanding I/O\n");
6156 nvme_rport = tgt->nvme_remote_port;6156 nvme_rport = tgt->nvme_remote_port;
6157 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT);6157 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
171 return 0;171 return 0;
172}172}
173 173
174static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id)174static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id,
175 bool track_mmap)
175{176{
176 struct leapraid_adapter *adapter;177 struct leapraid_adapter *adapter;
177 struct Scsi_Host *shost;178 struct Scsi_Host *shost;
@@ -184,6 +185,8 @@ static struct leapraid_adapter *leapraid_ctl_lookup_adapter(int adapter_id) · 6 unmodified lines
184 shost = adapter->shost;185 shost = adapter->shost;
185 if (!shost || !scsi_host_get(shost))186 if (!shost || !scsi_host_get(shost))
186 break;187 break;
188 if (track_mmap)
189 atomic_inc(&adapter->fw_log_desc.mmap_refcnt);
187 spin_unlock(&leapraid_adapter_lock);190 spin_unlock(&leapraid_adapter_lock);
188 return adapter;191 return adapter;
189 }192 }
@@ -589,7 +592,7 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd, · 399 unmodified lines
589 return -EFAULT;592 return -EFAULT;
590 }593 }
591 594
592 adapter = leapraid_ctl_lookup_adapter(ioctl_header.adapter_id);595 adapter = leapraid_ctl_lookup_adapter(ioctl_header.adapter_id, false);
593 if (!adapter)596 if (!adapter)
594 return -EFAULT;597 return -EFAULT;
595 598
@@ -697,6 +700,7 @@ static void leapraid_fw_mmap_open(struct vm_area_struct *vma) · 101 unmodified lines
697 if (!adapter)700 if (!adapter)
698 return;701 return;
699 702
703 get_device(&adapter->shost->shost_gendev);
700 atomic_inc(&adapter->fw_log_desc.mmap_refcnt);704 atomic_inc(&adapter->fw_log_desc.mmap_refcnt);
701}705}
702 706
@@ -727,7 +731,7 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma) · 24 unmodified lines
727 731
728 length = vma->vm_end - vma->vm_start;732 length = vma->vm_end - vma->vm_start;
729 733
730 adapter = leapraid_ctl_lookup_adapter(adapter_id);734 adapter = leapraid_ctl_lookup_adapter(adapter_id, true);
731 if (!adapter) {735 if (!adapter) {
732 pr_err("%s: No adapter found!\n", __func__);736 pr_err("%s: No adapter found!\n", __func__);
733 return -EINVAL;737 return -EINVAL;
@@ -767,10 +771,12 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma) · 33 unmodified lines
767 vma->vm_private_data = adapter;771 vma->vm_private_data = adapter;
768 vma->vm_ops = &leapraid_fw_mmap_vm_ops;772 vma->vm_ops = &leapraid_fw_mmap_vm_ops;
769 leapraid_fw_mmap_open(vma);773 leapraid_fw_mmap_open(vma);
770 adapter = NULL;
771 774
772 rc = 0;775 rc = 0;
773out_put:776out_put:
777 if (adapter &&
778 atomic_dec_and_test(&adapter->fw_log_desc.mmap_refcnt))
779 wake_up(&adapter->fw_log_desc.mmap_waitq);
774 leapraid_ctl_put_adapter(adapter);780 leapraid_ctl_put_adapter(adapter);
775 return rc;781 return rc;
776}782}
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
37{37{
38 enum scsi_host_state state;38 enum scsi_host_state state;
39 39
40 state = READ_ONCE(shost->shost_state);40 state = scsi_get_host_state(shost);
41 return state == SHOST_RECOVERY ||41 return state == SHOST_RECOVERY ||
42 state == SHOST_CANCEL_RECOVERY ||42 state == SHOST_CANCEL_RECOVERY ||
43 state == SHOST_DEL_RECOVERY ||43 state == SHOST_DEL_RECOVERY ||
drivers/scsi/leapraid/leapraid_func.h+2−2
@@ -1064,7 +1064,7 @@ struct leapraid_starget_priv { · 1063 unmodified lines
1064 * @starget_priv: Associated target private data.1064 * @starget_priv: Associated target private data.
1065 * @lun: Logical Unit Number.1065 * @lun: Logical Unit Number.
1066 * @flg: Flags.1066 * @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.
1068 * @block: Block flag.1068 * @block: Block flag.
1069 * @deleted: Deletion flag.1069 * @deleted: Deletion flag.
1070 * @sep: SEP flag.1070 * @sep: SEP flag.
@@ -1073,7 +1073,7 @@ struct leapraid_sdev_priv { · 2 unmodified lines
1073 struct leapraid_starget_priv *starget_priv;1073 struct leapraid_starget_priv *starget_priv;
1074 unsigned int lun;1074 unsigned int lun;
1075 u32 flg;1075 u32 flg;
1076 u8 ncq_cmd_prio_enable;1076 u8 ncq_prio_enable;
1077 u8 block;1077 u8 block;
1078 u8 deleted;1078 u8 deleted;
1079 u8 sep;1079 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
808 goto no_connect;808 goto no_connect;
809 809
810 if (sdev_priv->block &&810 if (sdev_priv->block &&
811 scmd->device->host->shost_state == SHOST_RECOVERY &&811 scsi_get_host_state(scmd->device->host) == SHOST_RECOVERY &&
812 scmd->cmnd[0] == TEST_UNIT_READY) {812 scmd->cmnd[0] == TEST_UNIT_READY) {
813 scsi_build_sense(scmd, 0, UNIT_ATTENTION,813 scsi_build_sense(scmd, 0, UNIT_ATTENTION,
814 LEAPRAID_SCSI_ASC_POWER_ON_RESET,814 LEAPRAID_SCSI_ASC_POWER_ON_RESET,
@@ -859,7 +859,7 @@ static u32 build_scsiio_req_control(struct scsi_cmnd *scmd, · 44 unmodified lines
859 859
860 control |= LEAPRAID_SCSIIO_CTRL_SIMPLEQ;860 control |= LEAPRAID_SCSIIO_CTRL_SIMPLEQ;
861 861
862 if (sdev_priv->ncq_cmd_prio_enable &&862 if (sdev_priv->ncq_prio_enable &&
863 (IOPRIO_PRIO_CLASS(req_get_ioprio(scsi_cmd_to_rq(scmd))) ==863 (IOPRIO_PRIO_CLASS(req_get_ioprio(scsi_cmd_to_rq(scmd))) ==
864 IOPRIO_CLASS_RT))864 IOPRIO_CLASS_RT))
865 control |= LEAPRAID_SCSIIO_CTRL_CMDPRI;865 control |= LEAPRAID_SCSIIO_CTRL_CMDPRI;
@@ -1854,7 +1854,16 @@ static ssize_t sas_device_handle_show(struct device *dev, · 988 unmodified lines
1854 sas_device_priv_data->starget_priv->hdl);1854 sas_device_priv_data->starget_priv->hdl);
1855}1855}
1856 1856
1857static ssize_t ncq_cmd_prio_enable_show(struct device *dev,1857static 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
1866static ssize_t sas_ncq_prio_enable_show(struct device *dev,
1858 struct device_attribute *attr,1867 struct device_attribute *attr,
1859 char *buf)1868 char *buf)
1860{1869{
@@ -1867,19 +1876,16 @@ static ssize_t ncq_cmd_prio_enable_show(struct device *dev, · 6 unmodified lines
1867 return -EINVAL;1876 return -EINVAL;
1868 }1877 }
1869 1878
1870 return sysfs_emit(buf, "%d\n",1879 return sysfs_emit(buf, "%d\n", sas_device_priv_data->ncq_prio_enable);
1871 sas_device_priv_data->ncq_cmd_prio_enable);
1872}1880}
1873 1881
1874static ssize_t ncq_cmd_prio_enable_store(struct device *dev,1882static ssize_t sas_ncq_prio_enable_store(struct device *dev,
1875 struct device_attribute *attr,1883 struct device_attribute *attr,
1876 const char *buf, size_t count)1884 const char *buf, size_t count)
1877{1885{
1878 struct scsi_device *sdev = to_scsi_device(dev);1886 struct scsi_device *sdev = to_scsi_device(dev);
1879 struct leapraid_sdev_priv *sas_device_priv_data = sdev->hostdata;1887 struct leapraid_sdev_priv *sas_device_priv_data = sdev->hostdata;
1880 struct scsi_vpd *vpd_pg89;1888 bool enable;
1881 int ncq_cmd_prio_enable;
1882 bool ncq_supported;
1883 1889
1884 if (!sas_device_priv_data) {1890 if (!sas_device_priv_data) {
1885 dev_err(&sdev->sdev_gendev,1891 dev_err(&sdev->sdev_gendev,
@@ -1887,44 +1893,63 @@ static ssize_t ncq_cmd_prio_enable_store(struct device *dev, · 1 unmodified line
1887 return -EINVAL;1893 return -EINVAL;
1888 }1894 }
1889 1895
1890 if (kstrtoint(buf, 0, &ncq_cmd_prio_enable))1896 if (kstrtobool(buf, &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);
1897 return -EINVAL;1897 return -EINVAL;
1898 }
1899 1898
1900 rcu_read_lock();1899 if (!sas_ata_ncq_prio_supported(sdev))
1901 vpd_pg89 = rcu_dereference(sdev->vpd_pg89);
1902 if (!vpd_pg89 || vpd_pg89->len < LEAPRAID_VPD_PG89_MIN_LEN) {
1903 rcu_read_unlock();
1904 return -EINVAL;1900 return -EINVAL;
1905 }
1906 1901
1907 ncq_supported = (vpd_pg89->data[LEAPRAID_VPD_PG89_NCQ_BYTE_IDX] >>1902 sas_device_priv_data->ncq_prio_enable = enable;
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;
1914 return count;1903 return count;
1915}1904}
1916 1905
1917static DEVICE_ATTR_RO(sas_device_handle);1906static DEVICE_ATTR_RO(sas_device_handle);
1907static DEVICE_ATTR_RO(sas_ncq_prio_supported);
1908static DEVICE_ATTR_RW(sas_ncq_prio_enable);
1909
1910static 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;
1918 1915
1919static 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}
1920 1922
1921static struct attribute *leapraid_sdev_attrs[] = {1923static struct attribute *leapraid_sdev_attrs[] = {
1922 &dev_attr_sas_device_handle.attr,1924 &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,
1924 NULL,1927 NULL,
1925};1928};
1926 1929
1927ATTRIBUTE_GROUPS(leapraid_sdev);1930static 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
1944static const struct attribute_group leapraid_sdev_attr_group = {
1945 .attrs = leapraid_sdev_attrs,
1946 .is_visible = leapraid_sdev_attr_is_visible,
1947};
1948
1949static const struct attribute_group *leapraid_sdev_groups[] = {
1950 &leapraid_sdev_attr_group,
1951 NULL,
1952};
1928 1953
1929static struct scsi_host_template leapraid_driver_template = {1954static struct scsi_host_template leapraid_driver_template = {
1930 .module = THIS_MODULE,1955 .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
345 SAS_ADDR(phy->attached_sas_addr), type);345 SAS_ADDR(phy->attached_sas_addr), type);
346}346}
347 347
348/* check if we have an existing attached ata device on this expander phy */348/* Return the domain device attached to an expander phy */
349struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id)349struct domain_device *sas_ex_phy_to_dev(struct domain_device *ex_dev, int phy_id)
350{350{
351 struct ex_phy *ex_phy = &ex_dev->ex_dev.ex_phy[phy_id];351 struct ex_phy *ex_phy = &ex_dev->ex_dev.ex_phy[phy_id];
352 struct domain_device *dev;
353 struct sas_rphy *rphy;352 struct sas_rphy *rphy;
354 353
355 if (!ex_phy->port)354 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
359 if (!rphy)358 if (!rphy)
360 return NULL;359 return NULL;
361 360
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 */
365struct 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);
363 368
364 if (dev && dev_is_sata(dev))369 if (dev && dev_is_sata(dev))
365 return dev;370 return dev;
@@ -1958,6 +1963,72 @@ static bool dev_type_flutter(enum sas_device_type new, enum sas_device_type old) · 1592 unmodified lines
1958 return false;1963 return false;
1959}1964}
1960 1965
1966static 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
1978static 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
2026out:
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
1961static int sas_rediscover_dev(struct domain_device *dev, int phy_id,2032static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
1962 bool last, int sibling)2033 bool last, int sibling)
1963{2034{
@@ -2011,27 +2082,16 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, · 47 unmodified lines
2011 if (res == 0)2082 if (res == 0)
2012 sas_set_ex_phy(dev, phy_id, disc_resp);2083 sas_set_ex_phy(dev, phy_id, disc_resp);
2013 goto out_free_resp;2084 goto out_free_resp;
2014 } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&2085 }
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);
2020 2086
2021 if (ata_dev && phy->attached_dev_type == SAS_SATA_PENDING)2087 if (sas_dev_is_flutter(dev, phy_id, sas_addr, type))
2022 action = ", needs recovery";
2023 pr_debug("ex %016llx phy%02d broadcast flutter%s\n",
2024 SAS_ADDR(dev->sas_addr), phy_id, action);
2025 goto out_free_resp;2088 goto out_free_resp;
2026 }
2027 2089
2028 /* we always have to delete the old device when we went here */2090 /* we always have to delete the old device when we went here */
2029 pr_info("ex %016llx phy%02d replace %016llx\n",2091 pr_info("ex %016llx phy%02d replace %016llx\n",
2030 SAS_ADDR(dev->sas_addr), phy_id,2092 SAS_ADDR(dev->sas_addr), phy_id,
2031 SAS_ADDR(phy->attached_sas_addr));2093 SAS_ADDR(phy->attached_sas_addr));
2032 sas_unregister_devs_sas_addr(dev, phy_id, last);2094 sas_rediscover_ex_phy(dev, phy_id, last);
2033
2034 res = sas_discover_new(dev, phy_id);
2035out_free_resp:2095out_free_resp:
2036 kfree(disc_resp);2096 kfree(disc_resp);
2037 return res;2097 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
91 91
92void sas_device_set_phy(struct domain_device *dev, struct sas_port *port);92void sas_device_set_phy(struct domain_device *dev, struct sas_port *port);
93struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);93struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
94struct domain_device *sas_ex_phy_to_dev(struct domain_device *ex_dev, int phy_id);
94struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id);95struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id);
95int sas_ex_phy_discover(struct domain_device *dev, int single);96int sas_ex_phy_discover(struct domain_device *dev, int single);
96int sas_get_report_phy_sata(struct domain_device *dev, int phy_id,97int 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
57#define LPFC_MIN_DEVLOSS_TMO 157#define LPFC_MIN_DEVLOSS_TMO 1
58#define LPFC_MAX_DEVLOSS_TMO 25558#define LPFC_MAX_DEVLOSS_TMO 255
59 59
60#define LPFC_MAX_INFO_TMP_LEN 100
61#define LPFC_INFO_MORE_STR "\nCould be more info...\n"60#define LPFC_INFO_MORE_STR "\nCould be more info...\n"
62/*61/*
63 * Write key size should be multiple of 4. If write key is changed62 * 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
126 int len = 0;125 int len = 0;
127 int cpu;126 int cpu;
128 u64 rcv, total;127 u64 rcv, total;
129 char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
130 128
131 if (phba->cgn_i)129 if (phba->cgn_i)
132 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;130 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
133 131
134 scnprintf(tmp, sizeof(tmp),132 len = strnlen(buf, PAGE_SIZE);
135 "Congestion Mgmt Info: E2Eattr %d Ver %d "133 len += sysfs_emit_at(buf, len,
136 "CMF %d cnt %d\n",134 "Congestion Mgmt Info: E2Eattr %d Ver %d CMF %d cnt %d\n",
137 phba->sli4_hba.pc_sli4_params.mi_cap,135 phba->sli4_hba.pc_sli4_params.mi_cap,
138 cp ? cp->cgn_info_version : 0,136 cp ? cp->cgn_info_version : 0,
139 phba->sli4_hba.pc_sli4_params.cmf, phba->cmf_timer_cnt);137 phba->sli4_hba.pc_sli4_params.cmf,
140 138 phba->cmf_timer_cnt);
141 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
142 goto buffer_done;
143 139
144 if (!phba->sli4_hba.pc_sli4_params.cmf)140 if (!phba->sli4_hba.pc_sli4_params.cmf)
145 goto buffer_done;141 goto buffer_done;
146 142
147 switch (phba->cgn_init_reg_signal) {143 switch (phba->cgn_init_reg_signal) {
148 case EDC_CG_SIG_WARN_ONLY:144 case EDC_CG_SIG_WARN_ONLY:
149 scnprintf(tmp, sizeof(tmp),145 len += sysfs_emit_at(buf, len,
150 "Register: Init: Signal:WARN ");146 "Register: Init: Signal:WARN ");
151 break;147 break;
152 case EDC_CG_SIG_WARN_ALARM:148 case EDC_CG_SIG_WARN_ALARM:
153 scnprintf(tmp, sizeof(tmp),149 len += sysfs_emit_at(buf, len,
154 "Register: Init: Signal:WARN|ALARM ");150 "Register: Init: Signal:WARN|ALARM ");
155 break;151 break;
156 default:152 default:
157 scnprintf(tmp, sizeof(tmp),153 len += sysfs_emit_at(buf, len,
158 "Register: Init: Signal:NONE ");154 "Register: Init: Signal:NONE ");
159 break;155 break;
160 }156 }
161 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
162 goto buffer_done;
163 157
164 switch (phba->cgn_init_reg_fpin) {158 switch (phba->cgn_init_reg_fpin) {
165 case LPFC_CGN_FPIN_WARN:159 case LPFC_CGN_FPIN_WARN:
166 scnprintf(tmp, sizeof(tmp),160 len += sysfs_emit_at(buf, len, "FPIN:WARN\n");
167 "FPIN:WARN\n");
168 break;161 break;
169 case LPFC_CGN_FPIN_ALARM:162 case LPFC_CGN_FPIN_ALARM:
170 scnprintf(tmp, sizeof(tmp),163 len += sysfs_emit_at(buf, len, "FPIN:ALARM\n");
171 "FPIN:ALARM\n");
172 break;164 break;
173 case LPFC_CGN_FPIN_BOTH:165 case LPFC_CGN_FPIN_BOTH:
174 scnprintf(tmp, sizeof(tmp),166 len += sysfs_emit_at(buf, len, "FPIN:WARN|ALARM\n");
175 "FPIN:WARN|ALARM\n");
176 break;167 break;
177 default:168 default:
178 scnprintf(tmp, sizeof(tmp),169 len += sysfs_emit_at(buf, len, "FPIN:NONE\n");
179 "FPIN:NONE\n");
180 break;170 break;
181 }171 }
182 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
183 goto buffer_done;
184 172
185 switch (phba->cgn_reg_signal) {173 switch (phba->cgn_reg_signal) {
186 case EDC_CG_SIG_WARN_ONLY:174 case EDC_CG_SIG_WARN_ONLY:
187 scnprintf(tmp, sizeof(tmp),175 len += sysfs_emit_at(buf, len,
188 " Current: Signal:WARN ");176 " Current: Signal:WARN ");
189 break;177 break;
190 case EDC_CG_SIG_WARN_ALARM:178 case EDC_CG_SIG_WARN_ALARM:
191 scnprintf(tmp, sizeof(tmp),179 len += sysfs_emit_at(buf, len,
192 " Current: Signal:WARN|ALARM ");180 " Current: Signal:WARN|ALARM ");
193 break;181 break;
194 default:182 default:
195 scnprintf(tmp, sizeof(tmp),183 len += sysfs_emit_at(buf, len,
196 " Current: Signal:NONE ");184 " Current: Signal:NONE ");
197 break;185 break;
198 }186 }
199 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
200 goto buffer_done;
201 187
202 switch (phba->cgn_reg_fpin) {188 switch (phba->cgn_reg_fpin) {
203 case LPFC_CGN_FPIN_WARN:189 case LPFC_CGN_FPIN_WARN:
204 scnprintf(tmp, sizeof(tmp),190 len += sysfs_emit_at(buf, len,
205 "FPIN:WARN ACQEcnt:%d\n", phba->cgn_acqe_cnt);191 "FPIN:WARN ACQEcnt:%d\n",
192 phba->cgn_acqe_cnt);
206 break;193 break;
207 case LPFC_CGN_FPIN_ALARM:194 case LPFC_CGN_FPIN_ALARM:
208 scnprintf(tmp, sizeof(tmp),195 len += sysfs_emit_at(buf, len,
209 "FPIN:ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);196 "FPIN:ALARM ACQEcnt:%d\n",
197 phba->cgn_acqe_cnt);
210 break;198 break;
211 case LPFC_CGN_FPIN_BOTH:199 case LPFC_CGN_FPIN_BOTH:
212 scnprintf(tmp, sizeof(tmp),200 len += sysfs_emit_at(buf, len,
213 "FPIN:WARN|ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);201 "FPIN:WARN|ALARM ACQEcnt:%d\n",
202 phba->cgn_acqe_cnt);
214 break;203 break;
215 default:204 default:
216 scnprintf(tmp, sizeof(tmp),205 len += sysfs_emit_at(buf, len,
217 "FPIN:NONE ACQEcnt:%d\n", phba->cgn_acqe_cnt);206 "FPIN:NONE ACQEcnt:%d\n",
207 phba->cgn_acqe_cnt);
218 break;208 break;
219 }209 }
220 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
221 goto buffer_done;
222 210
223 if (phba->cmf_active_mode != phba->cgn_p.cgn_param_mode) {211 if (phba->cmf_active_mode != phba->cgn_p.cgn_param_mode) {
224 switch (phba->cmf_active_mode) {212 switch (phba->cmf_active_mode) {
225 case LPFC_CFG_OFF:213 case LPFC_CFG_OFF:
226 scnprintf(tmp, sizeof(tmp), "Active: Mode:Off\n");214 len += sysfs_emit_at(buf, len, "Active: Mode:Off\n");
227 break;215 break;
228 case LPFC_CFG_MANAGED:216 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");
230 break;219 break;
231 case LPFC_CFG_MONITOR:220 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");
233 break;223 break;
234 default:224 default:
235 scnprintf(tmp, sizeof(tmp), "Active: Mode:Unknown\n");225 len += sysfs_emit_at(buf, len,
226 "Active: Mode:Unknown\n");
236 }227 }
237 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
238 goto buffer_done;
239 }228 }
240 229
241 switch (phba->cgn_p.cgn_param_mode) {230 switch (phba->cgn_p.cgn_param_mode) {
242 case LPFC_CFG_OFF:231 case LPFC_CFG_OFF:
243 scnprintf(tmp, sizeof(tmp), "Config: Mode:Off ");232 len += sysfs_emit_at(buf, len, "Config: Mode:Off ");
244 break;233 break;
245 case LPFC_CFG_MANAGED:234 case LPFC_CFG_MANAGED:
246 scnprintf(tmp, sizeof(tmp), "Config: Mode:Managed ");235 len += sysfs_emit_at(buf, len, "Config: Mode:Managed ");
247 break;236 break;
248 case LPFC_CFG_MONITOR:237 case LPFC_CFG_MONITOR:
249 scnprintf(tmp, sizeof(tmp), "Config: Mode:Monitor ");238 len += sysfs_emit_at(buf, len, "Config: Mode:Monitor ");
250 break;239 break;
251 default:240 default:
252 scnprintf(tmp, sizeof(tmp), "Config: Mode:Unknown ");241 len += sysfs_emit_at(buf, len, "Config: Mode:Unknown ");
253 }242 }
254 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
255 goto buffer_done;
256 243
257 total = 0;244 total = 0;
258 rcv = 0;245 rcv = 0;
@@ -262,24 +249,18 @@ lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr, · 3 unmodified lines
262 rcv += atomic64_read(&cgs->rcv_bytes);249 rcv += atomic64_read(&cgs->rcv_bytes);
263 }250 }
264 251
265 scnprintf(tmp, sizeof(tmp),252 len += sysfs_emit_at(buf, len,
266 "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",253 "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",
267 atomic_read(&phba->cmf_busy),254 atomic_read(&phba->cmf_busy),
268 phba->cmf_active_info, rcv, total);255 phba->cmf_active_info, rcv, total);
269 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
270 goto buffer_done;
271 256
272 scnprintf(tmp, sizeof(tmp),257 len += sysfs_emit_at(buf, len,
273 "Port_speed:%d Link_byte_cnt:%ld "258 "Port_speed:%d Link_byte_cnt:%ld Max_byte_per_interval:%ld\n",
274 "Max_byte_per_interval:%ld\n",259 lpfc_sli_port_speed_get(phba),
275 lpfc_sli_port_speed_get(phba),260 (unsigned long)phba->cmf_link_byte_count,
276 (unsigned long)phba->cmf_link_byte_count,261 (unsigned long)phba->cmf_max_bytes_per_interval);
277 (unsigned long)phba->cmf_max_bytes_per_interval);
278 strlcat(buf, tmp, PAGE_SIZE);
279 262
280buffer_done:263buffer_done:
281 len = strnlen(buf, PAGE_SIZE);
282
283 if (unlikely(len >= (PAGE_SIZE - 1))) {264 if (unlikely(len >= (PAGE_SIZE - 1))) {
284 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,265 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
285 "6312 Catching potential buffer "266 "6312 Catching potential buffer "
@@ -480,17 +461,19 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 194 unmodified lines
480 char *statep;461 char *statep;
481 int i;462 int i;
482 int len = 0;463 int len = 0;
483 char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
484 464
485 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {465 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");
487 return len;467 return len;
488 }468 }
469
470 len = strnlen(buf, PAGE_SIZE);
471
489 if (phba->nvmet_support) {472 if (phba->nvmet_support) {
490 if (!phba->targetport) {473 if (!phba->targetport) {
491 len = scnprintf(buf, PAGE_SIZE,474 len = sysfs_emit(buf,
492 "NVME Target: x%llx is not allocated\n",475 "NVME Target: x%llx is not allocated\n",
493 wwn_to_u64(vport->fc_portname.u.wwn));476 wwn_to_u64(vport->fc_portname.u.wwn));
494 return len;477 return len;
495 }478 }
496 /* Port state is only one of two values for now. */479 /* 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
498 statep = "REGISTERED";481 statep = "REGISTERED";
499 else482 else
500 statep = "INIT";483 statep = "INIT";
501 scnprintf(tmp, sizeof(tmp),484 len += sysfs_emit_at(buf, len,
502 "NVME Target Enabled State %s\n",485 "NVME Target Enabled State %s\n",
503 statep);486 statep);
504 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)487
505 goto buffer_done;488 len += sysfs_emit_at(buf, len,
506 489 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
507 scnprintf(tmp, sizeof(tmp),490 "NVME Target: lpfc",
508 "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",491 phba->brd_no,
509 "NVME Target: lpfc",492 wwn_to_u64(vport->fc_portname.u.wwn),
510 phba->brd_no,493 wwn_to_u64(vport->fc_nodename.u.wwn),
511 wwn_to_u64(vport->fc_portname.u.wwn),494 phba->targetport->port_id);
512 wwn_to_u64(vport->fc_nodename.u.wwn),495
513 phba->targetport->port_id);496 len += sysfs_emit_at(buf, len, "\nNVME Target: Statistics\n");
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;
520 497
521 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;498 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
522 scnprintf(tmp, sizeof(tmp),499 len += sysfs_emit_at(buf, len,
523 "LS: Rcv %08x Drop %08x Abort %08x\n",500 "LS: Rcv %08x Drop %08x Abort %08x\n",
524 atomic_read(&tgtp->rcv_ls_req_in),501 atomic_read(&tgtp->rcv_ls_req_in),
525 atomic_read(&tgtp->rcv_ls_req_drop),502 atomic_read(&tgtp->rcv_ls_req_drop),
526 atomic_read(&tgtp->xmt_ls_abort));503 atomic_read(&tgtp->xmt_ls_abort));
527 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
528 goto buffer_done;
529 504
530 if (atomic_read(&tgtp->rcv_ls_req_in) !=505 if (atomic_read(&tgtp->rcv_ls_req_in) !=
531 atomic_read(&tgtp->rcv_ls_req_out)) {506 atomic_read(&tgtp->rcv_ls_req_out)) {
532 scnprintf(tmp, sizeof(tmp),507 len += sysfs_emit_at(buf, len,
533 "Rcv LS: in %08x != out %08x\n",508 "Rcv LS: in %08x != out %08x\n",
534 atomic_read(&tgtp->rcv_ls_req_in),509 atomic_read(&tgtp->rcv_ls_req_in),
535 atomic_read(&tgtp->rcv_ls_req_out));510 atomic_read(&tgtp->rcv_ls_req_out));
536 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
537 goto buffer_done;
538 }511 }
539 512
540 scnprintf(tmp, sizeof(tmp),513 len += sysfs_emit_at(buf, len,
541 "LS: Xmt %08x Drop %08x Cmpl %08x\n",514 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
542 atomic_read(&tgtp->xmt_ls_rsp),515 atomic_read(&tgtp->xmt_ls_rsp),
543 atomic_read(&tgtp->xmt_ls_drop),516 atomic_read(&tgtp->xmt_ls_drop),
544 atomic_read(&tgtp->xmt_ls_rsp_cmpl));517 atomic_read(&tgtp->xmt_ls_rsp_cmpl));
545 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)518
546 goto buffer_done;519 len += sysfs_emit_at(buf, len,
547 520 "LS: RSP Abort %08x xb %08x Err %08x\n",
548 scnprintf(tmp, sizeof(tmp),521 atomic_read(&tgtp->xmt_ls_rsp_aborted),
549 "LS: RSP Abort %08x xb %08x Err %08x\n",522 atomic_read(&tgtp->xmt_ls_rsp_xb_set),
550 atomic_read(&tgtp->xmt_ls_rsp_aborted),523 atomic_read(&tgtp->xmt_ls_rsp_error));
551 atomic_read(&tgtp->xmt_ls_rsp_xb_set),524
552 atomic_read(&tgtp->xmt_ls_rsp_error));525 len += sysfs_emit_at(buf, len,
553 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)526 "FCP: Rcv %08x Defer %08x Release %08x Drop %08x\n",
554 goto buffer_done;527 atomic_read(&tgtp->rcv_fcp_cmd_in),
555 528 atomic_read(&tgtp->rcv_fcp_cmd_defer),
556 scnprintf(tmp, sizeof(tmp),529 atomic_read(&tgtp->xmt_fcp_release),
557 "FCP: Rcv %08x Defer %08x Release %08x "530 atomic_read(&tgtp->rcv_fcp_cmd_drop));
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;
565 531
566 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=532 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
567 atomic_read(&tgtp->rcv_fcp_cmd_out)) {533 atomic_read(&tgtp->rcv_fcp_cmd_out)) {
568 scnprintf(tmp, sizeof(tmp),534 len += sysfs_emit_at(buf, len,
569 "Rcv FCP: in %08x != out %08x\n",535 "Rcv FCP: in %08x != out %08x\n",
570 atomic_read(&tgtp->rcv_fcp_cmd_in),536 atomic_read(&tgtp->rcv_fcp_cmd_in),
571 atomic_read(&tgtp->rcv_fcp_cmd_out));537 atomic_read(&tgtp->rcv_fcp_cmd_out));
572 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
573 goto buffer_done;
574 }538 }
575 539
576 scnprintf(tmp, sizeof(tmp),540 len += sysfs_emit_at(buf, len,
577 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x "541 "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x drop %08x\n",
578 "drop %08x\n",542 atomic_read(&tgtp->xmt_fcp_read),
579 atomic_read(&tgtp->xmt_fcp_read),543 atomic_read(&tgtp->xmt_fcp_read_rsp),
580 atomic_read(&tgtp->xmt_fcp_read_rsp),544 atomic_read(&tgtp->xmt_fcp_write),
581 atomic_read(&tgtp->xmt_fcp_write),545 atomic_read(&tgtp->xmt_fcp_rsp),
582 atomic_read(&tgtp->xmt_fcp_rsp),546 atomic_read(&tgtp->xmt_fcp_drop));
583 atomic_read(&tgtp->xmt_fcp_drop));547
584 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)548 len += sysfs_emit_at(buf, len,
585 goto buffer_done;549 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
586 550 atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
587 scnprintf(tmp, sizeof(tmp),551 atomic_read(&tgtp->xmt_fcp_rsp_error),
588 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",552 atomic_read(&tgtp->xmt_fcp_rsp_drop));
589 atomic_read(&tgtp->xmt_fcp_rsp_cmpl),553
590 atomic_read(&tgtp->xmt_fcp_rsp_error),554 len += sysfs_emit_at(buf, len,
591 atomic_read(&tgtp->xmt_fcp_rsp_drop));555 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
592 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)556 atomic_read(&tgtp->xmt_fcp_rsp_aborted),
593 goto buffer_done;557 atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
594 558 atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
595 scnprintf(tmp, sizeof(tmp),559
596 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",560 len += sysfs_emit_at(buf, len,
597 atomic_read(&tgtp->xmt_fcp_rsp_aborted),561 "ABORT: Xmt %08x Cmpl %08x\n",
598 atomic_read(&tgtp->xmt_fcp_rsp_xb_set),562 atomic_read(&tgtp->xmt_fcp_abort),
599 atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));563 atomic_read(&tgtp->xmt_fcp_abort_cmpl));
600 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)564
601 goto buffer_done;565 len += sysfs_emit_at(buf, len,
602 566 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",
603 scnprintf(tmp, sizeof(tmp),567 atomic_read(&tgtp->xmt_abort_sol),
604 "ABORT: Xmt %08x Cmpl %08x\n",568 atomic_read(&tgtp->xmt_abort_unsol),
605 atomic_read(&tgtp->xmt_fcp_abort),569 atomic_read(&tgtp->xmt_abort_rsp),
606 atomic_read(&tgtp->xmt_fcp_abort_cmpl));570 atomic_read(&tgtp->xmt_abort_rsp_error));
607 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)571
608 goto buffer_done;572 len += sysfs_emit_at(buf, len,
609 573 "DELAY: ctx %08x fod %08x wqfull %08x\n",
610 scnprintf(tmp, sizeof(tmp),574 atomic_read(&tgtp->defer_ctx),
611 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n",575 atomic_read(&tgtp->defer_fod),
612 atomic_read(&tgtp->xmt_abort_sol),576 atomic_read(&tgtp->defer_wqfull));
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;
626 577
627 /* Calculate outstanding IOs */578 /* Calculate outstanding IOs */
628 tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);579 tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);
629 tot += atomic_read(&tgtp->xmt_fcp_release);580 tot += atomic_read(&tgtp->xmt_fcp_release);
630 tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;581 tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
631 582
632 scnprintf(tmp, sizeof(tmp),583 len += sysfs_emit_at(buf, len,
633 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"584 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
634 "CTX Outstanding %08llx\n\n",585 "CTX Outstanding %08llx\n\n",
635 phba->sli4_hba.nvmet_xri_cnt,586 phba->sli4_hba.nvmet_xri_cnt,
636 phba->sli4_hba.nvmet_io_wait_cnt,587 phba->sli4_hba.nvmet_io_wait_cnt,
637 phba->sli4_hba.nvmet_io_wait_total,588 phba->sli4_hba.nvmet_io_wait_total,
638 tot);589 tot);
639 strlcat(buf, tmp, PAGE_SIZE);
640 goto buffer_done;590 goto buffer_done;
641 }591 }
642 592
643 localport = vport->localport;593 localport = vport->localport;
644 if (!localport) {594 if (!localport) {
645 len = scnprintf(buf, PAGE_SIZE,595 len = sysfs_emit(buf,
646 "NVME Initiator x%llx is not allocated\n",596 "NVME Initiator x%llx is not allocated\n",
647 wwn_to_u64(vport->fc_portname.u.wwn));597 wwn_to_u64(vport->fc_portname.u.wwn));
648 return len;598 return len;
649 }599 }
650 lport = (struct lpfc_nvme_lport *)localport->private;600 lport = (struct lpfc_nvme_lport *)localport->private;
651 if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE)601 len += sysfs_emit_at(buf, len, "\nNVME Initiator Enabled\n");
652 goto buffer_done;
653 602
654 scnprintf(tmp, sizeof(tmp),603 len += sysfs_emit_at(buf, len,
655 "XRI Dist lpfc%d Total %d IO %d ELS %d\n",604 "XRI Dist lpfc%d Total %d IO %d ELS %d\n",
656 phba->brd_no,605 phba->brd_no,
657 phba->sli4_hba.max_cfg_param.max_xri,606 phba->sli4_hba.max_cfg_param.max_xri,
658 phba->sli4_hba.io_xri_max,607 phba->sli4_hba.io_xri_max,
659 lpfc_sli4_get_els_iocb_cnt(phba));608 lpfc_sli4_get_els_iocb_cnt(phba));
660 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
661 goto buffer_done;
662 609
663 /* Port state is only one of two values for now. */610 /* Port state is only one of two values for now. */
664 if (localport->port_id)611 if (localport->port_id)
@@ -666,15 +613,13 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 1 unmodified line
666 else613 else
667 statep = "UNKNOWN ";614 statep = "UNKNOWN ";
668 615
669 scnprintf(tmp, sizeof(tmp),616 len += sysfs_emit_at(buf, len,
670 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",617 "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
671 "NVME LPORT lpfc",618 "NVME LPORT lpfc",
672 phba->brd_no,619 phba->brd_no,
673 wwn_to_u64(vport->fc_portname.u.wwn),620 wwn_to_u64(vport->fc_portname.u.wwn),
674 wwn_to_u64(vport->fc_nodename.u.wwn),621 wwn_to_u64(vport->fc_nodename.u.wwn),
675 localport->port_id, statep);622 localport->port_id, statep);
676 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
677 goto buffer_done;
678 623
679 spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);624 spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
680 625
@@ -702,77 +647,55 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 21 unmodified lines
702 }647 }
703 648
704 /* Tab in to show lport ownership. */649 /* Tab in to show lport ownership. */
705 if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE)650 len += sysfs_emit_at(buf, len, "NVME RPORT ");
706 goto unlock_buf_done;651 if (phba->brd_no >= 10)
707 if (phba->brd_no >= 10) {652 len += sysfs_emit_at(buf, len, " ");
708 if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE)
709 goto unlock_buf_done;
710 }
711 653
712 scnprintf(tmp, sizeof(tmp), "WWPN x%llx ",654 len += sysfs_emit_at(buf, len, "WWPN x%llx ",
713 nrport->port_name);655 nrport->port_name);
714 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
715 goto unlock_buf_done;
716 656
717 scnprintf(tmp, sizeof(tmp), "WWNN x%llx ",657 len += sysfs_emit_at(buf, len, "WWNN x%llx ",
718 nrport->node_name);658 nrport->node_name);
719 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
720 goto unlock_buf_done;
721 659
722 scnprintf(tmp, sizeof(tmp), "DID x%06x ",660 len += sysfs_emit_at(buf, len, "DID x%06x ",
723 nrport->port_id);661 nrport->port_id);
724 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
725 goto unlock_buf_done;
726 662
727 /* An NVME rport can have multiple roles. */663 /* An NVME rport can have multiple roles. */
728 if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) {664 if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
729 if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE)665 len += sysfs_emit_at(buf, len, "INITIATOR ");
730 goto unlock_buf_done;666 if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
731 }667 len += sysfs_emit_at(buf, len, "TARGET ");
732 if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) {668 if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
733 if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE)669 len += sysfs_emit_at(buf, len, "DISCSRVC ");
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 }
740 if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |670 if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
741 FC_PORT_ROLE_NVME_TARGET |671 FC_PORT_ROLE_NVME_TARGET |
742 FC_PORT_ROLE_NVME_DISCOVERY)) {672 FC_PORT_ROLE_NVME_DISCOVERY))
743 scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x",673 len += sysfs_emit_at(buf, len, "UNKNOWN ROLE x%x",
744 nrport->port_role);674 nrport->port_role);
745 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)675
746 goto unlock_buf_done;676 len += sysfs_emit_at(buf, len, "%s\n", statep);
747 }
748 677
749 scnprintf(tmp, sizeof(tmp), "%s\n", statep);678 if (len >= PAGE_SIZE - 1)
750 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)679 break;
751 goto unlock_buf_done;
752 }680 }
753 spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);681 spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
754 682
755 if (!lport)683 if (!lport)
756 goto buffer_done;684 goto buffer_done;
757 685
758 if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE)686 len += sysfs_emit_at(buf, len, "\nNVME Statistics\n");
759 goto buffer_done;
760 687
761 scnprintf(tmp, sizeof(tmp),688 len += sysfs_emit_at(buf, len,
762 "LS: Xmt %010x Cmpl %010x Abort %08x\n",689 "LS: Xmt %010x Cmpl %010x Abort %08x\n",
763 atomic_read(&lport->fc4NvmeLsRequests),690 atomic_read(&lport->fc4NvmeLsRequests),
764 atomic_read(&lport->fc4NvmeLsCmpls),691 atomic_read(&lport->fc4NvmeLsCmpls),
765 atomic_read(&lport->xmt_ls_abort));692 atomic_read(&lport->xmt_ls_abort));
766 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
767 goto buffer_done;
768 693
769 scnprintf(tmp, sizeof(tmp),694 len += sysfs_emit_at(buf, len,
770 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",695 "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n",
771 atomic_read(&lport->xmt_ls_err),696 atomic_read(&lport->xmt_ls_err),
772 atomic_read(&lport->cmpl_ls_xb),697 atomic_read(&lport->cmpl_ls_xb),
773 atomic_read(&lport->cmpl_ls_err));698 atomic_read(&lport->cmpl_ls_err));
774 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
775 goto buffer_done;
776 699
777 totin = 0;700 totin = 0;
778 totout = 0;701 totout = 0;
@@ -785,40 +708,25 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, · 6 unmodified lines
785 data3 = cstat->control_requests;708 data3 = cstat->control_requests;
786 totout += (data1 + data2 + data3);709 totout += (data1 + data2 + data3);
787 }710 }
788 scnprintf(tmp, sizeof(tmp),711 len += sysfs_emit_at(buf, len,
789 "Total FCP Cmpl %016llx Issue %016llx "712 "Total FCP Cmpl %016llx Issue %016llx OutIO %016llx\n",
790 "OutIO %016llx\n",713 totin, totout, totout - totin);
791 totin, totout, totout - totin);714
792 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)715 len += sysfs_emit_at(buf, len,
793 goto buffer_done;716 "\tabort %08x noxri %08x nondlp %08x qdepth %08x wqerr %08x err %08x\n",
794 717 atomic_read(&lport->xmt_fcp_abort),
795 scnprintf(tmp, sizeof(tmp),718 atomic_read(&lport->xmt_fcp_noxri),
796 "\tabort %08x noxri %08x nondlp %08x qdepth %08x "719 atomic_read(&lport->xmt_fcp_bad_ndlp),
797 "wqerr %08x err %08x\n",720 atomic_read(&lport->xmt_fcp_qdepth),
798 atomic_read(&lport->xmt_fcp_abort),721 atomic_read(&lport->xmt_fcp_wqerr),
799 atomic_read(&lport->xmt_fcp_noxri),722 atomic_read(&lport->xmt_fcp_err));
800 atomic_read(&lport->xmt_fcp_bad_ndlp),723
801 atomic_read(&lport->xmt_fcp_qdepth),724 len += sysfs_emit_at(buf, len,
802 atomic_read(&lport->xmt_fcp_wqerr),725 "FCP CMPL: xb %08x Err %08x\n",
803 atomic_read(&lport->xmt_fcp_err));726 atomic_read(&lport->cmpl_fcp_xb),
804 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)727 atomic_read(&lport->cmpl_fcp_err));
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);
818 728
819 buffer_done:729 buffer_done:
820 len = strnlen(buf, PAGE_SIZE);
821
822 if (unlikely(len >= (PAGE_SIZE - 1))) {730 if (unlikely(len >= (PAGE_SIZE - 1))) {
823 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,731 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,
824 "6314 Catching potential buffer "732 "6314 Catching potential buffer "
@@ -844,13 +752,12 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, · 19 unmodified lines
844 u64 data1, data2, data3;752 u64 data1, data2, data3;
845 u64 tot, totin, totout;753 u64 tot, totin, totout;
846 int i;754 int i;
847 char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
848 755
849 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||756 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
850 (phba->sli_rev != LPFC_SLI_REV4))757 (phba->sli_rev != LPFC_SLI_REV4))
851 return 0;758 return 0;
852 759
853 scnprintf(buf, PAGE_SIZE, "SCSI HDWQ Statistics\n");760 len = sysfs_emit(buf, "SCSI HDWQ Statistics\n");
854 761
855 totin = 0;762 totin = 0;
856 totout = 0;763 totout = 0;
@@ -863,22 +770,20 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, · 6 unmodified lines
863 data3 = cstat->control_requests;770 data3 = cstat->control_requests;
864 totout += (data1 + data2 + data3);771 totout += (data1 + data2 + data3);
865 772
866 scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "773 len += sysfs_emit_at(buf, len,
867 "IO %016llx ", i, data1, data2, data3);774 "HDWQ (%d): Rd %016llx Wr %016llx IO %016llx ",
868 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)775 i, data1, data2, data3);
869 goto buffer_done;
870 776
871 scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",777 len += sysfs_emit_at(buf, len,
872 tot, ((data1 + data2 + data3) - tot));778 "Cmpl %016llx OutIO %016llx\n",
873 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)779 tot, ((data1 + data2 + data3) - tot));
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);
879 780
880buffer_done:781 if (len >= PAGE_SIZE - 1)
881 len = strnlen(buf, PAGE_SIZE);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);
882 787
883 return len;788 return len;
884}789}
drivers/scsi/lpfc/lpfc_bsg.c+2−4
@@ -1329,10 +1329,8 @@ lpfc_bsg_hba_get_event(struct bsg_job *job) · 1328 unmodified lines
1329 else1329 else
1330 bsg_reply->reply_payload_rcv_len = 0;1330 bsg_reply->reply_payload_rcv_len = 0;
1331 1331
1332 if (evt_dat) {1332 kfree(evt_dat->data);
1333 kfree(evt_dat->data);1333 kfree(evt_dat);
1334 kfree(evt_dat);
1335 }
1336 1334
1337 spin_lock_irqsave(&phba->ct_ev_lock, flags);1335 spin_lock_irqsave(&phba->ct_ev_lock, flags);
1338 lpfc_bsg_event_unref(evt);1336 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
1823 size_t size)1823 size_t size)
1824{1824{
1825 char fwrev[FW_REV_STR_SIZE] = {0};1825 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;
1833 1826
1834 lpfc_decode_firmware_rev(vport->phba, fwrev, 0);1827 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;
1846 1828
1829 memset(symbol, 0, size);
1847 /* Note :- OS name is "Linux" */1830 /* Note :- OS name is "Linux" */
1848 scnprintf(tmp, sizeof(tmp), " OS:%s", init_utsname()->sysname);1831 return scnprintf(symbol, size, "Emulex %s FV%s DV%s HN:%s OS:%s",
1849 strlcat(symbol, tmp, size);1832 vport->phba->ModelName, fwrev,
1850 1833 lpfc_release_version, vport->phba->os_host_name,
1851buffer_done:1834 init_utsname()->sysname);
1852 return strnlen(symbol, size);
1853
1854}1835}
1855 1836
1856static uint32_t1837static uint32_t
drivers/scsi/lpfc/lpfc_debugfs.c+87−115
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include <linux/idr.h>27#include <linux/idr.h>
28#include <linux/interrupt.h>28#include <linux/interrupt.h>
29#include <linux/kthread.h>29#include <linux/kthread.h>
30#include <linux/seq_buf.h>
30#include <linux/slab.h>31#include <linux/slab.h>
31#include <linux/pci.h>32#include <linux/pci.h>
32#include <linux/spinlock.h>33#include <linux/spinlock.h>
@@ -462,7 +463,8 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 429 unmodified lines
462 struct lpfc_pvt_pool *pvt_pool;463 struct lpfc_pvt_pool *pvt_pool;
463 struct lpfc_pbl_pool *pbl_pool;464 struct lpfc_pbl_pool *pbl_pool;
464 u32 txcmplq_cnt;465 u32 txcmplq_cnt;
465 char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0};466 size_t used;
467 struct seq_buf s;
466 468
467 if (phba->sli_rev != LPFC_SLI_REV4)469 if (phba->sli_rev != LPFC_SLI_REV4)
468 return 0;470 return 0;
@@ -475,6 +477,9 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 6 unmodified lines
475 return i;477 return i;
476 }478 }
477 479
480 used = strnlen(buf, size);
481 seq_buf_init(&s, buf + used, size - used);
482
478 /*483 /*
479 * Pbl: Current number of free XRIs in public pool484 * Pbl: Current number of free XRIs in public pool
480 * Pvt: Current number of free XRIs in private pool485 * 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
484 * pbl_empty: Incremented by 1 when all pbl_pool are empty during489 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
485 * IO submission490 * IO submission
486 */491 */
487 scnprintf(tmp, sizeof(tmp),492 seq_buf_printf(&s,
488 "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");493 "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
489 if (strlcat(buf, tmp, size) >= size)
490 return strnlen(buf, size);
491 494
492#ifdef LPFC_MXP_STAT495#ifdef LPFC_MXP_STAT
493 /*496 /*
@@ -501,25 +504,17 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 7 unmodified lines
501 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from504 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
502 * other pbl_pool505 * other pbl_pool
503 */506 */
504 scnprintf(tmp, sizeof(tmp),507 seq_buf_printf(&s, "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
505 "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
506 if (strlcat(buf, tmp, size) >= size)
507 return strnlen(buf, size);
508 508
509 /*509 /*
510 * sPbl: snapshot of Pbl 15 sec after stat gets cleared510 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
511 * sPvt: snapshot of Pvt 15 sec after stat gets cleared511 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
512 * sBusy: snapshot of Busy 15 sec after stat gets cleared512 * sBusy: snapshot of Busy 15 sec after stat gets cleared
513 */513 */
514 scnprintf(tmp, sizeof(tmp),514 seq_buf_printf(&s, " | sPbl sPvt sBusy");
515 " | sPbl sPvt sBusy");
516 if (strlcat(buf, tmp, size) >= size)
517 return strnlen(buf, size);
518#endif515#endif
519 516
520 scnprintf(tmp, sizeof(tmp), "\n");517 seq_buf_printf(&s, "\n");
521 if (strlcat(buf, tmp, size) >= size)
522 return strnlen(buf, size);
523 518
524 hwq_count = phba->cfg_hdw_queue;519 hwq_count = phba->cfg_hdw_queue;
525 for (i = 0; i < hwq_count; i++) {520 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
531 pvt_pool = &multixri_pool->pvt_pool;526 pvt_pool = &multixri_pool->pvt_pool;
532 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;527 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
533 528
534 scnprintf(tmp, sizeof(tmp),529 seq_buf_printf(&s,
535 "%03d: %4d %4d %4d %4d | %10d %10d ",530 "%03d: %4d %4d %4d %4d | %10d %10d ",
536 i, pbl_pool->count, pvt_pool->count,531 i, pbl_pool->count, pvt_pool->count,
537 txcmplq_cnt, pvt_pool->high_watermark,532 txcmplq_cnt, pvt_pool->high_watermark,
538 qp->empty_io_bufs, multixri_pool->pbl_empty_count);533 qp->empty_io_bufs,
539 if (strlcat(buf, tmp, size) >= size)534 multixri_pool->pbl_empty_count);
540 break;
541 535
542#ifdef LPFC_MXP_STAT536#ifdef LPFC_MXP_STAT
543 scnprintf(tmp, sizeof(tmp),537 seq_buf_printf(&s,
544 "%4d %10d %10d %10d %10d",538 "%4d %10d %10d %10d %10d",
545 multixri_pool->stat_max_hwm,539 multixri_pool->stat_max_hwm,
546 multixri_pool->above_limit_count,540 multixri_pool->above_limit_count,
547 multixri_pool->below_limit_count,541 multixri_pool->below_limit_count,
548 multixri_pool->local_pbl_hit_count,542 multixri_pool->local_pbl_hit_count,
549 multixri_pool->other_pbl_hit_count);543 multixri_pool->other_pbl_hit_count);
550 if (strlcat(buf, tmp, size) >= size)544
551 break;545 seq_buf_printf(&s,
552 546 " | %4d %4d %5d",
553 scnprintf(tmp, sizeof(tmp),547 multixri_pool->stat_pbl_count,
554 " | %4d %4d %5d",548 multixri_pool->stat_pvt_count,
555 multixri_pool->stat_pbl_count,549 multixri_pool->stat_busy_count);
556 multixri_pool->stat_pvt_count,
557 multixri_pool->stat_busy_count);
558 if (strlcat(buf, tmp, size) >= size)
559 break;
560#endif550#endif
561 551
562 scnprintf(tmp, sizeof(tmp), "\n");552 seq_buf_printf(&s, "\n");
563 if (strlcat(buf, tmp, size) >= size)553
554 if (seq_buf_has_overflowed(&s))
564 break;555 break;
565 }556 }
566 return strnlen(buf, size);557 return strnlen(buf, size);
@@ -1261,13 +1252,14 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size) · 694 unmodified lines
1261 u64 data1, data2, data3;1252 u64 data1, data2, data3;
1262 u64 tot, totin, totout;1253 u64 tot, totin, totout;
1263 int i;1254 int i;
1264 char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};1255 struct seq_buf s;
1265 1256
1266 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||1257 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
1267 (phba->sli_rev != LPFC_SLI_REV4))1258 (phba->sli_rev != LPFC_SLI_REV4))
1268 return 0;1259 return 0;
1269 1260
1270 scnprintf(buf, size, "SCSI HDWQ Statistics\n");1261 seq_buf_init(&s, buf, size);
1262 seq_buf_printf(&s, "SCSI HDWQ Statistics\n");
1271 1263
1272 totin = 0;1264 totin = 0;
1273 totout = 0;1265 totout = 0;
@@ -1280,21 +1272,18 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size) · 6 unmodified lines
1280 data3 = cstat->control_requests;1272 data3 = cstat->control_requests;
1281 totout += (data1 + data2 + data3);1273 totout += (data1 + data2 + data3);
1282 1274
1283 scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "1275 seq_buf_printf(&s, "HDWQ (%d): Rd %016llx Wr %016llx IO %016llx ",
1284 "IO %016llx ", i, data1, data2, data3);1276 i, data1, data2, data3);
1285 if (strlcat(buf, tmp, size) >= size)1277
1286 goto buffer_done;1278 seq_buf_printf(&s, "Cmpl %016llx OutIO %016llx\n",
1279 tot, ((data1 + data2 + data3) - tot));
1287 1280
1288 scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",1281 if (seq_buf_has_overflowed(&s))
1289 tot, ((data1 + data2 + data3) - tot));1282 break;
1290 if (strlcat(buf, tmp, size) >= size)
1291 goto buffer_done;
1292 }1283 }
1293 scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx "1284 seq_buf_printf(&s, "Total FCP Cmpl %016llx Issue %016llx OutIO %016llx\n",
1294 "OutIO %016llx\n", totin, totout, totout - totin);1285 totin, totout, totout - totin);
1295 strlcat(buf, tmp, size);
1296 1286
1297buffer_done:
1298 len = strnlen(buf, size);1287 len = strnlen(buf, size);
1299 1288
1300 return len;1289 return len;
@@ -1704,28 +1693,23 @@ lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size) · 403 unmodified lines
1704 uint32_t tot_xmt;1693 uint32_t tot_xmt;
1705 uint32_t tot_rcv;1694 uint32_t tot_rcv;
1706 uint32_t tot_cmpl;1695 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;
1708 1698
1709 scnprintf(tmp, sizeof(tmp), "HDWQ Stats:\n\n");1699 seq_buf_init(&s, buf + used, size - used);
1710 if (strlcat(buf, tmp, size) >= size)
1711 goto buffer_done;
1712 1700
1713 scnprintf(tmp, sizeof(tmp), "(NVME Accounting: %s) ",1701 seq_buf_printf(&s, "HDWQ Stats:\n\n");
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;
1719 1702
1720 scnprintf(tmp, sizeof(tmp), "(SCSI Accounting: %s) ",1703 seq_buf_printf(&s, "(NVME Accounting: %s) ",
1721 (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ?1704 (phba->hdwqstat_on &
1722 "Enabled" : "Disabled"));1705 (LPFC_CHECK_NVME_IO | LPFC_CHECK_NVMET_IO) ?
1723 if (strlcat(buf, tmp, size) >= size)1706 "Enabled" : "Disabled"));
1724 goto buffer_done;
1725 1707
1726 scnprintf(tmp, sizeof(tmp), "\n\n");1708 seq_buf_printf(&s, "(SCSI Accounting: %s) ",
1727 if (strlcat(buf, tmp, size) >= size)1709 (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ?
1728 goto buffer_done;1710 "Enabled" : "Disabled"));
1711
1712 seq_buf_printf(&s, "\n\n");
1729 1713
1730 for (i = 0; i < phba->cfg_hdw_queue; i++) {1714 for (i = 0; i < phba->cfg_hdw_queue; i++) {
1731 tot_rcv = 0;1715 tot_rcv = 0;
@@ -1744,62 +1728,50 @@ lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size) · 12 unmodified lines
1744 !c_stat->rcv_io)1728 !c_stat->rcv_io)
1745 continue;1729 continue;
1746 1730
1747 if (!tot_xmt && !tot_cmpl && !tot_rcv) {1731 /* Print HDWQ string only the first time */
1748 /* Print HDWQ string only the first time */1732 if (!tot_xmt && !tot_cmpl && !tot_rcv)
1749 scnprintf(tmp, sizeof(tmp), "[HDWQ %d]:\t", i);1733 seq_buf_printf(&s, "[HDWQ %d]:\t", i);
1750 if (strlcat(buf, tmp, size) >= size)
1751 goto buffer_done;
1752 }
1753 1734
1754 tot_xmt += c_stat->xmt_io;1735 tot_xmt += c_stat->xmt_io;
1755 tot_cmpl += c_stat->cmpl_io;1736 tot_cmpl += c_stat->cmpl_io;
1756 if (phba->nvmet_support)1737 if (phba->nvmet_support)
1757 tot_rcv += c_stat->rcv_io;1738 tot_rcv += c_stat->rcv_io;
1758 1739
1759 scnprintf(tmp, sizeof(tmp), "| [CPU %d]: ", j);1740 seq_buf_printf(&s, "| [CPU %d]: ", j);
1760 if (strlcat(buf, tmp, size) >= size)1741
1761 goto buffer_done;1742 if (phba->nvmet_support)
1762 1743 seq_buf_printf(&s,
1763 if (phba->nvmet_support) {1744 "XMT 0x%x CMPL 0x%x RCV 0x%x |",
1764 scnprintf(tmp, sizeof(tmp),1745 c_stat->xmt_io, c_stat->cmpl_io,
1765 "XMT 0x%x CMPL 0x%x RCV 0x%x |",1746 c_stat->rcv_io);
1766 c_stat->xmt_io, c_stat->cmpl_io,1747 else
1767 c_stat->rcv_io);1748 seq_buf_printf(&s,
1768 if (strlcat(buf, tmp, size) >= size)1749 "XMT 0x%x CMPL 0x%x |",
1769 goto buffer_done;1750 c_stat->xmt_io, c_stat->cmpl_io);
1770 } else {1751
1771 scnprintf(tmp, sizeof(tmp),1752 if (seq_buf_has_overflowed(&s))
1772 "XMT 0x%x CMPL 0x%x |",1753 break;
1773 c_stat->xmt_io, c_stat->cmpl_io);
1774 if (strlcat(buf, tmp, size) >= size)
1775 goto buffer_done;
1776 }
1777 }1754 }
1778 1755
1756 if (seq_buf_has_overflowed(&s))
1757 break;
1758
1779 /* Check if nothing to display */1759 /* Check if nothing to display */
1780 if (!tot_xmt && !tot_cmpl && !tot_rcv)1760 if (!tot_xmt && !tot_cmpl && !tot_rcv)
1781 continue;1761 continue;
1782 1762
1783 scnprintf(tmp, sizeof(tmp), "\t->\t[HDWQ Total: ");1763 seq_buf_printf(&s, "\t->\t[HDWQ Total: ");
1784 if (strlcat(buf, tmp, size) >= size)
1785 goto buffer_done;
1786 1764
1787 if (phba->nvmet_support) {1765 if (phba->nvmet_support)
1788 scnprintf(tmp, sizeof(tmp),1766 seq_buf_printf(&s,
1789 "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",1767 "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",
1790 tot_xmt, tot_cmpl, tot_rcv);1768 tot_xmt, tot_cmpl, tot_rcv);
1791 if (strlcat(buf, tmp, size) >= size)1769 else
1792 goto buffer_done;1770 seq_buf_printf(&s,
1793 } else {1771 "XMT 0x%x CMPL 0x%x]\n\n",
1794 scnprintf(tmp, sizeof(tmp),1772 tot_xmt, tot_cmpl);
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 }
1800 }1773 }
1801 1774
1802buffer_done:
1803 len = strnlen(buf, size);1775 len = strnlen(buf, size);
1804 return len;1776 return len;
1805}1777}
drivers/scsi/lpfc/lpfc_scsi.c+15−34
@@ -21,6 +21,7 @@ · 20 unmodified lines
21 * included with this package. *21 * included with this package. *
22 *******************************************************************/22 *******************************************************************/
23#include <linux/pci.h>23#include <linux/pci.h>
24#include <linux/seq_buf.h>
24#include <linux/slab.h>25#include <linux/slab.h>
25#include <linux/interrupt.h>26#include <linux/interrupt.h>
26#include <linux/export.h>27#include <linux/export.h>
@@ -5103,57 +5104,37 @@ lpfc_info(struct Scsi_Host *host) · 5076 unmodified lines
5103 struct lpfc_hba *phba = vport->phba;5104 struct lpfc_hba *phba = vport->phba;
5104 int link_speed = 0;5105 int link_speed = 0;
5105 static char lpfcinfobuf[384];5106 static char lpfcinfobuf[384];
5106 char tmp[384] = {0};5107 struct seq_buf s;
5107 5108
5108 memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));5109 memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
5110 seq_buf_init(&s, lpfcinfobuf, sizeof(lpfcinfobuf));
5109 if (phba && phba->pcidev){5111 if (phba && phba->pcidev){
5110 /* Model Description */5112 /* Model Description */
5111 scnprintf(tmp, sizeof(tmp), phba->ModelDesc);5113 seq_buf_printf(&s, "%s", phba->ModelDesc);
5112 if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5113 sizeof(lpfcinfobuf))
5114 goto buffer_done;
5115 5114
5116 /* PCI Info */5115 /* PCI Info */
5117 scnprintf(tmp, sizeof(tmp),5116 seq_buf_printf(&s, " on PCI bus %02x device %02x irq %d",
5118 " on PCI bus %02x device %02x irq %d",5117 phba->pcidev->bus->number, phba->pcidev->devfn,
5119 phba->pcidev->bus->number, phba->pcidev->devfn,5118 phba->pcidev->irq);
5120 phba->pcidev->irq);
5121 if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5122 sizeof(lpfcinfobuf))
5123 goto buffer_done;
5124 5119
5125 /* Port Number */5120 /* Port Number */
5126 if (phba->Port[0]) {5121 if (phba->Port[0])
5127 scnprintf(tmp, sizeof(tmp), " port %s", phba->Port);5122 seq_buf_printf(&s, " port %s", phba->Port);
5128 if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5129 sizeof(lpfcinfobuf))
5130 goto buffer_done;
5131 }
5132 5123
5133 /* Link Speed */5124 /* Link Speed */
5134 link_speed = lpfc_sli_port_speed_get(phba);5125 link_speed = lpfc_sli_port_speed_get(phba);
5135 if (link_speed != 0) {5126 if (link_speed != 0)
5136 scnprintf(tmp, sizeof(tmp),5127 seq_buf_printf(&s, " Logical Link Speed: %d Mbps",
5137 " Logical Link Speed: %d Mbps", link_speed);5128 link_speed);
5138 if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5139 sizeof(lpfcinfobuf))
5140 goto buffer_done;
5141 }
5142 5129
5143 /* Support for BSG ioctls */5130 /* Support for BSG ioctls */
5144 scnprintf(tmp, sizeof(tmp), " BSG");5131 seq_buf_printf(&s, " BSG");
5145 if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
5146 sizeof(lpfcinfobuf))
5147 goto buffer_done;
5148 5132
5149 /* PCI resettable */5133 /* PCI resettable */
5150 if (!lpfc_check_pci_resettable(phba)) {5134 if (!lpfc_check_pci_resettable(phba))
5151 scnprintf(tmp, sizeof(tmp), " PCI resettable");5135 seq_buf_printf(&s, " PCI resettable");
5152 strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf));
5153 }
5154 }5136 }
5155 5137
5156buffer_done:
5157 return lpfcinfobuf;5138 return lpfcinfobuf;
5158}5139}
5159 5140
drivers/scsi/lpfc/lpfc_scsi.h+0−3
@@ -158,6 +158,3 @@ struct fcp_cmnd32 { · 157 unmodified lines
158 158
159#define TXRDY_PAYLOAD_LEN 12159#define TXRDY_PAYLOAD_LEN 12
160 160
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
25#include <linux/pci.h>25#include <linux/pci.h>
26#include <linux/interrupt.h>26#include <linux/interrupt.h>
27#include <linux/delay.h>27#include <linux/delay.h>
28#include <linux/seq_buf.h>
28#include <linux/slab.h>29#include <linux/slab.h>
29#include <linux/lockdep.h>30#include <linux/lockdep.h>
30#include <linux/dmi.h>31#include <linux/dmi.h>
@@ -8109,17 +8110,18 @@ u32 lpfc_rx_monitor_report(struct lpfc_hba *phba, · 8078 unmodified lines
8109 u32 cnt = 0;8110 u32 cnt = 0;
8110 char tmp[DBG_LOG_STR_SZ] = {0};8111 char tmp[DBG_LOG_STR_SZ] = {0};
8111 bool log_to_kmsg = (!buf || !buf_len) ? true : false;8112 bool log_to_kmsg = (!buf || !buf_len) ? true : false;
8113 struct seq_buf s;
8112 8114
8113 if (!log_to_kmsg) {8115 if (!log_to_kmsg) {
8114 /* clear the buffer to be sure */8116 /* clear the buffer to be sure */
8115 memset(buf, 0, buf_len);8117 memset(buf, 0, buf_len);
8116 8118
8117 scnprintf(buf, buf_len, "\t%-16s%-16s%-16s%-16s%-8s%-8s%-8s"8119 seq_buf_init(&s, buf, buf_len);
8118 "%-8s%-8s%-8s%-16s\n",8120 seq_buf_printf(&s, "\t%-16s%-16s%-16s%-16s%-8s%-8s%-8s%-8s%-8s%-8s%-16s\n",
8119 "MaxBPI", "Tot_Data_CMF",8121 "MaxBPI", "Tot_Data_CMF",
8120 "Tot_Data_Cmd", "Tot_Data_Cmpl",8122 "Tot_Data_Cmd", "Tot_Data_Cmpl",
8121 "Lat(us)", "Avg_IO", "Max_IO", "Bsy",8123 "Lat(us)", "Avg_IO", "Max_IO", "Bsy",
8122 "IO_cnt", "Info", "BWutil(ms)");8124 "IO_cnt", "Info", "BWutil(ms)");
8123 }8125 }
8124 8126
8125 /* Needs to be _irq because record is called from timer interrupt8127 /* 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
8131 8133
8132 /* Read out this entry's data. */8134 /* Read out this entry's data. */
8133 if (!log_to_kmsg) {8135 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 */
8135 scnprintf(tmp, sizeof(tmp),8140 scnprintf(tmp, sizeof(tmp),
8136 "%03d:\t%-16llu%-16llu%-16llu%-16llu%-8llu"8141 "%03d:\t%-16llu%-16llu%-16llu%-16llu%-8llu%-8llu%-8llu%-8u%-8u%-8u%u(%u)\n",
8137 "%-8llu%-8llu%-8u%-8u%-8u%u(%u)\n",8142 *head_idx,
8138 *head_idx, entry->max_bytes_per_interval,8143 entry->max_bytes_per_interval,
8139 entry->cmf_bytes, entry->total_bytes,8144 entry->cmf_bytes,
8140 entry->rcv_bytes, entry->avg_io_latency,8145 entry->total_bytes,
8141 entry->avg_io_size, entry->max_read_cnt,8146 entry->rcv_bytes,
8147 entry->avg_io_latency,
8148 entry->avg_io_size,
8149 entry->max_read_cnt,
8142 entry->cmf_busy, entry->io_cnt,8150 entry->cmf_busy, entry->io_cnt,
8143 entry->cmf_info, entry->timer_utilization,8151 entry->cmf_info,
8152 entry->timer_utilization,
8144 entry->timer_interval);8153 entry->timer_interval);
8145 8154
8146 /* Check for buffer overflow */8155 if (seq_buf_puts(&s, tmp) < 0)
8147 if ((strlen(buf) + strlen(tmp)) >= buf_len)
8148 break;8156 break;
8149
8150 /* Append entry's data to buffer */
8151 strlcat(buf, tmp, buf_len);
8152 } else {8157 } else {
8153 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,8158 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
8154 "4410 %02u: MBPI %llu Xmit %llu "8159 "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
3072 3072
3073 scmd_printk(KERN_INFO, scmd,3073 scmd_printk(KERN_INFO, scmd,
3074 "SCSI host state: %d SCSI host busy: %d FW outstanding: %d\n",3074 "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),
3076 scsi_host_busy(scmd->device->host),3076 scsi_host_busy(scmd->device->host),
3077 atomic_read(&instance->fw_outstanding));3077 atomic_read(&instance->fw_outstanding));
3078 /*3078 /*
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
5172 5172
5173 /* Avoid error handling escalation when device is removed or blocked */5173 /* Avoid error handling escalation when device is removed or blocked */
5174 5174
5175 if (scmd->device->host->shost_state == SHOST_RECOVERY &&5175 if (scsi_get_host_state(scmd->device->host) == SHOST_RECOVERY &&
5176 scmd->cmnd[0] == TEST_UNIT_READY &&5176 scmd->cmnd[0] == TEST_UNIT_READY &&
5177 (stgt_priv_data->dev_removed || (dev_handle == MPI3MR_INVALID_DEV_HANDLE))) {5177 (stgt_priv_data->dev_removed || (dev_handle == MPI3MR_INVALID_DEV_HANDLE))) {
5178 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);5178 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
5870 5870
5871 if (ioc->pcie_sgl_dma_pool) {5871 if (ioc->pcie_sgl_dma_pool) {
5872 for (i = 0; i < ioc->scsiio_depth; i++) {5872 for (i = 0; i < ioc->scsiio_depth; i++) {
5873 if (!ioc->pcie_sg_lookup[i].pcie_sgl)
5874 continue;
5873 dma_pool_free(ioc->pcie_sgl_dma_pool,5875 dma_pool_free(ioc->pcie_sgl_dma_pool,
5874 ioc->pcie_sg_lookup[i].pcie_sgl,5876 ioc->pcie_sg_lookup[i].pcie_sgl,
5875 ioc->pcie_sg_lookup[i].pcie_sgl_dma);5877 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
5472 * Avoid error handling escallation when device is disconnected5472 * Avoid error handling escallation when device is disconnected
5473 */5473 */
5474 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) {5474 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 &&
5476 scmd->cmnd[0] == TEST_UNIT_READY) {5476 scmd->cmnd[0] == TEST_UNIT_READY) {
5477 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);5477 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);
5478 scsi_done(scmd);5478 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
2302 if (TMF_NOT_READY(fcport)) {2302 if (TMF_NOT_READY(fcport)) {
2303 ql_log(ql_log_warn, vha, 0x802c,2303 ql_log(ql_log_warn, vha, 0x802c,
2304 "Unable to acquire TM resource due to disruption.\n");2304 "Unable to acquire TM resource due to disruption.\n");
2305 rc = EIO;2305 rc = -EIO;
2306 break;2306 break;
2307 }2307 }
2308 if (ha->active_tmf < MAX_ACTIVE_TMF &&2308 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
9269 if (section == TIM) {9269 if (section == TIM) {
9270 if (section_size > req->length * qla_req_entry_size(ha)) {9270 if (section_size > req->length * qla_req_entry_size(ha)) {
9271 ql_log(ql_log_fatal, vha, 0x0098,9271 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",
9273 section_size,9273 section_size,
9274 req->length * qla_req_entry_size(ha));9274 req->length * qla_req_entry_size(ha));
9275 return QLA_FUNCTION_FAILED;9275 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
3507 msleep(QLA8044_FLASH_STATUS_REG_POLL_DELAY);3507 msleep(QLA8044_FLASH_STATUS_REG_POLL_DELAY);
3508 }3508 }
3509 3509
3510 if (!retries)3510 if (retries == -1)
3511 ret_val = QLA_FUNCTION_FAILED;3511 ret_val = QLA_FUNCTION_FAILED;
3512 3512
3513 return ret_val;3513 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
9411 * This routine finds that if reset host is called in EH9411 * This routine finds that if reset host is called in EH
9412 * scenario or from some application like sg_reset9412 * scenario or from some application like sg_reset
9413 **/9413 **/
9414static int qla4xxx_is_eh_active(struct Scsi_Host *shost)9414static bool qla4xxx_is_eh_active(struct Scsi_Host *shost)
9415{9415{
9416 if (shost->shost_state == SHOST_RECOVERY)9416 return scsi_get_host_state(shost) == SHOST_RECOVERY;
9417 return 1;
9418 return 0;
9419}9417}
9420 9418
9421/**9419/**
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
1663 goto done;1663 goto done;
1664 }1664 }
1665 1665
1666 if (unlikely(host->shost_state == SHOST_DEL)) {1666 if (unlikely(scsi_get_host_state(host) == SHOST_DEL)) {
1667 cmd->result = (DID_NO_CONNECT << 16);1667 cmd->result = (DID_NO_CONNECT << 16);
1668 goto done;1668 goto done;
1669
1670 }1669 }
1671 1670
1672 trace_scsi_dispatch_cmd_start(cmd);1671 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
1169 1169
1170/**1170/**
1171 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it1171 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
1172 * @shost: SCSI host pointer
1172 * @starget: pointer to target device structure1173 * @starget: pointer to target device structure
1173 * @lun: LUN of target device1174 * @lun: LUN of target device
1174 * @bflagsp: store bflags here if not NULL1175 * @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
1188 * attached at the LUN1189 * attached at the LUN
1189 * - SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized1190 * - SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
1190 **/1191 **/
1191static int scsi_probe_and_add_lun(struct scsi_target *starget,1192static int scsi_probe_and_add_lun(struct Scsi_Host *shost,
1193 struct scsi_target *starget,
1192 u64 lun, blist_flags_t *bflagsp,1194 u64 lun, blist_flags_t *bflagsp,
1193 struct scsi_device **sdevp,1195 struct scsi_device **sdevp,
1194 enum scsi_scan_mode rescan,1196 enum scsi_scan_mode rescan,
1195 void *hostdata)1197 void *hostdata)
1198 __must_hold(&shost->scan_mutex)
1196{1199{
1197 struct scsi_device *sdev;1200 struct scsi_device *sdev;
1198 unsigned char *result;1201 unsigned char *result;
1199 blist_flags_t bflags;1202 blist_flags_t bflags;
1200 int res = SCSI_SCAN_NO_RESPONSE, result_len = 256;1203 int res = SCSI_SCAN_NO_RESPONSE, result_len = 256;
1201 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1202 1204
1203 /*1205 /*
1204 * The rescan flag is used as an optimization, the first scan of a1206 * 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
1334 1336
1335/**1337/**
1336 * scsi_sequential_lun_scan - sequentially scan a SCSI target1338 * scsi_sequential_lun_scan - sequentially scan a SCSI target
1339 * @shost: SCSI host pointer
1337 * @starget: pointer to target structure to scan1340 * @starget: pointer to target structure to scan
1338 * @bflags: black/white list flag for LUN 01341 * @bflags: black/white list flag for LUN 0
1339 * @scsi_level: Which version of the standard does this device adhere to1342 * @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
1346 *1349 *
1347 * Modifies sdevscan->lun.1350 * Modifies sdevscan->lun.
1348 **/1351 **/
1349static void scsi_sequential_lun_scan(struct scsi_target *starget,1352static void scsi_sequential_lun_scan(struct Scsi_Host *shost,
1353 struct scsi_target *starget,
1350 blist_flags_t bflags, int scsi_level,1354 blist_flags_t bflags, int scsi_level,
1351 enum scsi_scan_mode rescan)1355 enum scsi_scan_mode rescan)
1356 __must_hold(&shost->scan_mutex)
1352{1357{
1353 uint max_dev_lun;1358 uint max_dev_lun;
1354 u64 sparse_lun, lun;1359 u64 sparse_lun, lun;
1355 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1356 1360
1357 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget,1361 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget,
1358 "scsi scan: Sequential scan\n"));1362 "scsi scan: Sequential scan\n"));
@@ -1412,14 +1416,15 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, · 53 unmodified lines
1412 * sparse_lun.1416 * sparse_lun.
1413 */1417 */
1414 for (lun = 1; lun < max_dev_lun; ++lun)1418 for (lun = 1; lun < max_dev_lun; ++lun)
1415 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan,1419 if (scsi_probe_and_add_lun(shost, starget, lun, NULL, NULL,
1416 NULL) != SCSI_SCAN_LUN_PRESENT) &&1420 rescan, NULL) != SCSI_SCAN_LUN_PRESENT &&
1417 !sparse_lun)1421 !sparse_lun)
1418 return;1422 return;
1419}1423}
1420 1424
1421/**1425/**
1422 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results1426 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
1427 * @shost: SCSI host pointer
1423 * @starget: which target1428 * @starget: which target
1424 * @bflags: Zero or a mix of BLIST_NOLUN, BLIST_REPORTLUN2, or BLIST_NOREPORTLUN1429 * @bflags: Zero or a mix of BLIST_NOLUN, BLIST_REPORTLUN2, or BLIST_NOREPORTLUN
1425 * @rescan: nonzero if we can skip code only needed on first scan1430 * @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
1438 * 0: scan completed (or no memory, so further scanning is futile)1443 * 0: scan completed (or no memory, so further scanning is futile)
1439 * 1: could not scan with REPORT LUN1444 * 1: could not scan with REPORT LUN
1440 **/1445 **/
1441static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags,1446static int scsi_report_lun_scan(struct Scsi_Host *shost,
1442 enum scsi_scan_mode rescan)1447 struct scsi_target *starget, blist_flags_t bflags,
1448 enum scsi_scan_mode rescan)
1449 __must_hold(&shost->scan_mutex)
1443{1450{
1444 unsigned char scsi_cmd[MAX_COMMAND_SIZE];1451 unsigned char scsi_cmd[MAX_COMMAND_SIZE];
1445 unsigned int length;1452 unsigned int length;
@@ -1448,7 +1455,6 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag · 2 unmodified lines
1448 int result;1455 int result;
1449 struct scsi_lun *lunp, *lun_data;1456 struct scsi_lun *lunp, *lun_data;
1450 struct scsi_device *sdev;1457 struct scsi_device *sdev;
1451 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
1452 struct scsi_failure failure_defs[] = {1458 struct scsi_failure failure_defs[] = {
1453 {1459 {
1454 .sense = UNIT_ATTENTION,1460 .sense = UNIT_ATTENTION,
@@ -1594,7 +1600,7 @@ retry: · 139 unmodified lines
1594 } else {1600 } else {
1595 int res;1601 int res;
1596 1602
1597 res = scsi_probe_and_add_lun(starget,1603 res = scsi_probe_and_add_lun(shost, starget,
1598 lun, NULL, NULL, rescan, NULL);1604 lun, NULL, NULL, rescan, NULL);
1599 if (res == SCSI_SCAN_NO_RESPONSE) {1605 if (res == SCSI_SCAN_NO_RESPONSE) {
1600 /*1606 /*
@@ -1641,7 +1647,7 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, · 40 unmodified lines
1641 scsi_complete_async_scans();1647 scsi_complete_async_scans();
1642 1648
1643 if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) {1649 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,
1645 SCSI_SCAN_RESCAN, hostdata);1651 SCSI_SCAN_RESCAN, hostdata);
1646 scsi_autopm_put_host(shost);1652 scsi_autopm_put_host(shost);
1647 }1653 }
@@ -1763,10 +1769,11 @@ unlock: · 115 unmodified lines
1763}1769}
1764EXPORT_SYMBOL(scsi_rescan_device);1770EXPORT_SYMBOL(scsi_rescan_device);
1765 1771
1766static void __scsi_scan_target(struct device *parent, unsigned int channel,1772static void __scsi_scan_target(struct Scsi_Host *shost, struct device *parent,
1767 unsigned int id, u64 lun, enum scsi_scan_mode rescan)1773 unsigned int channel, unsigned int id, u64 lun,
1774 enum scsi_scan_mode rescan)
1775 __must_hold(&shost->scan_mutex)
1768{1776{
1769 struct Scsi_Host *shost = dev_to_shost(parent);
1770 blist_flags_t bflags = 0;1777 blist_flags_t bflags = 0;
1771 int res;1778 int res;
1772 struct scsi_target *starget;1779 struct scsi_target *starget;
@@ -1786,7 +1793,8 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, · 13 unmodified lines
1786 /*1793 /*
1787 * Scan for a specific host/chan/id/lun.1794 * Scan for a specific host/chan/id/lun.
1788 */1795 */
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);
1790 goto out_reap;1798 goto out_reap;
1791 }1799 }
1792 1800
@@ -1794,14 +1802,15 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, · 1 unmodified line
1794 * Scan LUN 0, if there is some response, scan further. Ideally, we1802 * Scan LUN 0, if there is some response, scan further. Ideally, we
1795 * would not configure LUN 0 until all LUNs are scanned.1803 * would not configure LUN 0 until all LUNs are scanned.
1796 */1804 */
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);
1798 if (res == SCSI_SCAN_LUN_PRESENT || res == SCSI_SCAN_TARGET_PRESENT) {1807 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)
1800 /*1809 /*
1801 * The REPORT LUN did not scan the target,1810 * The REPORT LUN did not scan the target,
1802 * do a sequential scan.1811 * do a sequential scan.
1803 */1812 */
1804 scsi_sequential_lun_scan(starget, bflags,1813 scsi_sequential_lun_scan(shost, starget, bflags,
1805 starget->scsi_level, rescan);1814 starget->scsi_level, rescan);
1806 }1815 }
1807 1816
@@ -1851,7 +1860,7 @@ void scsi_scan_target(struct device *parent, unsigned int channel, · 43 unmodified lines
1851 scsi_complete_async_scans();1860 scsi_complete_async_scans();
1852 1861
1853 if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) {1862 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);
1855 scsi_autopm_put_host(shost);1864 scsi_autopm_put_host(shost);
1856 }1865 }
1857 mutex_unlock(&shost->scan_mutex);1866 mutex_unlock(&shost->scan_mutex);
@@ -1861,6 +1870,7 @@ EXPORT_SYMBOL(scsi_scan_target); · 3 unmodified lines
1861static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,1870static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
1862 unsigned int id, u64 lun,1871 unsigned int id, u64 lun,
1863 enum scsi_scan_mode rescan)1872 enum scsi_scan_mode rescan)
1873 __must_hold(&shost->scan_mutex)
1864{1874{
1865 uint order_id;1875 uint order_id;
1866 1876
@@ -1882,11 +1892,11 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, · 15 unmodified lines
1882 order_id = shost->max_id - id - 1;1892 order_id = shost->max_id - id - 1;
1883 else1893 else
1884 order_id = id;1894 order_id = id;
1885 __scsi_scan_target(&shost->shost_gendev, channel,1895 __scsi_scan_target(shost, &shost->shost_gendev, channel,
1886 order_id, lun, rescan);1896 order_id, lun, rescan);
1887 }1897 }
1888 else1898 else
1889 __scsi_scan_target(&shost->shost_gendev, channel,1899 __scsi_scan_target(shost, &shost->shost_gendev, channel,
1890 id, lun, rescan);1900 id, lun, rescan);
1891}1901}
1892 1902
drivers/scsi/scsi_sysfs.c+4−3
@@ -214,8 +214,9 @@ store_shost_state(struct device *dev, struct device_attribute *attr, · 213 unmodified lines
214 if (!state)214 if (!state)
215 return -EINVAL;215 return -EINVAL;
216 216
217 if (scsi_host_set_state(shost, state))217 scoped_guard(spinlock_irq, shost->host_lock)
218 return -EINVAL;218 if (scsi_host_set_state(shost, state))
219 return -EINVAL;
219 return count;220 return count;
220}221}
221 222
@@ -223,7 +224,7 @@ static ssize_t · 1 unmodified line
223show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)224show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
224{225{
225 struct Scsi_Host *shost = class_to_shost(dev);226 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));
227 228
228 if (!name)229 if (!name)
229 return -EINVAL;230 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
305 if (!shost->work_q) {305 if (!shost->work_q) {
306 SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");306 SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
307 307
308 scsi_remove_host(shost);
308 ret = -ENOMEM;309 ret = -ENOMEM;
309 }310 }
310 311
drivers/ufs/core/Makefile+2−0
@@ -1,5 +1,7 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2 2
3CONTEXT_ANALYSIS := y
4
3obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o5obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
4ufshcd-core-y += ufshcd.o ufs-sysfs.o ufs-mcq.o ufs-txeq.o6ufshcd-core-y += ufshcd.o ufs-sysfs.o ufs-mcq.o ufs-txeq.o
5ufshcd-core-$(CONFIG_RPMB) += ufs-rpmb.o7ufshcd-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
65 return 0;65 return 0;
66}66}
67 67
68token_context_lock(ufs_debugfs);
69
68static int ufs_debugfs_get_user_access(struct ufs_hba *hba)70static int ufs_debugfs_get_user_access(struct ufs_hba *hba)
69__acquires(&hba->host_sem)71 __cond_acquires(0, ufs_debugfs)
70{72{
71 down(&hba->host_sem);73 down(&hba->host_sem);
72 if (!ufshcd_is_user_access_allowed(hba)) {74 if (!ufshcd_is_user_access_allowed(hba)) {
@@ -74,14 +76,16 @@ __acquires(&hba->host_sem) · 1 unmodified line
74 return -EBUSY;76 return -EBUSY;
75 }77 }
76 ufshcd_rpm_get_sync(hba);78 ufshcd_rpm_get_sync(hba);
79 __acquire(ufs_debugfs);
77 return 0;80 return 0;
78}81}
79 82
80static void ufs_debugfs_put_user_access(struct ufs_hba *hba)83static void ufs_debugfs_put_user_access(struct ufs_hba *hba)
81__releases(&hba->host_sem)84 __releases(ufs_debugfs)
82{85{
83 ufshcd_rpm_put_sync(hba);86 ufshcd_rpm_put_sync(hba);
84 up(&hba->host_sem);87 up(&hba->host_sem);
88 __release(ufs_debugfs);
85}89}
86 90
87static int ee_usr_mask_set(void *data, u64 val)91static 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
1317 break;1317 break;
1318 }1318 }
1319 1319
1320 __set_current_state(TASK_UNINTERRUPTIBLE);
1320 io_schedule_timeout(msecs_to_jiffies(20));1321 io_schedule_timeout(msecs_to_jiffies(20));
1321 if (ktime_to_us(ktime_sub(ktime_get(), start)) >1322 if (ktime_to_us(ktime_sub(ktime_get(), start)) >
1322 wait_timeout_us) {1323 wait_timeout_us) {
@@ -1353,6 +1354,8 @@ out: · 30 unmodified lines
1353 * On failure, all acquired locks are released and the tagset is unquiesced.1354 * On failure, all acquired locks are released and the tagset is unquiesced.
1354 */1355 */
1355int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us)1356int 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)
1356{1359{
1357 int ret = 0;1360 int ret = 0;
1358 1361
@@ -1377,6 +1380,8 @@ int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us) · 18 unmodified lines
1377 * This function resumes command submissions.1380 * This function resumes command submissions.
1378 */1381 */
1379void ufshcd_resume_command_processing(struct ufs_hba *hba)1382void ufshcd_resume_command_processing(struct ufs_hba *hba)
1383 __releases(&hba->clk_scaling_lock)
1384 __releases(&hba->host->scan_mutex)
1380{1385{
1381 up_write(&hba->clk_scaling_lock);1386 up_write(&hba->clk_scaling_lock);
1382 blk_mq_unquiesce_tagset(&hba->host->tag_set);1387 blk_mq_unquiesce_tagset(&hba->host->tag_set);
@@ -1446,6 +1451,9 @@ config_pwr_mode: · 63 unmodified lines
1446 * Return: 0 upon success; -EBUSY upon timeout.1451 * Return: 0 upon success; -EBUSY upon timeout.
1447 */1452 */
1448static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)1453static 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)
1449{1457{
1450 int ret = 0;1458 int ret = 0;
1451 /*1459 /*
@@ -1475,6 +1483,9 @@ out: · 23 unmodified lines
1475}1483}
1476 1484
1477static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err)1485static 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)
1478{1489{
1479 up_write(&hba->clk_scaling_lock);1490 up_write(&hba->clk_scaling_lock);
1480 mutex_unlock(&hba->wb_mutex);1491 mutex_unlock(&hba->wb_mutex);
@@ -3304,6 +3315,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 1823 unmodified lines
3304}3315}
3305 3316
3306static void ufshcd_dev_man_lock(struct ufs_hba *hba)3317static void ufshcd_dev_man_lock(struct ufs_hba *hba)
3318 __acquires(&hba->dev_cmd.lock)
3319 __acquires_shared(&hba->clk_scaling_lock)
3307{3320{
3308 ufshcd_hold(hba);3321 ufshcd_hold(hba);
3309 mutex_lock(&hba->dev_cmd.lock);3322 mutex_lock(&hba->dev_cmd.lock);
@@ -3311,6 +3324,8 @@ static void ufshcd_dev_man_lock(struct ufs_hba *hba) · 1 unmodified line
3311}3324}
3312 3325
3313static void ufshcd_dev_man_unlock(struct ufs_hba *hba)3326static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
3327 __releases_shared(&hba->clk_scaling_lock)
3328 __releases(&hba->dev_cmd.lock)
3314{3329{
3315 up_read(&hba->clk_scaling_lock);3330 up_read(&hba->clk_scaling_lock);
3316 mutex_unlock(&hba->dev_cmd.lock);3331 mutex_unlock(&hba->dev_cmd.lock);
drivers/ufs/host/Makefile+2−0
@@ -1,5 +1,7 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2 2
3CONTEXT_ANALYSIS := y
4
3obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o5obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o
4obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o6obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o
5obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o7obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o
include/scsi/scsi_host.h+17−7
@@ -2,6 +2,7 @@ · 1 unmodified line
2#ifndef _SCSI_SCSI_HOST_H2#ifndef _SCSI_SCSI_HOST_H
3#define _SCSI_SCSI_HOST_H3#define _SCSI_SCSI_HOST_H
4 4
5#include <linux/cleanup.h>
5#include <linux/device.h>6#include <linux/device.h>
6#include <linux/list.h>7#include <linux/list.h>
7#include <linux/types.h>8#include <linux/types.h>
@@ -727,7 +728,7 @@ struct Scsi_Host { · 719 unmodified lines
727 unsigned int irq;728 unsigned int irq;
728 729
729 730
730 enum scsi_host_state shost_state;731 enum scsi_host_state shost_state __guarded_by(host_lock);
731 732
732 /* ldm bits */733 /* ldm bits */
733 struct device shost_gendev, shost_dev;734 struct device shost_gendev, shost_dev;
@@ -788,11 +789,18 @@ static inline struct Scsi_Host *dev_to_shost(struct device *dev) · 54 unmodified lines
788 return container_of(dev, struct Scsi_Host, shost_gendev);789 return container_of(dev, struct Scsi_Host, shost_gendev);
789}790}
790 791
792static 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
791static inline int scsi_host_in_recovery(struct Scsi_Host *shost)797static inline int scsi_host_in_recovery(struct Scsi_Host *shost)
792{798{
793 return shost->shost_state == SHOST_RECOVERY ||799 enum scsi_host_state state = scsi_get_host_state(shost);
794 shost->shost_state == SHOST_CANCEL_RECOVERY ||800
795 shost->shost_state == SHOST_DEL_RECOVERY ||801 return state == SHOST_RECOVERY ||
802 state == SHOST_CANCEL_RECOVERY ||
803 state == SHOST_DEL_RECOVERY ||
796 shost->tmf_in_progress;804 shost->tmf_in_progress;
797}805}
798 806
@@ -838,8 +846,9 @@ static inline struct device *scsi_get_device(struct Scsi_Host *shost) · 39 unmodified lines
838 **/846 **/
839static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)847static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)
840{848{
841 return shost->shost_state == SHOST_RUNNING ||849 enum scsi_host_state state = scsi_get_host_state(shost);
842 shost->shost_state == SHOST_RECOVERY;850
851 return state == SHOST_RUNNING || state == SHOST_RECOVERY;
843}852}
844 853
845extern void scsi_unblock_requests(struct Scsi_Host *);854extern 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
943 return shost->prot_guard_type;952 return shost->prot_guard_type;
944}953}
945 954
946extern int scsi_host_set_state(struct Scsi_Host *, enum scsi_host_state);955int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
956 __must_hold(shost->host_lock);
947 957
948#endif /* _SCSI_SCSI_HOST_H */958#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