]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
7 years agoscsi: qla2xxx: Add FC-NVMe command handling
Duane Grigsby [Wed, 21 Jun 2017 20:48:42 +0000 (13:48 -0700)]
scsi: qla2xxx: Add FC-NVMe command handling

This patch adds logic to handle the completion of FC-NVMe commands and
creates a sub-command in the SRB command structure to manage NVMe
commands.

Signed-off-by: Darren Trapp <darren.trapp@cavium.com>
Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Anil Gurumurthy <anil.gurumurhty@cavium.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Add FC-NVMe port discovery and PRLI handling
Duane Grigsby [Wed, 21 Jun 2017 20:48:41 +0000 (13:48 -0700)]
scsi: qla2xxx: Add FC-NVMe port discovery and PRLI handling

Added logic to change the login process into an optional PRIL step for
FC-NVMe ports as a separate operation, such that we can change type to
0x28 (NVMe).

Currently, the driver performs the PLOGI/PRLI together as one operation,
but if the discovered port is an NVMe port then we first issue the PLOGI
and then we issue the PRLI. Also, the fabric discovery logic was changed
to mark each discovered FC NVMe port, so that we can register them with
the FC-NVMe transport later.

Signed-off-by: Darren Trapp <darren.trapp@cavium.com>
Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Anil Gurumurthy <anil.gurumurhty@cavium.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.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>
7 years agoscsi: qla2xxx: Update driver version to 9.01.00.00-k
himanshu.madhani@cavium.com [Wed, 14 Jun 2017 03:47:30 +0000 (20:47 -0700)]
scsi: qla2xxx: Update driver version to 9.01.00.00-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Include Exchange offload/Extended Login into FW dump
Quinn Tran [Wed, 14 Jun 2017 03:47:29 +0000 (20:47 -0700)]
scsi: qla2xxx: Include Exchange offload/Extended Login into FW dump

Add missing memory dump of Exchange Offload and Extended login into FW
dump.

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>
7 years agoscsi: qla2xxx: Move target stat counters from vha to qpair.
Quinn Tran [Wed, 14 Jun 2017 03:47:28 +0000 (20:47 -0700)]
scsi: qla2xxx: Move target stat counters from vha to qpair.

Move counters to qpair to reduce cache miss.

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>
7 years agoscsi: qla2xxx: Remove datasegs_per_cmd and datasegs_per_cont field
Quinn Tran [Wed, 14 Jun 2017 03:47:27 +0000 (20:47 -0700)]
scsi: qla2xxx: Remove datasegs_per_cmd and datasegs_per_cont field

These fields only hold one set of value. Replace it with macros to
reduce cache thrash.

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>
7 years agoscsi: qla2xxx: Remove unused tgt_enable_64bit_addr flag
Quinn Tran [Wed, 14 Jun 2017 03:47:26 +0000 (20:47 -0700)]
scsi: qla2xxx: Remove unused tgt_enable_64bit_addr flag

By default this flag is forced to true.  Remove this flag and
unneccessary check for this flag.

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>
7 years agoscsi: qla2xxx: Add debug logging routine for qpair
Quinn Tran [Wed, 14 Jun 2017 03:47:25 +0000 (20:47 -0700)]
scsi: qla2xxx: Add debug logging routine for qpair

For target main path io routines that uses qpair, create new logging &
debugging routines to use qpair instead of reaching for scsi_qla_host to
reduce cache thrash.

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>
7 years agoscsi: qla2xxx: Add function call to qpair for door bell
Quinn Tran [Wed, 14 Jun 2017 03:47:24 +0000 (20:47 -0700)]
scsi: qla2xxx: Add function call to qpair for door bell

Add call back to door bell for qpair. This help reduce access to
qla_hw_data structure, in order to reduce cach thrash.

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>
7 years agoscsi: qla2xxx: use shadow register for ISP27XX
Quinn Tran [Wed, 14 Jun 2017 03:47:23 +0000 (20:47 -0700)]
scsi: qla2xxx: use shadow register for ISP27XX

For ISP27XX, use shadow register to read FW provided REQQ's consumer
index.  The shadow register is dma'ed by firmware.

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>
7 years agoscsi: qla2xxx: move fields from qla_hw_data to qla_qpair
Quinn Tran [Wed, 14 Jun 2017 03:47:22 +0000 (20:47 -0700)]
scsi: qla2xxx: move fields from qla_hw_data to qla_qpair

- Move chip_reset, enable_class_2 fields from qla_hw_data to qla_qpair
  to reduce cache thrash for target MQ.
- Optimizations to reduce unnecessary memory load for good path io.

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>
7 years agoscsi: qla2xxx: Add fw_started flags to qpair
Quinn Tran [Wed, 14 Jun 2017 03:47:21 +0000 (20:47 -0700)]
scsi: qla2xxx: Add fw_started flags to qpair

Add fw_started flag to qpair to reduce cache thrash.  This reduce access
to qla_hw_data structure by each 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>
7 years agoscsi: qla2xxx: Add debug knob for user control workload
Quinn Tran [Wed, 14 Jun 2017 03:47:20 +0000 (20:47 -0700)]
scsi: qla2xxx: Add debug knob for user control workload

For Target mode, user can control the work load by placing qla2xxx's irq
vector on certain CPU via the smp_affinity knob. This patch allows user
to control the number of QPair's irq to be active. The irqs are
allocated at driver load time until unload. The work itself is placed on
the QPair based on user setting.

Usage:
  modprobe qla2xxx qlini_mode=disabled ql2xuctrlirq=1
  mount -t debugfs none /sys/kernel/debug
  echo 2 > /sys/kernel/debug/qla2xxx/qla2xxx_[host num]/naqp
  echo [cpu id] > /proc/irq/[irq id]/smp_affinity_list

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>
7 years agoscsi: qla2xxx: Fix mailbox failure while deleting Queue pairs
Sawan Chandak [Wed, 14 Jun 2017 03:47:19 +0000 (20:47 -0700)]
scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs

In target mode driver, queue pairs are not created during driver load
time, instead they are created at the configuration time after chip
reset.  If a user tries to load/unload driver after queue pairs are
created, then there would be mailbox failure, while deleting queue
pairs.  Flag is added to check if queue pairs are created or not. Queue
pairs will be deleted only If they were created during target
configuration.

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>
7 years agoscsi: qla2xxx: Enable Target Multi Queue
Quinn Tran [Wed, 14 Jun 2017 03:47:18 +0000 (20:47 -0700)]
scsi: qla2xxx: Enable Target Multi Queue

Enable Multi Queue for Target mode. At Initiator LUN scan time, each LUN
is assign to a QPair. Each QPair is affinitize to certain CPU. When new
cmd arrives from the wire, the lunid is used to search for qpair. The
qpair's affinitized cpuid will be used to queue up the work element.

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>
7 years agoscsi: qla2xxx: Preparation for Target MQ.
Quinn Tran [Wed, 14 Jun 2017 03:47:17 +0000 (20:47 -0700)]
scsi: qla2xxx: Preparation for Target MQ.

In Current code, Req Q 0, RespQ 0 & hardware_lock are the main resources
for sending and process completion of Target IO. These resources are now
referenced behind a new qpair/"struct qla_qpair base_qpair".  Main path
IO handle will access those resources via the qpair pointer in
preparation for Target 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>
7 years agoscsi: qla2xxx: Combine Active command arrays.
Quinn Tran [Wed, 14 Jun 2017 03:47:16 +0000 (20:47 -0700)]
scsi: qla2xxx: Combine Active command arrays.

Merge active/outstanding cmd arrays from target side and initiator side
together in prepration for Target Multi Queue support.

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>
7 years agoscsi: cxlflash: Update TMF command processing
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:54 +0000 (21:16 -0500)]
scsi: cxlflash: Update TMF command processing

Currently, the SCSI command presented to the device reset handler is used
to send TMFs to the AFU for a device reset. This behavior is incorrect as
the command presented is an actual command and not a special notification.
As such, it should only be used for reference and not be acted upon.

Additionally, the existing TMF transmission routine does not account for
actual errors from the hardware, only reflecting failure when a timeout
occurs. This can lead to a condition where the device reset handler is
presented with a false 'success'.

Update send_tmf() to dynamically allocate a private command for sending
the TMF command and properly reflect failure when the completed command
indicates an error or was aborted. Detect TMF commands during response
processing and avoid scsi_done() for these types of commands. Lastly,
update comments in the TMF processing paths to describe the new behavior.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Remove zeroing of private command data
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:44 +0000 (21:16 -0500)]
scsi: cxlflash: Remove zeroing of private command data

The SCSI core now zeroes the per-command private data area prior to
calling into the LLD. Replace the clearing operation that takes place
when the private command data reference is obtained with a routine that
performs common initializations. The zeroing that takes place in the
device reset path remains intact as the private command data associated
with the specified SCSI command is not guaranteed to be cleared.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Support WS16 unmap
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:33 +0000 (21:16 -0500)]
scsi: cxlflash: Support WS16 unmap

The cxlflash driver supports performing a write-same16 to scrub virtual
luns when they are released by a user. To date, AFUs for adapters that
are supported by cxlflash do not have the capability to unmap as part of
the WS operation. This can lead to fragmented flash devices which results
in performance degradation.

Future AFUs can optionally support unmap write-same commands and reflects
this support via the context control register. This provides userspace
applications with direct visibility such that they need not depend on a
host API.

Detect unmap support during cxlflash initialization by reading the context
control register associated with the primary hardware queue. Update the
existing write_same16() routine to set the unmap bit in the CDB when unmap
is supported by the host.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Support AFU debug
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:22 +0000 (21:16 -0500)]
scsi: cxlflash: Support AFU debug

Adopt the SISLite AFU debug capability to allow future CXL Flash
adapters the ability to better debug AFU issues. Update the SISLite
header with the changes necessary to support AFU debug operations
and create a host ioctl interface for user debug software. Also
update the cxlflash documentation to describe this new host ioctl.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Support LUN provisioning
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:13 +0000 (21:16 -0500)]
scsi: cxlflash: Support LUN provisioning

Adopt the SISLite AFU LUN provisioning capability to allow future CXL
Flash adapters the ability to better manage storage. Update the SISLite
header with the changes necessary to support LUN provision operations
and create a host ioctl interface for user LUN management software. Also
update the cxlflash documentation to describe this new host ioctl.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Refactor AFU capability checking
Matthew R. Ochs [Thu, 22 Jun 2017 02:16:02 +0000 (21:16 -0500)]
scsi: cxlflash: Refactor AFU capability checking

The existing AFU capability checking infrastructure is closely tied to
the command mode capability bits. In order to support new capabilities,
refactor the existing infrastructure to be more generic.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Introduce host ioctl support
Matthew R. Ochs [Thu, 22 Jun 2017 02:15:42 +0000 (21:15 -0500)]
scsi: cxlflash: Introduce host ioctl support

As staging for supporting various host management functions, add a host
ioctl infrastructure to filter ioctl commands and perform operations that
are common for all host ioctls. Also update the cxlflash documentation to
create a new section for documenting host ioctls.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Separate AFU internal command handling from AFU sync specifics
Matthew R. Ochs [Thu, 22 Jun 2017 02:15:31 +0000 (21:15 -0500)]
scsi: cxlflash: Separate AFU internal command handling from AFU sync specifics

To date the only supported internal AFU command is AFU sync. The logic
to send an internal AFU command is embedded in the specific AFU sync
handler and would need to be duplicated for new internal AFU commands.

In order to support new internal AFU commands, separate code that is
common for AFU internal commands into a generic transmission routine
and support passing back command status through an IOASA structure.
The first user of this new routine is the existing AFU sync command.
As a cleanup, use a descriptive name for the AFU sync command instead
of a magic number.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Create character device to provide host management interface
Uma Krishnan [Thu, 22 Jun 2017 02:15:18 +0000 (21:15 -0500)]
scsi: cxlflash: Create character device to provide host management interface

The cxlflash driver currently lacks host management interface. Future
devices supported by cxlflash will provide a variety of host-wide
management functions. Examples include LUN provisioning, hardware debug
support, and firmware download.

In order to provide a way to manage the device, a character device will
be created during probe of each adapter. This device will support a set of
ioctls defined in the SISLite specification from which administrators can
manage the adapter.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Add scsi command abort handler
Uma Krishnan [Thu, 22 Jun 2017 02:15:06 +0000 (21:15 -0500)]
scsi: cxlflash: Add scsi command abort handler

To date, CXL flash devices do not support a single command abort operation.
Instead, the SISLite specification provides a context reset operation to
cleanup all pending commands for a given context.

When a context reset is successful, it is guaranteed that the AFU has
aborted all currently pending I/O. This sequence is less invasive than a
device or host reset and can be executed to support scsi command abort
requests. Add eh_abort_handler callback support to process command timeouts
and abort requests.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Flush pending commands in cleanup path
Uma Krishnan [Thu, 22 Jun 2017 02:14:56 +0000 (21:14 -0500)]
scsi: cxlflash: Flush pending commands in cleanup path

When the AFU is reset in an error path, pending scsi commands can be
silently dropped without completion or a formal abort. This puts the onus
on the cxlflash driver to notify mid-layer and indicating that the command
can be retried.

Once the card has been quiesced, the hardware send queue lock is acquired
to prevent any data movement while the pending commands are processed.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Track pending scsi commands in each hardware queue
Uma Krishnan [Thu, 22 Jun 2017 02:14:43 +0000 (21:14 -0500)]
scsi: cxlflash: Track pending scsi commands in each hardware queue

Currently, there is no book keeping of the pending scsi commands in the
cxlflash driver. This lack of tracking in-flight requests is too
restrictive and requires a heavy-hammer reset each time an adapter error is
encountered. Additionally, it does not allow for commands to be properly
retried.

In order to avoid this problem and to better handle error path command
cleanup, introduce a linked list for each hardware queue that tracks
pending commands.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Handle AFU sync failures
Uma Krishnan [Thu, 22 Jun 2017 02:14:30 +0000 (21:14 -0500)]
scsi: cxlflash: Handle AFU sync failures

AFU sync operations are not currently evaluated for failure. This is
acceptable for paths where there is not a dependency on the AFU being
consistent with the host. Examples include link reset events and LUN
cleanup operations. On paths where there is a dependency, such as a LUN
open, a sync failure should be acted upon.

In the event of AFU sync failures, either log or cleanup as appropriate for
operations that are dependent on a successful sync completion.

Update documentation to reflect behavior in the event of an AFU sync
failure.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Schedule asynchronous reset of the host
Uma Krishnan [Thu, 22 Jun 2017 02:14:17 +0000 (21:14 -0500)]
scsi: cxlflash: Schedule asynchronous reset of the host

A context reset failure indicates the AFU is in a bad state. At present,
when such a situation occurs, no further action is taken. This leaves the
adapter in an unusable state with no recoverable actions.

To avoid this situation, context reset failures will be escalated to a host
reset operation. This will be done asynchronously to allow the acting
thread to return to the user with a failure.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Reset hardware queue context via specified register
Uma Krishnan [Thu, 22 Jun 2017 02:14:02 +0000 (21:14 -0500)]
scsi: cxlflash: Reset hardware queue context via specified register

Per the SISLite specification, context_reset() writes 0x1 to the LSB of the
reset register. When the AFU processes this reset request, it is expected
to clear the bit after reset is complete. The current implementation simply
checks that the entire value read back is not 1, instead of masking off the
LSB and evaluating it for a change to 0. Should the AFU manipulate other
bits during the reset (reading back a value of 0xF for example), successful
completion will be prematurely indicated given the existing logic.

Additionally, in the event that the context reset operation fails, there
does not currently exist a way to provide feedback to the initiator of the
reset. This poses a problem for the rare case that a context reset fails as
the caller will proceed on the assumption that all is well.

To remedy these issues, refactor the context reset routine to only mask off
the LSB when evaluating for success and return status to the caller. Also
update the context reset handler parameters to pass a hardware queue
reference instead of a single command to better reflect that the entire
queue associated with the context is impacted by the reset.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Update cxlflash_afu_sync() to return errno
Uma Krishnan [Thu, 22 Jun 2017 02:13:48 +0000 (21:13 -0500)]
scsi: cxlflash: Update cxlflash_afu_sync() to return errno

The cxlflash_afu_sync() routine returns a negative one to indicate any kind
of failure. This makes it impossible to establish why the error occurred.

Update the return codes to clearly indicate the failure cause to the
caller.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Combine the send queue locks
Uma Krishnan [Thu, 22 Jun 2017 02:13:32 +0000 (21:13 -0500)]
scsi: cxlflash: Combine the send queue locks

Currently there are separate spin locks for the two supported I/O queueing
models. This makes it difficult to serialize with paths outside the enqueue
path.

As a design simplification and to support serialization with enqueue
operations, move to only a single lock that is used for enqueueing
regardless of the queueing model.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sgiwd93: switch to dma_alloc_attrs
Christoph Hellwig [Fri, 16 Jun 2017 07:17:11 +0000 (09:17 +0200)]
scsi: sgiwd93: switch to dma_alloc_attrs

Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent
wrapper.

[mkp: fixed driver name]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: 53c700: switch to dma_alloc_attrs
Christoph Hellwig [Fri, 16 Jun 2017 07:17:12 +0000 (09:17 +0200)]
scsi: 53c700: switch to dma_alloc_attrs

Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent
wrapper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedi: Remove comparison of u16 idx with zero.
Christos Gkekas [Sat, 24 Jun 2017 16:24:45 +0000 (17:24 +0100)]
scsi: qedi: Remove comparison of u16 idx with zero.

Variable idx is defined as u16 thus statement (idx < 0) is always false
and should be removed.

Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: fix spelling mistake: "encrypytion" -> "encryption"
Colin Ian King [Mon, 26 Jun 2017 13:31:10 +0000 (14:31 +0100)]
scsi: hpsa: fix spelling mistake: "encrypytion" -> "encryption"

Trivial fix to spelling mistake in dev_info message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: redefine hisi_sas_phy.phy_type as u32
John Garry [Mon, 26 Jun 2017 10:27:28 +0000 (18:27 +0800)]
scsi: hisi_sas: redefine hisi_sas_phy.phy_type as u32

Element phy_type is a bitmask and it only ever has 2 bits possibly set,
and it is overkill to define as a u64, so redefine as a u32.

This change resolves static code check complaint that "phy->phy_type &=
~PORT_TYPE_SAS;" would unintentionally clear the high 32 bits as well.

Structure hisi_sas_phy is also reordered to ensure packing efficiency.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: Remove the definition of VLC_SA_RECEIVE_CREDENTIAL
Bart Van Assche [Fri, 23 Jun 2017 17:32:39 +0000 (10:32 -0700)]
scsi: Remove the definition of VLC_SA_RECEIVE_CREDENTIAL

The symbolic name VLC_SA_RECEIVE_CREDENTIAL is not used anywhere in the
kernel. Additionally, since SPC 5 the RECEIVE CREDENTIAL command is
obsolete. The VLC_SA_RECEIVE_CREDENTIAL definition is misleading since
it occurs outside the list of other variable length CDB service action
codes (READ_32, WRITE_32, ...). Hence remove this definition.

References: commit e9ccc998b70f ("[SCSI] Add missing SPC-4 CDB and
MAINTENANCE_[IN,OUT] service action definitions")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: aacraid: Don't copy uninitialized stack memory to userspace
Seth Forshee [Fri, 23 Jun 2017 14:04:22 +0000 (09:04 -0500)]
scsi: aacraid: Don't copy uninitialized stack memory to userspace

Both aac_send_raw_srb() and aac_get_hba_info() may copy stack allocated
structs to userspace without initializing all members of these
structs. Clear out this memory to prevent information leaks.

Fixes: 423400e64d377 ("scsi: aacraid: Include HBA direct interface")
Fixes: c799d519bf088 ("scsi: aacraid: Retrieve HBA host information ioctl")
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: bnx2i: missing error code in bnx2i_ep_connect()
Dan Carpenter [Fri, 23 Jun 2017 07:02:00 +0000 (10:02 +0300)]
scsi: bnx2i: missing error code in bnx2i_ep_connect()

If bnx2i_map_ep_dbell_regs() then we accidentally return NULL instead of
an error pointer.  It results in a NULL dereference in
iscsi_if_ep_connect().

Fixes: cf4e6363859d ("[SCSI] bnx2i: Add bnx2i iSCSI driver.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hptiop: make function hptiop_iop_request_callback_itl static
Colin Ian King [Thu, 22 Jun 2017 15:52:19 +0000 (16:52 +0100)]
scsi: hptiop: make function hptiop_iop_request_callback_itl static

The function hptiop_iop_request_callback_itl does not need to be in
global scope, so make it static.

Cleans up sparse warning:
"symbol 'hptiop_iop_request_callback_itl' was not declared. Should it
 be static?"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxgb4i: assign rxqs in round robin mode
Varun Prakash [Thu, 22 Jun 2017 10:17:49 +0000 (15:47 +0530)]
scsi: cxgb4i: assign rxqs in round robin mode

Assign rxq to TCP connections in round robin mode to use all available
rxqs.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fix typos and grammar in comments of scsi_transport_fc.c
Tyrel Datwyler [Wed, 21 Jun 2017 20:24:39 +0000 (16:24 -0400)]
scsi: fix typos and grammar in comments of scsi_transport_fc.c

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: fix refcount error on node list
James Smart [Wed, 21 Jun 2017 17:51:23 +0000 (10:51 -0700)]
scsi: lpfc: fix refcount error on node list

A change in remote port removal introduced a spurious put which can
cause a premature structure teardown. The affects were most notable when
the driver attempted to unload as a null pointer would be hit.

Fix by removing the unnecessary put.

Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix nvme io stoppage after link bounce
James Smart [Wed, 21 Jun 2017 17:37:58 +0000 (10:37 -0700)]
scsi: lpfc: Fix nvme io stoppage after link bounce

On link down, transport is calling driver to abort outstanding ios.
Driver erroneously rejects the abort if the port indicates it isn't
logged in - which will be the case after the link down. Thus, the io
can't clean up. This prevents reconnection at the transport level.

Fix by allowing abort to proceed.

Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: virtio_scsi: let host do exception handling
Paolo Bonzini [Wed, 21 Jun 2017 14:35:46 +0000 (16:35 +0200)]
scsi: virtio_scsi: let host do exception handling

virtio_scsi tries to do exception handling after the default 30 seconds
timeout expires.  However, it's better to let the host control the
timeout, otherwise with a heavy I/O load it is likely that an abort will
also timeout.  This leads to fatal errors like filesystems going
offline.

Disable the 'sd' timeout and allow the host to do exception handling,
following the precedent of the storvsc driver.

Hannes has a proposal to introduce timeouts in virtio, but this provides
an immediate solution for stable kernels too.

[mkp: fixed typo]

Reported-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: linux-scsi@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: don't include <generated/utsrelease.h>
Johannes Berg [Wed, 21 Jun 2017 11:40:05 +0000 (13:40 +0200)]
scsi: qla2xxx: don't include <generated/utsrelease.h>

There's no need to use the static UTS_RELEASE string, since
utsname()->release contains the same.

This avoids rebuilding this file for every change of the release string.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fc: drop residual tsk_mgmt_response and it_nexus_response
Kefeng Wang [Wed, 21 Jun 2017 02:48:30 +0000 (10:48 +0800)]
scsi: fc: drop residual tsk_mgmt_response and it_nexus_response

After commit 556e26a70b64 ("scsi: remove tsk_mgmt_response and
it_nexus_response transport methods"), the target driver support was
removed totally. Drop the residual.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: csiostor: update module version
Varun Prakash [Tue, 20 Jun 2017 14:11:21 +0000 (19:41 +0530)]
scsi: csiostor: update module version

Add -ko to the module version similar to module version of other Chelsio
drivers.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd: Use sysfs_match_string()
Martin K. Petersen [Thu, 25 May 2017 13:34:30 +0000 (09:34 -0400)]
scsi: sd: Use sysfs_match_string()

Avoid unnecessary snprintf() when formatting variables for display in
sysfs and switch to sysfs_match_string() for validating user input.

Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: scsi_dh_alua: remove synchronous STPG support
Christoph Hellwig [Mon, 19 Jun 2017 12:27:24 +0000 (14:27 +0200)]
scsi: scsi_dh_alua: remove synchronous STPG support

Since 9c58b395 ("scsi: scsi_devinfo: remove synchronous ALUA for NETAPP
devices") this code is unused.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: remove various unused blist flags
Christoph Hellwig [Mon, 19 Jun 2017 12:27:23 +0000 (14:27 +0200)]
scsi: remove various unused blist flags

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: storvsc: use default I/O timeout handler for FC devices
Long Li [Tue, 13 Jun 2017 21:34:05 +0000 (14:34 -0700)]
scsi: storvsc: use default I/O timeout handler for FC devices

FC disks issue I/O directly to the host storage port driver, this is
diffirent to VHD disks where I/O is virtualized and timeout is handled
by the host VSP (Virtualization Service Provider).

FC disks are usually setup in a multipath system, and they don't want to
reset timer on I/O timeout. Timeout is detected by multipath as a good
time to failover and recover.

Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: aacraid: fix leak of data from stack back to userspace
Colin Ian King [Mon, 15 May 2017 14:56:05 +0000 (15:56 +0100)]
scsi: aacraid: fix leak of data from stack back to userspace

The fields sense_data_size and sense_data are unitialized garbage from
the stack and are being copied back to userspace.  Fix this leak of
stack information by ensuring they are zero'd.

Detected by CoverityScan, CID#1435473 ("Uninitialized scalar variable")

Fixes: 423400e64d377 ("scsi: aacraid: Include HBA direct interface")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: update to revision to 11.4.0.1
James Smart [Fri, 16 Jun 2017 05:56:51 +0000 (22:56 -0700)]
scsi: lpfc: update to revision to 11.4.0.1

Set lpfc driver revision to 11.4.0.1

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Driver responds LS_RJT to Beacon Off ELS - Linux
James Smart [Fri, 16 Jun 2017 05:56:50 +0000 (22:56 -0700)]
scsi: lpfc: Driver responds LS_RJT to Beacon Off ELS - Linux

Beacon OFF from switch is rejected by driver.

Driver fails Beacon OFF if frequency is set to 0. As per fc-ls spec,
status, capability, frequency and duration fields are only applicable
for Beacon ON.

Remove frequency and type checks. Reject Beacon ON if duration is non
zero.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix crash in lpfc_sli_ringtxcmpl_put when nvmet gets an abort request.
James Smart [Fri, 16 Jun 2017 05:56:49 +0000 (22:56 -0700)]
scsi: lpfc: Fix crash in lpfc_sli_ringtxcmpl_put when nvmet gets an abort request.

When running nvme detach-ns /dev/nvme0n1 -n 1 command, the nvmet lpfc
driver crashes with this stack dump:

kernel BUG at /root/NVME/lpfc_8.4/lpfc_sli.c:1393!
invalid opcode: 0000 [#1] SMP
Workqueue: nvmet-fc-cpu0 nvmet_fc_do_work_on_cpu [nvmet_fc]
 lpfc_sli4_issue_wqe+0x357/0x440 [lpfc]
 lpfc_nvmet_xmt_fcp_abort+0x36b/0x5c0 [lpfc]
 nvmet_fc_abort_op+0x30/0x50 [nvmet_fc]
 nvmet_fc_do_work_on_cpu+0xd9/0x130 [nvmet_fc]
 process_one_work+0x14e/0x410
 worker_thread+0x116/0x490
 kthread+0xc7/0xe0
 ret_from_fork+0x3f/0x70

Crash is due to an uninitialized iocbq->vport pointer.

Explicitly set the iocbq->vport field to phba->pport in
lpfc_nvmet_sol_fcp_issue_abort as it does all abort iocbq initialization
in the routine.  Using phba->pport is ok because target does not support
NPIV instances.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix crash doing IO with resets
James Smart [Fri, 16 Jun 2017 05:56:48 +0000 (22:56 -0700)]
scsi: lpfc: Fix crash doing IO with resets

During every reset, IOCBs are allocated. So, at one point, number of
allocated IOCBs reaches maximum limit and lpfc_sli_next_iotag fails.

Allocate IOCBs only during initialization. Reuse them after every reset
instead of allocating new set of IOCBs.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix crash after firmware flash when IO is running.
James Smart [Fri, 16 Jun 2017 05:56:47 +0000 (22:56 -0700)]
scsi: lpfc: Fix crash after firmware flash when IO is running.

OS crashes after the completion of firmware download.

Failure in posting SCSI SGL buffers because number of SGL buffers is
less than total count. Some of the pending IOs are not completed by
driver. SGL buffers for these IOs are not added back to the list.
Pending IOs are not completed because lpfc_wq_list list is initialized
before completion of pending IOs.

Postpone lpfc_wq_list reinitialization by moving
lpfc_sli4_queue_destroy() after lpfc_hba_down_post().

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix SLI3 drivers attempting NVME ELS commands.
James Smart [Fri, 16 Jun 2017 05:56:46 +0000 (22:56 -0700)]
scsi: lpfc: Fix SLI3 drivers attempting NVME ELS commands.

In a server with an 8G adapter and a 32G adapter, running NVME and FCP,
the server would crash with the following stack.

RIP: 0010: ... lpfc_nvme_register_port+0x38/0x420 [lpfc]
 lpfc_nlp_state_cleanup+0x154/0x4f0 [lpfc]
 lpfc_nlp_set_state+0x9d/0x1a0 [lpfc]
 lpfc_cmpl_prli_prli_issue+0x35f/0x440 [lpfc]
 lpfc_disc_state_machine+0x78/0x1c0 [lpfc]
 lpfc_cmpl_els_prli+0x17c/0x1f0 [lpfc]
 lpfc_sli_sp_handle_rspiocb+0x39b/0x6b0 [lpfc]
 lpfc_sli_handle_slow_ring_event_s3+0x134/0x2d0 [lpfc]
 lpfc_work_done+0x8ac/0x13b0 [lpfc]
 lpfc_do_work+0xf1/0x1b0 [lpfc]

Crash, on the 8G adapter, is due to a vport which does not have a nvme
local port structure. It's not supposed to have one. NVME is not
supported on the 8G adapter, so the NVME PRLI, which started this flow
shouldn't have been sent in the first place.

Correct discovery engine to recognize when on an SLI3 rport, which
doesn't support SLI3, if the rport supports only NVME, don't send a NVME
PRLI. Instead, as no FC4 will be used, a LOGO is sent.  If rport is FCP
and NVME, only execute the SCSI PRLI.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Break up IO ctx list into a separate get and put list
James Smart [Fri, 16 Jun 2017 05:56:45 +0000 (22:56 -0700)]
scsi: lpfc: Break up IO ctx list into a separate get and put list

Since unsol rcv ISR and command cmpl ISR both access/lock this list,
separate get/put lists will reduce contention.

Replaced
struct list_head lpfc_nvmet_ctx_list;
with
struct list_head lpfc_nvmet_ctx_get_list;
struct list_head lpfc_nvmet_ctx_put_list;
and all correpsonding locks and counters.

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>
7 years agoscsi: lpfc: Reduce time spent in IRQ for received NVME commands
James Smart [Fri, 16 Jun 2017 05:56:44 +0000 (22:56 -0700)]
scsi: lpfc: Reduce time spent in IRQ for received NVME commands

Removed unnecessary bzero of context area. Due to size of sg list, added
a substantial delay and played havoc on cpu caches.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Vport creation is failing with "Link Down" error
James Smart [Fri, 16 Jun 2017 05:56:43 +0000 (22:56 -0700)]
scsi: lpfc: Vport creation is failing with "Link Down" error

Vport creation fails for SLI-3 adapters.

Mailbox submission fails because mailbox interrupt is disabled. Mailbox
interrupt is disabled during port reset.

Do reset only for physical port.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix nvme_info sysfs output to be consistent
James Smart [Fri, 16 Jun 2017 05:56:42 +0000 (22:56 -0700)]
scsi: lpfc: Fix nvme_info sysfs output to be consistent

First line of nvme_info output is not consistent. There is an Extra
colon in the format.

First line of output will contain one of the following strings:
NVME Initiator Enabled
NVME Target Enabled
NVME Disabled

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix system panic when express lane enabled.
James Smart [Fri, 16 Jun 2017 05:56:41 +0000 (22:56 -0700)]
scsi: lpfc: Fix system panic when express lane enabled.

There is a null pointer dereference that can happen in the FOF interrupt
handler.

The driver was not setting up cq->assoc_qp_for sli4_hba->oas_cq.

Initialize cq->assoc_qp before accessing it.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: modify internal abort dev flow for v3 hw
Xiang Chen [Wed, 14 Jun 2017 15:33:32 +0000 (23:33 +0800)]
scsi: hisi_sas: modify internal abort dev flow for v3 hw

There is a change for abort dev for v3 hw: add registers to configure
unaborted iptt for a device, and then inform this to logic.

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>
7 years agoscsi: hisi_sas: add v3 code to fill some more hw function pointers
Xiang Chen [Wed, 14 Jun 2017 15:33:31 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code to fill some more hw function pointers

Add code to fill the interface of phy_hard_reset, phy_get_max_linkrate,
and phy enable/disable.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add get_wideport_bitmap_v3_hw()
Xiang Chen [Wed, 14 Jun 2017 15:33:30 +0000 (23:33 +0800)]
scsi: hisi_sas: add get_wideport_bitmap_v3_hw()

Add code for interface get_wideport_bitmap.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 code to send internal abort command
Xiang Chen [Wed, 14 Jun 2017 15:33:29 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code to send internal abort command

Add code to prepare internal abort command.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 code for itct setup and free
Xiang Chen [Wed, 14 Jun 2017 15:33:28 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code for itct setup and free

Add code to itct setup and free for v3 hw.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 code to send ATA frame
Xiang Chen [Wed, 14 Jun 2017 15:33:27 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code to send ATA frame

Add code to prepare ATA frame for v3 hw

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 code to send SMP frame
Xiang Chen [Wed, 14 Jun 2017 15:33:26 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code to send SMP frame

Add code to prepare SMP frame.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 code to send SSP frame
Xiang Chen [Wed, 14 Jun 2017 15:33:25 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 code to send SSP frame

Add code to prepare SSP frame and deliver it to hardware.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 cq interrupt handler
Xiang Chen [Wed, 14 Jun 2017 15:33:24 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 cq interrupt handler

Add v3 cq interrupt handler slot_complete_v3_hw().

Note: The slot error handling needs to be further refined in the future
to examine all fields in the error record, and handle appropriately,
instead of current solution - just report SAS_OPEN_REJECT.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add phy up/down/bcast and channel ISR
Xiang Chen [Wed, 14 Jun 2017 15:33:23 +0000 (23:33 +0800)]
scsi: hisi_sas: add phy up/down/bcast and channel ISR

Add code to initialise interrupts and add some interrupt handlers.

Also add function hisi_sas_v3_destroy_irqs() to clean-up irqs upon
module unloading.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 hw PHY init
Xiang Chen [Wed, 14 Jun 2017 15:33:22 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 hw PHY init

Add code to configure PHYs for v3 hw.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v3 hw init
Xiang Chen [Wed, 14 Jun 2017 15:33:21 +0000 (23:33 +0800)]
scsi: hisi_sas: add v3 hw init

Add code to initialise v3 hardware.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add initialisation for v3 pci-based controller
John Garry [Wed, 14 Jun 2017 15:33:20 +0000 (23:33 +0800)]
scsi: hisi_sas: add initialisation for v3 pci-based controller

Add the code to initialise the controller which is based on pci device
in hisi_sas_v3_hw.c

The core controller routines are still in hisi_sas_main.c; some common
initialisation functions are also exported from hisi_sas_main.c

For pci-based controller, the device properties, like phy count and sas
address are read from the firmware, same as platform device-based
controller.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add skeleton v3 hw driver
John Garry [Wed, 14 Jun 2017 15:33:19 +0000 (23:33 +0800)]
scsi: hisi_sas: add skeleton v3 hw driver

Add skeleton driver for v3 hw in hisi_sas_v3_hw.c

File hisi_sas_v3_hw.c will serve 2 purposes:
- probing and initialisation of the controller based on pci device
- hw layer for v3-based controllers

The controller design is quite similar to v2 hw in hip07.

However key differences include:
-All v2 hw bugs are fixed (hopefully), so workarounds are not required
-support for device deregistration
-some interrupt modifications
-configurable max device support

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: create hisi_sas_get_fw_info()
John Garry [Wed, 14 Jun 2017 15:33:18 +0000 (23:33 +0800)]
scsi: hisi_sas: create hisi_sas_get_fw_info()

Move the functionality to retrieve the fw info into a dedicated device
type-agnostic function, hisi_sas_get_fw_info().

The reasoning is that this function will be required for future
pci-based platforms.

Also add some debug logs for failure.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add pci_dev in hisi_hba struct
John Garry [Wed, 14 Jun 2017 15:33:17 +0000 (23:33 +0800)]
scsi: hisi_sas: add pci_dev in hisi_hba struct

Since hip08 SAS controller is based on pci device, add hisi_hba.pci_dev
for hip08 (will be v3), and also rename hisi_hba.pdev to .platform_dev
for clarity.

In addition, for common code which wants to reference the controller
device struct, add hisi_hba.dev, and change the common code to use it.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: relocate get_ncq_tag_v2_hw()
Xiang Chen [Wed, 14 Jun 2017 15:33:16 +0000 (23:33 +0800)]
scsi: hisi_sas: relocate get_ncq_tag_v2_hw()

Relocate get_ncq_tag_v2_hw() to a common location, as future hw versions
will require it.  Also rename with "hisi_sas_" prefix for consistency.

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>
7 years agoscsi: hisi_sas: relocate sata_done_v2_hw()
Xiang Chen [Wed, 14 Jun 2017 15:33:15 +0000 (23:33 +0800)]
scsi: hisi_sas: relocate sata_done_v2_hw()

Relocate get_ata_protocol() to a common location, as future hw versions
will require it.  Also rename with "hisi_sas_" prefix for consistency.

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>
7 years agoscsi: hisi_sas: relocate get_ata_protocol()
Xiang Chen [Wed, 14 Jun 2017 15:33:14 +0000 (23:33 +0800)]
scsi: hisi_sas: relocate get_ata_protocol()

Relocate get_ata_protocol() to a common location, as future hw versions
will require it.  Also rename with "hisi_sas_" prefix for consistency.

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>
7 years agoscsi: hisi_sas: optimise the usage of hisi_hba.lock
Xiang Chen [Wed, 14 Jun 2017 15:33:13 +0000 (23:33 +0800)]
scsi: hisi_sas: optimise the usage of hisi_hba.lock

Currently hisi_hba.lock is locked to deliver and receive a command
to/from any hw queue. This causes much contention at high data-rates.

To boost performance, lock on a per queue basis for sending and
receiving commands to/from hw.

Certain critical regions still need to be locked in the delivery and
completion stages with hisi_hba.lock.

New element hisi_sas_device.dq is added to store the delivery queue for
a device, so it does not need to be needlessly re-calculated for every
task.

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>
7 years agoscsi: hisi_sas: define hisi_sas_device.device_id as int
John Garry [Wed, 14 Jun 2017 15:33:12 +0000 (23:33 +0800)]
scsi: hisi_sas: define hisi_sas_device.device_id as int

Currently hisi_sas_device.device_id is a u64. This can create a problem
in selecting the queue for a device, in that this code does a 64b
division on device id. For some 32b systems, 64b division is slow and
the lib reference must be explicitly included.

The device id does not need to be 64b in size, so, as a solution, just
make as an int.

Also, struct hisi_sas_device elements are re-ordered to improve packing
efficiency.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: fix timeout check in hisi_sas_internal_task_abort()
Xiang Chen [Wed, 14 Jun 2017 15:33:11 +0000 (23:33 +0800)]
scsi: hisi_sas: fix timeout check in hisi_sas_internal_task_abort()

We need to check for timeout before task status, or the task will be
mistook as completed internal abort command.  Also add protection for
sas_task.task_state_flags in hisi_sas_tmf_timedout().

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>
7 years agoscsi: lpfc: update to revision to 11.4.0.0
James Smart [Fri, 2 Jun 2017 04:07:11 +0000 (21:07 -0700)]
scsi: lpfc: update to revision to 11.4.0.0

Set lpfc driver revision to 11.4.0.0

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>
7 years agoscsi: lpfc: Add auto EQ delay logic
James Smart [Fri, 2 Jun 2017 04:07:10 +0000 (21:07 -0700)]
scsi: lpfc: Add auto EQ delay logic

Administrator intervention is currently required to get good numbers
when switching from running latency tests to IOPS tests.

The configured interrupt coalescing values will greatly effect the
results of these tests.  Currently, the driver has a single coalescing
value set by values of the module attribute.  This patch changes the
driver to support auto-configuration of the coalescing value based on
the total number of outstanding IOs and average number of CQEs processed
per interrupt for an EQ.  Values are checked every 5 seconds.

The driver defaults to the automatic selection. Automatic selection can
be disabled by the new lpfc_auto_imax module_parameter.

Older hardware can only change interrupt coalescing by mailbox
command. Newer hardware supports change via a register. The patch
support both.

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>
7 years agoscsi: lpfc: Fix defects reported by Coverity Scan
James Smart [Fri, 2 Jun 2017 04:07:09 +0000 (21:07 -0700)]
scsi: lpfc: Fix defects reported by Coverity Scan

Addressed the following reported defects:

** CID 1411552:  Control flow issues  (MISSING_BREAK)
/drivers/scsi/lpfc/lpfc_sli.c: 13259 in lpfc_sli4_nvmet_handle_rcqe()

** CID 1411553:  Memory - illegal accesses  (OVERRUN)
/drivers/scsi/lpfc/lpfc_sli.c: 16218 in lpfc_fc_frame_check()

** CID 1411553:  Memory - illegal accesses  (OVERRUN)
   Overrunning array "lpfc_rctl_names" of 202 8-byte elements at element
   index 244 (byte offset 1952) using index "fc_hdr->fh_r_ctl" (which
   evaluates to 244).

** CID 1411554:  Null pointer dereferences  (REVERSE_INULL)
/drivers/scsi/lpfc/lpfc_nvmet.c: 2131 in lpfc_nvmet_unsol_fcp_abort_cmp()

** CID 1411555:  Memory - illegal accesses  (UNINIT)
/drivers/scsi/lpfc/lpfc_nvmet.c: 180 in lpfc_nvmet_ctxbuf_post()

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>
7 years agoscsi: lpfc: Fix vports not logging into target
James Smart [Fri, 2 Jun 2017 04:07:08 +0000 (21:07 -0700)]
scsi: lpfc: Fix vports not logging into target

vports cannot login to target.

For vports, lpfc_nodelist is allocated for targets only on completion of
GFF_ID command. Driver checks if lpfc_nodelist exists for target before
sending GFF_ID. So, GFF_ID and PLOGI are not sent.

As mentioned by the comment in lpfc_prep_node_fc4type() routine, do not
send GFF_ID only if this NPortID is previously identified as FCP
target. Send GFF_ID if it is a newly identified remote port from GID_FT
response.

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>
7 years agoscsi: lpfc: Fix PRLI retry handling when target rejects it.
James Smart [Fri, 2 Jun 2017 04:07:07 +0000 (21:07 -0700)]
scsi: lpfc: Fix PRLI retry handling when target rejects it.

The nvmet driver was rejecting the initiator's PRLI because its reg_rpi
for the PLOGI was still outstanding.  The initiator would resend the
PRLI without delay and get the same answer.  The PRLI retries would
exhaust causing the nvme initiator to set the nvmet ndlp to UNMAPPED.

The driver's lpfc_els_retry handler did not have a policy for an LS_RJT
with explanation CMD_IN_PROGRESS for PRLI or NVME_PRLI.  This caused the
delay to remain at 0 but retry set 1.

Fix: When the ELS response is LS_RJT, TPC and the command was PRLI or
NVME_PRLI, just set the delay to 1000 mS to get a 1 second delay on the
PRLI retry.  This was enough to allow the REG_RPI to complete at the
target.

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>
7 years agoscsi: lpfc: Null pointer dereference when log_verbose is set to 0xffffffff
James Smart [Fri, 2 Jun 2017 04:07:06 +0000 (21:07 -0700)]
scsi: lpfc: Null pointer dereference when log_verbose is set to 0xffffffff

Kernel panic when log_verbose is set to 0xffffffff

phba->pport is dereferenced before it is initialized

Fix: Do not dereference phba->pport if it is NULL

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>
7 years agoscsi: lpfc: Fix System panic after loading the driver
James Smart [Fri, 2 Jun 2017 04:07:05 +0000 (21:07 -0700)]
scsi: lpfc: Fix System panic after loading the driver

System panic with general protection fault during driver load

The driver uses a static array sli4_hba.handler_name to store the irq
handler names. If the io_channel_irqs exceeds the pre-allocated size
(32+1), then the driver will overwrite other fields of sli4_hba.

Fix: Dynamically allocate handler_name.

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>
7 years agoscsi: lpfc: Fix crash on powering off BFS VM with passthrough device
James Smart [Fri, 2 Jun 2017 04:07:04 +0000 (21:07 -0700)]
scsi: lpfc: Fix crash on powering off BFS VM with passthrough device

Null pointer dereference when BFS VM is powered off

The driver incorrectly uses sli3_ring on SLI-4 adapters

Use the correct ring structure based on sli_rev

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Tested-by: Raphael Silva <raphasil@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix return value of board_mode store routine in case of online failure
James Smart [Fri, 2 Jun 2017 04:07:03 +0000 (21:07 -0700)]
scsi: lpfc: Fix return value of board_mode store routine in case of online failure

On hbacmd reset failure, observing wrong string "nline" in kernel log.

On failure, non negative value (1) is returned from sysfs store
routine. It is interpreted as count by kernel and store routine is
called again with the remaining characters as input.

Fix: Return negative error code (-EIO) in case of failure.

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>
7 years agoscsi: lpfc: Fix counters so outstandng NVME IO count is accurate
James Smart [Fri, 2 Jun 2017 04:07:02 +0000 (21:07 -0700)]
scsi: lpfc: Fix counters so outstandng NVME IO count is accurate

NVME FC counters don't reflect actual results

Since counters are not atomic, or protected by a lock, the values often
get screwed up.

Make them atomic, like NVMET.  Fix up sysfs and debugfs display
accordingly Added Outstanding IOs to stats display

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>
7 years agoscsi: lpfc: Fix Port going offline after multiple resets.
James Smart [Fri, 2 Jun 2017 04:07:01 +0000 (21:07 -0700)]
scsi: lpfc: Fix Port going offline after multiple resets.

Observing lpfc port down after issuing hbacmd reset command

Failure in posting SGL buffers. If there is only one SGL buffer and rrq
is valid for its XRI, we are rightly returning NULL but not adding the
buffer back to the SGL list. So, number of buffers become less than
total count and repost fails during reset.

Add SGL buffer back to list before returning NULL.

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>