]> asedeno.scripts.mit.edu Git - linux.git/log
linux.git
4 years agoscsi: bnx2fc: Handle scope bits when array returns BUSY or TSF
Laurence Oberman [Wed, 11 Sep 2019 13:56:42 +0000 (09:56 -0400)]
scsi: bnx2fc: Handle scope bits when array returns BUSY or TSF

The qla2xxx driver had this issue as well when the newer array firmware
returned the retry_delay_timer in the fcp_rsp.  The bnx2fc is not handling
the masking of the scope bits either so the retry_delay_timestamp value
lands up being a large value added to the timer timestamp delaying I/O for
up to 27 Minutes.  This patch adds similar code to handle this to the
bnx2fc driver to avoid the huge delay.

Link: https://lore.kernel.org/r/1568210202-12794-1-git-send-email-loberman@redhat.com
Signed-off-by: Laurence Oberman <loberman@redhat.com>
Reported-by: David Jeffery <djeffery@redhat.com>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Fix the conflict between device gone and host reset
Xiang Chen [Fri, 6 Sep 2019 12:55:37 +0000 (20:55 +0800)]
scsi: hisi_sas: Fix the conflict between device gone and host reset

When device gone, it will check whether it is during reset, if not, it will
send internal task abort. Before internal task abort returned, reset
begins, and it will check whether SAS_PHY_UNUSED is set, if not, it will
call hisi_sas_init_device(), but at that time domain_device may already be
freed or part of it is freed, so it may referenece null pointer in
hisi_sas_init_device(). It may occur as follows:

    thread0 thread1
hisi_sas_dev_gone()
    check whether in RESET(no)
    internal task abort
    reset prep
    soft_reset
    ... (part of reset_done)
    internal task abort failed
    release resource anyway
    clear_itct
    device->lldd_dev=NULL
    hisi_sas_reset_init_all_device
check sas_dev->dev_type is SAS_PHY_UNUSED and
!device
    set dev_type SAS_PHY_UNUSED
    sas_free_device
hisi_sas_init_device
...

Semaphore hisi_hba.sema is used to sync the processes of device gone and
host reset.

To solve the issue, expand the scope that semaphore protects and let them
never occur together.

And also some places will check whether domain_device is NULL to judge
whether the device is gone. So when device gone, need to clear
sas_dev->sas_device.

Link: https://lore.kernel.org/r/1567774537-20003-14-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Add BIST support for phy loopback
Xiang Chen [Fri, 6 Sep 2019 12:55:36 +0000 (20:55 +0800)]
scsi: hisi_sas: Add BIST support for phy loopback

Add BIST (built in self test) support for phy loopback.

Through the new debugfs interface, the user can configure loopback
mode/linkrate/phy id/code mode before enabling it. And also user can
enable/disable BIST function.

Link: https://lore.kernel.org/r/1567774537-20003-13-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Add hisi_sas_debugfs_alloc() to centralise allocation
Luo Jiaxing [Fri, 6 Sep 2019 12:55:35 +0000 (20:55 +0800)]
scsi: hisi_sas: Add hisi_sas_debugfs_alloc() to centralise allocation

We extract the code of memory allocate and construct an new function for
it. We think it's convenient for subsequent optimization.

Link: https://lore.kernel.org/r/1567774537-20003-12-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Remove some unused function arguments
Luo Jiaxing [Fri, 6 Sep 2019 12:55:34 +0000 (20:55 +0800)]
scsi: hisi_sas: Remove some unused function arguments

Some function arguments are unused, so remove them.

Also move the timeout print in for wait_cmds_complete_timeout_vX_hw()
callsites into that same function.

Link: https://lore.kernel.org/r/1567774537-20003-11-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Remove redundant work declaration
Xiang Chen [Fri, 6 Sep 2019 12:55:33 +0000 (20:55 +0800)]
scsi: hisi_sas: Remove redundant work declaration

Remove redundant work declaration in HISI_SAS_DECLARE_RST_WORK_ON_STACK

Link: https://lore.kernel.org/r/1567774537-20003-10-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Remove hisi_sas_hw.slot_complete
Luo Jiaxing [Fri, 6 Sep 2019 12:55:32 +0000 (20:55 +0800)]
scsi: hisi_sas: Remove hisi_sas_hw.slot_complete

We never call hisi_sas_hw.slot_complete, so remove it.

Link: https://lore.kernel.org/r/1567774537-20003-9-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Assign NCQ tag for all NCQ commands
Xiang Chen [Fri, 6 Sep 2019 12:55:31 +0000 (20:55 +0800)]
scsi: hisi_sas: Assign NCQ tag for all NCQ commands

Currently the NCQ tag is only assigned for FPDMA READ and FPDMA WRITE
commands, and for other NCQ commands (such as FPDMA SEND), their NCQ tags
are set in the delivery command to 0.

So for all the NCQ commands, we also need to assign normal NCQ tag for
them, so drop the command type check in hisi_sas_get_ncq_tag() [drop
hisi_sas_get_ncq_tag() altogether actually], and always use the ATA command
NCQ tag when appropriate.

Link: https://lore.kernel.org/r/1567774537-20003-8-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Update all the registers after suspend and resume
Xiang Chen [Fri, 6 Sep 2019 12:55:30 +0000 (20:55 +0800)]
scsi: hisi_sas: Update all the registers after suspend and resume

After suspend and resume, the HW registers will be set back to their
initial value. We use init_reg_v3_hw() to set some registers, but some
registers are set via firmware in ACPI "_RST" method, so add reset handler
before init_reg_v3_hw().

Link: https://lore.kernel.org/r/1567774537-20003-7-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Retry 3 times TMF IO for SAS disks when init device
Xiang Chen [Fri, 6 Sep 2019 12:55:29 +0000 (20:55 +0800)]
scsi: hisi_sas: Retry 3 times TMF IO for SAS disks when init device

When init device for SAS disks, it will send TMF IO to clear disks. At that
time TMF IO is broken by some operations such as injecting controller reset
from HW RAs event, the TMF IO will be timeout, and at last device will be
gone. Print is as followed:

hisi_sas_v3_hw 0000:74:02.0: dev[240:1] found
...
hisi_sas_v3_hw 0000:74:02.0: controller resetting...
hisi_sas_v3_hw 0000:74:02.0: phyup: phy7 link_rate=10(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy0 link_rate=9(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy1 link_rate=9(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy2 link_rate=9(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy3 link_rate=9(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy6 link_rate=10(sata)
hisi_sas_v3_hw 0000:74:02.0: phyup: phy5 link_rate=11
hisi_sas_v3_hw 0000:74:02.0: phyup: phy4 link_rate=11
hisi_sas_v3_hw 0000:74:02.0: controller reset complete
hisi_sas_v3_hw 0000:74:02.0: abort tmf: TMF task timeout and not done
hisi_sas_v3_hw 0000:74:02.0: dev[240:1] is gone
sas: driver on host 0000:74:02.0 cannot handle device 5000c500a75a860d,
error:5

To improve the reliability, retry TMF IO max of 3 times for SAS disks which
is the same as softreset does.

Link: https://lore.kernel.org/r/1567774537-20003-6-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Remove sleep after issue phy reset if sas_smp_phy_control() fails
Luo Jiaxing [Fri, 6 Sep 2019 12:55:28 +0000 (20:55 +0800)]
scsi: hisi_sas: Remove sleep after issue phy reset if sas_smp_phy_control() fails

At expander environment, we delay after issue phy reset to wait for
hardware to handle phy reset. But if sas_smp_phy_control() fails, the
delay is unnecessary so remove it.

Link: https://lore.kernel.org/r/1567774537-20003-5-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Directly return when running I_T_nexus reset if phy disabled
Luo Jiaxing [Fri, 6 Sep 2019 12:55:27 +0000 (20:55 +0800)]
scsi: hisi_sas: Directly return when running I_T_nexus reset if phy disabled

At hisi_sas_debug_I_T_nexus_reset(), we call sas_phy_reset() to reset a
phy. But if the phy is disabled, sas_phy_reset() will directly return
-ENODEV without issue a phy reset request.

If so, We can directly return -ENODEV to libsas before issue a phy
reset.

Link: https://lore.kernel.org/r/1567774537-20003-4-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: Use true/false as input parameter of sas_phy_reset()
Luo Jiaxing [Fri, 6 Sep 2019 12:55:26 +0000 (20:55 +0800)]
scsi: hisi_sas: Use true/false as input parameter of sas_phy_reset()

When calling sas_phy_reset(), we need to specify whether the reset type
is hard reset or link reset - use true/false for clarity.

Link: https://lore.kernel.org/r/1567774537-20003-3-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: add debugfs auto-trigger for internal abort time out
Luo Jiaxing [Fri, 6 Sep 2019 12:55:25 +0000 (20:55 +0800)]
scsi: hisi_sas: add debugfs auto-trigger for internal abort time out

This trigger is add at _hisi_sas_internal_task_abort()

Link: https://lore.kernel.org/r/1567774537-20003-2-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: virtio_scsi: unplug LUNs when events missed
Matt Lupfer [Thu, 5 Sep 2019 18:19:28 +0000 (18:19 +0000)]
scsi: virtio_scsi: unplug LUNs when events missed

The event handler calls scsi_scan_host() when events are missed, which will
hotplug new LUNs.  However, this function won't remove any unplugged LUNs.
The result is that hotunplug doesn't work properly when the number of
unplugged LUNs exceeds the event queue size (currently 8).

Scan existing LUNs when events are missed to check if they are still
present.  If not, remove them.

Link: https://lore.kernel.org/r/20190905181903.29756-1-mlupfer@ddn.com
Signed-off-by: Matt Lupfer <mlupfer@ddn.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: scsi_dh_rdac: zero cdb in send_mode_select()
Martin Wilck [Wed, 4 Sep 2019 15:52:29 +0000 (15:52 +0000)]
scsi: scsi_dh_rdac: zero cdb in send_mode_select()

cdb in send_mode_select() is not zeroed and is only partially filled in
rdac_failover_get(), which leads to some random data getting to the
device. Users have reported storage responding to such commands with
INVALID FIELD IN CDB. Code before commit 327825574132 was not affected, as
it called blk_rq_set_block_pc().

Fix this by zeroing out the cdb first.

Identified & fix proposed by HPE.

Fixes: 327825574132 ("scsi_dh_rdac: switch to scsi_execute_req_flags()")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20190904155205.1666-1-martin.wilck@suse.com
Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Ales Novak <alnovak@suse.cz>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fcoe: fix null-ptr-deref Read in fc_release_transport
zhengbin [Tue, 20 Aug 2019 05:43:09 +0000 (13:43 +0800)]
scsi: fcoe: fix null-ptr-deref Read in fc_release_transport

In fcoe_if_init, if fc_attach_transport(&fcoe_vport_fc_functions)
fails, need to free the previously memory and return fail, otherwise
will trigger null-ptr-deref Read in fc_release_transport.

fcoe_exit
  fcoe_if_exit
    fc_release_transport(fcoe_vport_scsi_transport)

Link: https://lore.kernel.org/r/1566279789-58207-1-git-send-email-zhengbin13@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-hisi: use devm_platform_ioremap_resource() to simplify code
YueHaibing [Wed, 4 Sep 2019 13:04:57 +0000 (21:04 +0800)]
scsi: ufs-hisi: use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Link: https://lore.kernel.org/r/20190904130457.24744-1-yuehaibing@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufshcd: use devm_platform_ioremap_resource() to simplify code
YueHaibing [Wed, 4 Sep 2019 13:03:48 +0000 (21:03 +0800)]
scsi: ufshcd: use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Link: https://lore.kernel.org/r/20190904130348.24772-1-yuehaibing@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: use devm_platform_ioremap_resource() to simplify code
YueHaibing [Wed, 4 Sep 2019 13:02:56 +0000 (21:02 +0800)]
scsi: hisi_sas: use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Link: https://lore.kernel.org/r/20190904130256.24704-1-yuehaibing@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Use kmemdup in ufshcd_read_string_desc()
YueHaibing [Sat, 31 Aug 2019 12:44:24 +0000 (12:44 +0000)]
scsi: ufs: Use kmemdup in ufshcd_read_string_desc()

Use kmemdup rather than duplicating its implementation

Link: https://lore.kernel.org/r/20190831124424.18642-1-yuehaibing@huawei.com
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: arm64: dts: qcom: sdm845: Specify UFS device-reset GPIO
Bjorn Andersson [Wed, 28 Aug 2019 19:17:56 +0000 (12:17 -0700)]
scsi: arm64: dts: qcom: sdm845: Specify UFS device-reset GPIO

Specify the UFS device-reset gpio for db845c and mtp, so that the
controller will issue a reset of the UFS device.

Link: https://lore.kernel.org/r/20190828191756.24312-4-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: Implement device_reset vops
Bjorn Andersson [Wed, 28 Aug 2019 19:17:55 +0000 (12:17 -0700)]
scsi: ufs-qcom: Implement device_reset vops

The UFS_RESET pin on Qualcomm SoCs are controlled by TLMM and exposed
through the GPIO framework. Acquire the device-reset GPIO and use this to
implement the device_reset vops, to allow resetting the attached memory.

Based on downstream support implemented by Subhash Jadavani
<subhashj@codeaurora.org>.

Link: https://lore.kernel.org/r/20190828191756.24312-3-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Introduce vops for resetting device
Bjorn Andersson [Wed, 28 Aug 2019 19:17:54 +0000 (12:17 -0700)]
scsi: ufs: Introduce vops for resetting device

Some UFS memory devices needs their reset line toggled in order to get them
into a good state for initialization. Provide a new vops to allow the
platform driver to implement this operation.

Link: https://lore.kernel.org/r/20190828191756.24312-2-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix reset recovery paths that are not recovering
James Smart [Tue, 3 Sep 2019 21:54:41 +0000 (14:54 -0700)]
scsi: lpfc: Fix reset recovery paths that are not recovering

A recent patch unconditionally marks the hba as in error as part of
resetting the adapter. The driver flow that called the adapter reset was a
recovery path, which expects the adapter to not be in an error state in
order to finish the recovery.  Given the new error state being set, the
recovery fails and the adapter is left in limbo.

Revise the adapter reset routine so that it will only mark the adapter in
error if it was unable to reset the adapter.

Fixes: 8c24a4f643ed ("scsi: lpfc: Fix crash due to port reset racing vs adapter error handling")
Link: https://lore.kernel.org/r/20190903215441.10490-1-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Convert existing %pf users to %ps
Sakari Ailus [Wed, 4 Sep 2019 16:04:23 +0000 (19:04 +0300)]
scsi: lpfc: Convert existing %pf users to %ps

Convert the remaining %pf users to %ps to prepare for the removal of the
old %pf conversion specifier support.

Fixes: 323506644972 ("scsi: lpfc: Migrate to %px and %pf in kernel print calls")
Link: https://lore.kernel.org/r/20190904160423.3865-1-sakari.ailus@linux.intel.com
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Update driver version to 10.01.00.19-k
Himanshu Madhani [Fri, 30 Aug 2019 22:24:02 +0000 (15:24 -0700)]
scsi: qla2xxx: Update driver version to 10.01.00.19-k

Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20190830222402.23688-7-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix stale session
Quinn Tran [Fri, 30 Aug 2019 22:24:01 +0000 (15:24 -0700)]
scsi: qla2xxx: Fix stale session

On fast cable pull, where driver is unable to detect device has disappeared
and came back based on switch info, qla2xxx would not re-login while remote
port has already invalidated the session.  This causes IO timeout.  This
patch would relogin to remote device for RSCN affected port.

Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20190830222402.23688-6-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix stuck login session
Quinn Tran [Fri, 30 Aug 2019 22:24:00 +0000 (15:24 -0700)]
scsi: qla2xxx: Fix stuck login session

Login session was stucked on cable pull. When FW is in the middle PRLI
PENDING + driver is in Initiator mode, driver fails to check back with FW to
see if the PRLI has completed. This patch would re-check with FW again to
make sure PRLI would complete before pushing forward with relogin.

Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20190830222402.23688-5-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix driver reload for ISP82xx
Himanshu Madhani [Fri, 30 Aug 2019 22:23:59 +0000 (15:23 -0700)]
scsi: qla2xxx: Fix driver reload for ISP82xx

HINT_MBX_INT_PENDING is not guaranteed to be cleared by firmware. Remove
check that prevent driver load with ISP82XX.

Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20190830222402.23688-4-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix flash read for Qlogic ISPs
Quinn Tran [Fri, 30 Aug 2019 22:23:58 +0000 (15:23 -0700)]
scsi: qla2xxx: Fix flash read for Qlogic ISPs

Use adapter specific callback to read flash instead of ISP adapter
specific.

Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Link: https://lore.kernel.org/r/20190830222402.23688-3-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix message indicating vectors used by driver
Himanshu Madhani [Fri, 30 Aug 2019 22:23:57 +0000 (15:23 -0700)]
scsi: qla2xxx: Fix message indicating vectors used by driver

This patch updates log message which indicates number of vectors used by
the driver instead of displaying failure to get maximum requested
vectors. Driver will always request maximum vectors during
initialization. In the event driver is not able to get maximum requested
vectors, it will adjust the allocated vectors. This is normal and does not
imply failure in driver.

Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Link: https://lore.kernel.org/r/20190830222402.23688-2-hmadhani@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: sd: Improve unaligned completion resid message
Damien Le Moal [Wed, 28 Aug 2019 05:35:11 +0000 (14:35 +0900)]
scsi: sd: Improve unaligned completion resid message

For commands completing with a resid not aligned on the device logical
sector size, also print the command CDB in addition to the current message
to help debug hardware generating such incorrect command completion
information.

Link: https://lore.kernel.org/r/20190828053511.14818-1-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fnic: fix msix interrupt allocation
Govindarajulu Varadarajan [Tue, 27 Aug 2019 21:13:40 +0000 (14:13 -0700)]
scsi: fnic: fix msix interrupt allocation

pci_alloc_irq_vectors() returns number of vectors allocated.  Fix the check
for error condition.

Fixes: cca678dfbad49 ("scsi: fnic: switch to pci_alloc_irq_vectors")
Link: https://lore.kernel.org/r/20190827211340.1095-1-gvaradar@cisco.com
Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Acked-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fnic: print port speed only at driver init or speed change
John Pittman [Fri, 23 Aug 2019 14:08:52 +0000 (10:08 -0400)]
scsi: fnic: print port speed only at driver init or speed change

Port speed printing was added by commit d948e6383ec3 ("scsi: fnic: Add port
speed stat to fnic debug stats"). As currently configured, this will cause
the port speed to be printed to syslog every 2 seconds. To prevent log
spamming, only print the vnic port speed at driver initialization and if
the speed changes. Also clean up a small typo in fnic_trace.c.

Fixes: d948e6383ec3 ("scsi: fnic: Add port speed stat to fnic debug stats")
Signed-off-by: John Pittman <jpittman@redhat.com>
Reviewed-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bnx2fc: remove set but not used variables 'task','port','orig_task'
zhengbin [Fri, 23 Aug 2019 13:22:53 +0000 (21:22 +0800)]
scsi: bnx2fc: remove set but not used variables 'task','port','orig_task'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/bnx2fc/bnx2fc_hwi.c: In function bnx2fc_process_unsol_compl:
drivers/scsi/bnx2fc/bnx2fc_hwi.c:636:30: warning: variable task set but not used [-Wunused-but-set-variable]
drivers/scsi/bnx2fc/bnx2fc_hwi.c: In function bnx2fc_process_ofld_cmpl:
drivers/scsi/bnx2fc/bnx2fc_hwi.c:1125:21: warning: variable port set but not used [-Wunused-but-set-variable]
drivers/scsi/bnx2fc/bnx2fc_hwi.c: In function bnx2fc_init_seq_cleanup_task:
drivers/scsi/bnx2fc/bnx2fc_hwi.c:1468:30: warning: variable orig_task set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bnx2fc: remove set but not used variables 'lport','host'
zhengbin [Fri, 23 Aug 2019 13:22:52 +0000 (21:22 +0800)]
scsi: bnx2fc: remove set but not used variables 'lport','host'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/bnx2fc/bnx2fc_io.c: In function bnx2fc_initiate_seq_cleanup:
drivers/scsi/bnx2fc/bnx2fc_io.c:932:19: warning: variable lport set but not used [-Wunused-but-set-variable]
drivers/scsi/bnx2fc/bnx2fc_io.c: In function bnx2fc_initiate_cleanup:
drivers/scsi/bnx2fc/bnx2fc_io.c:1001:19: warning: variable lport set but not used [-Wunused-but-set-variable]
drivers/scsi/bnx2fc/bnx2fc_io.c: In function bnx2fc_process_scsi_cmd_compl:
drivers/scsi/bnx2fc/bnx2fc_io.c:1882:20: warning: variable host set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bnx2fc: remove set but not used variable 'fh'
zhengbin [Fri, 23 Aug 2019 13:22:51 +0000 (21:22 +0800)]
scsi: bnx2fc: remove set but not used variable 'fh'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/bnx2fc/bnx2fc_fcoe.c: In function bnx2fc_rcv:
drivers/scsi/bnx2fc/bnx2fc_fcoe.c:431:26: warning: variable fh set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Update the version to 8.42.3.0
Saurav Kashyap [Fri, 23 Aug 2019 09:52:44 +0000 (02:52 -0700)]
scsi: qedf: Update the version to 8.42.3.0

Update the driver version to 8.42.3.0.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Fix race betwen fipvlan request and response path
Saurav Kashyap [Fri, 23 Aug 2019 09:52:43 +0000 (02:52 -0700)]
scsi: qedf: Fix race betwen fipvlan request and response path

There is a race b/w fipvlan request and response path:

=====
qedf_fcoe_process_vlan_resp:113]:2: VLAN response, vid=0xffd.
qedf_initiate_fipvlan_req:165]:2: vlan = 0x6ffd already set.
qedf_set_vlan_id:139]:2: Setting vlan_id=0ffd prio=3.
======

The request thread sees that vlan is already set and fails to call
ctrl_link_up.

Fix:

 - While setting vlan_id use local variable and before setting vlan_id.

 - Call fcoe_ctlr_link_up in next iteration of fipvlan request.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Use discovery list to traverse rports
Hannes Reinecke [Fri, 23 Aug 2019 09:52:42 +0000 (02:52 -0700)]
scsi: qedf: Use discovery list to traverse rports

The list of rports might become stale so we should rather traverse the
discovery list when trying relogin.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Decrease the LL2 MTU size to 2500
Saurav Kashyap [Fri, 23 Aug 2019 09:52:41 +0000 (02:52 -0700)]
scsi: qedf: Decrease the LL2 MTU size to 2500

Decrease the LL2 MTU size to 2500.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Check for module unloading bit before processing link update AEN
Saurav Kashyap [Fri, 23 Aug 2019 09:52:40 +0000 (02:52 -0700)]
scsi: qedf: Check for module unloading bit before processing link update AEN

Prevent race where we're removing the module and we get link update

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Initiator fails to re-login to switch after link down
Saurav Kashyap [Fri, 23 Aug 2019 09:52:39 +0000 (02:52 -0700)]
scsi: qedf: Initiator fails to re-login to switch after link down

Problem Statement:

 - Driver has fc_id of 0xcc0200

 - Driver gets link down (due to test) and calls fcoe_ctlr_link_down().

 - At this point, the fc_id of the initiator port is zeroed out.

 - Driver gets a link up 14 seconds later.

 - Driver performs FIP VLAN request, gets a response from the switch.

 - No change in VLAN is detected.

 - Driver then notifies libfcoe via fcoe_ctlr_link_up().

 - Libfcoe then issues a multicast discovery solicitation as expected.

 - Cisco FCF responds to that correctly.

 - Libfcoe at this point starts a 3 sec count-down to allow any other FCFs
   to be discovered. However, at this point, it has been 20 seconds since
   the last FKA from the driver (which would have been sent prior to
   backlink toggle), which causes the CVL to be issued from Cisco CVL from
   the switch is dropped by the driver as the vx_port identification
   descriptor is present and has value of 0xcc0200, which does not match
   the driver's value of 0.  Libfcoe completes the 3 sec count down and
   proceeds to issue FLOGI as per protocol.  Switch rejects FLogi request.
   All subsequent FLOGI requests from libfc are rejected by the switch
   (possibly because it is now expecting a new solicitation).  This
   situation will continue until the next link toggle.

Solution:

The Vx_port descriptor in the CVL has three fields:

MAC address
Fabric ID
Port Name

Today, the code checks for both #1 and #2 above. In the case where we went
through a link down, both these will be zero until FLOGI succeeds.

We should change our code to check if any one of these 3 is valid and if
so, handle the CVL (basically switching from AND to OR). The port name
field is definitely expected to be valid always.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Add debug information for unsolicited processing
Saurav Kashyap [Fri, 23 Aug 2019 09:52:38 +0000 (02:52 -0700)]
scsi: qedf: Add debug information for unsolicited processing

Log s_id, d_id, type and command to the log message.

[mkp: fixed warning]

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Add support for 20 Gbps speed
Saurav Kashyap [Fri, 23 Aug 2019 09:52:37 +0000 (02:52 -0700)]
scsi: qedf: Add support for 20 Gbps speed

The current code doeesn't support 20Gbps speed for current and supported
speed. Add support for it.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Interpret supported caps value correctly
Saurav Kashyap [Fri, 23 Aug 2019 09:52:36 +0000 (02:52 -0700)]
scsi: qedf: Interpret supported caps value correctly

Driver was wrongly interpreting the supported cap value returned by qed.

Solution: Use QED define macros instead of OS defined for interpreting
supporting speeds.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Add shutdown callback handler
Saurav Kashyap [Fri, 23 Aug 2019 09:52:35 +0000 (02:52 -0700)]
scsi: qedf: Add shutdown callback handler

Add shutdown callback handler.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Update module description string
Nilesh Javali [Fri, 23 Aug 2019 09:52:34 +0000 (02:52 -0700)]
scsi: qedf: Update module description string

Update module description.

Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Fix crash during sg_reset
Arun Easi [Fri, 23 Aug 2019 09:52:33 +0000 (02:52 -0700)]
scsi: qedf: Fix crash during sg_reset

Driver was attempting to print cdb[0], which is not set for resets coming
from SCSI ioctls. Check for cmd_len before accessing cmnd.

Crash info:
[84790.864747] BUG: unable to handle kernel NULL pointer dereference at (null)
[84790.864783] IP: qedf_initiate_tmf+0x7a/0x6e0 [qedf]
[84790.865204] Call Trace:
[84790.865246]  scsi_try_target_reset+0x2b/0x90 [scsi_mod]
[84790.865266]  scsi_ioctl_reset+0x20f/0x2a0 [scsi_mod]
[84790.865284]  scsi_ioctl+0x131/0x3a0 [scsi_mod]

Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Stop sending fipvlan request on unload
Saurav Kashyap [Fri, 23 Aug 2019 09:52:32 +0000 (02:52 -0700)]
scsi: qedf: Stop sending fipvlan request on unload

 - On some setups fipvlan can be retried for long duration and the
   connection to switch was not there so it was not getting any reply.

 - During unload this thread was hanging.

Problem Resolution:

Check if unload is in progress, then quit from fipvlan thread.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qedf: Print message during bailout conditions
Saurav Kashyap [Fri, 23 Aug 2019 09:52:31 +0000 (02:52 -0700)]
scsi: qedf: Print message during bailout conditions

Print messages during exiting condition to help debugging.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: bump version
Don Brace [Thu, 22 Aug 2019 20:40:05 +0000 (15:40 -0500)]
scsi: smartpqi: bump version

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Gerry Morong <gerry.morong@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: update copyright
Don Brace [Thu, 22 Aug 2019 20:39:58 +0000 (15:39 -0500)]
scsi: smartpqi: update copyright

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add new pci ids
Gilbert Wu [Thu, 22 Aug 2019 20:39:51 +0000 (15:39 -0500)]
scsi: smartpqi: add new pci ids

Add:

      PM8222               VID_9005, DID_028F, SVID_1BD4 and SDID_004F
      3101E-4i (1G, no GB) VID_9005, DID_028F, SVID_9005 and SDID_0808
      3102E-8i (2G, no GB) VID_9005, DID_028F, SVID_9005 and SDID_0809

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Gilbert Wu <gilbert.wu@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: correct REGNEWD return status
Murthy Bhat [Thu, 22 Aug 2019 20:39:44 +0000 (15:39 -0500)]
scsi: smartpqi: correct REGNEWD return status

Return -EINPROGRESS when a rescan worker is queued.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Murthy Bhat <Murthy.Bhat@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add gigabyte controller
Gilbert Wu [Thu, 22 Aug 2019 20:39:38 +0000 (15:39 -0500)]
scsi: smartpqi: add gigabyte controller

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Gilbert Wu <gilbert.wu@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: correct hang when deleting 32 lds
Mahesh Rajashekhara [Thu, 22 Aug 2019 20:39:31 +0000 (15:39 -0500)]
scsi: smartpqi: correct hang when deleting 32 lds

When each ld is deleted, a rescan event is triggered in the driver. These
can stack up waiting on mutex_lock.

Change to mutex_try_lock and schedule a rescan for later.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add bay identifier
Gilbert Wu [Thu, 22 Aug 2019 20:39:25 +0000 (15:39 -0500)]
scsi: smartpqi: add bay identifier

Return identify physical device "Phys_Bay_in_Box" as bay_identifier.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Gilbert Wu <gilbert.wu@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add sysfs entries
Murthy Bhat [Thu, 22 Aug 2019 20:39:18 +0000 (15:39 -0500)]
scsi: smartpqi: add sysfs entries

 - serial number
 - model
 - vendor

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Murthy Bhat <Murthy.Bhat@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add module param to hide vsep
Dave Carroll [Thu, 22 Aug 2019 20:39:11 +0000 (15:39 -0500)]
scsi: smartpqi: add module param to hide vsep

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add pci ids for fiberhome controller
Gilbert Wu [Thu, 22 Aug 2019 20:39:04 +0000 (15:39 -0500)]
scsi: smartpqi: add pci ids for fiberhome controller

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Gilbert Wu <gilbert.wu@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: smartpqi: add module param for exposure order
Gilbert Wu [Thu, 22 Aug 2019 20:38:58 +0000 (15:38 -0500)]
scsi: smartpqi: add module param for exposure order

Expose physical devices before logical devices.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Gilbert Wu <gilbert.wu@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: fix 12.4.0.0 GPF at boot
James Smart [Wed, 28 Aug 2019 23:19:11 +0000 (16:19 -0700)]
scsi: lpfc: fix 12.4.0.0 GPF at boot

The 12.4.0.0 patch that merged WQ/CQ pairs into single per-cpu pair
contained a bug: a local variable was set to the queue pair by index.  This
should have allowed the local variable to be natively used.  Instead, the
code reused the index relative to the local variable, obtaining a random
pointer value that when used eventually faulted the system

Convert offending code to use local variable.

Fixes: c00f62e6c546 ("scsi: lpfc: Merge per-protocol WQ/CQ pairs into single per-cpu pair")
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Tested-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Remove bg debugfs buffers
James Smart [Tue, 27 Aug 2019 21:28:05 +0000 (14:28 -0700)]
scsi: lpfc: Remove bg debugfs buffers

Capturing and downloading dif command data and dif data was done a dozen
years ago and no longer being used. Also creates a potential security hole.

Remove the debugfs buffer for dif debugging.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
CC: KyleMahlkuch <kmahlkuc@linux.vnet.ibm.com>
CC: Hannes Reinecke <hare@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Resolve checker warning for lpfc_new_io_buf()
James Smart [Tue, 27 Aug 2019 21:27:46 +0000 (14:27 -0700)]
scsi: lpfc: Resolve checker warning for lpfc_new_io_buf()

Per Dan Carpenter:

The patch d79c9e9d4b3d: "scsi: lpfc: Support dynamic unbounded SGL lists on
G7 hardware." from Aug 14, 2019, leads to the following static checker
warning:

   drivers/scsi/lpfc/lpfc_init.c:4107 lpfc_new_io_buf()
  error: not allocating enough data 784 vs 768

There was no need to compare sizes nor to allocate size based on a define.

Change allocation to use actual structure length

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: remove set but not used variable 'val'
zhengbin [Mon, 26 Aug 2019 01:15:49 +0000 (09:15 +0800)]
scsi: ufs: remove set but not used variable 'val'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/ufs/ufs-qcom.c: In function ufs_qcom_pwr_change_notify:
drivers/scsi/ufs/ufs-qcom.c:808:6: warning: variable val set but not used [-Wunused-but-set-variable]

Fixes: 1e1e465c6d23 ("scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls from host")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: fix spelling mistake "initializatin" -> "initialization"
Colin Ian King [Thu, 22 Aug 2019 21:56:51 +0000 (22:56 +0100)]
scsi: qla2xxx: fix spelling mistake "initializatin" -> "initialization"

There is a spelling mistake in a ql_log message. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: hisi_sas: remove set but not used variable 'irq_value'
zhengbin [Thu, 22 Aug 2019 14:20:47 +0000 (22:20 +0800)]
scsi: hisi_sas: remove set but not used variable 'irq_value'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/scsi/hisi_sas/hisi_sas_v1_hw.c: In function cq_interrupt_v1_hw:
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1542:6: warning: variable irq_value set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: mpt3sas: Introduce module parameter to override queue depth
Sreekanth Reddy [Thu, 22 Aug 2019 06:19:01 +0000 (02:19 -0400)]
scsi: mpt3sas: Introduce module parameter to override queue depth

This patch provides a module parameter and sysfs interface to select
whether the queue depth for each device should be based on the
protocol-specific value set by the driver (the default) or the maximum
supported by the controller (can_queue).

Although we have a sysfs interface per sdev to change the queue depth
of individual scsi devices, this implementation provides a single
sysfs entry per shost to switch between the controller max and the
driver default.

[mkp: tweaked commit desc]

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix a recently introduced kernel warning
Bart Van Assche [Tue, 20 Aug 2019 02:18:36 +0000 (19:18 -0700)]
scsi: qla2xxx: Fix a recently introduced kernel warning

According to the firmware documentation a status type 0 IOCB can be
followed by one or more status continuation type 0 IOCBs. Hence do not
complain if the completion function is not called from inside the status
type 0 IOCB handler.

WARNING: CPU: 10 PID: 425 at drivers/scsi/qla2xxx/qla_isr.c:2784
qla2x00_status_entry.isra.7+0x484/0x17b0 [qla2xxx]
CPU: 10 PID: 425 Comm: kworker/10:1 Tainted: G            E     5.3.0-rc4-next-20190813-autotest-autotest #1
Workqueue: qla2xxx_wq qla25xx_free_rsp_que [qla2xxx]
Call Trace:
 qla2x00_status_entry.isra.7+0x1484/0x17b0 [qla2xxx] (unreliable)
 qla24xx_process_response_queue+0x7d8/0xbd0 [qla2xxx]
 qla25xx_free_rsp_que+0x1a0/0x220 [qla2xxx]
 process_one_work+0x25c/0x520
 worker_thread+0x8c/0x5e0
 kthread+0x154/0x1a0
 ret_from_kernel_thread+0x5c/0x7c

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Reported-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: fix broken hba->outstanding_tasks
Stanley Chu [Mon, 19 Aug 2019 13:43:28 +0000 (21:43 +0800)]
scsi: ufs: fix broken hba->outstanding_tasks

Currently bits in hba->outstanding_tasks are cleared only after their
corresponding task management commands are successfully done by
__ufshcd_issue_tm_cmd().

If timeout happens in a task management command, its corresponding bit in
hba->outstanding_tasks will not be cleared until next task management
command with the same tag used successfully finishes.

This is wrong and can lead to some issues, like power issue.  For example,
ufshcd_release() and ufshcd_gate_work() will do nothing if
hba->outstanding_tasks is not zero even if both UFS host and devices are
actually idle.

Solution is referred from error handling of device commands: bits in
hba->outstanding_tasks shall be cleared regardless of their execution
results.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fcoe: remove redundant call to skb_transport_header
Colin Ian King [Thu, 15 Aug 2019 09:14:54 +0000 (10:14 +0100)]
scsi: fcoe: remove redundant call to skb_transport_header

Pointer fh is being assigned a return value from the call to
skb_transport_header however this value is never read and fh is being
re-assigned immediately afterwards with a new value.  Since there are
side-effects from calling skb_transport_header the call is redundant and
can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Disable local LCC in .link_startup_notify() in Cadence UFS
Anil Varughese [Tue, 13 Aug 2019 07:42:50 +0000 (08:42 +0100)]
scsi: ufs: Disable local LCC in .link_startup_notify() in Cadence UFS

Some UFS devices have issues if LCC is enabled. So we are setting
PA_LOCAL_TX_LCC_Enable to 0 before link startup which will make sure that
both host and device TX LCC are disabled once link startup is completed.

Signed-off-by: Anil Varughese <aniljoy@cadence.com>
Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: bfa: remove redundant assignment to variable error
Colin Ian King [Wed, 31 Jul 2019 22:11:52 +0000 (23:11 +0100)]
scsi: bfa: remove redundant assignment to variable error

Variable error is being initialized with a value that is never read and
error is being re-assigned a little later on. The assignment is redundant
and hence can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Update lpfc version to 12.4.0.0
James Smart [Wed, 14 Aug 2019 23:57:12 +0000 (16:57 -0700)]
scsi: lpfc: Update lpfc version to 12.4.0.0

Update lpfc version to 12.4.0.0

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Merge per-protocol WQ/CQ pairs into single per-cpu pair
James Smart [Wed, 14 Aug 2019 23:57:11 +0000 (16:57 -0700)]
scsi: lpfc: Merge per-protocol WQ/CQ pairs into single per-cpu pair

Currently, each hardware queue, typically allocated per-cpu, consists of a
WQ/CQ pair per protocol. Meaning if both SCSI and NVMe are supported 2
WQ/CQ pairs will exist for the hardware queue. Separate queues are
unnecessary. The current implementation wastes memory backing the 2nd set
of queues, and the use of double the SLI-4 WQ/CQ's means less hardware
queues can be supported which means there may not always be enough to have
a pair per cpu. If there is only 1 pair per cpu, more cpu's may get their
own WQ/CQ.

Rework the implementation to use a single WQ/CQ pair by both protocols.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Add NVMe sequence level error recovery support
James Smart [Wed, 14 Aug 2019 23:57:10 +0000 (16:57 -0700)]
scsi: lpfc: Add NVMe sequence level error recovery support

FC-NVMe-2 added support for sequence level error recovery in the FC-NVME
protocol. This allows for the detection of errors and lost frames and
immediate retransmission of data to avoid exchange termination, which
escalates into NVMeoFC connection and association failures. A significant
RAS improvement.

The driver is modified to indicate support for SLER in the NVMe PRLI is
issues and to check for support in the PRLI response.  When both sides
support it, the driver will set a bit in the WQE to enable the recovery
behavior on the exchange. The adapter will take care of all detection and
retransmission.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.
James Smart [Wed, 14 Aug 2019 23:57:09 +0000 (16:57 -0700)]
scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.

Typical SLI-4 hardware supports up to 2 4KB pages to be registered per XRI
to contain the exchanges Scatter/Gather List. This caps the number of SGL
elements that can be in the SGL. There are not extensions to extend the
list out of the 2 pages.

The G7 hardware adds a SGE type that allows the SGL to be vectored to a
different scatter/gather list segment. And that segment can contain a SGE
to go to another segment and so on.  The initial segment must still be
pre-registered for the XRI, but it can be a much smaller amount (256Bytes)
as it can now be dynamically grown.  This much smaller allocation can
handle the SG list for most normal I/O, and the dynamic aspect allows it to
support many MB's if needed.

The implementation creates a pool which contains "segments" and which is
initially sized to hold the initial small segment per xri. If an I/O
requires additional segments, they are allocated from the pool.  If the
pool has no more segments, the pool is grown based on what is now
needed. After the I/O completes, the additional segments are returned to
the pool for use by other I/Os. Once allocated, the additional segments are
not released under the assumption of "if needed once, it will be needed
again". Pools are kept on a per-hardware queue basis, which is typically
1:1 per cpu, but may be shared by multiple cpus.

The switch to the smaller initial allocation significantly reduces the
memory footprint of the driver (which only grows if large ios are
issued). Based on the several K of XRIs for the adapter, the 8KB->256B
reduction can conserve 32MBs or more.

It has been observed with per-cpu resource pools that allocating a resource
on CPU A, may be put back on CPU B. While the get routines are distributed
evenly, only a limited subset of CPUs may be handling the put routines.
This can put a strain on the lpfc_put_cmd_rsp_buf_per_cpu routine because
all the resources are being put on a limited subset of CPUs.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Add MDS driver loopback diagnostics support
James Smart [Wed, 14 Aug 2019 23:57:08 +0000 (16:57 -0700)]
scsi: lpfc: Add MDS driver loopback diagnostics support

Added code to support driver loopback with MDS Diagnostics.  This style of
diagnostics passes frames from the fabric to the driver who then echo them
back out the link.  SEND_FRAME WQEs are used to transmit the frames.  Added
the SOF and EOF field location definitions for use by SEND_FRAME.

Also ensure that enable_mds_diags is a RW parameter.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Add first and second level hardware revisions to sysfs reporting
James Smart [Wed, 14 Aug 2019 23:57:07 +0000 (16:57 -0700)]
scsi: lpfc: Add first and second level hardware revisions to sysfs reporting

To aid better hardware detection when there are issues, report the first
and second level hardware revisions from the READ_REV command.  Add the
elements to the existing hardware id string.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Migrate to %px and %pf in kernel print calls
James Smart [Wed, 14 Aug 2019 23:57:06 +0000 (16:57 -0700)]
scsi: lpfc: Migrate to %px and %pf in kernel print calls

In order to see real addresses, convert %p with %px for kernel addresses
and replace %p with %pf for functions.

While converting, standardize on "x%px" throughout (not %px or 0x%px).

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Add simple unlikely optimizations to reduce NVME latency
James Smart [Wed, 14 Aug 2019 23:57:05 +0000 (16:57 -0700)]
scsi: lpfc: Add simple unlikely optimizations to reduce NVME latency

While performing code review, several relatively simple optimizations can
be done in the fast path.

Add these optimizations (unlikely designators).

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix coverity warnings
James Smart [Wed, 14 Aug 2019 23:57:04 +0000 (16:57 -0700)]
scsi: lpfc: Fix coverity warnings

Running on Coverity produced the following errors:

 - coding style (indentation)

 - memset size mismatch errors
   note: comment cases where it is purposely a mismatch

Fix the errors.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix nvme first burst module parameter description
James Smart [Wed, 14 Aug 2019 23:57:03 +0000 (16:57 -0700)]
scsi: lpfc: Fix nvme first burst module parameter description

modinfo for lpfc_nvme_enable_fb is incorrect. FirstBurst on lpfc target is
not fully supported.

Update the attribute description

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix BlockGuard enablement on FCoE adapters
James Smart [Wed, 14 Aug 2019 23:57:02 +0000 (16:57 -0700)]
scsi: lpfc: Fix BlockGuard enablement on FCoE adapters

The driver is allowing the user to change lpfc_enable_bg while loading the
driver against a FCoE adapter. This is not supported.

No check is made for the adapter type when applying the blockguard
enablement value.

Fix by verifying the adapter type before setting the enablement flag.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix reported physical link speed on a disabled trunked link
James Smart [Wed, 14 Aug 2019 23:57:01 +0000 (16:57 -0700)]
scsi: lpfc: Fix reported physical link speed on a disabled trunked link

GetTrunkInfo is displaying an incorrect link speed when the link is a trunk
and the link has gone down.  The driver is not clearing the logical speed
as part of the link down transition.

Fix by setting the logical speed to UNKNOWN SPEED when the link goes down.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix Max Frame Size value shown in fdmishow output
James Smart [Wed, 14 Aug 2019 23:57:00 +0000 (16:57 -0700)]
scsi: lpfc: Fix Max Frame Size value shown in fdmishow output

Max Frame Size value is shown as 34816 in fdmishow from Switch.

The driver uses bbRcvSize in common service param which is obtained from
the READ_SPARM mailbox command. The bbRcvSize field which is displayed is a
three nibble field but the driver is printing a full four nibbles.

Fix by masking off the upper nibble.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix upcall to bsg done in non-success cases
James Smart [Wed, 14 Aug 2019 23:56:59 +0000 (16:56 -0700)]
scsi: lpfc: Fix upcall to bsg done in non-success cases

The scsi transport fc bsg interface does not expect the bsg_job_done()
callback to be done if the bsg request call returns failure. Several of the
HST_VENDOR cases in the driver unconditionally call bsg_job_done()
regardless of the returning value.

Fix the code to only call bsg_job_done() if the call to lpfc_bsg_request()
will return success.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix sli4 adapter initialization with MSI
James Smart [Wed, 14 Aug 2019 23:56:58 +0000 (16:56 -0700)]
scsi: lpfc: Fix sli4 adapter initialization with MSI

When forcing the use of MSI (vs MSI-X) the driver is crashing in
pci_irq_get_affinity.

The driver was not using the new pci_alloc_irq_vectors interface in the MSI
path.

Fix by using pci_alloc_irq_vectors() with PCI_RQ_MSI in the MSI path.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix nvme sg_seg_cnt display if HBA does not support NVME
James Smart [Wed, 14 Aug 2019 23:56:57 +0000 (16:56 -0700)]
scsi: lpfc: Fix nvme sg_seg_cnt display if HBA does not support NVME

The driver is currently reporting a non-zero nvme sg_seg_cnt value of 256
when nvme is disabled. It should be zero.

Fix by ensuring the value is cleared.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix nvme target mode ABTSing a received ABTS
James Smart [Wed, 14 Aug 2019 23:56:56 +0000 (16:56 -0700)]
scsi: lpfc: Fix nvme target mode ABTSing a received ABTS

If an unsolicited ABTS was received, the driver looks up the exchange it
references. It it does various searches looking for the exchange
context. When one is eventually matched and it is associated with an XRI
context, the driver sends an ABORT WQE to terminate the exchange. Current
code looks at whether the transport had taken action on the XRI yet or not
(no action if set to LPFC_NVMET_STE_RCV; action if non-LPFC_NVMET_STE_RCV).
Based on action or not one of two (sol vs unsol) issue abort routines are
called. The unsol version cheats and transmits a sequence containing an
ABTS with no interaction with the adapter.  The sol version issues an Abort
WQE and lets the adapter manage whether the ABTS is sent to not.

The issue is the unsol version is sending ABTS unconditionally for the
exchange that received the ABTS. It's unnecessary.

Remove the conditional and just call the adapter command-based routine to
let the adapter manage the ABTS.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix hang when downloading fw on port enabled for nvme
James Smart [Wed, 14 Aug 2019 23:56:55 +0000 (16:56 -0700)]
scsi: lpfc: Fix hang when downloading fw on port enabled for nvme

As part of firmware download, the adapter is reset. On the adapter the
reset causes the function to stop and all outstanding io is terminated
(without responses). The reset path then starts teardown of the adapter,
starting with deregistration of the remote ports with the nvme-fc
transport. The local port is then deregistered and the driver waits for
local port deregistration. This never finishes.

The remote port deregistrations terminated the nvme controllers, causing
them to send aborts for all the outstanding io. The aborts were serviced in
the driver, but stalled due to its state. The nvme layer then stops to
reclaim it's outstanding io before continuing.  The io must be returned
before the reset on the controller is deemed complete and the controller
delete performed.  The remote port deregistration won't complete until all
the controllers are terminated. And the local port deregistration won't
complete until all controllers and remote ports are terminated. Thus things
hang.

The issue is the reset which stopped the adapter also stopped all the
responses that would drive i/o completions, and the aborts were also
stopped that stopped i/o completions. The driver, when resetting the
adapter like this, needs to be generating the completions as part of the
adapter reset so that I/O complete (in error), and any aborts are not
queued.

Fix by adding flush routines whenever the adapter port has been reset or
discovered in error. The flush routines will generate the completions for
the scsi and nvme outstanding io. The abort ios, if waiting, will be caught
and flushed as well.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix too many sg segments spamming in kernel log
James Smart [Wed, 14 Aug 2019 23:56:54 +0000 (16:56 -0700)]
scsi: lpfc: Fix too many sg segments spamming in kernel log

This issue is specific to SLI-3 adapters, specifically when DIF is used.

Once seen, this message floods the logs:
9064 BLKGRD: lpfc_scsi_prep_dma_buf_s3: Too many sg segments from
  dma_map_sg

The driver, upon detecting an error such as too many elements in an sglist,
misrepresents the error by treating it as a temporary resource issue by
returning MLQUEUE_HOST_BUSY.  In these cases, no retry will fix it and it
should have been a hard error. The repeated retry was causing the spamming
of the log.

As for the initial reason of why an I/O encountered this issue at all is
not clear as parameters set by the driver should have avoided this.  The
dm multipath maintainer has been notified of the issue.

Fix by changing the return code for the dma mapping routines to indicate
cases that are not retryable and return DID_ERROR on those cases.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix crash due to port reset racing vs adapter error handling
James Smart [Wed, 14 Aug 2019 23:56:53 +0000 (16:56 -0700)]
scsi: lpfc: Fix crash due to port reset racing vs adapter error handling

If the adapter encounters a condition which causes the adapter to fail
(driver must detect the failure) simultaneously to a request to the driver
to reset the adapter (such as a host_reset), the reset path will be racing
with the asynchronously-detect adapter failure path.  In the failing
situation, one path has started to tear down the adapter data structures
(io_wq's) while the other path has initiated a repeat of the teardown and
is in the lpfc_sli_flush_xxx_rings path and attempting to access the
just-freed data structures.

Fix by the following:

 - In cases where an adapter failure is detected, rather than explicitly
   calling offline_eratt() to start the teardown, change the adapter state
   and let the later calls of posted work to the slowpath thread invoke the
   adapter recovery.  In essence, this means all requests to reset are
   serialized on the slowpath thread.

 - Clean up the routine that restarts the adapter. If there is a failure
   from brdreset, don't immediately error and leave things in a partial
   state. Instead, ensure the adapter state is set and finish the teardown
   of structures before returning.

 - If in the scsi host reset handler and the board fails to reset and
   restart (which can be due to parallel reset/recovery paths), instead of
   hard failing and explicitly calling offline_eratt() (which gets into the
   redundant path), just fail out and let the asynchronous path resolve the
   adapter state.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix deadlock on host_lock during cable pulls
James Smart [Wed, 14 Aug 2019 23:56:52 +0000 (16:56 -0700)]
scsi: lpfc: Fix deadlock on host_lock during cable pulls

During cable pull testing a deadlock was seen between lpfc_nlp_counters()
vs lpfc_mbox_process_link_up() vs lpfc_work_list_done(). They are all
waiting on the shost->host_lock.

Issue is all of these cases raise irq when taking out the lock but use
spin_unlock_irq() when unlocking. The unlock path is will unconditionally
re-enable interrupts in cases where irq state should be preserved. The
re-enablement allowed the other paths to execute which then causes the
deadlock.

Fix by converting the lock/unlock to irqsave/irqrestore.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix error in remote port address change
James Smart [Wed, 14 Aug 2019 23:56:51 +0000 (16:56 -0700)]
scsi: lpfc: Fix error in remote port address change

In a test with high nvme remote port counts connected via a multi-hop FC
switch config where switches were systematically reset (e.g. fabric
partitioning and re-establishment), the nvme remote ports would switch
addresses based on the switch reconfiguration events. The driver would get
into a situation where the nvme port changed address, PLOGI and PRLI would
succeed nvme transport registration occurred, but subsequent LS requests by
the nvme subsystem failed due to a bad ndlp state and connectivity to the
device failed.

The driver hit a race condition on multiple devices that address swapped
simultaneously. In cases where the driver notices the remote port structure
came back as the same value as previously (meaning a nvme_rport structure
was re-enabled and did not go through devloss_tmo/connect_tmo_failures on
all controllers) the driver would unconditionally exit assuming the ndlp
information was correct. But, if the ndlp's had been swapped, the ndlp had
stale port state information, which when used by the LS request commands,
would fail the commands.

Fix by checking whether a node swap had occurred, and only exit if no ndlp
swap had occurred.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix driver nvme rescan logging
James Smart [Wed, 14 Aug 2019 23:56:50 +0000 (16:56 -0700)]
scsi: lpfc: Fix driver nvme rescan logging

In situations where zoning is not being used, thus NVMe initiators see
other NVMe initiators as well as NVMe targets, a link bounce on an
initiator will cause the NVMe initiators to spew "6169" State Error
messages.

The driver is not qualifying whether the remote port is a NVMe targer or
not before calling the lpfc_nvme_rescan_port(), which validates the role
and prints the message if its only an NVMe initiator.

Fix by the following:

 - Before calling lpfc_nvme_rescan_port() ensure that the node is a NVMe
   storage target or a NVMe discovery controller.

 - Clean up implementation of lpfc_nvme_rescan_port. remoteport pointer
   will always be NULL if a NVMe initiator only. But, grabbing of
   remoteport pointer should be done under lock to coincide with the
   registering of the remote port with the fc transport.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix sg_seg_cnt for HBAs that don't support NVME
James Smart [Wed, 14 Aug 2019 23:56:49 +0000 (16:56 -0700)]
scsi: lpfc: Fix sg_seg_cnt for HBAs that don't support NVME

On an SLI-3 adapter which does not support NVMe, but with the driver global
attribute to enable nvme on any adapter if it does support NVMe
(e.g. module parameter lpfc_enable_fc4_type=3), the SGL and total SGE
values are being munged by the protocol enablement when it shouldn't be.

Correct by changing the location of where the NVME sgl information is being
applied, which will avoid any SLI-3-based adapter.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix propagation of devloss_tmo setting to nvme transport
James Smart [Wed, 14 Aug 2019 23:56:48 +0000 (16:56 -0700)]
scsi: lpfc: Fix propagation of devloss_tmo setting to nvme transport

If admin changes the devloss_tmo on an rport via the fc_remote_port rport
dev_loss_tmo attribute, the value is on set on scsi stack.  The change is
not propagated to NVMe.

The set routine in the lldd lacks the call to
nvme_fc_set_remoteport_devloss() to set the value.

Fix by adding the call to the lldd set routine.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>