openwrt/staging/blogic.git
5 years agoscsi: target/iscsi: Convert comments about locking into runtime checks
Bart Van Assche [Fri, 25 Jan 2019 18:34:53 +0000 (10:34 -0800)]
scsi: target/iscsi: Convert comments about locking into runtime checks

Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/iscsi: Remove an incorrect comment
Bart Van Assche [Fri, 25 Jan 2019 18:34:52 +0000 (10:34 -0800)]
scsi: target/iscsi: Remove an incorrect comment

The single iscsit_start_nopin_response_timer() caller does not hold any
locks. Hence remove the comment above this function.

Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: RDMA/srpt: Fix a credit leak for aborted commands
Bart Van Assche [Fri, 25 Jan 2019 18:34:51 +0000 (10:34 -0800)]
scsi: RDMA/srpt: Fix a credit leak for aborted commands

Make sure that the next time a response is sent to the initiator that the
credit it had allocated for the aborted request gets freed.

Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: 131e6abc674e ("target: Add TFO->abort_task for aborted task resources release") # v3.15
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: RDMA/srpt: Rework I/O context allocation
Bart Van Assche [Fri, 25 Jan 2019 18:34:50 +0000 (10:34 -0800)]
scsi: RDMA/srpt: Rework I/O context allocation

Instead of maintaining a list of free I/O contexts, use an sbitmap data
structure to track which I/O contexts are in use and which are free. This
makes the ib_srpt driver more consistent with other LIO drivers.

Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: RDMA/srpt: Fix handling of TMF submission failure
Bart Van Assche [Fri, 25 Jan 2019 18:34:49 +0000 (10:34 -0800)]
scsi: RDMA/srpt: Fix handling of TMF submission failure

If submitting a TMF to the target core fails, send the "FUNCTION REJECTED"
response to the initiator.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: RDMA/srpt: Fix handling of command / TMF submission failure
Bart Van Assche [Fri, 25 Jan 2019 18:34:48 +0000 (10:34 -0800)]
scsi: RDMA/srpt: Fix handling of command / TMF submission failure

If submitting an SRP IU to the target core fails, send the SCSI response
"BUSY" to the initiator instead of not sending any response.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/core: Add target_send_busy()
Bart Van Assche [Fri, 25 Jan 2019 18:34:47 +0000 (10:34 -0800)]
scsi: target/core: Add target_send_busy()

Introduce a function that sends the SCSI status "BUSY" back to the
initiator. The next patch will add a call to this function in the srpt
target driver.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/core: Inline transport_lun_remove_cmd()
Bart Van Assche [Fri, 25 Jan 2019 18:34:46 +0000 (10:34 -0800)]
scsi: target/core: Inline transport_lun_remove_cmd()

Remove the code that clears .se_lun from transport_cmd_check_stop_to_fabric()
such that the transport_lun_remove_cmd() call can be moved into
target_release_cmd_kref(). Because this guarantees that
transport_lun_remove_cmd() will be called exactly once, it is safe to change
the cmpxchg() call into a test of se_cmd.lun_ref_active. Inline
transport_lun_remove_cmd() because it is not worth to keep it as a separate
function.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/core: Simplify the LUN RESET implementation
Bart Van Assche [Fri, 25 Jan 2019 18:34:45 +0000 (10:34 -0800)]
scsi: target/core: Simplify the LUN RESET implementation

Due to the task management handling rework it is safe to wait for a TMF
that is not in the active state. Hence remove the CMD_T_ACTIVE test from
core_tmr_drain_tmr_list(). Additionally, call __target_check_io_state()
instead of open coding it.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/core: Remove several state tests from the TMF code
Bart Van Assche [Fri, 25 Jan 2019 18:34:44 +0000 (10:34 -0800)]
scsi: target/core: Remove several state tests from the TMF code

Whether or not a session is being torn down does not affect whether or not
SCSI commands are in the task set. Hence remove the "tearing down" checks
from the TMF code. The TRANSPORT_ISTATE_PROCESSING check is left out
because it is now safe to wait for a command that is in that state. The
CMD_T_PRE_EXECUTE is left out because abort processing is postponed until
after commands have left the pre-execute state since the patch that makes
TMF processing synchronous.

See also commit 1c21a48055a6 ("target: Avoid early CMD_T_PRE_EXECUTE
failures during ABORT_TASK").

Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: target/core: Remove the write_pending_status() callback function
Bart Van Assche [Fri, 25 Jan 2019 18:34:43 +0000 (10:34 -0800)]
scsi: target/core: Remove the write_pending_status() callback function

Due to the patch that makes TMF handling synchronous the
write_pending_status() callback function is no longer called.  Hence remove
it.

Acked-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Reviewed-by: Andy Grover <agrover@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Himanshu Madhani <himanshu.madhani@qlogic.com>
Cc: Quinn Tran <quinn.tran@qlogic.com>
Cc: Saurav Kashyap <saurav.kashyap@qlogic.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: csiostor: Remove set but not used variable 'pln'
YueHaibing [Fri, 25 Jan 2019 01:57:19 +0000 (01:57 +0000)]
scsi: csiostor: Remove set but not used variable 'pln'

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

drivers/scsi/csiostor/csio_attr.c: In function 'csio_fcoe_free_vnp':
drivers/scsi/csiostor/csio_attr.c:500:21: warning:
 variable 'pln' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add new FC-NVMe enable BIT to enable FC-NVMe feature
Giridhar Malavali [Wed, 30 Jan 2019 17:50:44 +0000 (09:50 -0800)]
scsi: qla2xxx: Add new FC-NVMe enable BIT to enable FC-NVMe feature

This patch adds new BIT detection to enable FC-NVMe feature in the driver.

[mkp: fixed Giridhar's SoB]

Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Add missing seq_printf() call in hisi_sas_show_row_32()
John Garry [Fri, 25 Jan 2019 14:22:39 +0000 (22:22 +0800)]
scsi: hisi_sas: Add missing seq_printf() call in hisi_sas_show_row_32()

This call must have been missed when I reworked the debugfs feature for
upstreaming, so add it back.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd
John Garry [Fri, 25 Jan 2019 14:22:38 +0000 (22:22 +0800)]
scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd

A NULL-pointer dereference was introduced for TMF SSP commands from the
upstreaming reworking.

Fix this by relocating the scsi_get_prot_op() callsite.

Fixes: d6a9000b81be ("scsi: hisi_sas: Add support for DIF feature for v2 hw")
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Some misc tidy-up
John Garry [Fri, 25 Jan 2019 14:22:37 +0000 (22:22 +0800)]
scsi: hisi_sas: Some misc tidy-up

Sparse detected some problems in the driver, so tidy them up.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Correct memory allocation size for DQ debugfs
Luo Jiaxing [Fri, 25 Jan 2019 14:22:36 +0000 (22:22 +0800)]
scsi: hisi_sas: Correct memory allocation size for DQ debugfs

Some sizes we allocate for debugfs structure are incorrect, so fix them.

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>
5 years agoscsi: hisi_sas: Fix losing directly attached disk when hot-plug
Xiaofei Tan [Fri, 25 Jan 2019 14:22:35 +0000 (22:22 +0800)]
scsi: hisi_sas: Fix losing directly attached disk when hot-plug

Hot-plugging SAS wire of direct hard disk backplane may cause disk lost. We
have done this test with several types of SATA disk from different venders,
and only two models from Seagate has this problem, ST4000NM0035-1V4107 and
ST3000VM002-1ET166.

The root cause is that the disk doesn't send D2H frame after OOB finished.
SAS controller will issue phyup interrupt only when D2H frame is received,
otherwise, will be waiting there all the time.

When this issue happen, we can find the disk again with link reset.  To fix
this issue, we setup an timer after OOB finished. If the PHY is not up in
20s, do link reset. Notes: the 20s is an experience value.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G
Luo Jiaxing [Fri, 25 Jan 2019 14:22:34 +0000 (22:22 +0800)]
scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G

The SAS controller cannot support a programmed minimum linkrate of > 1.5G
(it will always negotiate to 1.5G at least), so just reject it.

This solves a strange situation where the PHY negotiated linkrate may be
less than the programmed minimum linkrate.

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>
5 years agoscsi: hisi_sas: Remove unused parameter of function hisi_sas_alloc()
Xiang Chen [Fri, 25 Jan 2019 14:22:33 +0000 (22:22 +0800)]
scsi: hisi_sas: Remove unused parameter of function hisi_sas_alloc()

In function hisi_sas_alloc(), parameter shost is not used, so remove it.

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>
5 years agoscsi: hisi_sas: remove the check of sas_dev status in hisi_sas_I_T_nexus_reset()
Xiang Chen [Fri, 25 Jan 2019 14:22:32 +0000 (22:22 +0800)]
scsi: hisi_sas: remove the check of sas_dev status in hisi_sas_I_T_nexus_reset()

When issing a hardreset to a SATA device when running IO, it is possible
that abnormal CQs of the device are returned. Then enter error handler, it
doesn't enter function hisi_sas_abort_task() as there is no timeout IO, and
it doesn't set device as HISI_SAS_DEV_EH. So when hardreset by libata
later, it actually doesn't issue hardreset as there is a check to judge
whether device is in error.

For this situation, actually need to hardreset the device to recover.
So remove the check of sas_dev status in hisi_sas_I_T_nexus_reset().

Before we add the check to avoid the endless loop of reset for
directly-attached SATA device at probe time, actually we flutter it for
it, so it is not necessary to add the check now.

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>
5 years agoscsi: hisi_sas: shutdown axi bus to avoid exception CQ returned
Xiang Chen [Fri, 25 Jan 2019 14:22:31 +0000 (22:22 +0800)]
scsi: hisi_sas: shutdown axi bus to avoid exception CQ returned

When injecting 2 bit ECC error, it will cause fatal AXI interrupts. Before
the recovery of SAS controller reset, the internal of SAS controller is in
error. If CQ interrupts return at the time, actually it is exception CQ
interrupt, and it may cause resource release in disorder.

To avoid the exception situation, shutdown AXI bus after fatal AXI
interrupt. In SAS controller reset, it will restart AXI bus. For later
version of v3 hw, hardware will shutdown AXI bus for this situation, so
just fix current ver of v3 hw.

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>
5 years agoscsi: hisi_sas: send primitive NOTIFY to SSP situation only
Xiang Chen [Fri, 25 Jan 2019 14:22:30 +0000 (22:22 +0800)]
scsi: hisi_sas: send primitive NOTIFY to SSP situation only

Send primitive NOTIFY to SSP situation only, or it causes underflow issue
when sending IO. Also rename hisi_sas_hw.sl_notify() to hisi_sas_hw.
sl_notify_ssp().

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>
5 years agoscsi: hisi_sas: Add debugfs ITCT file and add file operations
Luo Jiaxing [Fri, 25 Jan 2019 14:22:29 +0000 (22:22 +0800)]
scsi: hisi_sas: Add debugfs ITCT file and add file operations

This patch creates debugfs file for ITCT and adds file operations.

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>
5 years agoscsi: hisi_sas: Fix type casting and missing static qualifier in debugfs code
John Garry [Fri, 25 Jan 2019 14:22:28 +0000 (22:22 +0800)]
scsi: hisi_sas: Fix type casting and missing static qualifier in debugfs code

Sparse can detect some type casting issues in the debugfs code, so fix it
up.

Also a missing static qualifier is added to hisi_sas_debugfs_to_reg_name().

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: No need to check return value of debugfs_create functions
John Garry [Fri, 25 Jan 2019 14:22:27 +0000 (22:22 +0800)]
scsi: hisi_sas: No need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value. The function can work or not, but the code logic should never do
something different based on this.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: pcmcia: nsp_cs: Remove unnecessary parentheses
Nathan Chancellor [Mon, 10 Dec 2018 23:55:40 +0000 (16:55 -0700)]
scsi: pcmcia: nsp_cs: Remove unnecessary parentheses

Clang warns:

drivers/scsi/pcmcia/nsp_cs.c:1137:27: warning: equality comparison with
extraneous parentheses [-Wparentheses-equality]
                if ((tmpSC->SCp.Message == MSG_COMMAND_COMPLETE)) {
                     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/pcmcia/nsp_cs.c:1137:27: note: remove extraneous
parentheses around the comparison to silence this warning
                if ((tmpSC->SCp.Message == MSG_COMMAND_COMPLETE)) {
                    ~                   ^                      ~
drivers/scsi/pcmcia/nsp_cs.c:1137:27: note: use '=' to turn this
equality comparison into an assignment
                if ((tmpSC->SCp.Message == MSG_COMMAND_COMPLETE)) {
                                        ^~
                                        =
1 warning generated.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: nsp32: Remove unnecessary self assignment in nsp32_set_sync_entry
Nathan Chancellor [Mon, 10 Dec 2018 23:51:56 +0000 (16:51 -0700)]
scsi: nsp32: Remove unnecessary self assignment in nsp32_set_sync_entry

Clang warns:

drivers/scsi/nsp32.c:2444:14: warning: explicitly assigning value of
variable of type 'unsigned char' to itself [-Wself-assign]
        offset      = offset;
        ~~~~~~      ^

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: GOTO Masanori <gotom@debian.or.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: prefix header search paths with $(srctree)/
Masahiro Yamada [Fri, 25 Jan 2019 07:09:04 +0000 (16:09 +0900)]
scsi: prefix header search paths with $(srctree)/

Currently, the Kbuild core manipulates header search paths in a crazy way
[1].

To fix this mess, I want all Makefiles to add explicit $(srctree)/ to the
search paths in the srctree. Some Makefiles are already written in that
way, but not all. The goal of this work is to make the notation consistent,
and finally get rid of the gross hacks.

Having whitespaces after -I does not matter since commit 48f6e3cf5bc6
("kbuild: do not drop -I without parameter").

[1]: https://patchwork.kernel.org/patch/9632347/

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: remove unneeded header search paths
Masahiro Yamada [Fri, 25 Jan 2019 07:09:03 +0000 (16:09 +0900)]
scsi: remove unneeded header search paths

I was able to build without these extra header search paths.

Especially, the header search path -I. in kernel Makefiles is always
suspicious; it allows the compiler to search for headers in the top of
$(srctree), where obviously no header file exists.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Remove set but not used variable 'vdev'
YueHaibing [Fri, 25 Jan 2019 02:00:14 +0000 (10:00 +0800)]
scsi: fnic: Remove set but not used variable 'vdev'

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

drivers/scsi/fnic/vnic_wq.c: In function 'vnic_wq_alloc_bufs':
drivers/scsi/fnic/vnic_wq.c:50:19: warning:
 variable 'vdev' set but not used [-Wunused-but-set-variable]

drivers/scsi/fnic/vnic_rq.c: In function 'vnic_rq_alloc_bufs':
drivers/scsi/fnic/vnic_rq.c:30:19: warning:
 variable 'vdev' set but not used [-Wunused-but-set-variable]

Never used since introduction.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Protect against READ(6) or WRITE(6) with zero block transfer length
Bart Van Assche [Wed, 23 Jan 2019 19:12:37 +0000 (11:12 -0800)]
scsi: sd: Protect against READ(6) or WRITE(6) with zero block transfer length

Since the READ(6) and WRITE(6) commands interpret a zero in the transfer
length field in the CDB as 256 logical blocks, avoid submitting such
commands.

Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Reported-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: Remove scsi_to_u32()
Bart Van Assche [Wed, 23 Jan 2019 19:08:05 +0000 (11:08 -0800)]
scsi: libsas: Remove scsi_to_u32()

Since the function scsi_to_u32() is identical to get_unaligned_be32(),
change all scsi_to_u32() calls into get_unaligned_be32() calls.

Cc: Jian Luo <luojian5@huawei.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
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: hpsa: clean up two indentation issues
Colin Ian King [Tue, 22 Jan 2019 15:18:30 +0000 (15:18 +0000)]
scsi: hpsa: clean up two indentation issues

There are two statements that are indented incorrectly. Fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:06 +0000 (16:09 +0100)]
scsi: qla2xxx: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: qla2xxx-upstream@qlogic.com
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qedf: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:05 +0000 (16:09 +0100)]
scsi: qedf: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: QLogic-Storage-Upstream@cavium.com
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: lpfc: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:04 +0000 (16:09 +0100)]
scsi: lpfc: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: James Smart <james.smart@broadcom.com>
Cc: Dick Kennedy <dick.kennedy@broadcom.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: snic: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:03 +0000 (16:09 +0100)]
scsi: snic: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:02 +0000 (16:09 +0100)]
scsi: fnic: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: Satish Kharat <satishkh@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: csiostor: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:01 +0000 (16:09 +0100)]
scsi: csiostor: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Varun Prakash <varun@chelsio.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Oza Pawandeep <poza@codeaurora.org>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bfa: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 22 Jan 2019 15:09:00 +0000 (16:09 +0100)]
scsi: bfa: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return
value.  The function can work or not, but the code logic should never do
something different based on this.

[mkp: removed unused label]

Cc: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: MAINTAINERS: Move FCoE to Hannes Reinecke
Johannes Thumshirn [Mon, 28 Jan 2019 11:06:34 +0000 (12:06 +0100)]
scsi: MAINTAINERS: Move FCoE to Hannes Reinecke

I'll be moving on to different things in the storage stack and Hannes
agreed to take over FCoE.

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fcoe: remove unneeded fcoe_ctlr_destroy_store export
Greg Kroah-Hartman [Tue, 22 Jan 2019 14:28:18 +0000 (15:28 +0100)]
scsi: fcoe: remove unneeded fcoe_ctlr_destroy_store export

There's no need to export fcoe_ctlr_destroy_store as a symbol, so remove
the EXPORT_SYMBOL() line for it.

Cc: Johannes Thumshirn <jth@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fcoe: convert to use BUS_ATTR_WO
Greg Kroah-Hartman [Tue, 22 Jan 2019 14:27:35 +0000 (15:27 +0100)]
scsi: fcoe: convert to use BUS_ATTR_WO

We are trying to get rid of BUS_ATTR() and the usage of that in the fcoe
driver can be trivially converted to use BUS_ATTR_WO(), so use that
instead.

Cc: Johannes Thumshirn <jth@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Update driver version to v1.40.00.10-20190116
Ching Huang [Fri, 18 Jan 2019 03:01:49 +0000 (11:01 +0800)]
scsi: arcmsr: Update driver version to v1.40.00.10-20190116

From Ching Huang <ching2048@areca.com.tw>

Update driver version to v1.40.00.10-20190116.

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_B part 2
Ching Huang [Fri, 18 Jan 2019 02:58:51 +0000 (10:58 +0800)]
scsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_B part 2

From Ching Huang <ching2048@areca.com.tw>

For ACB_ADAPTER_TYPE_B controller, the read/write after hibernate and
resume may sometimes result in 'isr get an illegal ccb command' in
/var/log/messages. This patch fixes it.

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Use dma_alloc_coherent to replace dma_zalloc_coherent
Ching Huang [Fri, 18 Jan 2019 02:53:41 +0000 (10:53 +0800)]
scsi: arcmsr: Use dma_alloc_coherent to replace dma_zalloc_coherent

From Ching Huang <ching2048@areca.com.tw>

dma_zalloc_coherent will be phased out. Use dma_alloc_coherent instead.

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Update fnic driver version to 1.6.0.47
Satish Kharat [Fri, 18 Jan 2019 22:51:45 +0000 (14:51 -0800)]
scsi: fnic: Update fnic driver version to 1.6.0.47

Update fnic driver to version 1.6.0.47.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Enable fnic devcmd2 interface
Satish Kharat [Fri, 18 Jan 2019 22:51:44 +0000 (14:51 -0800)]
scsi: fnic: Enable fnic devcmd2 interface

This patch adds changes to check if fnic devcmd2 interface is exported by
the firmware. If devcmd2 interfaces is exported, driver starts using it
else falls back to fnic devcmd1 interface.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Adding devcmd2 init and posting interfaces
Satish Kharat [Fri, 18 Jan 2019 22:51:43 +0000 (14:51 -0800)]
scsi: fnic: Adding devcmd2 init and posting interfaces

This patch adds fnic devcmd2 interfaces for initialization and posting
commands to fw.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Add devcmd2 initialization helpers
Satish Kharat [Fri, 18 Jan 2019 22:51:42 +0000 (14:51 -0800)]
scsi: fnic: Add devcmd2 initialization helpers

This patch adds the devcmd2 wq initalization and devcmd2 ring allocation
helper interfaces used by devcmd2 init.

[mkp: typos]
Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: fnic devcmd2 controller definitions
Satish Kharat [Fri, 18 Jan 2019 22:51:41 +0000 (14:51 -0800)]
scsi: fnic: fnic devcmd2 controller definitions

This patch adds the fnic devcmd2 controller definitions.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: fnic devcmd2 interface definitions
Satish Kharat [Fri, 18 Jan 2019 22:51:40 +0000 (14:51 -0800)]
scsi: fnic: fnic devcmd2 interface definitions

This patch adds the fnic devcmd2 command structre and the command result
structure definitions.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Impose upper limit on max. # of CQs processed per intr
Satish Kharat [Tue, 15 Jan 2019 01:09:29 +0000 (17:09 -0800)]
scsi: fnic: Impose upper limit on max. # of CQs processed per intr

Impose an upper limit on the max number of CQ entries (corresponding to the
copy wq) processed in an interrupt.  Use module parameter to set the limit.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: RQ enable and then post descriptors
Satish Kharat [Tue, 15 Jan 2019 01:09:28 +0000 (17:09 -0800)]
scsi: fnic: RQ enable and then post descriptors

Do RQ enable before posting descriptor. This is needed for later hw
revisions.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: delaying vnic dev enable till after req intr
Satish Kharat [Tue, 15 Jan 2019 01:09:27 +0000 (17:09 -0800)]
scsi: fnic: delaying vnic dev enable till after req intr

Doing vnic_device_enable before this could cause interrupts to happen
before they are setup.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Warn when calling done for IO not issued to fw
Satish Kharat [Tue, 15 Jan 2019 01:09:26 +0000 (17:09 -0800)]
scsi: fnic: Warn when calling done for IO not issued to fw

The change is to print warning when scsi done is called for an IO that has
not yet been issued to the fw. Also adding sc and tag to debug print when
IO is cleaned up.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: fnic stats for max CQs processed and ISR time
Satish Kharat [Tue, 15 Jan 2019 01:09:25 +0000 (17:09 -0800)]
scsi: fnic: fnic stats for max CQs processed and ISR time

This change is to add fnic stats for the max number of CQs (corresponding
to copy WQ) processed in a given interrupt, max time taken by the ISR.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: Add port speed stat to fnic debug stats
Satish Kharat [Tue, 15 Jan 2019 01:09:24 +0000 (17:09 -0800)]
scsi: fnic: Add port speed stat to fnic debug stats

This patch adds the current fnic port speed stat to fnic debug stats.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: use fnic_lock to guard fnic->state_flags
Satish Kharat [Tue, 15 Jan 2019 01:09:23 +0000 (17:09 -0800)]
scsi: fnic: use fnic_lock to guard fnic->state_flags

Need to use fnic_lock as well as host lock in that order to set state
flags.

[mkp: typos]
Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: vnic_rq_clean change BUG_ON to WARN_ON
Satish Kharat [Tue, 15 Jan 2019 01:09:22 +0000 (17:09 -0800)]
scsi: fnic: vnic_rq_clean change BUG_ON to WARN_ON

rq->ctrl not enabled when this is called is bad but not fatal and can
continue.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: change fnic queue depth to 256
Satish Kharat [Tue, 15 Jan 2019 01:09:21 +0000 (17:09 -0800)]
scsi: fnic: change fnic queue depth to 256

This patch changes the default lun queuedepth for fnic to 256.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: fnic: support to display 20G port speed
Satish Kharat [Tue, 15 Jan 2019 01:09:20 +0000 (17:09 -0800)]
scsi: fnic: support to display 20G port speed

This patch is to add fnic 20G port speed display in sysfs.

[mkp: typo]

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: core: Remove an atomic instruction from the hot path
Bart Van Assche [Wed, 16 Jan 2019 00:50:03 +0000 (16:50 -0800)]
scsi: core: Remove an atomic instruction from the hot path

From scsi_init_command(), a function called by scsi_mq_prep_fn():

/* zero out the cmd, except for the embedded scsi_request */
memset((char *)cmd + sizeof(cmd->req), 0,
sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size);

In other words, scsi_mq_prep_fn() clears scsi_cmnd.flags. Hence move the
clear_bit() call into the else branch, the only branch in which this code
is necessary.

See also commit f1342709d18a ("scsi: Do not rely on blk-mq for double
completions").

Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Rename 'SCpnt' into 'cmd'
Bart Van Assche [Wed, 16 Jan 2019 00:50:02 +0000 (16:50 -0800)]
scsi: sd: Rename 'SCpnt' into 'cmd'

This patch makes the source code more uniform and does not change any
functionality.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: extracted this patch from a larger patch ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Clean up sd_setup_read_write_cmnd()
Martin K. Petersen [Wed, 16 Jan 2019 00:50:01 +0000 (16:50 -0800)]
scsi: sd: Clean up sd_setup_read_write_cmnd()

Rework sd_setup_read_write_cmnd() so it becomes more readable. Put all the
sanity checking at the head of the function and sanitize the logged error
messages. Move the legacy SCSI logging calls to the end of the functions
and reduce conditional nesting.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: ported this patch from kernel v4.11 to kernel v5.0 ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Create helper functions for read/write commands
Martin K. Petersen [Wed, 16 Jan 2019 00:50:00 +0000 (16:50 -0800)]
scsi: sd: Create helper functions for read/write commands

Create a helper function for each of the 6, 10, 16 and 32-byte READ/WRITE
variants and use those when setting up reads and writes.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: ported this patch from kernel v4.11 to kernel v5.0 and made
  function names shorter. ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Simplify misaligned I/O check
Martin K. Petersen [Wed, 16 Jan 2019 00:49:59 +0000 (16:49 -0800)]
scsi: sd: Simplify misaligned I/O check

Avoid open coding the checks for the supported logical block sizes and use
a mask to check for misaligned I/O. Use our helper functions to scale lba
and block count.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: ported this patch from kernel v4.11 to kernel v5.0 ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Be consistent about blocks vs. sectors
Martin K. Petersen [Wed, 16 Jan 2019 00:49:58 +0000 (16:49 -0800)]
scsi: sd: Be consistent about blocks vs. sectors

We have had several bugs due mixing sector and logical block size
terminology. In the block layer, a sector is a 512-byte unit regardless of
the logical block size of the underlying device. But the term "sector" is
still widely used in sd.c when referring to logical block sized units.

We previously introduced helper functions such as sectors_to_logical() and
logical_to_sectors() to make the distinction clear. Use these to make the
code in sd.c consistent wrt. logical blocks and block layer sectors.

Use "lba" to describe a logical block address and "nr_blocks" when counting
logical blocks. SBC uses "TRANSFER LENGTH" to describe the latter but this
term was avoided to prevent confusion with the very similar DMA transfer
size (->transfersize) which is counted in bytes.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: ported this patch from kernel v4.11 to kernel v5.0 ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Remove a local variable
Bart Van Assche [Wed, 16 Jan 2019 00:49:57 +0000 (16:49 -0800)]
scsi: sd: Remove a local variable

This patch does not change any functionality.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ bvanassche: extracted this patch from a larger patch ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: ufs: Remove select of phy-qcom-ufs from ufs-qcom
Evan Green [Fri, 11 Jan 2019 23:31:59 +0000 (15:31 -0800)]
scsi: ufs: Remove select of phy-qcom-ufs from ufs-qcom

CONFIG_SCSI_UFS_QCOM selects CONFIG_PHY_QCOM_UFS, assuming that this was
the only possible PHY driver Qualcomm's UFS controller would use. But in
SDM845, the UFS driver is bundled into phy-qcom-qmp, and phy-qcom-ufs is
unused.

Remove the select, since for SDM845 it adds useless drivers to the build.

Signed-off-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: doc: remove reference to tmscsim.txt file
Otto Sabart [Wed, 9 Jan 2019 19:08:56 +0000 (20:08 +0100)]
scsi: doc: remove reference to tmscsim.txt file

The tmscsim.txt doc file was removed in c121107d0f84.

Fixes: c121107d0f84 ("scsi: documentation: Obsolete documentation references")
Signed-off-by: Otto Sabart <ottosabart@seberm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery
John Garry [Fri, 4 Jan 2019 16:01:28 +0000 (00:01 +0800)]
scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery

   +----------+             +----------+
   |          |             |          |
   |          |--- 3.0 G ---|          |--- 6.0 G --- SAS  disk
   |          |             |          |
   |          |--- 3.0 G ---|          |--- 6.0 G --- SAS  disk
   |initiator |             |          |
   | device   |--- 3.0 G ---| Expander |--- 6.0 G --- SAS  disk
   |          |             |          |
   |          |--- 3.0 G ---|          |--- 6.0 G --- SATA disk  -->failed to connect
   |          |             |          |
   |          |             |          |--- 6.0 G --- SATA disk  -->failed to connect
   |          |             |          |
   +----------+             +----------+

According to Serial Attached SCSI - 1.1 (SAS-1.1):
If an expander PHY attached to a SATA PHY is using a physical link rate
greater than the maximum connection rate supported by the pathway from an
STP initiator port, a management application client should use the SMP PHY
CONTROL function (see 10.4.3.10) to set the PROGRAMMED MAXIMUM PHYSICAL
LINK RATE field of the expander PHY to the maximum connection rate
supported by the pathway from that STP initiator port.

Currently libsas does not support checking if this condition occurs, nor
rectifying when it does.

Such a condition is not at all common, however it has been seen on some
pre-silicon environments where the initiator PHY only supports a 1.5 Gbit
maximum linkrate, mated with 12G expander PHYs and 3/6G SATA phy.

This patch adds support for checking and rectifying this condition during
initial device discovery only.

We do support checking min pathway connection rate during revalidation phase,
when new devices can be detected in the topology. However we do not
support in the case of the the user reprogramming PHY linkrates, such that
min pathway condition is not met/maintained.

A note on root port PHY rates:
The libsas root port PHY rates calculation is broken. Libsas sets the
rates (min, max, and current linkrate) of a root port to the same linkrate
of the first PHY member of that same port. In doing so, it assumes that
all other PHYs which subsequently join the port to have the same
negotiated linkrate, when they could actually be different.

In practice this doesn't happen, as initiator and expander PHYs are
normally initialised with consistent min/max linkrates.

This has not caused an issue so far, so leave alone for now.

Tested-by: Jian Luo <luojian5@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: Check SMP PHY control function result
John Garry [Fri, 4 Jan 2019 16:01:27 +0000 (00:01 +0800)]
scsi: libsas: Check SMP PHY control function result

Currently the SMP PHY control execution result is checked, however the
function result for the command is not.

As such, we may be missing all potential errors, like SMP FUNCTION FAILED,
INVALID REQUEST FRAME LENGTH, etc., meaning the PHY control request has
failed.

In some scenarios we need to ensure the function result is accepted, so add
a check for this.

Tested-by: Jian Luo <luojian5@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: libsas: Fix some indentation in libsas.h
John Garry [Fri, 4 Jan 2019 16:01:26 +0000 (00:01 +0800)]
scsi: libsas: Fix some indentation in libsas.h

Currently much indentation in this file is done with whitespaces instead of
tabs, which can make reading difficult, so fix this up.

Some other little minor tidy-up is done, but this file still has many other
checkpatch warnings (generally linelength > 80 or function arguments have
no identifier names).

All libsas code can be audited for checkpatch issues later.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Fix DMA error when the DIF sg buffer crosses 4GB boundary
Giridhar Malavali [Fri, 21 Dec 2018 17:33:45 +0000 (09:33 -0800)]
scsi: qla2xxx: Fix DMA error when the DIF sg buffer crosses 4GB boundary

When SGE buffer containing DIF information crosses 4G boundary, it results
in DMA error. This patch fixes this issue by calculating SGE buffer size
and if it crosses 4G boundary, driver will split it into multiple SGE
buffers to avoid DMA error.

Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla2xxx: Add protection mask module parameters
Martin K. Petersen [Fri, 21 Dec 2018 17:33:44 +0000 (09:33 -0800)]
scsi: qla2xxx: Add protection mask module parameters

Allow user to selectively enable/disable DIF/DIX protection
capabilities mask.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: aic7xxx: aic79xx: mark expected switch fall-through
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:26:19 +0000 (22:26 -0600)]
scsi: aic7xxx: aic79xx: mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Notice that, in some cases, I replaced "FALLTHROUGH" with a "fall through"
annotation and then placed it at the bottom of the corresponding switch
case, which is what GCC is expecting to find.

Addresses-Coverity-ID: 114961 ("Missing break in switch")
Addresses-Coverity-ID: 114962 ("Missing break in switch")
Addresses-Coverity-ID: 114963 ("Missing break in switch")
Addresses-Coverity-ID: 114964 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bfa: bfa_ioc: Mark expected switch fall-throughs
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:27:32 +0000 (22:27 -0600)]
scsi: bfa: bfa_ioc: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Notice that, in this particular case, I replaced "!!! fall through !!!"
comment with "fall through" annotations, which is what GCC is expecting to
find.

Addresses-Coverity-ID: 146155 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bfa: bfa_fcs_rport: Mark expected switch fall-throughs
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:27:23 +0000 (22:27 -0600)]
scsi: bfa: bfa_fcs_rport: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Notice that I replaced "!! fall through !!" and "!!! fall through !!!"
comments with "fall through" annotations, which is what GCC is expecting to
find.

Addresses-Coverity-ID: 744899 ("Missing break in switch")
Addresses-Coverity-ID: 744900 ("Missing break in switch")
Addresses-Coverity-ID: 744901 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bfa: bfa_fcs_lport: Mark expected switch fall-throughs
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:27:15 +0000 (22:27 -0600)]
scsi: bfa: bfa_fcs_lport: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Notice that, in this particular case, I replaced "!!! fall through !!!"
with a "fall through" annotation, which is what GCC is expecting to find.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: esas2r: esas2r_init: mark expected switch fall-throughs
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:28:57 +0000 (22:28 -0600)]
scsi: esas2r: esas2r_init: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Bradley Grove <bgrove@atto.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: st: mark expected switch fall-throughs
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:33:54 +0000 (22:33 -0600)]
scsi: st: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Addresses-Coverity-ID: 114994 ("Missing break in switch")
Addresses-Coverity-ID: 114995 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: qla4xxx: ql4_os: mark expected switch fall-through
Gustavo A. R. Silva [Wed, 28 Nov 2018 04:33:43 +0000 (22:33 -0600)]
scsi: qla4xxx: ql4_os: mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Notice that, in this particular case, I replaced "allow fall-through" with
a "fall through" annotation, which is what GCC is expecting to find.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: bnx2i: fix indentation issue, remove a tab
Colin Ian King [Fri, 4 Jan 2019 17:02:24 +0000 (17:02 +0000)]
scsi: bnx2i: fix indentation issue, remove a tab

The return statement is indented incorrectly, fix this by removing a single
tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: sd: Make protection lookup tables static and relocate functions
John Garry [Tue, 8 Jan 2019 15:14:52 +0000 (23:14 +0800)]
scsi: sd: Make protection lookup tables static and relocate functions

Currently the protection lookup tables in sd_prot_flag_mask() and
sd_prot_op() are declared as non-static. As such, they will be rebuilt for
each respective function call.

Optimise by making them static.

This saves ~100B object code for sd.c:

Before:
   text    data     bss     dec     hex filename
  25403    1024      16   26443    674b drivers/scsi/sd.o

After:
  text    data     bss     dec     hex filename
  25299    1024      16   26339    66e3 drivers/scsi/sd.o

In addition, since those same functions are declared in sd.h, but each are
only referenced in sd.c, relocate them to that same c file.

The inline specifier is dropped also, since gcc should be able to make the
decision to inline.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: hisi_sas: Add debugfs IOST file and add file operations
Luo Jiaxing [Wed, 19 Dec 2018 15:56:46 +0000 (23:56 +0800)]
scsi: hisi_sas: Add debugfs IOST file and add file operations

This patch create debugfs file for IOST and add file operations.

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>
5 years agoscsi: hisi_sas: Add debugfs DQ file and add file operations
Luo Jiaxing [Wed, 19 Dec 2018 15:56:45 +0000 (23:56 +0800)]
scsi: hisi_sas: Add debugfs DQ file and add file operations

This patch create debugfs file for DQ and add file operations

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>
5 years agoscsi: hisi_sas: Add debugfs CQ file and add file operations
Luo Jiaxing [Wed, 19 Dec 2018 15:56:44 +0000 (23:56 +0800)]
scsi: hisi_sas: Add debugfs CQ file and add file operations

This patch create debugfs file for CQ and add file operations.

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>
5 years agoscsi: hisi_sas: Add debugfs for port registers
Luo Jiaxing [Wed, 19 Dec 2018 15:56:43 +0000 (23:56 +0800)]
scsi: hisi_sas: Add debugfs for port registers

This patch create debugfs file for port register and add file operations.

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>
5 years agoscsi: hisi_sas: Debugfs global register create file and add file operations
Luo Jiaxing [Wed, 19 Dec 2018 15:56:42 +0000 (23:56 +0800)]
scsi: hisi_sas: Debugfs global register create file and add file operations

This patch create debugfs file for global register and add file
operations.

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>
5 years agoscsi: hisi_sas: Take debugfs snapshot for all regs
Luo Jiaxing [Wed, 19 Dec 2018 15:56:41 +0000 (23:56 +0800)]
scsi: hisi_sas: Take debugfs snapshot for all regs

This patch takes snapshot for global regs, port regs, CQ, DQ, IOST, ITCT.

Add code for snapshot trig and generate dump directory.

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>
5 years agoscsi: hisi_sas: Alloc debugfs snapshot buffer memory for all registers
Luo Jiaxing [Wed, 19 Dec 2018 15:56:40 +0000 (23:56 +0800)]
scsi: hisi_sas: Alloc debugfs snapshot buffer memory for all registers

This patch allocates snapshot memory for global reg, port regs, CQ, DQ,
IOST, ITCT.

When we fail to allocate memory for some registers, we free the memory
and set hisi_sas_debugfs_enable as 0 to stop loading debugfs from running.

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>
5 years agoscsi: hisi_sas: Create root and device debugfs directories
Luo Jiaxing [Wed, 19 Dec 2018 15:56:39 +0000 (23:56 +0800)]
scsi: hisi_sas: Create root and device debugfs directories

This patch creates root directory at hisi_sas_init() and generates device
directory when we probe device driver.

And we remove the root directory at hisi_sas_exit(), but recursively
delete device directory when we remove device driver.

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>
5 years agoscsi: arcmsr: Update driver version to v1.40.00.10-20181217
Ching Huang [Wed, 19 Dec 2018 09:02:08 +0000 (17:02 +0800)]
scsi: arcmsr: Update driver version to v1.40.00.10-20181217

From Ching Huang <ching2048@areca.com.tw>

Update driver version to v1.40.00.10-20181217

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_B
Ching Huang [Wed, 19 Dec 2018 08:59:48 +0000 (16:59 +0800)]
scsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_B

From Ching Huang <ching2048@areca.com.tw>

Fix suspend/resume of ACB_ADAPTER_TYPE_B

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Separate 'set dma mask' as a function
Ching Huang [Wed, 19 Dec 2018 08:56:34 +0000 (16:56 +0800)]
scsi: arcmsr: Separate 'set dma mask' as a function

From Ching Huang <ching2048@areca.com.tw>

Separate 'set dma mask' as a function

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Add an option of set dma_mask_64 for ACB_ADAPTER_TYPE_A
Ching Huang [Wed, 19 Dec 2018 08:53:44 +0000 (16:53 +0800)]
scsi: arcmsr: Add an option of set dma_mask_64 for ACB_ADAPTER_TYPE_A

From Ching Huang <ching2048@areca.com.tw>

Add an option of set dma_mask_64 for ACB_ADAPTER_TYPE_A

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Update ACB_ADAPTER_TYPE_D for >4GB ccb addressing
Ching Huang [Wed, 19 Dec 2018 08:51:14 +0000 (16:51 +0800)]
scsi: arcmsr: Update ACB_ADAPTER_TYPE_D for >4GB ccb addressing

From Ching Huang <ching2048@areca.com.tw>

Update ACB_ADAPTER_TYPE_D for >4gb ccb addressing

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 years agoscsi: arcmsr: Update ACB_ADAPTER_TYPE_C for >4GB ccb addressing
Ching Huang [Wed, 19 Dec 2018 08:48:16 +0000 (16:48 +0800)]
scsi: arcmsr: Update ACB_ADAPTER_TYPE_C for >4GB ccb addressing

From Ching Huang <ching2048@areca.com.tw>

Update ACB_ADAPTER_TYPE_C for >4GB ccb addressing

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>