platform/kernel/linux-rpi.git
6 years agoscsi: aacraid: use timespec64 instead of timeval
Arnd Bergmann [Tue, 7 Nov 2017 10:46:05 +0000 (11:46 +0100)]
scsi: aacraid: use timespec64 instead of timeval

aacraid passes the current time to the firmware in one of two ways,
either as year/month/day/... or as 32-bit unsigned seconds.

The first one is broken on 32-bit architectures as it cannot go past
year 2038. Using timespec64 here makes it behave properly on both 32-bit
and 64-bit architectures, and avoids relying on signed integer overflow
to pass times into the second interface.

The interface used in aac_send_hosttime() however is still problematic
in year 2106 when 32-bit seconds overflow. Hopefully we don't have to
worry about aacraid by that time.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_transport_fc: add 64GBIT and 128GBIT port speed definitions
James Smart [Fri, 3 Nov 2017 23:26:08 +0000 (16:26 -0700)]
scsi: scsi_transport_fc: add 64GBIT and 128GBIT port speed definitions

Add 64GBIT and 128GBIT port speed definitions.

Upcoming hardware will reference these speeds.

Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Suppress a kernel complaint in qla_init_base_qpair()
Bart Van Assche [Mon, 6 Nov 2017 19:59:05 +0000 (11:59 -0800)]
scsi: qla2xxx: Suppress a kernel complaint in qla_init_base_qpair()

Avoid that the following is reported while loading the qla2xxx
kernel module:

BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/783
caller is debug_smp_processor_id+0x17/0x20
CPU: 7 PID: 783 Comm: modprobe Not tainted 4.14.0-rc8-dbg+ #2
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 dump_stack+0x8e/0xce
 check_preemption_disabled+0xe3/0xf0
 debug_smp_processor_id+0x17/0x20
 qla2x00_probe_one+0xf43/0x26c0 [qla2xxx]
 pci_device_probe+0xca/0x140
 driver_probe_device+0x2e2/0x440
 __driver_attach+0xa3/0xe0
 bus_for_each_dev+0x5f/0x90
 driver_attach+0x19/0x20
 bus_add_driver+0x1c0/0x260
 driver_register+0x5b/0xd0
 __pci_register_driver+0x63/0x70
 qla2x00_module_init+0x1d6/0x222 [qla2xxx]
 do_one_initcall+0x3c/0x163
 do_init_module+0x55/0x1eb
 load_module+0x20a2/0x2890
 SYSC_finit_module+0xd7/0xf0
 SyS_finit_module+0x9/0x10
 entry_SYSCALL_64_fastpath+0x23/0xc2

Fixes: commit 8abfa9e22683 ("scsi: qla2xxx: Add function call to qpair for door bell")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Quinn Tran <quinn.tran@cavium.com>
Cc: Himanshu Madhani <himanshu.madhani@cavium.com>
Cc: <stable@vger.kernel.org>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: fix dma_addr_t casts
Arnd Bergmann [Mon, 6 Nov 2017 13:35:16 +0000 (14:35 +0100)]
scsi: mpt3sas: fix dma_addr_t casts

The newly added base_make_prp_nvme function triggers a build warning on
some 32-bit configurations:

drivers/scsi/mpt3sas/mpt3sas_base.c: In function 'base_make_prp_nvme':
drivers/scsi/mpt3sas/mpt3sas_base.c:1664:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  msg_phys = (dma_addr_t)mpt3sas_base_get_pcie_sgl_dma(ioc, smid);

After taking a closer look, I found that the problem is that the new
code mixes up pointers and dma_addr_t values unnecessarily.

This changes it to use the correct types consistently, which lets us get
rid of a lot of type casts in the process. I'm also renaming some
variables to avoid confusion between physical and dma address spaces
that are often distinct.

Fixes: 016d5c35e278 ("scsi: mpt3sas: SGL to PRP Translation for I/Os to NVMe devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: be2iscsi: Use kasprintf
Himanshu Jha [Wed, 11 Oct 2017 15:36:14 +0000 (21:06 +0530)]
scsi: be2iscsi: Use kasprintf

Use kasprintf instead of combination of kmalloc and sprintf.  Also,
remove BEISCSI_MSI_NAME macro used to specify size of string as
kasprintf handles size computations.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: storvsc: Avoid excessive host scan on controller change
Long Li [Tue, 31 Oct 2017 21:58:08 +0000 (14:58 -0700)]
scsi: storvsc: Avoid excessive host scan on controller change

When there are multiple disks attached to the same SCSI controller, the
host may send several VSTOR_OPERATION_REMOVE_DEVICE or
VSTOR_OPERATION_ENUMERATE_BUS messages in a row, to indicate there is a
change on the SCSI controller. In response, storvsc rescans the SCSI
host.

There is no need to do multiple scans on the same host. Fix the code to
do only one scan.

[mkp: applied by hand]

Signed-off-by: Long Li <longli@microsoft.com>
Tested-by: Cathy Avery <cavery@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: fix kzalloc-simple.cocci warnings
Vasyl Gomonovych [Wed, 11 Oct 2017 19:42:41 +0000 (21:42 +0200)]
scsi: lpfc: fix kzalloc-simple.cocci warnings

drivers/scsi/lpfc/lpfc_debugfs.c:5460:22-29: WARNING: kzalloc should be used for phba -> nvmeio_trc, instead of kmalloc/memset
drivers/scsi/lpfc/lpfc_debugfs.c:2230:20-27: WARNING: kzalloc should be used for phba -> nvmeio_trc, instead of kmalloc/memset

 Use kzalloc rather than kmalloc followed by memset with 0

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

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Update mpt3sas driver version.
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:39 +0000 (18:02 +0530)]
scsi: mpt3sas: Update mpt3sas driver version.

Updated mpt3sas driver version to 17.100.00.00

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Fix sparse warnings
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:38 +0000 (18:02 +0530)]
scsi: mpt3sas: Fix sparse warnings

1) Used variable __le64/__le32 whichever required in building NVME
PRP, and passed to LE Controller.

2) Remove unused functions, And Declared functions as static which are
used only in mpt3sas_scsih.c.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Fix nvme drives checking for tlr.
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:37 +0000 (18:02 +0530)]
scsi: mpt3sas: Fix nvme drives checking for tlr.

Check for NVMe drives before enabling or checking tlr.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: NVMe drive support for BTDHMAPPING ioctl command and log info
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:36 +0000 (18:02 +0530)]
scsi: mpt3sas: NVMe drive support for BTDHMAPPING ioctl command and log info

* Added debug prints for pcie devices in ioctl debug path. Which
will be helpful for debugging.
* Added PCIe device support for ioctl BTDHMAPPING ioctl.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Add-Task-management-debug-info-for-NVMe-drives.
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:35 +0000 (18:02 +0530)]
scsi: mpt3sas: Add-Task-management-debug-info-for-NVMe-drives.

Added debug information for NVMe/PCIe drives in target rest path

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: scan and add nvme device after controller reset
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:34 +0000 (18:02 +0530)]
scsi: mpt3sas: scan and add nvme device after controller reset

After Controller reset, Scan and add nvme device back to the topology.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Set NVMe device queue depth as 128
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:33 +0000 (18:02 +0530)]
scsi: mpt3sas: Set NVMe device queue depth as 128

Sets nvme device queue depth, name and displays device capabilities

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Handle NVMe PCIe device related events generated from firmware.
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:32 +0000 (18:02 +0530)]
scsi: mpt3sas: Handle NVMe PCIe device related events generated from firmware.

* The controller firmware sends separate events for NVMe devices and
  PCIe switches similar to existing SAS events.

* NVMe device detection, addition and removal are reported by the
  firmware through PCIe Topology Change list events.

* The PCIe device state change events are sent when the firmware
  detects any abnormal conditions with a NVMe device or switch.

* The enumeration event are sent when the firmware starts PCIe device
  enumeration and stops.

* This patch has the code change to handle the events and add/remove
  NVMe devices in driver's inventory.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: API's to remove nvme drive from sml
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:31 +0000 (18:02 +0530)]
scsi: mpt3sas: API's to remove nvme drive from sml

The following functions are called in nvme drive remove path:

_scsih_pcie_device_remove_by_handle
_scsih_pcie_device_remove_from_sml

[mkp: clarify commit message]

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: API 's to support NVMe drive addition to SML
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:30 +0000 (18:02 +0530)]
scsi: mpt3sas: API 's to support NVMe drive addition to SML

Below Functions are added in various paths to support NVMe drive
addition.

_scsih_pcie_add_device
_scsih_pcie_device_add
_scsih_pcie_device_init_add
_scsih_check_pcie_access_status
_scsih_pcie_check_device

mpt3sas_get_pdev_by_handle

mpt3sas_config_get_pcie_device_pg0
mpt3sas_config_get_pcie_device_pg2

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Added support for nvme encapsulated request message.
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:29 +0000 (18:02 +0530)]
scsi: mpt3sas: Added support for nvme encapsulated request message.

* Mpt3sas driver uses the NVMe Encapsulated Request message to send an
  NVMe command to an NVMe device attached to the IOC.

* Normal I/O commands like reads and writes are passed to the
  controller as SCSI commands and the controller has the ability to
  translate the commands to NVMe equivalent.

* This encapsulated NVMe command is used by applications to send
  direct NVMe commands to NVMe drives.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: SGL to PRP Translation for I/Os to NVMe devices
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:28 +0000 (18:02 +0530)]
scsi: mpt3sas: SGL to PRP Translation for I/Os to NVMe devices

* Added support for translating the SGLs associated with incoming
commands either to IEE SGL or NVMe PRPs for NVMe devices.

* The hardware translation of IEEE SGL to NVMe PRPs has limitations
and if a command cannot be translated by hardware then it will go to
firmware and the firmware needs to translate it. This will have a
performance impact. To avoid that, the driver proactively checks
whether the translation will be done in hardware or not. If not, then
driver translates.

[mkp: clarified commit message]

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mpt3sas: Add nvme device support in slave alloc, target alloc and probe
Suganath Prabu Subramani [Tue, 31 Oct 2017 12:32:27 +0000 (18:02 +0530)]
scsi: mpt3sas: Add nvme device support in slave alloc, target alloc and probe

1) Added support for probing pcie device and adding NVMe drives to SML
and driver's internal list pcie_device_list.

2) Added support for determing NVMe as boot device.

3) Added nvme device support for call back functions scan_finished
target_alloc,slave_alloc,target destroy and slave destroy.

 a) During scan, pcie devices are probed and added to SML to drivers
internal list.

 b) target_alloc & slave alloc API's allocates resources for
(MPT3SAS_TARGET & MPT3SAS_DEVICE) private datas and holds information
like handle, target_id etc.

 c) slave_destroy & target_destroy are called when driver unregisters
or removes device. Also frees allocated resources and info.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: fix spelling mistake: "thershold" -> "threshold"
Colin Ian King [Thu, 2 Nov 2017 10:18:10 +0000 (10:18 +0000)]
scsi: megaraid_sas: fix spelling mistake: "thershold" -> "threshold"

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>
6 years agoscsi: storvsc: Allow only one remove lun work item to be issued per lun
Cathy Avery [Tue, 31 Oct 2017 12:52:06 +0000 (08:52 -0400)]
scsi: storvsc: Allow only one remove lun work item to be issued per lun

When running multipath on a VM if all available paths go down the driver
can schedule large amounts of storvsc_remove_lun work items to the same
lun. In response to the failing paths typically storvsc responds by
taking host->scan_mutex and issuing a TUR per lun. If there has been
heavy IO to the failed device all the failed IOs are returned from the
host. A remove lun work item is issued per failed IO. If the outstanding
TURs have not been completed in a timely manner the scan_mutex is never
released or released too late. Consequently the many remove lun work
items are not completed as scsi_remove_device also tries to take
host->scan_mutex.  This results in dragging the VM down and sometimes
completely.

This patch only allows one remove lun to be issued to a particular lun
while it is an instantiated member of the scsi stack.

Signed-off-by: Cathy Avery <cavery@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid: Remove redundant code in megasas_alloc_cmds
Yisheng Xie [Wed, 25 Oct 2017 09:57:07 +0000 (17:57 +0800)]
scsi: megaraid: Remove redundant code in megasas_alloc_cmds

megasas_alloc_cmds is to alloc cmd_list of instance instead of fusion,
and fusion is useless in this function. Just remove it.

Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_error: DID_SOFT_ERROR comment clean up
Petros Koutoupis [Mon, 30 Oct 2017 21:38:10 +0000 (16:38 -0500)]
scsi: scsi_error: DID_SOFT_ERROR comment clean up

Updated comment. We are keeping track of maximum number of retries per
command via retries/allowed in struct scsi_cmnd. Corrected comment
positioning.

[mkp: applied by hand]

Signed-off-by: Petros Koutoupis <petros@petroskoutoupis.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_debug: write_same: fix error report
Douglas Gilbert [Sun, 29 Oct 2017 14:47:19 +0000 (10:47 -0400)]
scsi: scsi_debug: write_same: fix error report

The scsi_debug driver incorrectly suggests there is an error with the
SCSI WRITE SAME command when the number_of_logical_blocks is greater
than 1. It will also suggest there is an error when NDOB
(no data-out buffer) is set and the number_of_logical_blocks is
greater than 0. Both are valid, fix.

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_transport_iscsi: fix spelling mistake: 'Cound' -> 'Could'
Arvind Yadav [Sun, 29 Oct 2017 06:09:46 +0000 (11:39 +0530)]
scsi: scsi_transport_iscsi: fix spelling mistake: 'Cound' -> 'Could'

Trivial fix to spelling mistakes in 'iscsi_get_host_stats'.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: NCR5380: Suppress SDTR and WDTR message logging
Finn Thain [Thu, 26 Oct 2017 05:51:50 +0000 (16:51 +1100)]
scsi: NCR5380: Suppress SDTR and WDTR message logging

The 5380 drivers only support asynchronous transfers and the 5380
controllers only have narrow busses. Hence, the core driver will reject
any SDTR and WDTR messages from target devices. Don't log this, it's
expected behaviour. Also, fix the off-by-one array indices in the
arguments to scmd_printk().

Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Derive pid through accessors
Matthew R. Ochs [Wed, 25 Oct 2017 21:36:29 +0000 (16:36 -0500)]
scsi: cxlflash: Derive pid through accessors

The cxlflash driver tracks process IDs alongside contexts to validate
context ownership. Currently, the process IDs are derived by directly
accessing values from the 'current' task pointer. While this method of
access is fine for the current process, it is incorrect when the parent
process ID is needed as the access requires serialization.

To address the incorrect issue and provide a consistent means of
deriving the process ID within the cxlflash driver, use the task
accessors defined linux/sched.h.

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: Allow cards without WWPN VPD to configure
Matthew R. Ochs [Wed, 25 Oct 2017 21:36:20 +0000 (16:36 -0500)]
scsi: cxlflash: Allow cards without WWPN VPD to configure

Currently, all adapters that cxlflash supports must have WWPN VPD
keywords to complete configuration. This was required as cards with
external FC ports needed to be programmed with WWPNs.

Newer supported cards do not have an external FC interface and therefore
do not require WWPN. To support backwards compatibility, these devices
have included 'dummy' WWPN VPD with WWPN values of zero. This however
places a dependency that all future cards have WWPN VPD, which may not
always be the case.

Allow for cards to not have WWPN, designating which cards are expected
to have it in order to configure properly.

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: Use derived maximum write same length
Matthew R. Ochs [Wed, 25 Oct 2017 21:35:57 +0000 (16:35 -0500)]
scsi: cxlflash: Use derived maximum write same length

The existing write same routine within the cxlflash driver uses a
statically defined value for the maximum write same transfer length.
While this is close to the value reflected by the original device that
was supported by cxlflash, newer devices are capable of much larger
lengths. Supporting what the device is capable of offers substantial
performance improvement as the scrub routine within cxlflash operates on
'chunk size' units (256MB with a 4K sector size).

Instead of a #define, use the write same maximum length that is stored
in the block layer in units of 512 byte sectors. This value is initially
determined from the block limits VPD page during device discovery and
can also be manipulated from sysfs. As a general cleanup, designate the
timeout used when executing the write same command as constant.

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: hisi_sas: add v3 hw port AXI error handling
Xiaofei Tan [Tue, 24 Oct 2017 15:51:49 +0000 (23:51 +0800)]
scsi: hisi_sas: add v3 hw port AXI error handling

Add support for servicing AXI errors handling. We do a host controller
reset for such errors.

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: add v3 hw support for AXI fatal error
Xiaofei Tan [Tue, 24 Oct 2017 15:51:48 +0000 (23:51 +0800)]
scsi: hisi_sas: add v3 hw support for AXI fatal error

Add support for processing AXI bus fatal errors.

If AXI bus fatal error happen, do controller reset to recover.

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: complete all tasklets prior to host reset
Xiaofei Tan [Tue, 24 Oct 2017 15:51:47 +0000 (23:51 +0800)]
scsi: hisi_sas: complete all tasklets prior to host reset

The CQ event is handled in tasklet context, and it could be delayed if
the system loading is high.

It is possible to run into some problems when executing a host reset
when cq_tasklet_vx_hw() is being executed.

So, prior to host reset, execute tasklet_kill() to ensure that all CQ
tasklets are complete.

Besides, as the function hisi_sas_wait_tasklets_done() is added to do
tasklet_kill(), this patch refactors some code where tasklet_kill() is
used.

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: fix a bug when free device for v3 hw
Xiang Chen [Tue, 24 Oct 2017 15:51:46 +0000 (23:51 +0800)]
scsi: hisi_sas: fix a bug when free device for v3 hw

Use completion to wait on ITCT CLR interrupt finishing before
processing other things when freeing a device.

This is safer than the pre-existing process of polling the register.

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: add hisi_hba.rst_work init for v3 hw
Xiaofei Tan [Tue, 24 Oct 2017 15:51:45 +0000 (23:51 +0800)]
scsi: hisi_sas: add hisi_hba.rst_work init for v3 hw

Add init code of hisi_hba->rst_work for v3 hw. Because v3 hw also need
it to recover controller when some hw errors occurs.

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: add v3 hw DFX feature
Xiaofei Tan [Tue, 24 Oct 2017 15:51:44 +0000 (23:51 +0800)]
scsi: hisi_sas: add v3 hw DFX feature

Realise get_events() to add DFX feature for v3 hw. Just like v2 hw, We
support the following errors:
- loss_of_dword_sync_count
- invalid_dword_count
- phy_reset_problem_count
- running_disparity_error_count

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: init connect cfg register for v3 hw
Xiaofei Tan [Tue, 24 Oct 2017 15:51:43 +0000 (23:51 +0800)]
scsi: hisi_sas: init connect cfg register for v3 hw

Add initialization of register CON_CFG_DRIVER for v3 hw, to limit
number of the times of setup connection.

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: check PHY state in get_wideport_bitmap_v3_hw()
Xiaofei Tan [Tue, 24 Oct 2017 15:51:42 +0000 (23:51 +0800)]
scsi: hisi_sas: check PHY state in get_wideport_bitmap_v3_hw()

We should check register PHY_STATE when getting the bitmap of a
wideport, as, if the PHY is not ready, the value of register
PHY_PORT_NUM_MA is not valid.

V2 hw has done this check, and v3 hw should do this check too.

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 array for v2 hw AXI errors
Shiju Jose [Tue, 24 Oct 2017 15:51:39 +0000 (23:51 +0800)]
scsi: hisi_sas: use array for v2 hw AXI errors

The code to print AXI errors in v2 hw driver is repetitive.

This patch condenses the code by looping an array of errors.

Also, a formatting error in one_bit_ecc_errors[] and
multi_bit_ecc_errors[] is fixed.

Signed-off-by: Shiju Jose <shiju.jose@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: fix the risk of freeing slot twice
Xiaofei Tan [Tue, 24 Oct 2017 15:51:38 +0000 (23:51 +0800)]
scsi: hisi_sas: fix the risk of freeing slot twice

The function hisi_sas_slot_task_free() is used to free the slot and do
tidy-up of LLDD resources. The LLDD generally should know the state of
a slot and decide when to free it, and it should only be done once.

For some scenarios, we really don't know the state, like when TMF
timeout. In this case, we check task->lldd_task before calling
hisi_sas_slot_task_free().

However, we may miss some scenarios when we should also check
task->lldd_task, and it is not SMP safe to check task->lldd_task as we
don't protect it within spin lock.

This patch is to fix this risk of freeing slot twice, as follows:

  1. Check task->lldd_task in the hisi_sas_slot_task_free(), and give
     up freeing of this time if task->lldd_task is NULL.

  2. Set slot->buf to NULL after it is freed.

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: fix NULL check in SMP abort task path
Xiaofei Tan [Tue, 24 Oct 2017 15:51:37 +0000 (23:51 +0800)]
scsi: hisi_sas: fix NULL check in SMP abort task path

This patch adds a NULL check of task->lldd_task before freeing the
slot in SMP path.

This is to guard against the scenario of the slot being freed during
the from the preceding internal abort.

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: us start_phy in PHY_FUNC_LINK_RESET
Xiang Chen [Tue, 24 Oct 2017 15:51:36 +0000 (23:51 +0800)]
scsi: hisi_sas: us start_phy in PHY_FUNC_LINK_RESET

When a PHY_FUNC_LINK_RESET is issued, we need to fill the transport
identify_frame to SAS controller before the PHYs are enabled.

Without this, we may find that if a PHY which belonged to a wideport
before the reset may generate a new port id.

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: fix SATA breakpoint memory size
Xiang Chen [Tue, 24 Oct 2017 15:51:35 +0000 (23:51 +0800)]
scsi: hisi_sas: fix SATA breakpoint memory size

Currently the size of memory we allocate for SATA breakpoint buffer is
incorrect.

The breakpoint memory size should be as follows: 32 (NCQ tags) * 128 *
2048 (max #devs) = 8MB

Currently we only allocate 0.5MB, but get away with it as we never
have SATA device index > 128 typically.

To conserve precious DMA memory (8MB may not be even available), limit
the number of devices per HBA to 1024, which means 4MB of memory
required for SATA breakpoint.

The 1024 device limit applied to all HW versions. For v3 hw, we need
to configure this value.

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: grab hisi_hba.lock when processing slots
Xiang Chen [Tue, 24 Oct 2017 15:51:34 +0000 (23:51 +0800)]
scsi: hisi_sas: grab hisi_hba.lock when processing slots

When adding/removing slots from device list, we need to lock this
operation with hisi_hba lock for safety.

This patch adds missing instances of this.

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: use spin_lock_irqsave() for hisi_hba.lock
Xiaofei Tan [Tue, 24 Oct 2017 15:51:33 +0000 (23:51 +0800)]
scsi: hisi_sas: use spin_lock_irqsave() for hisi_hba.lock

We used spin_lock() to grab hisi_hba.lock in two places where
spin_lock_irqsave() should be used, as hisi_hba.lock can be taken in
interrupt context.

This patch is to fix this.

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: fix internal abort slot timeout bug
Xiang Chen [Tue, 24 Oct 2017 15:51:32 +0000 (23:51 +0800)]
scsi: hisi_sas: fix internal abort slot timeout bug

When an internal abort times out in hisi_sas_internal_task_abort(),
goto the exit label in and not go through the other task status
checks.

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 get_ncq_tag_v3_hw()
Xiang Chen [Tue, 24 Oct 2017 15:51:31 +0000 (23:51 +0800)]
scsi: hisi_sas: delete get_ncq_tag_v3_hw()

We already relocated hisi_sas_get_ncq_tag() into common file main.c,
so delete get_ncq_tag_v3_hw() and use hisi_sas_get_ncq_tag() instead.

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: scsi_devinfo: Add scsi_devinfo_tbl.c
Jeffy Chen [Wed, 25 Oct 2017 07:39:10 +0000 (15:39 +0800)]
scsi: scsi_devinfo: Add scsi_devinfo_tbl.c

Add generated scsi_devinfo_tbl.c into .gitignore.

Fixes: 345e29608b4b ("scsi: scsi: Export blacklist flags to sysfs")
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.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 [Thu, 19 Oct 2017 09:49:06 +0000 (02:49 -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: Add support for 64bit consistent DMA
Shivasharan S [Thu, 19 Oct 2017 09:49:05 +0000 (02:49 -0700)]
scsi: megaraid_sas: Add support for 64bit consistent DMA

The latest MegaRAID Firmware (for Invader series) has support for 64bit
DMA for both streaming and consistent DMA buffers.  All Ventura series
controller FW always support 64 bit consistent DMA.  Also, on a few
architectures 32bit DMA is not supported.

Current driver always prefers 32bit for consistent DMA and 64bit for
streaming DMA.  This behavior was unintentional and carried forwarded
from legacy controller FW. Need to enhance the driver to support 64bit
consistent DMA buffers based on the firmware capability.

Below is the DMA setting strategy in driver with this patch.  For
Ventura series, always try to set 64bit DMA mask. If it fails fall back
to 32bit DMA mask.  For Invader series and earlier generation
controllers, first try to set to 32bit consistent DMA mask irrespective
of FW capability. This is needed to ensure firmware downgrades do not
break. If 32bit DMA setting fails, check FW capability and try seting to
64bit DMA mask.

There are certain restrictions in the hardware for having all sense
buffers and all reply descriptors to be in the same 4GB memory region.
This limitation is h/w dependent and can not be changed in firmware.
This limitation needs to be taken care in driver while allocating the
buffers.  There was a discussion regarding this - find details at below
link.  https://www.spinics.net/lists/linux-scsi/msg108251.html

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Do not limit queue_depth to 1k in non-RDPQ mode
Shivasharan S [Thu, 19 Oct 2017 09:49:04 +0000 (02:49 -0700)]
scsi: megaraid_sas: Do not limit queue_depth to 1k in non-RDPQ mode

Driver load fails if memory allocation for request frame pool fails due
to the higher queue_depth requirement. The driver now allows dynamically
reducing queue_depth if memory allocations fail rather than failing
load.  With this, there is no need to limit queue_depth to 1K.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Retry with reduced queue depth when alloc fails for higher QD
Shivasharan S [Thu, 19 Oct 2017 09:49:03 +0000 (02:49 -0700)]
scsi: megaraid_sas: Retry with reduced queue depth when alloc fails for higher QD

In certain cases, the host memory is limited and with FW supporting
higher queue depths there are increasing chances of IO request frame
allocation failures that we are seeing. In case of request frame
allocation failures, retry allocation with reduced queue depth (in steps
of 64) to continue to configure the controller with a reduced
performance rather than failing load.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Incorrect processing of IOCTL frames for SMP/STP commands
Shivasharan S [Thu, 19 Oct 2017 09:49:02 +0000 (02:49 -0700)]
scsi: megaraid_sas: Incorrect processing of IOCTL frames for SMP/STP commands

cmd->frame->dcmd.opcode will be valid only for MFI_CMD_DCMD
IOCTL frames. Currently driver check for cmd->frame->dcmd.opcode without
checking cmd type. Ensure we check dcmd opcode only for MFI_CMD_DCMD
commands. Separate handling of MFI_CMD_SMP/STP commands from
MFI_CMD_DCMD in completion path.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Resize MFA frame used for IOC INIT to 4k
Shivasharan S [Thu, 19 Oct 2017 09:49:01 +0000 (02:49 -0700)]
scsi: megaraid_sas: Resize MFA frame used for IOC INIT to 4k

Older firmware version unconditionally pulls 4k frame for IOC INIT MFA
frame.  But driver allocates 1k or 4k max_chain_frame_sz based on FW
capability.  During boot time, this results in DMA read errors.
Workaround fix in driver by allocating separate ioc_init frame of 4k
size to support older firmware.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Update current host time to FW during IOC Init
Shivasharan S [Thu, 19 Oct 2017 09:49:00 +0000 (02:49 -0700)]
scsi: megaraid_sas: Update current host time to FW during IOC Init

Driver needs to send current host time to firmware during init.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Move controller memory allocations and DMA mask settings from...
Shivasharan S [Thu, 19 Oct 2017 09:48:59 +0000 (02:48 -0700)]
scsi: megaraid_sas: Move controller memory allocations and DMA mask settings from probe to megasas_init_fw

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Move initialization of instance parameters inside newly created...
Shivasharan S [Thu, 19 Oct 2017 09:48:58 +0000 (02:48 -0700)]
scsi: megaraid_sas: Move initialization of instance parameters inside newly created function megasas_init_ctrl_params

Code refactoring, no functional change. Create new function to
initialize all the controller parameters during load time.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: remove instance->ctrl_info
Shivasharan S [Thu, 19 Oct 2017 09:48:57 +0000 (02:48 -0700)]
scsi: megaraid_sas: remove instance->ctrl_info

Re-use the pre-allocated ctrl_info DMA buffer.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Pre-allocate frequently used DMA buffers
Shivasharan S [Thu, 19 Oct 2017 09:48:56 +0000 (02:48 -0700)]
scsi: megaraid_sas: Pre-allocate frequently used DMA buffers

Pre-allocate few of the frequently used DMA buffers during load time.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Create separate functions for allocating and freeing controller...
Shivasharan S [Thu, 19 Oct 2017 09:48:55 +0000 (02:48 -0700)]
scsi: megaraid_sas: Create separate functions for allocating and freeing controller DMA buffers

Code refactoring - create separate functions to allocate and free
controller DMA buffers

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Create separate functions to allocate ctrl memory
Shivasharan S [Thu, 19 Oct 2017 09:48:54 +0000 (02:48 -0700)]
scsi: megaraid_sas: Create separate functions to allocate ctrl memory

No functional change. Code refactoring to improve readability.  Move the
code to allocate and free controller memory into separate functions.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: reduce size of fusion_context and use kmalloc for allocation
Shivasharan S [Thu, 19 Oct 2017 09:48:53 +0000 (02:48 -0700)]
scsi: megaraid_sas: reduce size of fusion_context and use kmalloc for allocation

fusion_context structure is very large around 180kB and most of the size
is contributed by log_to_span array. Move log_to_span out of fusion
context and have separate allocation for log_to_span. And use kmalloc to
allocate fusion_context.  Currently kmemleak reports 1000s of false
positives for fusion->cmd_list[]. kmemleak does not track page
allocation for fusion_context. This change will also fix the false
positives reported by kmemleak.

Ref: https://marc.info/?l=linux-scsi&m=150545293900917

Reported-by: Shu Wang <shuwang@redhat.com>
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: replace is_ventura with adapter_type checks
Shivasharan S [Thu, 19 Oct 2017 09:48:52 +0000 (02:48 -0700)]
scsi: megaraid_sas: replace is_ventura with adapter_type checks

No functional change.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Remove redundant checks for ctrl_context
Shivasharan S [Thu, 19 Oct 2017 09:48:51 +0000 (02:48 -0700)]
scsi: megaraid_sas: Remove redundant checks for ctrl_context

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: replace instance->ctrl_context checks with instance->adapter_type
Shivasharan S [Thu, 19 Oct 2017 09:48:50 +0000 (02:48 -0700)]
scsi: megaraid_sas: replace instance->ctrl_context checks with instance->adapter_type

Increase code readability. No functional change.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_sas: Add support for Crusader controllers
Shivasharan S [Thu, 19 Oct 2017 09:48:49 +0000 (02:48 -0700)]
scsi: megaraid_sas: Add support for Crusader controllers

Add support for PCI VID/DID 0x1000/0x0015 based MegaRAID controllers.
Since the DID 0x0015 conflicts with DELL PERC5 controllers,
add vendor ID based check specific for DELL PERC5.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
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 adapter_type for all gen controllers
Shivasharan S [Thu, 19 Oct 2017 09:48:48 +0000 (02:48 -0700)]
scsi: megaraid_sas: use adapter_type for all gen controllers

No functional change.
Refactor adapter_type to set for all generation controllers, not
just for fusion controllers.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: bump driver version
Don Brace [Fri, 20 Oct 2017 21:52:17 +0000 (16:52 -0500)]
scsi: hpsa: bump driver version

Reviewed-by: Gerry Morong <gerry.morong@microsemi.com>
Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: add enclosure logical identifier
Don Brace [Fri, 20 Oct 2017 21:52:10 +0000 (16:52 -0500)]
scsi: hpsa: add enclosure logical identifier

Add support for enclosure logical identifier

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: correct logical volume removal
Don Brace [Fri, 20 Oct 2017 21:52:04 +0000 (16:52 -0500)]
scsi: hpsa: correct logical volume removal

Suggested-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: reduce warning messages on device removal
Don Brace [Fri, 20 Oct 2017 21:51:57 +0000 (16:51 -0500)]
scsi: hpsa: reduce warning messages on device removal

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: update queue depth for externals
Don Brace [Fri, 20 Oct 2017 21:51:51 +0000 (16:51 -0500)]
scsi: hpsa: update queue depth for externals

Preserve external device queue depth during a scan operation.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: correct smart path enabled
Don Brace [Fri, 20 Oct 2017 21:51:45 +0000 (16:51 -0500)]
scsi: hpsa: correct smart path enabled

Correct re-enabling ioaccel after:
  1) RAID transformations and
  2) multi-path fail-overs.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: change timeout for internal cmds
Don Brace [Fri, 20 Oct 2017 21:51:38 +0000 (16:51 -0500)]
scsi: hpsa: change timeout for internal cmds

There are times when the DEFAULT_TIMEOUT (30 seconds) is not enough.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: update discovery polling
Bader Ali Saleh [Fri, 20 Oct 2017 21:51:32 +0000 (16:51 -0500)]
scsi: hpsa: update discovery polling

Correct a corner case where newly created volumes are not detected
automatically on an external RAID controller that has no configured
volumes during initial device discovery.

The fix is to set the discovery_polling flag when an external RAID
controller is detected. This causes a device rescan every 20-30 seconds,
so that newly created volumes will be detected automatically.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: add controller checkpoint
Don Brace [Fri, 20 Oct 2017 21:51:26 +0000 (16:51 -0500)]
scsi: hpsa: add controller checkpoint

Tell hpsa controller to generate a checkpoint for rare lockup
conditions.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: clear tmpdevice in scan thread
Scott Teel [Fri, 20 Oct 2017 21:51:20 +0000 (16:51 -0500)]
scsi: hpsa: clear tmpdevice in scan thread

clean up stale information.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: cleanup sas_phy structures in sysfs when unloading
Martin Wilck [Fri, 20 Oct 2017 21:51:14 +0000 (16:51 -0500)]
scsi: hpsa: cleanup sas_phy structures in sysfs when unloading

I am resubmitting this patch on behalf of Martin Wilck with his
permission.

The original patch can be found here:
https://www.spinics.net/lists/linux-scsi/msg102083.html

This patch did not help until Hannes's
commit 9441284fbc39 ("scsi-fixup-kernel-warning-during-rmmod")
was applied to the kernel.

--------------------------------------
Original patch description from Martin:
--------------------------------------

When the hpsa module is unloaded using rmmod, dangling
symlinks remain under /sys/class/sas_phy. Fix this by
calling sas_phy_delete() rather than sas_phy_free (which,
according to comments, should not be called for PHYs that
have been set up successfully, anyway).

Tested-by: Don Brace <don.brace@microsemi.com>
Reviewed-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin Wilck <mwilck@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: destroy sas transport properties before scsi_host
Martin Wilck [Fri, 20 Oct 2017 21:51:08 +0000 (16:51 -0500)]
scsi: hpsa: destroy sas transport properties before scsi_host

This patch cleans up a lot of warnings when unloading the driver.

A current example of the stack trace starts with:
    [  142.570715] sysfs group 'power' not found for kobject 'port-5:0'
There can be hundreds of these messages during a driver unload.

I am resubmitting this patch on behalf of Martin Wilck with his
permission.

His original patch can be found here:
https://www.spinics.net/lists/linux-scsi/msg102085.html

This patch did not help until Hannes's
commit 9441284fbc39 ("scsi-fixup-kernel-warning-during-rmmod")
was applied to the kernel.

---------------------------
Original patch description:
---------------------------

Unloading the hpsa driver causes warnings

[ 1063.793652] WARNING: CPU: 1 PID: 4850 at ../fs/sysfs/group.c:237 device_del+0x54/0x240()
[ 1063.793659] sysfs group ffffffff81cf21a0 not found for kobject 'port-2:0'

with two different stacks:
1)
[ 1063.793774]  [<ffffffff81448af4>] device_del+0x54/0x240
[ 1063.793780]  [<ffffffff8145178a>] transport_remove_classdev+0x4a/0x60
[ 1063.793784]  [<ffffffff81451216>] attribute_container_device_trigger+0xa6/0xb0
[ 1063.793802]  [<ffffffffa0105d46>] sas_port_delete+0x126/0x160 [scsi_transport_sas]
[ 1063.793819]  [<ffffffffa036ebcc>] hpsa_free_sas_port+0x3c/0x70 [hpsa]

2)
[ 1063.797103]  [<ffffffff81448af4>] device_del+0x54/0x240
[ 1063.797118]  [<ffffffffa0105d4e>] sas_port_delete+0x12e/0x160 [scsi_transport_sas]
[ 1063.797134]  [<ffffffffa036ebcc>] hpsa_free_sas_port+0x3c/0x70 [hpsa]

This is caused by the fact that host device hostX is deleted before the
SAS transport devices hostX/port-a:b.

This patch fixes this by reverting the order of device deletions.

Tested-by: Don Brace <don.brace@microsemi.com>
Reviewed-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin Wilck <mwilck@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: smartpqi: correct spelling error in documentation
Don Brace [Fri, 20 Oct 2017 19:11:51 +0000 (14:11 -0500)]
scsi: smartpqi: correct spelling error in documentation

Correct spelling error.

Signed-off-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Clarify SCSI core module parameter documentation
Martin K. Petersen [Thu, 19 Oct 2017 14:20:03 +0000 (10:20 -0400)]
scsi: Clarify SCSI core module parameter documentation

Ever since it became possible to compile the SCSI core code as a module,
the documentation describing the module parameters has been incorrect.
Update the documentation to add a "scsi_mod." prefix to the relevant
options.

Reported-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: corrected linkrate value.
Viswas G [Wed, 18 Oct 2017 06:09:15 +0000 (11:39 +0530)]
scsi: pm80xx: corrected linkrate value.

Corrected the value defined for LINKRATE_60 (6 Gig).

Signed-off-by: Raj Dinesh <Raj.Dinesh@microsemi.com>
Signed-off-by: Viswas G <viswas.g@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: panic on ncq error cleaning up the read log.
Viswas G [Wed, 18 Oct 2017 06:09:14 +0000 (11:39 +0530)]
scsi: pm80xx: panic on ncq error cleaning up the read log.

when there's an error in 'ncq mode' the host has to read the ncq error
log (10h) to clear the error state. however, the ccb that is setup for
doing this doesn't setup the ccb so that the previous state is
cleared. if the ccb was previously used for an IO n_elems is set and
pm8001_ccb_task_free() treats this as the signal to go free a
scatter-gather list (that's already been freed).

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: corrected SATA abort handling sequence.
Viswas G [Wed, 18 Oct 2017 06:09:13 +0000 (11:39 +0530)]
scsi: pm80xx: corrected SATA abort handling sequence.

Modified SATA abort handling with following steps:

1) Set device state as recovery.
2) Send phy reset.
3) Wait for reset completion.
4) After successful reset, abort all IO's to the device.
5) After aborting all IO's to device, set device state as operational.

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: modified port reset timer value for PM8006 card
Viswas G [Wed, 18 Oct 2017 06:09:12 +0000 (11:39 +0530)]
scsi: pm80xx: modified port reset timer value for PM8006 card

Added port reset timer value as 2000ms for PM8006 sata controller.

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: cleanup in pm8001_abort_task function.
Viswas G [Wed, 18 Oct 2017 06:09:11 +0000 (11:39 +0530)]
scsi: pm80xx: cleanup in pm8001_abort_task function.

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: tag allocation for phy control request.
Viswas G [Wed, 18 Oct 2017 06:09:10 +0000 (11:39 +0530)]
scsi: pm80xx: tag allocation for phy control request.

tag is taken from the tag pool instead of using the hardcoded tag
value(1).

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: Different SAS addresses for phys.
Viswas G [Wed, 18 Oct 2017 06:09:09 +0000 (11:39 +0530)]
scsi: pm80xx: Different SAS addresses for phys.

Different SAS addresses are assigned for each set of phys.

Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: ILA and inactive firmware version through sysfs
Viswas G [Wed, 18 Oct 2017 06:09:08 +0000 (11:39 +0530)]
scsi: pm80xx: ILA and inactive firmware version through sysfs

Added support to read ILA version and inactive firmware version from MPI
configuration table and export through sysfs.

Signed-off-by: Deepak Ukey <deepak.ukey@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: pm80xx: redefine sas_identify_frame structure
Viswas G [Wed, 18 Oct 2017 06:09:07 +0000 (11:39 +0530)]
scsi: pm80xx: redefine sas_identify_frame structure

sas_identify structure defined by pm80xx doesn't have CRC field.  So
added a new sas_identify structure without CRC.

Signed-off-by: Raj Dinesh <Raj.Dinesh@microsemi.com>
Signed-off-by: Viswas G <Viswas.G@microsemi.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_error: Handle power-on reset unit attention
Hannes Reinecke [Tue, 17 Oct 2017 07:11:24 +0000 (09:11 +0200)]
scsi: scsi_error: Handle power-on reset unit attention

As per SAM there is a status precedence, with any sense code 29/XX
taking second place just after an ACA ACTIVE status.  Additionally, each
target might prefer to not queue any unit attention conditions, but just
report one.  Due to the above, this will be that one with the highest
precedence.  This results in the sense code 29/XX effectively
overwriting any other unit attention.  Hence we should report the
power-on reset to userland so that it can take appropriate action.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_error: Do not retry illegal function error
Hannes Reinecke [Tue, 17 Oct 2017 07:10:56 +0000 (09:10 +0200)]
scsi: scsi_error: Do not retry illegal function error

Hitachi USP-V returns 'ILLEGAL FUNCTION' when the internal staging
mechanism encountered an error. These errors should not be retried on
another path.

[mkp: s/invalid/illegal/]

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry
Kurt Garloff [Tue, 17 Oct 2017 07:10:45 +0000 (09:10 +0200)]
scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry

All EMC SYMMETRIX support REPORT_LUNS, even if configured to report
SCSI-2 for whatever reason.

Signed-off-by: Kurt Garloff <garloff@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI OPEN-V blacklist entry
Hannes Reinecke [Tue, 17 Oct 2017 07:10:33 +0000 (09:10 +0200)]
scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI OPEN-V blacklist entry

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: Add 'AIX VDASD' to blacklist
Hannes Reinecke [Tue, 17 Oct 2017 07:10:26 +0000 (09:10 +0200)]
scsi: scsi_devinfo: Add 'AIX VDASD' to blacklist

The AIX VDASD devices do support VPD pages, but implement only SPC. So
set BLIST_TRY_VPD_PAGES to correctly display the VPD information in
sysfs.

[mkp: typo]

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: change manage_start_stop to bool in sysfs interface
weiping zhang [Thu, 12 Oct 2017 06:57:06 +0000 (14:57 +0800)]
scsi: sd: change manage_start_stop to bool in sysfs interface

/sys/class/scsi_disk/0:2:0:0/manage_start_stop can be changed to 0
unexpectly by writing an invalid string.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: change allow_restart to bool in sysfs interface
weiping zhang [Thu, 12 Oct 2017 06:56:44 +0000 (14:56 +0800)]
scsi: sd: change allow_restart to bool in sysfs interface

/sys/class/scsi_disk/0:2:0:0/allow_restart can be changed to 0
unexpectedly by writing an invalid string such as the following:

echo asdf > /sys/class/scsi_disk/0:2:0:0/allow_restart

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: fixup string compare
Hannes Reinecke [Mon, 2 Oct 2017 14:26:37 +0000 (16:26 +0200)]
scsi: scsi_devinfo: fixup string compare

When checking the model and vendor string we need to use the minimum
value of either string, otherwise we'll miss out on wildcard matches.

And we should take care when matching with zero size strings; results
might be unpredictable.  With this patch the rules for matching devinfo
strings are as follows:

- Vendor strings must match exactly
- Empty Model strings will only match if the devinfo model
  is also empty
- Model strings shorter than the devinfo model string will
  not match

Fixes: 5e7ff2c ("SCSI: fix new bug in scsi_dev_info_list string matching")
Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: Whitespace fixes
Hannes Reinecke [Mon, 2 Oct 2017 14:26:36 +0000 (16:26 +0200)]
scsi: scsi_devinfo: Whitespace fixes

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_devinfo: Reformat blacklist flags
Hannes Reinecke [Mon, 2 Oct 2017 14:26:35 +0000 (16:26 +0200)]
scsi: scsi_devinfo: Reformat blacklist flags

Reformat blacklist flags to make the values easier to read and to
enhance error checking.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Bart van Assche <bart.vanassche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>