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