OSDN Git Service

uclinux-h8/linux.git
5 years agoscsi: NCR5380: Don't clear busy flag when abort fails
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Don't clear busy flag when abort fails

When NCR5380_abort() returns FAILED, the driver forgets that the target is
still busy. Hence, further commands may be sent to the target, which may fail
during selection and produce the error message, "reselection after won
arbitration?". Prevent this by leaving the busy flag set when NCR5380_abort()
fails.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Check for invalid reselection target
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Check for invalid reselection target

The X3T9.2 specification (draft) says, under "6.1.4.1 RESELECTION", that "the
initiator shall not respond to a RESELECTION phase if other than two SCSI ID
bits are on the DATA BUS." This issue (too many bits set) has been observed in
the wild, so add a check.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Use DRIVER_SENSE to indicate valid sense data
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Use DRIVER_SENSE to indicate valid sense data

When sense data is valid, call set_driver_byte(cmd, DRIVER_SENSE).  Otherwise
some callers of scsi_execute() will ignore sense data.  Don't set DID_ERROR or
DID_RESET just because sense data is missing.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Withhold disconnect privilege for REQUEST SENSE
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Withhold disconnect privilege for REQUEST SENSE

This is mostly needed because an AztecMonster II target has been observed
disconnecting REQUEST SENSE commands and then failing to reselect properly.

Suggested-by: Michael Schmitz <schmitzmic@gmail.com>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Have NCR5380_select() return a bool
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Have NCR5380_select() return a bool

The return value is taken to mean "retry" or "don't retry". Change it to bool
to improve readability. Fix related comments. No functional change.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Reduce goto statements in NCR5380_select()
Finn Thain [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Reduce goto statements in NCR5380_select()

Replace a 'goto' statement with a simple 'return' where possible.  This
improves readability. No functional change.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: NCR5380: Clear all unissued commands on host reset
Hannes Reinecke [Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)]
scsi: NCR5380: Clear all unissued commands on host reset

When doing a host reset we should be clearing all outstanding commands, not
just the command triggering the reset.

[mkp: adjusted Hannes' SoB address]

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Ondrey Zary <linux@rainbow-software.org>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: mptfusion: Remove unnecessary parentheses
Nathan Chancellor [Sat, 15 Sep 2018 06:36:45 +0000 (23:36 -0700)]
scsi: mptfusion: Remove unnecessary parentheses

Clang warns when multiple pairs of parentheses are used for a single
conditional statement.

drivers/message/fusion/mptbase.c:338:11: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
        if ((ioc == NULL))
             ~~~~^~~~~~~
drivers/message/fusion/mptbase.c:338:11: note: remove extraneous
parentheses around the comparison to silence this warning
        if ((ioc == NULL))
            ~    ^      ~
drivers/message/fusion/mptbase.c:338:11: note: use '=' to turn this
equality comparison into an assignment
        if ((ioc == NULL))
                 ^~
                 =
drivers/message/fusion/mptbase.c:342:12: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
        if ((pdev == NULL))
             ~~~~~^~~~~~~
drivers/message/fusion/mptbase.c:342:12: note: remove extraneous
parentheses around the comparison to silence this warning
        if ((pdev == NULL))
            ~     ^      ~
drivers/message/fusion/mptbase.c:342:12: note: use '=' to turn this
equality comparison into an assignment
        if ((pdev == NULL))
                  ^~
                  =
2 warnings generated.

Remove them and while we're at it, simplify the NULL checks as '!var' is
used more than 'var == NULL'.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla4xxx: Remove redundant check on drvr_wait
Colin Ian King [Wed, 26 Sep 2018 13:08:48 +0000 (14:08 +0100)]
scsi: qla4xxx: Remove redundant check on drvr_wait

The check for a non-zero drvr_wait is redundant as the same check is performed
earlier in the outer while loop, the inner check will always be true if we
reached this point inside the while loop.  Remove the redundant if check.

Detected by cppcheck:
(warning) Identical inner 'if' condition is always true.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Move log messages before issuing command to firmware
Giridhar Malavali [Thu, 27 Sep 2018 05:05:18 +0000 (22:05 -0700)]
scsi: qla2xxx: Move log messages before issuing command to firmware

There is a probability that the SRB structure might have been released by the
time the debug log message dereferences it.  This patch moved the log messages
before the command is issued to the firmware to prevent unknown behavior and
kernel crash

Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery")
Cc: <stable@vger.kernel.org>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix for double free of SRB structure
Giridhar Malavali [Thu, 27 Sep 2018 05:05:17 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix for double free of SRB structure

This patch fixes issue during switch command query where driver was freeing
SRB resources multiple times

Following stack trace will be seen
[  853.436234] BUG: unable to handle kernel NULL pointer dereference at
0000000000000001
[  853.436348] IP: [<ffffffff811df514>] kmem_cache_alloc+0x74/0x1e0
[  853.436476] PGD 0
[  853.436601] Oops: 0000 [#1] SMP

[  853.454700]  [<ffffffff81099f6a>] ? mod_timer+0x14a/0x220
[  853.455543]  [<ffffffff81185465>] mempool_alloc_slab+0x15/0x20
[  853.456395]  [<ffffffff811855a9>] mempool_alloc+0x69/0x170
[  853.457257]  [<ffffffff81098af2>] ? internal_add_timer+0x32/0x70
[  853.458136]  [<ffffffffc0092d2b>] qla2xxx_queuecommand+0x29b/0x3f0 [qla2xxx]
[  853.459024]  [<ffffffff8146535a>] scsi_dispatch_cmd+0xaa/0x230
[  853.459923]  [<ffffffff8146e11f>] scsi_request_fn+0x4df/0x680
[  853.460829]  [<ffffffff81029557>] ? __switch_to+0xd7/0x510
[  853.461747]  [<ffffffff812f7113>] __blk_run_queue+0x33/0x40
[  853.462670]  [<ffffffff812f7735>] blk_delay_work+0x25/0x40
[  853.463603]  [<ffffffff810a882a>] process_one_work+0x17a/0x440
[  853.464546]  [<ffffffff810a94f6>] worker_thread+0x126/0x3c0
[  853.465501]  [<ffffffff810a93d0>] ? manage_workers.isra.24+0x2a0/0x2a0
[  853.466447]  [<ffffffff810b099f>] kthread+0xcf/0xe0
[  853.467379]  [<ffffffff810b08d0>] ? insert_kthread_work+0x40/0x40
[  853.470172] Code: db e2 7e 49 8b 50 08 4d 8b 20 49 8b 40 10 4d 85 e4 0f 84 20
01 00 00 48 85 c0 0f 84 17 01 00 00 49 63 46 20 48 8d 4a 01 4d 8b 06 <49> 8b 1c
04 4c 89 e0 65 49 0f c7 08 0f 94 c0 84 c0 74 ba 49 63
[  853.472072] RIP  [<ffffffff811df514>] kmem_cache_alloc+0x74/0x1e0
[  853.472971]  RSP <ffff88103726fc50>

Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery")
Cc: <stable@vger.kernel.org>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix recursive mailbox timeout
Quinn Tran [Thu, 27 Sep 2018 05:05:16 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix recursive mailbox timeout

This patch prevents user space mailbox request from doing chip reset if the
mailbox timed out. The chip reset is only reserved for the DPC thread to
ensure all mailbox requests are flushed properly. The DPC thread is
responsible for the flushing all MBs and chip reset.

Fixes: b2000805a975 ("scsi: qla2xxx: Flush mailbox commands on chip reset")
Cc: <stable@ger.kernel.org>
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix driver hang when FC-NVMe LUNs are configured
Himanshu Madhani [Thu, 27 Sep 2018 05:05:15 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix driver hang when FC-NVMe LUNs are configured

This patch fixes multiple call for qla_nvme_unregister_remote_port() as part
of qlt_schedule_session_for_deletion(), Do not call it again during
qla_nvme_delete()

Fixes: e473b3074104 ("scsi: qla2xxx: Add FC-NVMe abort processing")
Cc: <stable@vger.kernel.org>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix re-using LoopID when handle is in use
Quinn Tran [Thu, 27 Sep 2018 05:05:14 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix re-using LoopID when handle is in use

This patch fixes issue where driver clears NPort ID map instead of marking
handle in use. Once driver clears NPort ID from the database, it can reuse
the same NPort ID resulting in a PLOGI failure.

[mkp: fixed Himanshu's SoB]

Fixes: a084fd68e1d2 ("scsi: qla2xxx: Fix re-login for Nport Handle in use")
Cc: <stable@vger.kernel.org>
Signed-of-by: Quinn Tran <quinn.tran@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <hmadhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix duplicate switch database entries
Quinn Tran [Thu, 27 Sep 2018 05:05:13 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix duplicate switch database entries

The response data buffer used in switch scan is reused 4 times.  (For example,
for commands GPN_FT, GNN_FT for FCP and FC-NVME) Before driver reuses this
buffer, clear it to prevent duplicate entries in our database.

Fixes: a4239945b8ad1 ("scsi: qla2xxx: Add switch command to simplify fabric discovery"
Cc: <stable@vger.kernel.org>
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix NVMe Target discovery
Quinn Tran [Thu, 27 Sep 2018 05:05:12 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix NVMe Target discovery

This patch fixes issue when remoteport registers itself as both FCP and
FC-NVMe with the switch, driver will pick FC-NVMe personality as default when
scanning for targets.

Driver was using comaprative operator instead of bitwise operator to check for
fc4_type for both FCP and FC-NVME.

Fixes: 2b5b96473efc ("scsi: qla2xxx: Fix FC-NVMe LUN discovery")
Cc: <stable@vger.kernel.org>
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix NVMe session hang on unload
Quinn Tran [Thu, 27 Sep 2018 05:05:11 +0000 (22:05 -0700)]
scsi: qla2xxx: Fix NVMe session hang on unload

Send aborts only when chip is active.

Fixes: 623ee824e579 ("scsi: qla2xxx: Fix FC-NVMe IO abort during driver reset")
Cc: <stable@vger.kernel.org> # 4.14
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: don't allow negative thresholds
Dan Carpenter [Thu, 20 Sep 2018 10:02:36 +0000 (13:02 +0300)]
scsi: qla2xxx: don't allow negative thresholds

We shouldn't allow negative thresholds.  I don't know what it would do
but it can't be good.

Fixes: 8b4673ba3a1b ("scsi: qla2xxx: Add support for ZIO6 interrupt threshold")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix comment in MODULE_PARM_DESC in qla2xxx
Masanari Iida [Tue, 11 Sep 2018 09:48:11 +0000 (18:48 +0900)]
scsi: qla2xxx: Fix comment in MODULE_PARM_DESC in qla2xxx

Default value of ql2xasynctmfenable for qla2xxx driver was set to 1 in
commit 043dc1d7e850 ("scsi: qla2xxx: Enable Async TMF processing") but
comment in MODULE_PARAM_DESC was not modified.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: iscsi: cxgbit: fix csk leak
Varun Prakash [Wed, 19 Sep 2018 14:14:57 +0000 (19:44 +0530)]
scsi: target: iscsi: cxgbit: fix csk leak

csk leak can happen if a new TCP connection gets established after
cxgbit_accept_np() returns, to fix this leak free remaining csk in
cxgbit_free_np().

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: fix a race condition when smp task timeout
Jason Yan [Tue, 25 Sep 2018 02:56:54 +0000 (10:56 +0800)]
scsi: libsas: fix a race condition when smp task timeout

When the lldd is processing the complete sas task in interrupt and set the
task stat as SAS_TASK_STATE_DONE, the smp timeout timer is able to be
triggered at the same time. And smp_task_timedout() will complete the task
wheter the SAS_TASK_STATE_DONE is set or not. Then the sas task may freed
before lldd end the interrupt process. Thus a use-after-free will happen.

Fix this by calling the complete() only when SAS_TASK_STATE_DONE is not
set. And remove the check of the return value of the del_timer(). Once the
LLDD sets DONE, it must call task->done(), which will call
smp_task_done()->complete() and the task will be completed and freed
correctly.

Reported-by: chenxiang <chenxiang66@hisilicon.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: check the ata device status by ata_dev_enabled()
Jason Yan [Tue, 25 Sep 2018 02:56:53 +0000 (10:56 +0800)]
scsi: libsas: check the ata device status by ata_dev_enabled()

When ata device IDENTIFY failed, the ata device status is ATA_DEV_UNKNOWN. The
libata reported like:

[113518.620433] ata5.00: qc timeout (cmd 0xec)
[113518.653646] ata5.00: failed to IDENTIFY (I/O error, err_mask=0x4)

But libsas verifies the device status by ata_dev_disabled(), which skipped
ATA_DEV_UNKNOWN. This will make libsas think the ata device probing succeed
the device cannot be actually brought up. And even the new bcast of this
device will be considered as flutter and will not probe this device again.

Change ata_dev_disabled() to !ata_dev_enabled() so that libsas can deal with
this if the ata device probe failed. New bcasts can let us try to probe the
device again and bring it up if it is fine to IDENTIFY.

Tested-by: Zhou Yupeng <zhouyupeng1@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: always unregister the old device if going to discover new
Jason Yan [Tue, 25 Sep 2018 02:56:52 +0000 (10:56 +0800)]
scsi: libsas: always unregister the old device if going to discover new

If we went into sas_rediscover_dev() the attached_sas_addr was already insured
not to be zero. So it's unnecessary to check if the attached_sas_addr is zero.

And although if the sas address is not changed, we always have to unregister
the old device when we are going to register a new one. We cannot just leave
the device there and bring up the new.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: chenxiang <chenxiang66@hisilicon.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: make the lldd_port_deformed method optional
Jason Yan [Tue, 25 Sep 2018 02:56:51 +0000 (10:56 +0800)]
scsi: libsas: make the lldd_port_deformed method optional

Now LLDDs have to implement lldd_port_deformed method otherwise NULL
dereference will happen. Make it optional and remove the dummy implementation
in hisi_sas.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Acked-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: delete dead code in scsi_transport_sas.c
Jason Yan [Tue, 25 Sep 2018 02:56:50 +0000 (10:56 +0800)]
scsi: libsas: delete dead code in scsi_transport_sas.c

This code is dead and no clue implies that it will be back again.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: megaraid: fix spelling mistake "maibox" -> "mailbox"
Colin Ian King [Sun, 23 Sep 2018 22:25:48 +0000 (23:25 +0100)]
scsi: megaraid: fix spelling mistake "maibox" -> "mailbox"

Trivial fix to spelling mistake in warning message and comments

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: FlashPoint: Remove unnecessary parentheses
Nathan Chancellor [Thu, 20 Sep 2018 21:10:32 +0000 (14:10 -0700)]
scsi: FlashPoint: Remove unnecessary parentheses

Clang warns when multiple pairs of parentheses are used for a single
conditional statement.

In file included from drivers/scsi/BusLogic.c:57:
drivers/scsi/FlashPoint.c:2947:34: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
                                if ((currSCCB->Sccb_scsistat == SELECT_SN_ST)) {
                                     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
drivers/scsi/FlashPoint.c:2947:34: note: remove extraneous parentheses around the comparison to silence this warning
                                if ((currSCCB->Sccb_scsistat == SELECT_SN_ST)) {
                                    ~                        ^              ~
drivers/scsi/FlashPoint.c:2947:34: note: use '=' to turn this equality comparison into an assignment
                                if ((currSCCB->Sccb_scsistat == SELECT_SN_ST)) {
                                                             ^~
                                                             =
drivers/scsi/FlashPoint.c:2956:39: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
                                else if ((currSCCB->Sccb_scsistat ==
                                          ~~~~~~~~~~~~~~~~~~~~~~~~^~
drivers/scsi/FlashPoint.c:2956:39: note: remove extraneous parentheses around the comparison to silence this warning
                                else if ((currSCCB->Sccb_scsistat ==
                                         ~                        ^
drivers/scsi/FlashPoint.c:2956:39: note: use '=' to turn this equality comparison into an assignment
                                else if ((currSCCB->Sccb_scsistat ==
                                                                  ^~
                                                                  =
2 warnings generated.

Link: https://github.com/ClangBuiltLinux/linux/issues/156
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hpsa: Use vmemdup_user to replace the open code
zhong jiang [Tue, 18 Sep 2018 15:54:41 +0000 (23:54 +0800)]
scsi: hpsa: Use vmemdup_user to replace the open code

vmemdup_user is better than duplicating its implementation, So just replace
the open code.

The issue is detected with the help of Coccinelle.

Tested-by: Don Brace <don.brace@microsemi.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: advansys: Remove unnecessary parentheses
Nathan Chancellor [Thu, 20 Sep 2018 20:58:58 +0000 (13:58 -0700)]
scsi: advansys: Remove unnecessary parentheses

Clang warns when multiple pairs of parentheses are used for a single
conditional statement.

drivers/scsi/advansys.c:6451:20: warning: equality comparison with
extraneous parentheses [-Wparentheses-equality]
                                if ((sdtr_data == 0xFF)) {
                                     ~~~~~~~~~~^~~~~~~
drivers/scsi/advansys.c:6451:20: note: remove extraneous parentheses
around the comparison to silence this warning
                                if ((sdtr_data == 0xFF)) {
                                    ~          ^      ~
drivers/scsi/advansys.c:6451:20: note: use '=' to turn this equality
comparison into an assignment
                                if ((sdtr_data == 0xFF)) {
                                               ^~
                                               =
1 warning generated.

Link: https://github.com/ClangBuiltLinux/linux/issues/155
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target: iblock: split T10 PI SGL across command bios
Greg Edwards [Tue, 4 Sep 2018 17:19:10 +0000 (11:19 -0600)]
scsi: target: iblock: split T10 PI SGL across command bios

When T10 PI is enabled on a backing device for the iblock backstore, the PI
SGL for the entire command is attached to the first bio only.  This works fine
if the command is covered by a single bio, but can result in ref tag errors in
the client for the other bios in a multi-bio command, e.g.

[   47.631236] sda: ref tag error at location 2048 (rcvd 0)
[   47.637658] sda: ref tag error at location 4096 (rcvd 0)
[   47.644228] sda: ref tag error at location 6144 (rcvd 0)

The command will be split into multiple bios if the number of data SG elements
exceeds BIO_MAX_PAGES (see iblock_get_bio()).

The bios may later be split again in the block layer on the host after
iblock_submit_bios(), depending on the queue limits of the backing device.
The block and SCSI layers will pass through the whole PI SGL down to the LLDD
however that first bio is split up, but the LLDD may only use the portion that
corresponds to the data length (depends on the LLDD, tested with scsi_debug).

Split the PI SGL across the bios in the command, so each bio's
bio_integrity_payload contains the protection information for the data in the
bio.  Use an sg_mapping_iter to keep track of where we are in PI SGL, so we
know where to start with the next bio.

Signed-off-by: Greg Edwards <gedwards@ddn.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove set but not used variable 'ptr_dma'
YueHaibing [Thu, 13 Sep 2018 02:40:56 +0000 (02:40 +0000)]
scsi: qla2xxx: Remove set but not used variable 'ptr_dma'

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

drivers/scsi/qla2xxx/qla_iocb.c: In function 'qla24xx_els_dcmd2_iocb':
drivers/scsi/qla2xxx/qla_iocb.c:2644:13: warning:
 variable 'ptr_dma' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Remove set but not used variable 'sgl_size'
YueHaibing [Thu, 13 Sep 2018 02:04:59 +0000 (02:04 +0000)]
scsi: lpfc: Remove set but not used variable 'sgl_size'

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

drivers/scsi/lpfc/lpfc_nvme.c: In function 'lpfc_new_nvme_buf':
drivers/scsi/lpfc/lpfc_nvme.c:2238:24: warning:
 variable 'sgl_size' set but not used [-Wunused-but-set-variable]
  int bcnt, num_posted, sgl_size;
                        ^
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bnx2fc: Remove set but not used variable 'oxid'
YueHaibing [Wed, 12 Sep 2018 02:50:52 +0000 (02:50 +0000)]
scsi: bnx2fc: Remove set but not used variable 'oxid'

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

drivers/scsi/bnx2fc/bnx2fc_fcoe.c: In function 'bnx2fc_rcv':
drivers/scsi/bnx2fc/bnx2fc_fcoe.c:435:17: warning:
 variable 'oxid' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: remove unnecessary unlikely()
Igor Stoppa [Wed, 5 Sep 2018 20:47:20 +0000 (23:47 +0300)]
scsi: core: remove unnecessary unlikely()

BUG_ON() already contains an unlikely(), there is no need for another one.

Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: aic7xxx: remove set but not used variable 'shared_scb_data'
YueHaibing [Tue, 4 Sep 2018 03:36:01 +0000 (03:36 +0000)]
scsi: aic7xxx: remove set but not used variable 'shared_scb_data'

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

drivers/scsi/aic7xxx/aic79xx_pci.c: In function 'ahd_pci_config':
drivers/scsi/aic7xxx/aic79xx_pci.c:291:19: warning:
 variable 'shared_scb_data' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: iscsi: target: fix spelling mistake "entires" -> "entries"
Colin Ian King [Fri, 14 Sep 2018 12:28:08 +0000 (13:28 +0100)]
scsi: iscsi: target: fix spelling mistake "entires" -> "entries"

Trivial fix to spelling mistake in function name and comment

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Remove set but not used variable 'page_code'
YueHaibing [Fri, 14 Sep 2018 01:38:56 +0000 (01:38 +0000)]
scsi: pm80xx: Remove set but not used variable 'page_code'

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

drivers/scsi/pm8001/pm80xx_hwi.c: In function 'pm8001_set_phy_profile':
drivers/scsi/pm8001/pm80xx_hwi.c:4679:6: warning:
 variable 'page_code' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Remove set but not used variable 'device_id'
YueHaibing [Thu, 13 Sep 2018 01:54:24 +0000 (01:54 +0000)]
scsi: pm80xx: Remove set but not used variable 'device_id'

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

drivers/scsi/pm8001/pm8001_sas.c: In function 'pm8001_I_T_nexus_event_handler':
drivers/scsi/pm8001/pm8001_sas.c:1052:6: warning:
 variable 'device_id' set but not used [-Wunused-but-set-variable]

drivers/scsi/pm8001/pm8001_sas.c: In function 'pm8001_abort_task':
drivers/scsi/pm8001/pm8001_sas.c:1191:6: warning:
 variable 'device_id' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufshcd: Fix NULL pointer dereference for in ufshcd_init
Vivek Gautam [Tue, 7 Aug 2018 17:47:39 +0000 (23:17 +0530)]
scsi: ufshcd: Fix NULL pointer dereference for in ufshcd_init

Error paths in ufshcd_init() ufshcd_hba_exit() killed clk_scaling workqueue
when the workqueue is actually created quite late in ufshcd_init().  So, we
end up getting NULL pointer dereference in such error paths.  Fix this by
moving clk_scaling initialization and kill codes to two separate methods, and
call them at required places.

Fixes: 401f1e4490ee ("scsi: ufs: don't suspend clock scaling during clock
gating")

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: Matthias Kaehlcke <mka@chromium.org>
Cc: Evan Green <evgreen@chromium.org>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: message: fusion: fix a few trivial spelling mistakes
Colin Ian King [Mon, 10 Sep 2018 09:11:07 +0000 (10:11 +0100)]
scsi: message: fusion: fix a few trivial spelling mistakes

Trival fix to spelling mistakes:

 PrimativeSeqErrCount -> PrimitiveSeqErrCount
 Primative -> Primitive
 primative -> primitive
 mptsas_broadcast_primative_work -> mptsas_broadcast_primitive_work
 Broadcase -> Broadcast

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Update driver version to 0.1.39
Deepak Ukey [Tue, 11 Sep 2018 08:48:05 +0000 (14:18 +0530)]
scsi: pm80xx: Update driver version to 0.1.39

Updated the driver version from 0.1.38 to 0.1.39.

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Fixed system hang issue during kexec boot
Deepak Ukey [Tue, 11 Sep 2018 08:48:04 +0000 (14:18 +0530)]
scsi: pm80xx: Fixed system hang issue during kexec boot

When the firmware is not responding, execution of kexec boot causes a system
hang. When firmware assertion happened, driver get notified with interrupt
vector updated in MPI configuration table. Then, the driver will read
scratchpad register and set controller_fatal_error flag to true.

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Corrected dma_unmap_sg() parameter
Deepak Ukey [Tue, 11 Sep 2018 08:48:03 +0000 (14:18 +0530)]
scsi: pm80xx: Corrected dma_unmap_sg() parameter

For the function dma_unmap_sg(), the <nents> parameter should be number of
elements in the scatter list prior to the mapping, not after the mapping.

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pm80xx: Fix for phy enable/disable functionality
Deepak Ukey [Tue, 11 Sep 2018 08:48:02 +0000 (14:18 +0530)]
scsi: pm80xx: Fix for phy enable/disable functionality

Added proper mask for phy id in mpi_phy_stop_resp().

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: fix typo "CT-PASSTRHU" -> "CT-PASSTHRU"
Colin Ian King [Sun, 9 Sep 2018 22:25:03 +0000 (23:25 +0100)]
scsi: qla2xxx: fix typo "CT-PASSTRHU" -> "CT-PASSTHRU"

Trivial fix to typo in debug message text.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: aic7xxx: remove unused redundant variable num_chip_names
Colin Ian King [Tue, 4 Sep 2018 14:36:56 +0000 (15:36 +0100)]
scsi: aic7xxx: remove unused redundant variable num_chip_names

Variable num_chip_names is defined but not used, hence it is redundant and can
be removed.

Cleans up clang warning:
'num_chip_names' defined but not used [-Wunused-const-variable=]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libfc: remove set but not used variable 'rpriv'
YueHaibing [Tue, 4 Sep 2018 03:31:07 +0000 (03:31 +0000)]
scsi: libfc: remove set but not used variable 'rpriv'

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

drivers/scsi/libfc/fc_fcp.c: In function 'fc_queuecommand':
drivers/scsi/libfc/fc_fcp.c:1875:30: warning:
 variable 'rpriv' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Johannes Thumshirn <jth@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Spelling s/rebulid/rebuild/
Geert Uytterhoeven [Mon, 3 Sep 2018 17:35:29 +0000 (19:35 +0200)]
scsi: arcmsr: Spelling s/rebulid/rebuild/

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sym53c8xx: fix NULL pointer dereference panic in sym_int_sir()
George Kennedy [Wed, 29 Aug 2018 15:38:16 +0000 (11:38 -0400)]
scsi: sym53c8xx: fix NULL pointer dereference panic in sym_int_sir()

sym_int_sir() in sym_hipd.c does not check the command pointer for NULL before
using it in debug message prints.

Suggested-by: Matthew Wilcox <matthew.wilcox@oracle.com>
Signed-off-by: George Kennedy <george.kennedy@oracle.com>
Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
Acked-by: Matthew Wilcox <matthew.wilcox@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: update driver version to 12.0.0.7
James Smart [Mon, 10 Sep 2018 17:30:51 +0000 (10:30 -0700)]
scsi: lpfc: update driver version to 12.0.0.7

Update the driver version to 12.0.0.7

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: add support to retrieve firmware logs
James Smart [Mon, 10 Sep 2018 17:30:50 +0000 (10:30 -0700)]
scsi: lpfc: add support to retrieve firmware logs

This patch adds the ability to read firmware logs from the adapter. The driver
registers a buffer with the adapter that is then written to by the adapter.
The adapter posts CQEs to indicate content updates in the buffer. While the
adapter is writing to the buffer in a circular fashion, an application will
poll the driver to read the next amount of log data from the buffer.

Driver log buffer size is configurable via the ras_fwlog_buffsize sysfs
attribute. Verbosity to be used by firmware when logging to host memory is
controlled through the ras_fwlog_level attribute.  The ras_fwlog_func
attribute enables or disables loggy by firmware.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: reduce locking when updating statistics
James Smart [Mon, 10 Sep 2018 17:30:49 +0000 (10:30 -0700)]
scsi: lpfc: reduce locking when updating statistics

Currently, on each io completion, the stats update routine indiscriminately
holds a lock. While holding the adapter-wide lock, checks are made to check
whether status are being tracked. When disabled (the default), the locking
wasted a lot of cycles.

Check for stats enablement before taking the lock.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Fix errors in log messages.
James Smart [Mon, 10 Sep 2018 17:30:48 +0000 (10:30 -0700)]
scsi: lpfc: Fix errors in log messages.

Message 6408 is displayed for each entry in an array, but the cpu and queue
numbers were incorrect for the entry.  Message 6001 includes an extraneous
character.

Resolve both issues

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Correct invalid EQ doorbell write on if_type=6
James Smart [Mon, 10 Sep 2018 17:30:47 +0000 (10:30 -0700)]
scsi: lpfc: Correct invalid EQ doorbell write on if_type=6

During attachment, the driver writes the EQ doorbell to disable potential
interrupts from an EQ. The current EQ doorbell format used for clearing the
interrupt is incorrect and uses an if_type=2 format, making the operation act
on the wrong EQ.

Correct the code to use the proper if_type=6 EQ doorbell format.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Correct irq handling via locks when taking adapter offline
James Smart [Mon, 10 Sep 2018 17:30:46 +0000 (10:30 -0700)]
scsi: lpfc: Correct irq handling via locks when taking adapter offline

When taking the board offline while performing i/o, unsafe locking errors
occurred and irq level isn't properly managed.

In lpfc_sli_hba_down, spin_lock_irqsave(&phba->hbalock, flags) does not
disable softirqs raised from timer expiry.  It is possible that a softirq is
raised from the lpfc_els_retry_delay routine and recursively requests the same
phba->hbalock spinlock causing deadlock.

Address the deadlocks by creating a new port_list lock. The softirq behavior
can then be managed a level deeper into the calling sequences.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Correct soft lockup when running mds diagnostics
James Smart [Mon, 10 Sep 2018 17:30:45 +0000 (10:30 -0700)]
scsi: lpfc: Correct soft lockup when running mds diagnostics

When running an mds diagnostic that passes frames with the switch, soft
lockups are detected. The driver is in a CQE processing loop and has
sufficient amount of traffic that it never exits the ring processing routine,
thus the "lockup".

Cap the number of elements in the work processing routine to 64 elements. This
ensures that the cpu will be given up and the handler reschedule to process
additional items.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Correct race with abort on completion path
James Smart [Mon, 10 Sep 2018 17:30:44 +0000 (10:30 -0700)]
scsi: lpfc: Correct race with abort on completion path

On io completion, the driver is taking an adapter wide lock and nulling the
scsi command back pointer.  The nulling of the back pointer is to signify the
io was completed and the scsi_done() routine was called.  However, the routine
makes no check to see if the abort routine had done the same thing and
possibly nulled the pointer. Thus it may doubly-complete the io.

Make the following mods:

- Check to make sure forward progress (call scsi_done()) only happens if the
  command pointer was non-null.

- As the taking of the lock, which is adapter wide, is very costly on a system
  under load, null the pointer using an xchg operation rather than under lock.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Raise nvme defaults to support a larger io and more connectivity
James Smart [Mon, 10 Sep 2018 17:30:43 +0000 (10:30 -0700)]
scsi: lpfc: Raise nvme defaults to support a larger io and more connectivity

When nvme is enabled, change the default for two parameters:
 sg_seg_cnt - raise the per-io sg list size so that 1MB ios are
     supported (based on a 4k buffer per element).
 iocb_cnt - raise the number of buffers used for things like
     NVME LS request/responses to allow more concurrent requests
     to for larger nvme configs.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: raise sg count for nvme to use available sg resources
James Smart [Mon, 10 Sep 2018 17:30:42 +0000 (10:30 -0700)]
scsi: lpfc: raise sg count for nvme to use available sg resources

The driver allocates a sg list per io struture based on a fixed maximum
size. When it registers with the protocol transports and indicates the max sg
list size it supports, the driver manipulates the fixed value to report a
lesser amount so that it has reserved space for sg elements that are used for
DIF.

The driver initialization path sets the cfg_sg_seg_cnt field to the
manipulated value for scsi. NVME initialization ran afterward and capped it's
maximum by the manipulated value for SCSI. This erroneously made NVME report
the SCSI-reduce-for-DIF value that reduced the max io size for nvme and wasted
sg elements.

Rework the driver so that cfg_sg_seg_cnt becomes the overall maximum size and
allow the max size to be tunable.  A separate (new) scsi sg count is then
setup with the scsi-modified reduced value. NVME then initializes based off
the overall maximum.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: Fix GFT_ID and PRLI logic for RSCN
James Smart [Mon, 10 Sep 2018 17:30:41 +0000 (10:30 -0700)]
scsi: lpfc: Fix GFT_ID and PRLI logic for RSCN

Driver only sends NVME PRLI to a device that also supports FCP.  This resuls
in remote ports that don't have fc_remote_ports created for them. The driver
is clearing the nlp_fc4_type for a ndlp at the wrong time.

Fix by moving the nlp_fc4_type clearing to the discovery engine in the
DEVICE_RECOVERY state. Also ensure that rport registration is done for all
nlp_fc4_types.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Update driver version to 10.00.00.11-k
Himanshu Madhani [Tue, 11 Sep 2018 17:18:27 +0000 (10:18 -0700)]
scsi: qla2xxx: Update driver version to 10.00.00.11-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix double increment of switch scan retry count
Quinn Tran [Tue, 11 Sep 2018 17:18:26 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix double increment of switch scan retry count

This patch fixes issue when switch command fails, current code increments
retry count twice. This results in a smaller number of retries.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix duplicate switch's Nport ID entries
Quinn Tran [Tue, 11 Sep 2018 17:18:25 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix duplicate switch's Nport ID entries

Current code relies on switch to provide a unique combination of WWPN +
NPORTID to tract an FC port.  This patch tries to detect a case where switch
data base can get corrupted where multiple WWPNs can have the same Nport ID.
The 1st Nport ID on the list will be kept while the duplicate Nport ID will be
discarded.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove stale debug trace message from tcm_qla2xxx
Quinn Tran [Tue, 11 Sep 2018 17:18:24 +0000 (10:18 -0700)]
scsi: qla2xxx: Remove stale debug trace message from tcm_qla2xxx

Remove stale debug trace.

Fixes: 1eb42f965ced ("qla2xxx: Make trace flags more readable")
Cc: stable@vger.kernel.org #4.10
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix premature command free
Quinn Tran [Tue, 11 Sep 2018 17:18:23 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix premature command free

When qla2xxx and Target Core gets out of sync during command cleanup, qla2xxx
will not free command until it is out of firmware's hand and Target Core has
called the release on the command.

This patch adds synchronization using cmd_lock and release flag.  If the
release flag is set, then qla2xxx will free up the command using
qlt_free_cmd() otherwise transport_generic_free_cmd() will be responsible for
relase of the command.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Reject bsg request if chip is down.
Quinn Tran [Tue, 11 Sep 2018 17:18:22 +0000 (10:18 -0700)]
scsi: qla2xxx: Reject bsg request if chip is down.

Reject bsg request if chip is down.  This prevent erroneous timeout.

Fixes: d051a5aa1c23 ("[SCSI] qla2xxx: Add an "is reset active" helper.")
Cc: stable@vger.kernel.org # 4.10
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: shutdown chip if reset fail
Quinn Tran [Tue, 11 Sep 2018 17:18:21 +0000 (10:18 -0700)]
scsi: qla2xxx: shutdown chip if reset fail

If chip unable to fully initialize, use full shutdown sequence to clear out
any stale FW state.

Fixes: e315cd28b9ef ("[SCSI] qla2xxx: Code changes for qla data structure refactoring")
Cc: stable@vger.kernel.org #4.10
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix stuck session in PLOGI state
Quinn Tran [Tue, 11 Sep 2018 17:18:20 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix stuck session in PLOGI state

On PLOGI complete + RSCN received, driver tries to handle RSCN but failed to
reset the session back to the beginning to restart the login process. Instead
the session was left in the Plogi complete without moving forward.  This patch
will push the session state back to the delete state and restart the
connection.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix early srb free on abort
Quinn Tran [Tue, 11 Sep 2018 17:18:19 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix early srb free on abort

Task abort can take 2 paths: 1) serial/synchronous abort where the calling
thread will put to sleep, wait for completion and free cmd resource.  2) async
abort where the cmd free will be free by the completion thread.  For path 2,
driver is freeing the SRB too early.

Fixes: f6145e86d21f ("scsi: qla2xxx: Fix race between switch cmd completion and timeout")
Cc: stable@vger.kernel.org # 4.19
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add mode control for each physical port
Quinn Tran [Tue, 11 Sep 2018 17:18:18 +0000 (10:18 -0700)]
scsi: qla2xxx: Add mode control for each physical port

Add ability to allow each physical port to control operating mode.  Current
code forces all ports to behave in one mode (i.e. initiator, target or
dual). This patch allows user to select the operating mode for each port.

- Driver must be loaded in dual mode to allow resource allocation

modprobe qla2xxx qlini_mode=dual

- In addition user can make adjustment to exchange resources using following
  command

echo 1024 > /sys/class/scsi_host/host<x>/ql2xiniexchg
echo 1024 > /sys/class/scsi_host/host<x>/ql2xexchoffld

- trigger mode change and new setting of ql2xexchoffld|ql2xiniexchg

echo [<value>] > /sys/class/scsi_host/host<x>/qlini_mode

where, value can be one of following
  - enabled
  - disabled
  - dual
  - exclusive

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix race condition for resource cleanup
Quinn Tran [Tue, 11 Sep 2018 17:18:17 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix race condition for resource cleanup

For Loop topology + Initiator, FW is in control of PLOGI/PRLI.  When link is
reset, driver will try to cleanup the session by doing an Implicit Logout.
Instead, the code is doing an Explicit Logout.  The explicit logout interferes
with FW state machine in trying to reconnect.  The implicit logout was meant
for FW to flush commands.  In loop, it is not needed because FW will auto
flush.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix dropped srb resource.
Quinn Tran [Tue, 11 Sep 2018 17:18:16 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix dropped srb resource.

When FW rejects a command due to "entry_status" error (malform IOCB), the srb
resource needs to be returned back for cleanup.  The filter to catch this is
in the wrong location.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix port speed display on chip reset
Quinn Tran [Tue, 11 Sep 2018 17:18:15 +0000 (10:18 -0700)]
scsi: qla2xxx: Fix port speed display on chip reset

Clear port speed value on chip reset.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Check for Register disconnect
Sawan Chandak [Tue, 11 Sep 2018 17:18:14 +0000 (10:18 -0700)]
scsi: qla2xxx: Check for Register disconnect

During adapter shutdown process check for register disconnect before
proceeding to call PCI functions.

Signed-off-by: Sawan Chandak <sawan.chandak@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Increase abort timeout value
Quinn Tran [Tue, 11 Sep 2018 17:18:13 +0000 (10:18 -0700)]
scsi: qla2xxx: Increase abort timeout value

Abort IOCB request can take up to 40s or 2 ABTS timeout.  We will wait for
ABTS response for 20s. On a timeout, second ABTS can go out with another 20s
timeout. On 2nd ABTS timeout FW will automatically do Logout.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Allow FC-NVMe underrun to be handled by transport
Darren Trapp [Tue, 11 Sep 2018 17:18:12 +0000 (10:18 -0700)]
scsi: qla2xxx: Allow FC-NVMe underrun to be handled by transport

This patch allows FC-NVMe under-run to be handled by transport

Signed-off-by: Darren Trapp <darren.trapp@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Update driver version to 10.00.00.10-k
Himanshu Madhani [Tue, 4 Sep 2018 21:19:21 +0000 (14:19 -0700)]
scsi: qla2xxx: Update driver version to 10.00.00.10-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Move ABTS code behind qpair
Quinn Tran [Tue, 4 Sep 2018 21:19:20 +0000 (14:19 -0700)]
scsi: qla2xxx: Move ABTS code behind qpair

Current abort code defaults to legacy single queue where hardware_lock is used
to protect command search.  This patch moves this code behind the QPair where
the qp_lock_ptr will reference the appropriate lock for either legacy/single
queue or MQ.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove stale ADISC_DONE event
Himanshu Madhani [Tue, 4 Sep 2018 21:19:19 +0000 (14:19 -0700)]
scsi: qla2xxx: Remove stale ADISC_DONE event

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix Remote port registration
Quinn Tran [Tue, 4 Sep 2018 21:19:18 +0000 (14:19 -0700)]
scsi: qla2xxx: Fix Remote port registration

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove ASYNC GIDPN switch command
Himanshu Madhani [Tue, 4 Sep 2018 21:19:17 +0000 (14:19 -0700)]
scsi: qla2xxx: Remove ASYNC GIDPN switch command

Using GPNFT/GNNFT command will be able to cover switch database with less
number of scans. This patch removes Get NportID with provided WWPN/GIDPN
switch command. By making this change, in large fabric with lots of remote
port or NPIV ports with noisy SAN, the number of GIDPN commands issued by a
port when it detects large number of remote ports going away or coming back,
can overwhelmn the switch and it can becomde unresponsive. In a case where the
fabric has not change, GIDPN is not required.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Reduce holding sess_lock to prevent CPU lock-up
Quinn Tran [Tue, 4 Sep 2018 21:19:16 +0000 (14:19 -0700)]
scsi: qla2xxx: Reduce holding sess_lock to prevent CPU lock-up

- Reduce sess_lock holding to prevent CPU Lock up. sess_lock was held across
  fc_port registration and deletion.  These calls can be blocked by upper
  layer. Sess_lock is also being accessed by interrupt thread.

- Reduce number of loops in processing work_list to prevent kernel complaint
  of CPU lockup or holding sess_lock.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Move {get|rel}_sp to base_qpair struct
Quinn Tran [Tue, 4 Sep 2018 21:19:15 +0000 (14:19 -0700)]
scsi: qla2xxx: Move {get|rel}_sp to base_qpair struct

Currently, qla2x00_[get_sp|rel_sp] routines does {get|release} of srb
resource/srb_mempool directly from qla_hw_data.  qla2x00_start_sp() is used to
issue management commands through the default Request Q 0 & Response Q 0 or
base_qpair. This patch moves access of these resources through
base_qpair. Instead of having knowledge of specific Q number and lock to
rsp/req queue, this change will key off the qpair that is assigned to the srb
resource. This lays the ground work for other routines to see this resource
through the qpair.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add support for ZIO6 interrupt threshold
Quinn Tran [Tue, 4 Sep 2018 21:19:14 +0000 (14:19 -0700)]
scsi: qla2xxx: Add support for ZIO6 interrupt threshold

Add sysfs support to control zio6 interrupt threshold. Using this sysfs hook
user can set when to generate interrupts. This value will be used to tell
firmware to generate interrupt at a certain interval.  If the number of
exchanges/commands fall below defined setting, then the interrupt will be
generated immediately by the firmware.

By default ZIO6 will coalesce interrupts to a specified interval
regardless of low traffic or high traffic.

[mkp: fixed several typos]

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix out of order Termination and ABTS response
Quinn Tran [Tue, 4 Sep 2018 21:19:13 +0000 (14:19 -0700)]
scsi: qla2xxx: Fix out of order Termination and ABTS response

Following changes are added by this patch

- Prevent ABTS Response from getting in front of Termination of exchange.
  Firmware requires driver to cleanup exchanges before ABTS response can be
  sent. This reduces ABTS response error which triggers extra command
  re-termination and re-sending of ABTS response.

- Add bits in driver and tracks CTIO/ATIO attribute bits for proper command
  Termination. A copy of the ATTR bits will be kept in the ABTS task
  management command as a back up copy, if an ABTS response encounters an
  error.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add logic to detect ABTS hang and response completion
Quinn Tran [Tue, 4 Sep 2018 21:19:12 +0000 (14:19 -0700)]
scsi: qla2xxx: Add logic to detect ABTS hang and response completion

ABTS error completion can trigger an exchange cleanup from the driver and
another ABTS response will be generated.  This retry of ABTS response can
cause loop between driver trying to send ABTS and firmware returning error.

This patch fixes this issue by adding logic to check for unresolved exchanges
and clean up before ABTS is retried.  This patch also addes the fix to use the
same qpair as the ABTS completion for the terminatation of exchange as well as
retry of ABTS response.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add appropriate debug info for invalid RX_ID
Quinn Tran [Tue, 4 Sep 2018 21:19:11 +0000 (14:19 -0700)]
scsi: qla2xxx: Add appropriate debug info for invalid RX_ID

When driver detect CTIO_INVALID_RX_ID status for CTIO, print message with
correct information to help with debugging.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix deadlock between ATIO and HW lock
Quinn Tran [Tue, 4 Sep 2018 21:19:10 +0000 (14:19 -0700)]
scsi: qla2xxx: Fix deadlock between ATIO and HW lock

Move ATIO queue processing out of hardware_lock to prevent deadlock.

Fixes: 3bb67df5b5f8 ("qla2xxx: Check for online flag instead of active reset when transmitting responses")
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Serialize mailbox request
Quinn Tran [Tue, 4 Sep 2018 21:19:09 +0000 (14:19 -0700)]
scsi: qla2xxx: Serialize mailbox request

For driver MBX submission, use mbox_busy to serialize request.  For Userspace
MBX submission, use optrom mutex to serialize request.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Update driver to version 10.00.00.09-k
Himanshu Madhani [Fri, 31 Aug 2018 18:24:39 +0000 (11:24 -0700)]
scsi: qla2xxx: Update driver to version 10.00.00.09-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Terminate Plogi/PRLI if WWN is 0
Quinn Tran [Fri, 31 Aug 2018 18:24:38 +0000 (11:24 -0700)]
scsi: qla2xxx: Terminate Plogi/PRLI if WWN is 0

When driver receive PLOGI/PRLI from FW, the WWPN value will be provided.  If
it is not, then driver will terminate it.  The WWPN allows driver to locate
the session or create a new session.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Defer chip reset until target mode is enabled
Quinn Tran [Fri, 31 Aug 2018 18:24:37 +0000 (11:24 -0700)]
scsi: qla2xxx: Defer chip reset until target mode is enabled

For target mode, any chip reset triggered before target mode is enabled will
be held off until user is ready to enable.  This prevents the chip from
starting or running before it is intended.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix iIDMA error
Quinn Tran [Fri, 31 Aug 2018 18:24:36 +0000 (11:24 -0700)]
scsi: qla2xxx: Fix iIDMA error

When switch responds with error for Get Port Speed Command (GPSC), driver
should not proceed with telling FW about the speed of the remote port.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove all rports if fabric scan retry fails
Quinn Tran [Fri, 31 Aug 2018 18:24:35 +0000 (11:24 -0700)]
scsi: qla2xxx: Remove all rports if fabric scan retry fails

When all fabric scan retries fail, remove all RPorts, DMA resources for the
command. Otherwise we have stale Rports.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Force fw cleanup on ADISC error
Quinn Tran [Fri, 31 Aug 2018 18:24:34 +0000 (11:24 -0700)]
scsi: qla2xxx: Force fw cleanup on ADISC error

Turn ON logout_on_delete flag to make sure firmware resource for fcport is
cleaned up on ADISC error.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Turn off IOCB timeout timer on IOCB completion
Quinn Tran [Fri, 31 Aug 2018 18:24:33 +0000 (11:24 -0700)]
scsi: qla2xxx: Turn off IOCB timeout timer on IOCB completion

Turn off IOCB timeout timer on IOCB completion instead of turning it off in a
deferred task.  This prevent false alarm if the deferred task is stalled out.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Decrement login retry count for only plogi
Quinn Tran [Fri, 31 Aug 2018 18:24:32 +0000 (11:24 -0700)]
scsi: qla2xxx: Decrement login retry count for only plogi

Decrement login retry count only for plogi instead of number of attempts made
for login.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Move rport registration out of internal work_list
Quinn Tran [Fri, 31 Aug 2018 18:24:31 +0000 (11:24 -0700)]
scsi: qla2xxx: Move rport registration out of internal work_list

Currently, the rport registration is being called from a single work element
that is used to process QLA internal "work_list".  This work_list is meant for
quick and simple task (ie no sleep).  The Rport registration process sometime
can be delayed by upper layer.  This causes back pressure with the internal
queue where other jobs are unable to move forward.

This patch will schedule the registration process with a new work element
(fc_port.reg_work).  While the RPort is being registered, the current state of
the fcport will not move forward until the registration is done.  If the state
of the fabric has changed, a new field/next_disc_state will record the next
action on whether to 'DELETE' or 'Reverify the session/ADISC'.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Remove redundant check for fcport deletion
Quinn Tran [Fri, 31 Aug 2018 18:24:30 +0000 (11:24 -0700)]
scsi: qla2xxx: Remove redundant check for fcport deletion

Remove redundant check for fcport is deleted or being delete.  The same check
is already in the deletion routine.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Update rscn_rcvd field to more meaningful scan_needed
Quinn Tran [Fri, 31 Aug 2018 18:24:29 +0000 (11:24 -0700)]
scsi: qla2xxx: Update rscn_rcvd field to more meaningful scan_needed

Rename rscn_rcvd field to scan_needed to be more meaningful.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>