platform/kernel/linux-starfive.git
6 years agoscsi: ips: fix firmware timestamps for 32-bit
Arnd Bergmann [Fri, 20 Apr 2018 16:04:40 +0000 (18:04 +0200)]
scsi: ips: fix firmware timestamps for 32-bit

do_gettimeofday() is deprecated since it will stop working in 2038 on
32-bit platforms, leading to incorrect times passed to the firmware.
On 64-bit platforms the current code appears to be fine, as the
calculation passes an 8-bit century number into the firmware that can
represent times long in the future (possibly until 25599).

Using ktime_get_real_seconds() to get a 64-bit seconds value and
time64_to_tm() to convert it into the firmware format greatly simplifies
the ips timekeeping code, makes 32-bit and 64-bit behave the same way
here, and gets us closer to removing the deprecated interfaces.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: esas2r: use ktime_get_real_seconds()
Arnd Bergmann [Fri, 20 Apr 2018 16:02:09 +0000 (18:02 +0200)]
scsi: esas2r: use ktime_get_real_seconds()

do_gettimeofday() is deprecated because of the y2038 overflow.  Here, we
use the result to pass into a 32-bit field in the firmware, which still
risks an overflow, but if the firmware is written to expect unsigned
values, it can at least last until y2106, and there is not much we can
do about it.

This changes do_gettimeofday() to ktime_get_real_seconds(), which at
least simplifies the code a bit, and avoids the deprecated
interface. I'm adding a comment about the overflow to document what
happens.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mvumi: Using module_pci_driver
YueHaibing [Thu, 29 Mar 2018 11:43:11 +0000 (19:43 +0800)]
scsi: mvumi: Using module_pci_driver

Remove boilerplate code by using macro module_pci_driver.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: add driver-api document
Randy Dunlap [Sat, 14 Apr 2018 17:51:06 +0000 (10:51 -0700)]
scsi: target: add driver-api document

Add a driver-api document for target/iSCSI interfaces.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: linux-scsi@vger.kernel.org
Cc: target-devel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: target_core_user.[ch]: convert comments into DOC:
Randy Dunlap [Sat, 14 Apr 2018 17:51:05 +0000 (10:51 -0700)]
scsi: target: target_core_user.[ch]: convert comments into DOC:

Make documentation on target-supported userspace-I/O design be
usable by kernel-doc by using "DOC:". This is used in the driver-api
Documentation chapter.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: linux-scsi@vger.kernel.org
Cc: target-devel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: target_core_transport.c: enable+fix kernel-doc
Randy Dunlap [Sat, 14 Apr 2018 17:51:04 +0000 (10:51 -0700)]
scsi: target: target_core_transport.c: enable+fix kernel-doc

For exported functions that already have near-kernel-doc notation,
fix them to begin with "/**" and make a few corrections so that they
don't have any kernel-doc warnings.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: linux-scsi@vger.kernel.org
Cc: target-devel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: target_core_transport.c: fix kernel-doc warnings
Randy Dunlap [Sat, 14 Apr 2018 17:51:03 +0000 (10:51 -0700)]
scsi: target: target_core_transport.c: fix kernel-doc warnings

Correct a function parameter's name to eliminate kernel-doc warnings
in drivers/target/target_core_transport.c.

Fixes these kernel-doc warnings: (tested by adding these files to a new
target.rst documentation file)

../drivers/target/target_core_transport.c:1671: warning: No description found for parameter 'fabric_tmr_ptr'
../drivers/target/target_core_transport.c:1671: warning: Excess function parameter 'fabric_context' description in 'target_submit_tmr'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: linux-scsi@vger.kernel.org
Cc: target-devel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: st: Replace GFP_ATOMIC with GFP_KERNEL in new_tape_buffer
Jia-Ju Bai [Tue, 10 Apr 2018 12:38:42 +0000 (20:38 +0800)]
scsi: st: Replace GFP_ATOMIC with GFP_KERNEL in new_tape_buffer

new_tape_buffer() is never called in atomic context. new_tape_buffer()
is only called by st_probe(), which is only set as ".probe" in struct
scsi_driver.

Despite never getting called from atomic context, new_tape_buffer()
calls kzalloc() with GFP_ATOMIC, which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, which
can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: st: Replace GFP_ATOMIC with GFP_KERNEL in st_probe
Jia-Ju Bai [Tue, 10 Apr 2018 12:37:59 +0000 (20:37 +0800)]
scsi: st: Replace GFP_ATOMIC with GFP_KERNEL in st_probe

st_probe() is never called in atomic context. st_probe() is only set as
".probe" in struct scsi_driver.

Despite never getting called from atomic context, st_probe() calls
kzalloc() with GFP_ATOMIC, which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, which
can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: BLIST_RETRY_ASC_C1 for Fujitsu ETERNUS
Martin Wilck [Tue, 17 Apr 2018 23:35:11 +0000 (01:35 +0200)]
scsi: devinfo: BLIST_RETRY_ASC_C1 for Fujitsu ETERNUS

On Fujitsu ETERNUS systems, sense code ABORTED COMMAND with ASC/Q C1/01
is used to indicate temporary condition where the storage-internal path
to a target is switched from one controller to another. SCSI commands
that return with this error code must be retried unconditionally
(i.e. without the "maybe_retry" logic in scsi_decide_disposition);
otherwise dm-multipath might initiate a failover from a healthy path
e.g. for REQ_FAILFAST_DEV commands.

Introduce a new blist flag for this case.

[mkp: applied by hand]

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: add BLIST_RETRY_ITF for EMC Symmetrix
Martin Wilck [Tue, 17 Apr 2018 23:35:10 +0000 (01:35 +0200)]
scsi: devinfo: add BLIST_RETRY_ITF for EMC Symmetrix

EMC Symmetrix returns 'internal target error' for a variety of
conditions, most of which will be transient.  So we should always retry
it, even with failfast set.  Otherwise we'd get spurious path flaps with
multipath.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: warn on undefined blist flags
Martin Wilck [Tue, 17 Apr 2018 23:35:09 +0000 (01:35 +0200)]
scsi: devinfo: warn on undefined blist flags

Warn if a device (or the user) sets blist flags which are unknown
or have been removed. This should enable us to reuse freed blist
bits in later releases.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: change blist_flag_t to 64bit
Martin Wilck [Tue, 17 Apr 2018 23:35:08 +0000 (01:35 +0200)]
scsi: devinfo: change blist_flag_t to 64bit

Space for SCSI blist flags is gradually running out. Change the type to
__u64 and fix a checkpatch complaint about symbolic mode flags in
scsi_devinfo.c.

Make checkpatch happy by replacing simple_strtoul() with kstrtoull().

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: use const_ilog2 for array indices
Martin Wilck [Tue, 17 Apr 2018 23:35:07 +0000 (01:35 +0200)]
scsi: devinfo: use const_ilog2 for array indices

Use the just introduced const_ilog2() macro to avoid sparse errors.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ilog2: create truly constant version for sparse
Martin Wilck [Tue, 17 Apr 2018 23:35:06 +0000 (01:35 +0200)]
scsi: ilog2: create truly constant version for sparse

Sparse emits errors about ilog2() in array indices because of the use of
__ilog2_32() and __ilog2_64(), rightly so
(https://www.spinics.net/lists/linux-sparse/msg03471.html).

Create a const_ilog2() variant that works with sparse for this scenario.

(Note: checkpatch.pl complains about missing parentheses, but that
appears to be a false positive. I can get rid of the warning simply by
inserting whitespace, making checkpatch "see" the whole macro).

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: storvsc: Select channel based on available percentage of ring buffer to write
Long Li [Thu, 19 Apr 2018 21:54:24 +0000 (14:54 -0700)]
scsi: storvsc: Select channel based on available percentage of ring buffer to write

This is a best effort for estimating on how busy the ring buffer is for
that channel, based on available buffer to write in percentage. It is
still possible that at the time of actual ring buffer write, the space
may not be available due to other processes may be writing at the time.

Selecting a channel based on how full it is can reduce the possibility
that a ring buffer write will fail, and avoid the situation a channel is
over busy.

Now it's possible that storvsc can use a smaller ring buffer size
(e.g. 40k bytes) to take advantage of cache locality.

Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: Change return type to vm_fault_t
Souptick Joarder [Sat, 14 Apr 2018 18:55:57 +0000 (00:25 +0530)]
scsi: target: Change return type to vm_fault_t

Use new return type vm_fault_t for fault handler in struct
vm_operations_struct.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: target: prefer dbroot of /etc/target over /var/target
Lee Duncan [Fri, 6 Apr 2018 18:31:41 +0000 (11:31 -0700)]
scsi: target: prefer dbroot of /etc/target over /var/target

The target database root directory, dbroot, has defaulted to /var/target
for a while, but its main client, targetcli-fb, has been moving it to
/etc/target for quite some time. With the plethora of target drivers now
appearing, it has become more difficult to initialize this attribute
before use by any child drivers.

If the directory /etc/target exists, use that as the DB root. Otherwise,
fall back to using /var/target.

The ability to override this dbroot attribute still exists via sysfs.

Signed-off-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mptfc: fix spelling mistake in macro names
Colin Ian King [Wed, 18 Apr 2018 11:30:38 +0000 (12:30 +0100)]
scsi: mptfc: fix spelling mistake in macro names

Rename macros MPI_FCPORTPAGE0_SUPPORT_SPEED_UKNOWN and
MPI_FCPORTPAGE0_CURRENT_SPEED_UKNOWN to add in missing N in UNKNOWN

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd_zbc: Let the SCSI core handle ILLEGAL REQUEST / ASC 0x21
Bart Van Assche [Tue, 17 Apr 2018 01:04:40 +0000 (18:04 -0700)]
scsi: sd_zbc: Let the SCSI core handle ILLEGAL REQUEST / ASC 0x21

scsi_io_completion() translates the sense key ILLEGAL REQUEST / ASC 0x21 into
ACTION_FAIL. That means that setting cmd->allowed to zero in sd_zbc_complete()
for this sense code / ASC combination is not necessary. Hence remove the code
that resets cmd->allowed from sd_zbc_complete().

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd_zbc: Change the type of the ZBC fields into u32
Bart Van Assche [Tue, 17 Apr 2018 01:04:39 +0000 (18:04 -0700)]
scsi: sd_zbc: Change the type of the ZBC fields into u32

This patch does not change any functionality but makes it clear that it is on
purpose that these fields are 32 bits wide.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: storsvc: don't set a bounce limit
Christoph Hellwig [Mon, 16 Apr 2018 08:50:22 +0000 (10:50 +0200)]
scsi: storsvc: don't set a bounce limit

The default already is to never bounce, so the call is a no-op.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: iscsi_tcp: don't set a bounce limit
Christoph Hellwig [Mon, 16 Apr 2018 08:50:21 +0000 (10:50 +0200)]
scsi: iscsi_tcp: don't set a bounce limit

The default already is to never bounce, so the call is a no-op.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sg: Change return type to vm_fault_t
Souptick Joarder [Sat, 14 Apr 2018 18:47:41 +0000 (00:17 +0530)]
scsi: sg: Change return type to vm_fault_t

Use new return type vm_fault_t for fault handler in struct
vm_operations_struct.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: zorro_esp: New driver for Amiga Zorro NCR53C9x boards
Michael Schmitz [Thu, 12 Apr 2018 01:53:26 +0000 (13:53 +1200)]
scsi: zorro_esp: New driver for Amiga Zorro NCR53C9x boards

New combined SCSI driver for all ESP based Zorro SCSI boards for m68k Amiga.

Code largely based on board specific parts of the old drivers (blz1230.c,
blz2060.c, cyberstorm.c, cyberstormII.c, fastlane.c which were removed after
the 2.6 kernel series for lack of maintenance) with contributions by Tuomas
Vainikka (TCQ bug tests and workaround) and Finn Thain (TCQ bugfix by use of
PIO in extended message in transfer).

New Kconfig option and Makefile entries for new Amiga Zorro ESP SCSI driver
included in this patch.

Use DMA transfers wherever possible, with board-specific DMA set-up functions
copied from the old driver code. Three byte reselection messages do appear to
cause DMA timeouts. So wire up a PIO transfer routine for these
instead. esp_reselect_with_tag explicitly sets
esp->cmd_block_dma as target address for the message bytes but PIO
requires a virtual address.  Substiute kernel virtual address
esp->cmd_block in PIO transfer call if DMA address is esp->cmd_block_dma
and phase is message in.

PIO code taken from mac_esp.c where the reselection timeout issue was debugged
and fixed first, with minor macro and function rename.

Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christian T. Steigies <cts@debian.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_dh: replace too broad "TP9" string with the exact models
Xose Vazquez Perez [Fri, 6 Apr 2018 22:47:23 +0000 (00:47 +0200)]
scsi: scsi_dh: replace too broad "TP9" string with the exact models

SGI/TP9100 is not an RDAC array:
    ^^^
https://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=blob;f=libmultipath/hwtable.c;h=88b4700beb1d8940008020fbe4c3cd97d62f4a56;hb=HEAD#l235

This partially reverts commit 35204772ea03 ("[SCSI] scsi_dh_rdac :
Consolidate rdac strings together")

[mkp: fixed up the new entries to align with rest of struct]

Cc: NetApp RDAC team <ng-eseries-upstream-maintainers@netapp.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: SCSI ML <linux-scsi@vger.kernel.org>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: devinfo: delete duplicate "Generic"/"USB Storage-SMC" device
Xose Vazquez Perez [Fri, 6 Apr 2018 22:15:07 +0000 (00:15 +0200)]
scsi: devinfo: delete duplicate "Generic"/"USB Storage-SMC" device

The revision field is currently unused by the devinfo pattern matching
code. Combine two blacklist entries into one.

$ egrep "Generic.*Storage-SMC" /proc/scsi/device_info
'Generic' 'USB Storage-SMC' 0x402
'Generic' 'USB Storage-SMC' 0x402

[mkp: tweaked commit desc]

Cc: Hannes Reinecke <hare@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
Cc: SCSI ML <linux-scsi@vger.kernel.org>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: update driver version to 12.0.0.2
James Smart [Mon, 9 Apr 2018 21:24:33 +0000 (14:24 -0700)]
scsi: lpfc: update driver version to 12.0.0.2

Update the driver version to 12.0.0.2

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>
6 years agoscsi: lpfc: Correct missing remoteport registration during link bounces
James Smart [Mon, 9 Apr 2018 21:24:32 +0000 (14:24 -0700)]
scsi: lpfc: Correct missing remoteport registration during link bounces

Remote port disappearance/reappearances would cause a series of RSCN
events to be delivered to the driver. During the resulting GID_FT
handling, the driver clears the fc4 settings on the remote port, which
makes it skip registration. As such, the nvme associations eventually
fail and return io errors to the applications.

Correct by not clearng the nlp_fc4_types for all nodes in
lpfc_issue_gidft.  Instead, when the GID_FT response is handled, clear
the nlp_fc4_types of FCP and NVME prior to evaluating the fc4_type
returned by the GID_FT response.  This approach leaves "skipped" nodes
with their nlp_fc4_types intacted.

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>
6 years agoscsi: lpfc: Fix NULL pointer reference when resetting adapter
James Smart [Mon, 9 Apr 2018 21:24:31 +0000 (14:24 -0700)]
scsi: lpfc: Fix NULL pointer reference when resetting adapter

Points referencing local port structures didn't accommodate cases where
the localport may not be registered yet.

Add NULL pointer checks to logic.

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>
6 years agoscsi: lpfc: Fix nvme remoteport registration race conditions
James Smart [Mon, 9 Apr 2018 21:24:30 +0000 (14:24 -0700)]
scsi: lpfc: Fix nvme remoteport registration race conditions

On tests adding and removing a remote port, calls to nvme_info would
eventually show fewer target ports discovered than were present in the
san. Additionally, the following error messages were seen:

  6031 RemotePort Registration failed err: -116, DID x471301

There is a race condition that exists between the driver and the nvme
transport on remote port unregister vs the confirmed deletion. It's
possible that the driver may rediscover the remote port and reregister
the remote port before a prior unregister delete callback was made (as
it rebinded to the prior remoteport structure). However, the driver was
coded to expect the callback before seeing the remote port again thus a
new registration. The logic results in the driver having an invalid
remoteport pointer set.

Correct by tracking when waiting for the delete callback. In cases where
the ndlp remoteport pointer is updated, it is only cleared when the wait
has not been superceded by a prior registration.

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>
6 years agoscsi: lpfc: Fix driver not recovering NVME rports during target link faults
James Smart [Mon, 9 Apr 2018 21:24:29 +0000 (14:24 -0700)]
scsi: lpfc: Fix driver not recovering NVME rports during target link faults

During target-side port faults, the driver would not recover all target
port logins. This resulted in a loss of nvme device discovery.

The driver is coded to wait for all GID_FT requests to complete before
restarting discovery. A fault is seen where the outstanding GIT_FT
counts are not properly decremented, thus discovery would never
start. Another fault was found in the clearing of the gidft_inp counter
that would be skipped in this condition. And a third fault found with
lpfc_nvme_register_port that would remove a reverence on the ndlp which
then allows a node swap on a port address change to prematurely remove
the reference and release the ndlp.

The following changes are made:

 - Correct the decrementing of the outstanding GID_FT counters.

 - In RSCN handling, no longer zero the counter before calling to issue
   another GID_FT.

 - No longer remove the reference on the dlp when the ndlp->nrport value
   is not yet null.

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>
6 years agoscsi: lpfc: Fix WQ/CQ creation for older asic's.
James Smart [Mon, 9 Apr 2018 21:24:28 +0000 (14:24 -0700)]
scsi: lpfc: Fix WQ/CQ creation for older asic's.

The patch to enlarge WQ/CQ creation keys off of an adapter response that
indicates support for the larger values. Older adapters return an
incorrect response and are limited in size.  Thus the adapters fail the
WQ creation steps.

Augment the WQ sizing checks with a check on the older adapter types and
limit them to the restricted sizes.

Fixes: c176ffa0841c ("scsi: lpfc: Increase CQ and WQ sizes for SCSI")
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>
6 years agoscsi: lpfc: Fix NULL pointer access in lpfc_nvme_info_show
James Smart [Mon, 9 Apr 2018 21:24:27 +0000 (14:24 -0700)]
scsi: lpfc: Fix NULL pointer access in lpfc_nvme_info_show

After making remoteport unregister requests, the ndlp nrport pointer was
stale.

Track when waiting for waiting for unregister completion callback and
adjust nldp pointer assignment.  Add a few safety checks for NULL
pointer values.

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>
6 years agoscsi: lpfc: Fix lingering lpfc_wq resource after driver unload
James Smart [Mon, 9 Apr 2018 21:24:26 +0000 (14:24 -0700)]
scsi: lpfc: Fix lingering lpfc_wq resource after driver unload

After driver unloads, lpfc_wq remains active. The destroy_workqueue
calls were not being made in driver unload.  Additionally, SLI3 is
allocating lpfc_wq resources, but never uses it.

Make the destroy_workqueue calls on driver unload.  Modify the SLI3 code
path no longer allocate lpfc_wq resources.

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>
6 years agoscsi: lpfc: Fix Abort request WQ selection
James Smart [Mon, 9 Apr 2018 21:24:25 +0000 (14:24 -0700)]
scsi: lpfc: Fix Abort request WQ selection

When running loads that generated aborts, io errors where seen.  Turns
out the abort requests where not placed on the proper WQ resulting in
the errors. Closer inspection inspection of this error also showed
improper spinlock api use.

Correct the WQ selection policy for the abort requests.  Correct
spin_lock/spin_lock_irq/spin_lock_irqsave usage.

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>
6 years agoscsi: lpfc: Enlarge nvmet asynchronous receive buffer counts
James Smart [Mon, 9 Apr 2018 21:24:24 +0000 (14:24 -0700)]
scsi: lpfc: Enlarge nvmet asynchronous receive buffer counts

Under large io load, the current sizing of asynchronous buffer counts
could be exceeded, indicated by a 2885 log message:

  2885 Port Status Event: port status reg 0x81800000, port smphr
      reg 0xc000, error 1=0x52004a01, error 2=0x0

Enlarge the async receive queue size.  Allow for a configurable number
of buffers to be posted to each RQ, using the new attribute
lpfc_nvmet_mrq_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>
6 years agoscsi: lpfc: Add per io channel NVME IO statistics
James Smart [Mon, 9 Apr 2018 21:24:23 +0000 (14:24 -0700)]
scsi: lpfc: Add per io channel NVME IO statistics

When debugging various issues, per IO channel IO statistics were useful
to understand what was happening. However, many of the stats were on a
port basis rather than an io channel basis.

Move statistics to an io channel basis.

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>
6 years agoscsi: lpfc: Correct target queue depth application changes
James Smart [Mon, 9 Apr 2018 21:24:22 +0000 (14:24 -0700)]
scsi: lpfc: Correct target queue depth application changes

The max_scsicmpl_time parameter can be used to perform scsi cmd queue
depth mgmt based on io completion time: the queue depth is reduced to
make completion time shorter. However, as soon as an io completes and
the completion time is within limits, the code immediately bumps the
queue depth limit back up to the target queue depth. Thus the procedure
restarts, effectively limiting the usefulness of adjusting queue depth
to help completion time.

This patch makes the following changes:

 - Removes the code at io completion that resets the queue depth as soon
   as within limits.

 - As the code removed was where the target queue depth was first
   applied, change target queue depth application so that it occurs when
   the parameter is changed.

 - Makes target queue depth a standard parameter: both a module
   parameter and a sysfs parameter.

 - Optimizes the command pending count by using atomics rather than
   locks.

 - Updates the debugfs nodelist stats to allow better debugging of
   pending command counts.

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>
6 years agoscsi: lpfc: Fix multiple PRLI completion error path
James Smart [Mon, 9 Apr 2018 21:24:21 +0000 (14:24 -0700)]
scsi: lpfc: Fix multiple PRLI completion error path

Nodelist entry for SCSI array ends up in UNMAPPED state. This is due to
illegal discovery State machine transition because of two PRLIs and the
first one failing with LS_RJT. Also, the error path was designed
assuming the PRLIs complete in the order they were sent, FCP first, then
NVME. In a failing case, the array thinks about the first PRLI (FCP),
but issues LS_RJT for the 2nd PRLI immediately.

Fix PRLI completion error path for the ordering expectation.  Ensure the
discovery state machine update is not set until all outstanding PRLIs
are complete.

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>
6 years agoscsi: megaraid_sas: driver version upgrade
Shivasharan S [Fri, 6 Apr 2018 09:02:12 +0000 (02:02 -0700)]
scsi: megaraid_sas: driver version upgrade

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Increase timeout by 1 sec for non-RAID fastpath IOs
Shivasharan S [Fri, 6 Apr 2018 09:02:11 +0000 (02:02 -0700)]
scsi: megaraid_sas: Increase timeout by 1 sec for non-RAID fastpath IOs

Hardware could time out Fastpath IOs one second earlier than the timeout
provided by the host.

For non-RAID devices, driver provides timeout value based on OS provided
timeout value. Under certain scenarios, if the OS provides a timeout
value of 1 second, due to above behavior hardware will timeout
immediately.

Increase timeout value for non-RAID fastpath IOs by 1 second.

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Use zeroing memory allocator than allocator/memset
Himanshu Jha [Fri, 6 Apr 2018 09:02:10 +0000 (02:02 -0700)]
scsi: megaraid_sas: Use zeroing memory allocator than allocator/memset

Use pci_zalloc_consistent for allocating zeroed memory and remove
unnecessary memset function.

Done using Coccinelle.
Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Suggested-by: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: netvsc: Use the vmbus function to calculate ring buffer percentage
Long Li [Wed, 28 Mar 2018 00:48:39 +0000 (17:48 -0700)]
scsi: netvsc: Use the vmbus function to calculate ring buffer percentage

In Vmbus, we have defined a function to calculate available ring buffer
percentage to write.

Use that function and remove netvsc's private version.

[mkp: typo]

Signed-off-by: Long Li <longli@microsoft.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: vmbus: Add function to report available ring buffer to write in total ring...
Long Li [Wed, 28 Mar 2018 00:48:38 +0000 (17:48 -0700)]
scsi: vmbus: Add function to report available ring buffer to write in total ring size percentage

Netvsc has a function to calculate how much ring buffer in percentage is
available to write. This function is also useful for storvsc and other
vmbus devices.

Define a similar function in vmbus to be used by other vmbus devices.

Signed-off-by: Long Li <longli@microsoft.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: libsas: add transport class for ATA devices
Jason Yan [Mon, 26 Mar 2018 09:27:41 +0000 (17:27 +0800)]
scsi: libsas: add transport class for ATA devices

Now ata devices attached with sas controller do not have transport
class, so that we can not see any information of these ata devices in
/sys/class/ata_port(or ata_link or ata_device).

Add transport class for the ata devices attached with sas controller.
The /sys/class directory will show the infomation of the ata devices
as follows:

localhost:/sys/class # ls ata*
ata_device:
dev1.0  dev2.0

ata_link:
link1  link2

ata_port:
ata1  ata2

No functional change of the device scanning and io path. The ata
transport class was deleted when destroying the sas devices.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Tejun Heo <tj@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hisi_sas: remove some unneeded structure members
John Garry [Fri, 23 Mar 2018 16:05:15 +0000 (00:05 +0800)]
scsi: hisi_sas: remove some unneeded structure members

This patch removes unneeded structure elements:

- hisi_sas_phy.dev_sas_addr: only ever written
- Also remove associated function which writes it,
  hisi_sas_init_add().

- hisi_sas_device.attached_phy: only ever written
- Also remove code to set it in hisi_sas_dev_found()

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hisi_sas: print device id for errors
John Garry [Fri, 23 Mar 2018 16:05:14 +0000 (00:05 +0800)]
scsi: hisi_sas: print device id for errors

When we find an erroneous slot completion, to help aid debugging add the
device index to the current debug log.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hisi_sas: check IPTT is valid before using it for v3 hw
Xiaofei Tan [Fri, 23 Mar 2018 16:05:13 +0000 (00:05 +0800)]
scsi: hisi_sas: check IPTT is valid before using it for v3 hw

There is a bug of v3 hw development version. When AXI error happen, hw
may return an abnormal CQ that IPTT value is 0xffff.  This will cause
IPTT out-of-bounds reference.

This patch adds a check of IPTT in cq_tasklet_v3_hw() and discards
invalid slot. This workaround scheme is just to enhance fault-tolerance
of the driver. So, we will apply this scheme for all version of v3 hw,
although release version has fixed this SoC bug.

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>
6 years agoscsi: hisi_sas: consolidate command check in hisi_sas_get_ata_protocol()
Xiaofei Tan [Fri, 23 Mar 2018 16:05:12 +0000 (00:05 +0800)]
scsi: hisi_sas: consolidate command check in hisi_sas_get_ata_protocol()

Currently we check the fis->command value in 2 locations in
hisi_sas_get_ata_protocol() switch statement. Fix this by consolidating
the check for fis->command value to 1 location only.

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>
6 years agoscsi: hisi_sas: use dma_zalloc_coherent()
Xiang Chen [Fri, 23 Mar 2018 16:05:11 +0000 (00:05 +0800)]
scsi: hisi_sas: use dma_zalloc_coherent()

This is a warning coming from Coccinelle, and need to use new interface
dma_zalloc_coherent() instead of dma_alloc_coherent()/memset().

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>
6 years agoscsi: hisi_sas: delete timer when removing hisi_sas driver
Xiang Chen [Fri, 23 Mar 2018 16:05:10 +0000 (00:05 +0800)]
scsi: hisi_sas: delete timer when removing hisi_sas driver

Delete timer for v1 and v3 hw when removing hisi_sas driver.

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>
6 years agoscsi: hisi_sas: update RAS feature for later revision of v3 HW
Xiaofei Tan [Fri, 23 Mar 2018 16:05:09 +0000 (00:05 +0800)]
scsi: hisi_sas: update RAS feature for later revision of v3 HW

There is an modification for later revision of v3 hw. More HW errors are
reported through RAS interrupt. These errors were originally reported
only through MSI.

When report to RAS, some combinations are done to port AXI errors and
FIFO OMIT errors. For example, each port has 4 AXI errors, and they are
combined to one when report to RAS.

This patch does two things:

1. Enable RAS interrupt of these errors and handle them in PCI
   error handlers.

2. Disable MSI interrupts of these errors for this later revision hw.

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>
6 years agoscsi: hisi_sas: make SAS address of SATA disks unique
Xiang Chen [Fri, 23 Mar 2018 16:05:08 +0000 (00:05 +0800)]
scsi: hisi_sas: make SAS address of SATA disks unique

When directly connected with SATA disks in different SAS cores, fill SAS
address with scsi_host's id to make it's fake SAS address unique.

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>
6 years agoscsi: cxlflash: Handle spurious interrupts
Uma Krishnan [Mon, 26 Mar 2018 16:35:42 +0000 (11:35 -0500)]
scsi: cxlflash: Handle spurious interrupts

The following Oops can occur when there is heavy I/O traffic and the host is
reset by a tool such as sg_reset.

[c000200fff3fbc90c00800001690117c process_cmd_doneq+0x104/0x500
                                       [cxlflash] (unreliable)
[c000200fff3fbd80c008000016901648 cxlflash_rrq_irq+0xd0/0x150 [cxlflash]
[c000200fff3fbde0c000000000193130 __handle_irq_event_percpu+0xa0/0x310
[c000200fff3fbea0c0000000001933d8 handle_irq_event_percpu+0x38/0x90
[c000200fff3fbee0c000000000193494 handle_irq_event+0x64/0xb0
[c000200fff3fbf10c000000000198ea0 handle_fasteoi_irq+0xc0/0x230
[c000200fff3fbf40c00000000019182c generic_handle_irq+0x4c/0x70
[c000200fff3fbf60c00000000001794c __do_irq+0x7c/0x1c0
[c000200fff3fbf90c00000000002a390 call_do_irq+0x14/0x24
[c000200e5828fab0c000000000017b2c do_IRQ+0x9c/0x130
[c000200e5828fb00c000000000009b04 h_virt_irq_common+0x114/0x120

When a context is reset, the pending commands are flushed and the AFU is
notified. Before the AFU handles this request there could be command
completion interrupts queued to PHB which are yet to be delivered to the
context. In this scenario, a context could receive an interrupt for a command
that has been flushed, leading to a possible crash when the memory for the
flushed command is accessed.

To resolve this problem, a boolean will indicate if the hardware queue is
ready to process interrupts or not. This can be evaluated in the interrupt
handler before proessing an interrupt.

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>
6 years agoscsi: cxlflash: Remove commmands from pending list on timeout
Uma Krishnan [Mon, 26 Mar 2018 16:35:34 +0000 (11:35 -0500)]
scsi: cxlflash: Remove commmands from pending list on timeout

The following Oops can occur if an internal command sent to the AFU does not
complete within the timeout:

[c000000ff101b810c008000016020d94 term_mc+0xfc/0x1b0 [cxlflash]
[c000000ff101b8a0c008000016020fb0 term_afu+0x168/0x280 [cxlflash]
[c000000ff101b930c0080000160232ec cxlflash_pci_error_detected+0x184/0x230
                                       [cxlflash]
[c000000ff101b9e0c00800000d95d468 cxl_vphb_error_detected+0x90/0x150[cxl]
[c000000ff101ba20c00800000d95f27c cxl_pci_error_detected+0xa4/0x240 [cxl]
[c000000ff101bac0c00000000003eaf8 eeh_report_error+0xd8/0x1b0
[c000000ff101bb20c00000000003d0b8 eeh_pe_dev_traverse+0x98/0x170
[c000000ff101bbb0c00000000003f438 eeh_handle_normal_event+0x198/0x580
[c000000ff101bc60c00000000003fba4 eeh_handle_event+0x2a4/0x338
[c000000ff101bd10c0000000000400b8 eeh_event_handler+0x1f8/0x200
[c000000ff101bdc0c00000000013da48 kthread+0x1a8/0x1b0
[c000000ff101be30c00000000000b528 ret_from_kernel_thread+0x5c/0xb4

When an internal command times out, the command buffer is freed while it is
still in the pending commands list of the context. This corrupts the list and
when the context is cleaned up, a crash is encountered.

To resolve this issue, when an AFU command or TMF command times out, the
command should be deleted from the hardware queue pending command list before
freeing the buffer.

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>
6 years agoscsi: cxlflash: Synchronize reset and remove ops
Uma Krishnan [Mon, 26 Mar 2018 16:35:27 +0000 (11:35 -0500)]
scsi: cxlflash: Synchronize reset and remove ops

The following Oops can be encountered if a device removal or system shutdown
is initiated while an EEH recovery is in process:

[c000000ff2f479c0c008000015256f18 cxlflash_pci_slot_reset+0xa0/0x100
                                      [cxlflash]
[c000000ff2f47a30c00800000dae22e0 cxl_pci_slot_reset+0x168/0x290 [cxl]
[c000000ff2f47ae0c00000000003ef1c eeh_report_reset+0xec/0x170
[c000000ff2f47b20c00000000003d0b8 eeh_pe_dev_traverse+0x98/0x170
[c000000ff2f47bb0c00000000003f80c eeh_handle_normal_event+0x56c/0x580
[c000000ff2f47c60c00000000003fba4 eeh_handle_event+0x2a4/0x338
[c000000ff2f47d10c0000000000400b8 eeh_event_handler+0x1f8/0x200
[c000000ff2f47dc0c00000000013da48 kthread+0x1a8/0x1b0
[c000000ff2f47e30c00000000000b528 ret_from_kernel_thread+0x5c/0xb4

The remove handler frees AFU memory while the EEH recovery is in progress,
leading to a race condition. This can result in a crash if the recovery thread
tries to access this memory.

To resolve this issue, the cxlflash remove handler will evaluate the device
state and yield to any active reset or probing threads.

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>
6 years agoscsi: cxlflash: Enable OCXL operations
Uma Krishnan [Mon, 26 Mar 2018 16:35:21 +0000 (11:35 -0500)]
scsi: cxlflash: Enable OCXL operations

This commit enables the OCXL operations for the OCXL devices.

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>
6 years agoscsi: cxlflash: Support AFU reset
Uma Krishnan [Mon, 26 Mar 2018 16:35:15 +0000 (11:35 -0500)]
scsi: cxlflash: Support AFU reset

The cxlflash core driver resets the AFU when the master contexts are created
in the initialization or recovery paths. Today, the OCXL provider service to
perform this operation is pending implementation.  To avoid a crash due to a
missing fop, log an error once and return success to continue with execution.

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>
6 years agoscsi: cxlflash: Register for translation errors
Uma Krishnan [Mon, 26 Mar 2018 16:35:07 +0000 (11:35 -0500)]
scsi: cxlflash: Register for translation errors

While enabling a context on the link, a predefined callback can be registered
with the OCXL provider services to be notified on translation errors. These
errors can in turn be passed back to the user on a read operation.

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>
6 years agoscsi: cxlflash: Introduce OCXL context state machine
Uma Krishnan [Mon, 26 Mar 2018 16:35:00 +0000 (11:35 -0500)]
scsi: cxlflash: Introduce OCXL context state machine

In order to protect the OCXL hardware contexts from getting clobbered, a
simple state machine is added to indicate when a context is in open, close or
start state. The expected states are validated throughout the code to prevent
illegal operations on a context. A mutex is added to protect writes to the
context state field.

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>
6 years agoscsi: cxlflash: Update synchronous interrupt status bits
Uma Krishnan [Mon, 26 Mar 2018 16:34:55 +0000 (11:34 -0500)]
scsi: cxlflash: Update synchronous interrupt status bits

The SISLite specification has been updated to define new synchronous interrupt
status bits. These bits are set by the AFU when a given PASID or EA is bad and
a synchronous interrupt is triggered.

The SISLite header file is updated to support these new bits. Note that there
are also some formatting updates to some of the existing bits to allow all of
the definitions to line up uniformly.

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>
6 years agoscsi: cxlflash: Setup LISNs for master contexts
Uma Krishnan [Mon, 26 Mar 2018 16:34:48 +0000 (11:34 -0500)]
scsi: cxlflash: Setup LISNs for master contexts

Similar to user contexts, master contexts also require that the per-context
LISN registers be programmed for certain AFUs. The mapped trigger page is
obtained from underlying transport and registered with AFU for each master
context.

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>
6 years agoscsi: cxlflash: Setup LISNs for user contexts
Uma Krishnan [Mon, 26 Mar 2018 16:34:42 +0000 (11:34 -0500)]
scsi: cxlflash: Setup LISNs for user contexts

The SISLite specification has been updated for OCXL to support communicating
data to generate AFU interrupts to the AFU. This includes a new capability bit
that is advertised for OCXL AFUs and new registers to hold the object handle
and translation PASID of each interrupt. For Power, the object handle is the
mapped trigger page. Note that because these mappings are kernel only, the
PASID of a kernel context must be used to satisfy the translation.

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>
6 years agoscsi: cxlflash: Introduce object handle fop
Uma Krishnan [Mon, 26 Mar 2018 16:34:35 +0000 (11:34 -0500)]
scsi: cxlflash: Introduce object handle fop

OCXL requires that AFUs use an opaque object handle to represent an AFU
interrupt. The specification does not provide a common means to communicate
the object handle to the AFU - each AFU must define this within the AFU
specification. To support this model, the object handle must be passed back to
the core driver as it manages the AFU specification (SISLite) for cxlflash.
Note that for Power systems, the object handle is the effective address of the
trigger page.

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>
6 years agoscsi: cxlflash: Support file descriptor mapping
Uma Krishnan [Mon, 26 Mar 2018 16:34:27 +0000 (11:34 -0500)]
scsi: cxlflash: Support file descriptor mapping

The cxlflash core fop API requires a way to invoke the fault and release
handlers of underlying transports using their native file-based APIs. This
provides the core with the ability to insert selectively itself into the
processing stream of these operations for cleanup. Implement these two fops to
map and release when requested.

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>
6 years agoscsi: cxlflash: Support adapter context mmap and release
Uma Krishnan [Mon, 26 Mar 2018 16:34:20 +0000 (11:34 -0500)]
scsi: cxlflash: Support adapter context mmap and release

The cxlflash userspace API requires that users be able to mmap and release the
adapter context. Support mapping by implementing the AFU mmap fop to map the
context MMIO space and install the corresponding page table entry upon page
fault. Similarly, implement the AFU release fop to terminate and clean up the
context when invoked.

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>
6 years agoscsi: cxlflash: Support adapter context reading
Uma Krishnan [Mon, 26 Mar 2018 16:34:12 +0000 (11:34 -0500)]
scsi: cxlflash: Support adapter context reading

The cxlflash userspace API requires that users be able to read the adapter
context for any pending events or interrupts from the AFU. Support reading
various events by implementing the AFU read fop to copy out event data.

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>
6 years agoscsi: cxlflash: Support adapter context polling
Uma Krishnan [Mon, 26 Mar 2018 16:34:03 +0000 (11:34 -0500)]
scsi: cxlflash: Support adapter context polling

The cxlflash userspace API requires that users be able to poll the adapter
context for any pending events or interrupts from the AFU. Support polling on
various events by implementing the AFU poll fop using a waitqueue.

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>
6 years agoscsi: cxlflash: Support starting user contexts
Uma Krishnan [Mon, 26 Mar 2018 16:33:55 +0000 (11:33 -0500)]
scsi: cxlflash: Support starting user contexts

User contexts request interrupts and are started using the "start work"
interface. Populate the start_work() fop to allocate and map interrupts before
starting the user context. As part of starting the context, update the user
process identification logic to properly derive the data required by the
SPA. Also, introduce a skeleton interrupt handler using a bitmap, flag, and
spinlock to track interrupts. This handler will be expanded in future commits.

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>
6 years agoscsi: cxlflash: Support AFU interrupt mapping and registration
Uma Krishnan [Mon, 26 Mar 2018 16:33:48 +0000 (11:33 -0500)]
scsi: cxlflash: Support AFU interrupt mapping and registration

Add support to map and unmap the irq space and manage irq registrations with
the kernel for each allocated AFU interrupt. Also support mapping the physical
trigger page to obtain an effective address that will be provided to the
cxlflash core in a future commit.

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>
6 years agoscsi: cxlflash: Support AFU interrupt management
Uma Krishnan [Mon, 26 Mar 2018 16:33:41 +0000 (11:33 -0500)]
scsi: cxlflash: Support AFU interrupt management

Add support to allocate and free AFU interrupts using the OCXL provider
services. The trigger page returned upon successful allocation will be mapped
and exposed to the cxlflash core in a future commit.

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>
6 years agoscsi: cxlflash: Support process element lifecycle
Uma Krishnan [Mon, 26 Mar 2018 16:33:35 +0000 (11:33 -0500)]
scsi: cxlflash: Support process element lifecycle

As part of the context lifecycle, the associated process element within the
Shared Process Area (SPA) of the link must be updated. Each process is defined
by various parameters (pid, tid, PASID mm) that are stored in the SPA upon
starting a context and invalidated when a context is stopped.

Use the OCXL provider services to configure the SPA with the appropriate data
that is unique to the process when starting a context. Initially only kernel
contexts are supported and therefore these process values are not applicable.
Note that the OCXL service used has an optional callback for translation fault
error notification. While not used here, it will be expanded in a future
commit.

Also add a service to stop a context by terminating the corresponding PASID
and remove the process element from the SPA.

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>
6 years agoscsi: cxlflash: Setup OCXL transaction layer
Uma Krishnan [Mon, 26 Mar 2018 16:33:28 +0000 (11:33 -0500)]
scsi: cxlflash: Setup OCXL transaction layer

The first function of the link needs to configure the transaction layer
between the host and device. This is accomplished by a call to the OCXL
provider services.

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>
6 years agoscsi: cxlflash: Setup function OCXL link
Uma Krishnan [Mon, 26 Mar 2018 16:33:21 +0000 (11:33 -0500)]
scsi: cxlflash: Setup function OCXL link

After reading and modifying the function configuration, setup the OCXL link
using the OCXL provider services. The link is released when the adapter is
unconfigured.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Support reading adapter VPD data
Uma Krishnan [Mon, 26 Mar 2018 16:33:14 +0000 (11:33 -0500)]
scsi: cxlflash: Support reading adapter VPD data

Use the PCI VPD services to support reading the VPD data of the underlying
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>
6 years agoscsi: cxlflash: Support AFU state toggling
Uma Krishnan [Mon, 26 Mar 2018 16:33:05 +0000 (11:33 -0500)]
scsi: cxlflash: Support AFU state toggling

The AFU should be enabled following a successful configuration and disabled
near the end of the cleanup path.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Support process specific mappings
Uma Krishnan [Mon, 26 Mar 2018 16:32:56 +0000 (11:32 -0500)]
scsi: cxlflash: Support process specific mappings

Once the context is started, the assigned MMIO space can be mapped and
unmapped. Provide means to map and unmap the context MMIO space.

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>
6 years agoscsi: cxlflash: Support starting an adapter context
Uma Krishnan [Mon, 26 Mar 2018 16:32:48 +0000 (11:32 -0500)]
scsi: cxlflash: Support starting an adapter context

Once the adapter context is created, it needs to be started by assigning the
MMIO space for the context and by enabling the process element in the
link. This commit adds the skeleton for starting the context and assigns the
context specific MMIO space. Master contexts have access to the global MMIO
space while the rest have access to the context specific space.

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>
6 years agoscsi: cxlflash: MMIO map the AFU
Uma Krishnan [Mon, 26 Mar 2018 16:32:37 +0000 (11:32 -0500)]
scsi: cxlflash: MMIO map the AFU

When the AFU is configured, the global and per process MMIO regions are
presented by the configuration space. Save these regions and map the global
MMIO region that is used to access all of the control and provisioning data in
the AFU.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Support image reload policy modification
Uma Krishnan [Mon, 26 Mar 2018 16:32:29 +0000 (11:32 -0500)]
scsi: cxlflash: Support image reload policy modification

On a PERST, the AFU image can be reloaded or left intact. Provide means to set
this image reload policy.

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>
6 years agoscsi: cxlflash: Support adapter context discovery
Uma Krishnan [Mon, 26 Mar 2018 16:32:20 +0000 (11:32 -0500)]
scsi: cxlflash: Support adapter context discovery

Provide means to obtain the process element of an adapter context as well as
locate an adapter context by file.

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>
6 years agoscsi: cxlflash: Support adapter file descriptors for OCXL
Uma Krishnan [Mon, 26 Mar 2018 16:32:09 +0000 (11:32 -0500)]
scsi: cxlflash: Support adapter file descriptors for OCXL

Allocate a file descriptor for an adapter context when requested. In order to
allocate inodes for the file descriptors, a pseudo filesystem is created and
used.

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>
6 years agoscsi: cxlflash: Use IDR to manage adapter contexts
Uma Krishnan [Mon, 26 Mar 2018 16:32:00 +0000 (11:32 -0500)]
scsi: cxlflash: Use IDR to manage adapter contexts

A range of PASIDs are used as identifiers for the adapter contexts. These
contexts may be destroyed and created randomly. Use an IDR to keep track of
contexts that are in use and assign a unique identifier to new ones.

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>
6 years agoscsi: cxlflash: Adapter context support for OCXL
Uma Krishnan [Mon, 26 Mar 2018 16:31:53 +0000 (11:31 -0500)]
scsi: cxlflash: Adapter context support for OCXL

Add support to create and release the adapter contexts for OCXL and provide
means to specify certain contexts as a master.

The existing cxlflash core has a design requirement that each host will have a
single host context available by default. To satisfy this requirement, one
host adapter context is created when the hardware AFU is initialized. This is
returned by the get_context() fop.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Setup AFU PASID
Uma Krishnan [Mon, 26 Mar 2018 16:31:44 +0000 (11:31 -0500)]
scsi: cxlflash: Setup AFU PASID

Per the OCXL specification, the maximum PASID supported by the AFU is
indicated by a field within the configuration space. Similar to acTags,
implementations can choose to use any sub-range of PASID within their assigned
range. For cxlflash, the entire range is used.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Setup AFU acTag range
Uma Krishnan [Mon, 26 Mar 2018 16:31:36 +0000 (11:31 -0500)]
scsi: cxlflash: Setup AFU acTag range

The OCXL specification supports distributing acTags amongst different AFUs and
functions on the link. As cxlflash devices are expected to only support a
single AFU per function, the entire range that was assigned to the function is
also assigned to the AFU.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Read host AFU configuration
Uma Krishnan [Mon, 26 Mar 2018 16:31:29 +0000 (11:31 -0500)]
scsi: cxlflash: Read host AFU configuration

The host AFU configuration is read on the initialization path to identify the
features and configuration of the AFU. This data is cached for use in later
configuration steps.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Setup function acTag range
Uma Krishnan [Mon, 26 Mar 2018 16:31:21 +0000 (11:31 -0500)]
scsi: cxlflash: Setup function acTag range

The OCXL specification supports distributing acTags amongst different AFUs and
functions on the link. The platform-specific acTag range for the link is
obtained using the OCXL provider services and then assigned to the host
function based on implementation.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Read host function configuration
Uma Krishnan [Mon, 26 Mar 2018 16:31:09 +0000 (11:31 -0500)]
scsi: cxlflash: Read host function configuration

Per the OCXL specification, the underlying host can have multiple AFUs per
function with each function supporting its own configuration. The host
function configuration is read on the initialization path to evaluate the
number of functions present and identify the features and configuration of the
functions present. This data is cached for use in later configuration
steps. Note that for the OCXL hardware supported by the cxlflash driver, only
one AFU per function is expected.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Hardware AFU for OCXL
Uma Krishnan [Mon, 26 Mar 2018 16:31:01 +0000 (11:31 -0500)]
scsi: cxlflash: Hardware AFU for OCXL

When an adapter is initialized, transport specific configuration and MMIO
mapping details need to be saved. For CXL, this data is managed by the
underlying kernel module. To maintain a separation between the cxlflash core
and underlying transports, introduce a new structure to store data specific to
the OCXL AFU.

Initially only the pointers to underlying PCI and generic devices are added to
this new structure - it will be expanded further in future commits. Services
to create and destroy this hardware AFU are added and integrated in the probe
and exit paths of the driver.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Introduce OCXL backend
Uma Krishnan [Mon, 26 Mar 2018 16:30:51 +0000 (11:30 -0500)]
scsi: cxlflash: Introduce OCXL backend

Add initial infrastructure to support a new cxlflash transport, OCXL.

Claim a dependency on OCXL and add a new file, ocxl_hw.c, which will host the
backend routines that are specific to OCXL.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Add argument identifier names
Uma Krishnan [Mon, 26 Mar 2018 16:30:37 +0000 (11:30 -0500)]
scsi: cxlflash: Add argument identifier names

Checkpatch throws a warning when the argument identifier names are not
included in the function definitions.

To avoid these warnings, argument identifiers are added in the existing
function definitions.

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>
6 years agoscsi: cxlflash: Avoid clobbering context control register value
Matthew R. Ochs [Mon, 26 Mar 2018 16:30:22 +0000 (11:30 -0500)]
scsi: cxlflash: Avoid clobbering context control register value

The SISLite specification originally defined the context control register with
a single field of bits to represent the LISN and also stipulated that the
register reset value be 0. The cxlflash driver took advantage of this when
programming the LISN for the master contexts via an unconditional write - no
other bits were preserved.

When unmap support was added, SISLite was updated to define bit 0 of the
context control register as a way for the AFU to notify the context owner that
unmap operations were supported. Thus the assumptions under which the register
is setup changed and the existing unconditional write is clobbering the unmap
state for master contexts. This is presently not an issue due to the order in
which the context control register is programmed in relation to the unmap bit
being queried but should be addressed to avoid a future regression in the
event this code is moved elsewhere.

To remedy this issue, preserve the bits when programming the LISN field in the
context control register. Since the LISN will now be programmed using a read
value, assert that the initial state of the LISN field is as described in
SISLite (0).

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>
6 years agoscsi: cxlflash: Preserve number of interrupts for master contexts
Uma Krishnan [Mon, 26 Mar 2018 16:29:56 +0000 (11:29 -0500)]
scsi: cxlflash: Preserve number of interrupts for master contexts

The number of interrupts requested for user contexts are stored in the context
specific structures and utilized to manage the interrupts. For the master
contexts, this number is only used once and therefore not saved.

To prepare for future commits where the number of interrupts will be required
in more than one place, preserve the value in the master context structure.

[mkp: typo in comment]

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>
6 years agoLinux 4.17-rc1
Linus Torvalds [Mon, 16 Apr 2018 01:24:20 +0000 (18:24 -0700)]
Linux 4.17-rc1

6 years agoMerge tag 'for-4.17-part2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
Linus Torvalds [Mon, 16 Apr 2018 01:08:35 +0000 (18:08 -0700)]
Merge tag 'for-4.17-part2-tag' of git://git./linux/kernel/git/kdave/linux

Pull more btrfs updates from David Sterba:
 "We have queued a few more fixes (error handling, log replay,
  softlockup) and the rest is SPDX updates that touche almost all files
  so the diffstat is long"

* tag 'for-4.17-part2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: Only check first key for committed tree blocks
  btrfs: add SPDX header to Kconfig
  btrfs: replace GPL boilerplate by SPDX -- sources
  btrfs: replace GPL boilerplate by SPDX -- headers
  Btrfs: fix loss of prealloc extents past i_size after fsync log replay
  Btrfs: clean up resources during umount after trans is aborted
  btrfs: Fix possible softlock on single core machines
  Btrfs: bail out on error during replay_dir_deletes
  Btrfs: fix NULL pointer dereference in log_dir_items

6 years agoMerge tag '4.17-rc1SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Mon, 16 Apr 2018 01:06:22 +0000 (18:06 -0700)]
Merge tag '4.17-rc1SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "SMB3 fixes, a few for stable, and some important cleanup work from
  Ronnie of the smb3 transport code"

* tag '4.17-rc1SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: change validate_buf to validate_iov
  cifs: remove rfc1002 hardcoded constants from cifs_discard_remaining_data()
  cifs: Change SMB2_open to return an iov for the error parameter
  cifs: add resp_buf_size to the mid_q_entry structure
  smb3.11: replace a 4 with server->vals->header_preamble_size
  cifs: replace a 4 with server->vals->header_preamble_size
  cifs: add pdu_size to the TCP_Server_Info structure
  SMB311: Improve checking of negotiate security contexts
  SMB3: Fix length checking of SMB3.11 negotiate request
  CIFS: add ONCE flag for cifs_dbg type
  cifs: Use ULL suffix for 64-bit constant
  SMB3: Log at least once if tree connect fails during reconnect
  cifs: smb2pdu: Fix potential NULL pointer dereference

6 years agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Mon, 16 Apr 2018 00:24:12 +0000 (17:24 -0700)]
Merge tag 'scsi-fixes' of git://git./linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "This is a set of minor (and safe changes) that didn't make the initial
  pull request plus some bug fixes.

  The status handling code is actually a running regression from the
  previous merge window which had an incomplete fix (now reverted) and
  most of the remaining bug fixes are for problems older than the
  current merge window"

[ Side note: this merge also takes the base kernel git repository to 6+
  million objects for the first time. Technically we hit it a couple of
  merges ago already if you count all the tag objects, but now it
  reaches 6M+ objects reachable from HEAD.

  I was joking around that that's when I should switch to 5.0, because
  3.0 happened at the 2M mark, and 4.0 happened at 4M objects. But
  probably not, even if numerology is about as good a reason as any.

                                                              - Linus ]

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: devinfo: Add Microsoft iSCSI target to 1024 sector blacklist
  scsi: cxgb4i: silence overflow warning in t4_uld_rx_handler()
  scsi: dpt_i2o: Use after free in I2ORESETCMD ioctl
  scsi: core: Make scsi_result_to_blk_status() recognize CONDITION MET
  scsi: core: Rename __scsi_error_from_host_byte() into scsi_result_to_blk_status()
  Revert "scsi: core: return BLK_STS_OK for DID_OK in __scsi_error_from_host_byte()"
  scsi: aacraid: Insure command thread is not recursively stopped
  scsi: qla2xxx: Correct setting of SAM_STAT_CHECK_CONDITION
  scsi: qla2xxx: correctly shift host byte
  scsi: qla2xxx: Fix race condition between iocb timeout and initialisation
  scsi: qla2xxx: Avoid double completion of abort command
  scsi: qla2xxx: Fix small memory leak in qla2x00_probe_one on probe failure
  scsi: scsi_dh: Don't look for NULL devices handlers by name
  scsi: core: remove redundant assignment to shost->use_blk_mq

6 years agoMerge tag 'kbuild-v4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
Linus Torvalds [Mon, 16 Apr 2018 00:21:30 +0000 (17:21 -0700)]
Merge tag 'kbuild-v4.17-2' of git://git./linux/kernel/git/masahiroy/linux-kbuild

Pull more Kbuild updates from Masahiro Yamada:

 - pass HOSTLDFLAGS when compiling single .c host programs

 - build genksyms lexer and parser files instead of using shipped
   versions

 - rename *-asn1.[ch] to *.asn1.[ch] for suffix consistency

 - let the top .gitignore globally ignore artifacts generated by flex,
   bison, and asn1_compiler

 - let the top Makefile globally clean artifacts generated by flex,
   bison, and asn1_compiler

 - use safer .SECONDARY marker instead of .PRECIOUS to prevent
   intermediate files from being removed

 - support -fmacro-prefix-map option to make __FILE__ a relative path

 - fix # escaping to prepare for the future GNU Make release

 - clean up deb-pkg by using debian tools instead of handrolled
   source/changes generation

 - improve rpm-pkg portability by supporting kernel-install as a
   fallback of new-kernel-pkg

 - extend Kconfig listnewconfig target to provide more information

* tag 'kbuild-v4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kconfig: extend output of 'listnewconfig'
  kbuild: rpm-pkg: use kernel-install as a fallback for new-kernel-pkg
  Kbuild: fix # escaping in .cmd files for future Make
  kbuild: deb-pkg: split generating packaging and build
  kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
  kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS markers
  kbuild: rename *-asn1.[ch] to *.asn1.[ch]
  kbuild: clean up *-asn1.[ch] patterns from top-level Makefile
  .gitignore: move *-asn1.[ch] patterns to the top-level .gitignore
  kbuild: add %.dtb.S and %.dtb to 'targets' automatically
  kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
  genksyms: generate lexer and parser during build instead of shipping
  kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile
  .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore
  kbuild: use HOSTLDFLAGS for single .c executables