GitHub/moto-9609/android_kernel_motorola_exynos9610.git
7 years agoscsi: qla2xxx: Fix WWPN/WWNN in debug message
Darren Trap [Wed, 23 Aug 2017 22:04:59 +0000 (15:04 -0700)]
scsi: qla2xxx: Fix WWPN/WWNN in debug message

Signed-off-by: Darren Trap <darren.trap@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Add command completion for error path
Duane Grigsby [Wed, 23 Aug 2017 22:04:58 +0000 (15:04 -0700)]
scsi: qla2xxx: Add command completion for error path

The driver held spinlocks during callbacks for NVME errors which
resulted in a deadlock because recovery LS cmds needed the same lock.

Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Update fw_started flags at qpair creation.
himanshu.madhani@cavium.com [Wed, 23 Aug 2017 22:04:57 +0000 (15:04 -0700)]
scsi: qla2xxx: Update fw_started flags at qpair creation.

Fixes: 4b60c82736d0 ("scsi: qla2xxx: Add fw_started flags to qpair")
Cc: <stable@vger.kernel.org>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Fix target multiqueue configuration
Michael Hernandez [Wed, 23 Aug 2017 22:04:56 +0000 (15:04 -0700)]
scsi: qla2xxx: Fix target multiqueue configuration

Following error will be logged in to message file while trying to
configure target with multiqueue.

"Cmd 0x1f aborted with timeout since ISP Abort is pending"
"qla25xx_init_queues Rsp que: 1 init failed."

Fixes: 82de802ad46e ("scsi: qla2xxx: Preparation for Target MQ.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Michael Hernandez <michael.hernandez@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Correction to vha->vref_count timeout
Joe Carnuccio [Wed, 23 Aug 2017 22:04:55 +0000 (15:04 -0700)]
scsi: qla2xxx: Correction to vha->vref_count timeout

Fix incorrect second argument for wait_event_timeout()

Fixes: c4a9b538ab2a ("qla2xxx: Allow vref count to timeout on vport delete.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: driver version upgrade
Shivasharan S [Wed, 23 Aug 2017 11:47:08 +0000 (04:47 -0700)]
scsi: megaraid_sas: driver version upgrade

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: call megasas_dump_frame with correct IO frame size
Shivasharan S [Wed, 23 Aug 2017 11:47:07 +0000 (04:47 -0700)]
scsi: megaraid_sas: call megasas_dump_frame with correct IO frame size

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: modified few prints in OCR and IOC INIT path
Shivasharan S [Wed, 23 Aug 2017 11:47:06 +0000 (04:47 -0700)]
scsi: megaraid_sas: modified few prints in OCR and IOC INIT path

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: replace internal FALSE/TRUE definitions with false/true
Shivasharan S [Wed, 23 Aug 2017 11:47:05 +0000 (04:47 -0700)]
scsi: megaraid_sas: replace internal FALSE/TRUE definitions with false/true

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in...
Shivasharan S [Wed, 23 Aug 2017 11:47:04 +0000 (04:47 -0700)]
scsi: megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in case adapter is dead

After a kill adapter, since the cmd_status is not set, the IOCTLs will
be hung in driver resulting in application hang.  Set cmd_status
MFI_STAT_WRONG_STATE when completing pended IOCTLs.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map
Shivasharan S [Wed, 23 Aug 2017 11:47:03 +0000 (04:47 -0700)]
scsi: megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map

Driver's local RAID map is accessed frequently. We will first try to get
memory from __get_free_pages. If this fails, fall back to using vmalloc.
For crash dump buffers always prefer vmalloc.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Use SMID for Task abort case only
Shivasharan S [Wed, 23 Aug 2017 11:47:02 +0000 (04:47 -0700)]
scsi: megaraid_sas: Use SMID for Task abort case only

In TM code, smid_task is valid only in case of task aborts.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Check valid aen class range to avoid kernel panic
Shivasharan S [Wed, 23 Aug 2017 11:47:01 +0000 (04:47 -0700)]
scsi: megaraid_sas: Check valid aen class range to avoid kernel panic

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Fix endianness issues in DCMD handling
Shivasharan S [Wed, 23 Aug 2017 11:47:00 +0000 (04:47 -0700)]
scsi: megaraid_sas: Fix endianness issues in DCMD handling

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Do not re-fire shutdown DCMD after OCR
Shivasharan S [Wed, 23 Aug 2017 11:46:59 +0000 (04:46 -0700)]
scsi: megaraid_sas: Do not re-fire shutdown DCMD after OCR

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Call megasas_complete_cmd_dpc_fusion every 1 second while there...
Shivasharan S [Wed, 23 Aug 2017 11:46:58 +0000 (04:46 -0700)]
scsi: megaraid_sas: Call megasas_complete_cmd_dpc_fusion every 1 second while there are pending commands

megasas_wait_for_outstanding_fusion checks for pending commands every 1
second. But megasas_complete_cmd_dpc_fusion is only called every 5
seconds.  If the commands are already completed by firmware, there is an
additional delay of 5 seconds before driver will process completion for
these commands.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Use synchronize_irq in target reset case
Shivasharan S [Wed, 23 Aug 2017 11:46:57 +0000 (04:46 -0700)]
scsi: megaraid_sas: Use synchronize_irq in target reset case

Similar to task abort case, use synchronize_irq API in target reset
case.  Also, remove redundant call to megasas_complete_cmd_dpc_fusion
after calling megasas_sync_irqs in task abort case.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: set minimum value of resetwaittime to be 1 secs
Shivasharan S [Wed, 23 Aug 2017 11:46:56 +0000 (04:46 -0700)]
scsi: megaraid_sas: set minimum value of resetwaittime to be 1 secs

Setting resetwaittime to 0 during a FW fault will result in driver not
calling the OCR.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: mismatch of allocated MFI frame size and length exposed in MFI...
Shivasharan S [Wed, 23 Aug 2017 11:46:55 +0000 (04:46 -0700)]
scsi: megaraid_sas: mismatch of allocated MFI frame size and length exposed in MFI MPT pass through command

Driver allocated 256 byte MFI frames bytes but while sending MFI frame
(embedded inside chain frame of MPT frame) to firmware, driver sets the
length as 4k. This results in DMA read error messages during boot.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: remove useless code in lpfc_sli4_bsg_link_diag_test
Gustavo A. R. Silva [Tue, 22 Aug 2017 20:53:53 +0000 (15:53 -0500)]
scsi: lpfc: remove useless code in lpfc_sli4_bsg_link_diag_test

Remove variable assignments. The value stored in local variable _rc_ is
overwritten at line 2448:rc = lpfc_sli4_bsg_set_link_diag_state(phba,
0); before it can be used.

Addresses-Coverity-ID: 1226935
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE
Todd Poynor [Wed, 16 Aug 2017 05:41:08 +0000 (22:41 -0700)]
scsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE

Take f_mutex around mmap() processing to protect against races with the
SG_SET_RESERVED_SIZE ioctl.  Ensure the reserve buffer length remains
consistent during the mapping operation, and set the "mmap called" flag
to prevent further changes to the reserved buffer size as an atomic
operation with the mapping.

[mkp: fixed whitespace]

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sg: recheck MMAP_IO request length with lock held
Todd Poynor [Wed, 16 Aug 2017 04:48:43 +0000 (21:48 -0700)]
scsi: sg: recheck MMAP_IO request length with lock held

Commit 1bc0eb044615 ("scsi: sg: protect accesses to 'reserved' page
array") adds needed concurrency protection for the "reserve" buffer.
Some checks that are initially made outside the lock are replicated once
the lock is taken to ensure the checks and resulting decisions are made
using consistent state.

The check that a request with flag SG_FLAG_MMAP_IO set fits in the
reserve buffer also needs to be performed again under the lock to ensure
the reserve buffer length compared against matches the value in effect
when the request is linked to the reserve buffer.  An -ENOMEM should be
returned in this case, instead of switching over to an indirect buffer
as for non-MMAP_IO requests.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: fix the device_id in hpsa_update_device_info()
Dan Carpenter [Thu, 17 Aug 2017 14:44:44 +0000 (17:44 +0300)]
scsi: hpsa: fix the device_id in hpsa_update_device_info()

The parentheses are in the wrong place so we specify the length as
"sizeof(this_device->device_id) < 0" which is zero.

Fixes: 988b87edd231 ("scsi: hpsa: Ignore errors for unsupported LV_DEVICE_ID VPD page")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: aha1542: constify pnp_device_id
Arvind Yadav [Wed, 16 Aug 2017 04:59:24 +0000 (10:29 +0530)]
scsi: aha1542: constify pnp_device_id

pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by <linux/pnp.h> work with const
pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: scsi-sysfs: Adjust error returned for adapter reset request
weiping zhang [Thu, 10 Aug 2017 17:52:17 +0000 (01:52 +0800)]
scsi: scsi-sysfs: Adjust error returned for adapter reset request

If scsi_host_template->host_reset is NULL and the user requests an
adapter reset through

echo adapter > /sys/class/scsi_host/hostx/host_reset

-EINVAL will be returned even though the "adapter" argument is perfectly
valid.

Change this so that we only return -EINVAL if the provided string is
invalid.  If the host does not implement a ->host_reset function we'll
return -EOPNOTSUPP.

[mkp: tweaked patch description]

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ch: add refcounting
Hannes Reinecke [Tue, 15 Aug 2017 14:28:49 +0000 (16:28 +0200)]
scsi: ch: add refcounting

struct scsi_changer needs refcounting as the device might be removed
while the fd is still open.

[mkp: whitespace]

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: pmcraid: fix duplicated code for different branches
Gustavo A. R. Silva [Sun, 13 Aug 2017 01:26:32 +0000 (20:26 -0500)]
scsi: pmcraid: fix duplicated code for different branches

Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ncr5380: constify pnp_device_id
Arvind Yadav [Wed, 16 Aug 2017 04:58:40 +0000 (10:28 +0530)]
scsi: ncr5380: constify pnp_device_id

pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by <linux/pnp.h> work with const
pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Update driver version to 8.20.5.0.
Chad Dupuis [Tue, 15 Aug 2017 17:08:21 +0000 (10:08 -0700)]
scsi: qedf: Update driver version to 8.20.5.0.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Fix up modinfo parameter name for 'debug' in modinfo output.
Chad Dupuis [Tue, 15 Aug 2017 17:08:20 +0000 (10:08 -0700)]
scsi: qedf: Fix up modinfo parameter name for 'debug' in modinfo output.

Because we were passing 'qedf_debug' instead of 'debug' to the
MODULE_PARM_DESC() macro, modinfo listed the parameter name as 'qedf_debug'
instead of it's proper name 'debug'.  Correct the parameter name.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Covert single-threaded workqueues to regular workqueues.
Chad Dupuis [Tue, 15 Aug 2017 17:08:19 +0000 (10:08 -0700)]
scsi: qedf: Covert single-threaded workqueues to regular workqueues.

There is no ordering required for the various workqueues the driver uses
so they can be converted to regular workqueues.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Corrent VLAN tag insertion in fallback VLAN case.
Chad Dupuis [Tue, 15 Aug 2017 17:08:18 +0000 (10:08 -0700)]
scsi: qedf: Corrent VLAN tag insertion in fallback VLAN case.

Currently in the driver the qedf_ctx attribute vlan_hw_insert is used to
which whether to insert a VLAN tag in FIP frames (except for FIP VLAN
request which is explicitly sent out untagged at least from the driver's
point of view).

When we receive a FIP VLAN response, we set qedf->vlan_hw_insert to 0 which
makes the qedf_fip_send function insert the VLAN.  However when we exhaust
our FIP VLAN retries, we do not set qedf->vlan_hw_insert to 0 which means
that the driver will not tag the FIP frame with the correct VLAN ID.  The
result that was observed on the wire is that some entity either in the LL2
or L2 firmware is adding a NULL VLAN tag which can cause FIP solicitation
to fail.

The offload FCoE frame function, qedf_xmit, does not use the vlan_hw_insert
attribute to decide whether to tag frames with the FIP/FCoE VLAN.  Instead
it unilaterially tags the offload frames with the VLAN ID stored in
qedf->vlan_id. This is the correct behavior so the driver can guarantee
that non-offload FIP frames go out with the correct VLAN ID.

Also use the Linux network layer helpers instead of doing the VLAN insert
manually.

Also fix setting the fallback VLAN so that it used the module parameter and
is not hardcoded to 1002 (though 1002 is the default).

[mkp: fixed typo]

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Use granted MAC from the FCF for the FCoE source address if it is available.
Chad Dupuis [Tue, 15 Aug 2017 17:08:17 +0000 (10:08 -0700)]
scsi: qedf: Use granted MAC from the FCF for the FCoE source address if it is available.

Currently in the driver we've been using the fc_fcoe_set_mac() function to
set the source MAC for FCoE traffic.  This works well in most cases as it
uses the spec. default FCF-MAC.  However, if the administrator changes the
FCF-MAC switch, then any FCoE traffic we send will be dropped by the
switch.

Instead we should check the granted MAC from the FLOGI payload and use that
address if it is present.  Otherwise, fall back to using the the default
FCF-MAC and the fabric ID of the port as the FCoE MAC address.

Once this address is known we need to set it when doing non-offload
traffic, offload traffic and setting the data_src_address libfcoe uses for
FIP keep alive messages.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedf: Set WWNN and WWPN based on values from qed.
Chad Dupuis [Tue, 15 Aug 2017 17:08:16 +0000 (10:08 -0700)]
scsi: qedf: Set WWNN and WWPN based on values from qed.

If dev_info.wwpn and dev_info.wwnn are set by qed use these values to set
the WWNs of the port. Otherwise fall back to the old method using
fcoe_wwn_from_mac().

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: fix spelling mistake of variable sfp_additonal_info
Colin Ian King [Wed, 16 Aug 2017 08:51:20 +0000 (09:51 +0100)]
scsi: qla2xxx: fix spelling mistake of variable sfp_additonal_info

Trivial fix to variable name, sfp_additonal_info should be
sfp_additional_info (add in missing i).

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: osst: silence underflow warning in osst_verify_frame()
Dan Carpenter [Fri, 4 Aug 2017 08:17:33 +0000 (11:17 +0300)]
scsi: osst: silence underflow warning in osst_verify_frame()

The code looks like this:

i = ntohl(aux->filemark_cnt);
if (STp->header_cache != NULL && i < OS_FM_TAB_MAX && (i > STp->filemark_cnt ||
    STp->first_frame_position - 1 != ntohl(STp->header_cache->dat_fm_tab.fm_tab_ent[i]))) {

If i is negative then it's less than OS_FM_TAB_MAX so we read before
the start of the STp->header_cache->dat_fm_tab.fm_tab_ent[] array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: osst: add missing indent on a for loop statement
Colin Ian King [Tue, 15 Aug 2017 14:08:28 +0000 (15:08 +0100)]
scsi: osst: add missing indent on a for loop statement

The for loop is statement is missing an indent, add it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: fix pr_info message continuation
Colin Ian King [Tue, 15 Aug 2017 13:51:45 +0000 (14:51 +0100)]
scsi: mpt3sas: fix pr_info message continuation

An optional discovery status should be printed with a pr_cont and needs
a leading space to make it more readable. The final new line should also
be a pr_cont and the indentation is out by one, so fix that too.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ses: make page2 support optional
Hannes Reinecke [Tue, 15 Aug 2017 08:21:43 +0000 (10:21 +0200)]
scsi: ses: make page2 support optional

Simple subenclosures do not need to support SES page 2, so make it
optional.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ses: Fixup error message 'failed to get diagnostic page 0xffffffea'
Hannes Reinecke [Tue, 15 Aug 2017 08:21:42 +0000 (10:21 +0200)]
scsi: ses: Fixup error message 'failed to get diagnostic page 0xffffffea'

The printk was using the result as argument, leading to a slightly
confusing log message.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ses: check return code from ses_recv_diag()
Hannes Reinecke [Tue, 15 Aug 2017 08:21:41 +0000 (10:21 +0200)]
scsi: ses: check return code from ses_recv_diag()

We should be checking the return code from ses_recv_diag() to avoid
accessing invalid data.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: Remove 'hpsa_allow_any' module option
Hannes Reinecke [Tue, 15 Aug 2017 06:58:09 +0000 (08:58 +0200)]
scsi: hpsa: Remove 'hpsa_allow_any' module option

As the cciss driver has been removed there are no overlapping
PCI IDs anymore, and the 'hpsa_allow_any' flag can be removed.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cciss: Drop obsolete driver
Hannes Reinecke [Tue, 15 Aug 2017 06:58:08 +0000 (08:58 +0200)]
scsi: cciss: Drop obsolete driver

The hpsa driver now has support for all boards the cciss driver
used to support, so this patch removes the cciss driver and
make hpsa an alias to cciss.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: do not print errors for unsupported report luns format
Hannes Reinecke [Tue, 15 Aug 2017 06:58:07 +0000 (08:58 +0200)]
scsi: hpsa: do not print errors for unsupported report luns format

Legacy boards might not support the 'extended' report luns format,
but as this is to be expected we don't need to print out an error here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: Ignore errors for unsupported LV_DEVICE_ID VPD page
Hannes Reinecke [Tue, 15 Aug 2017 06:58:06 +0000 (08:58 +0200)]
scsi: hpsa: Ignore errors for unsupported LV_DEVICE_ID VPD page

Legacy boards might not support the LV_DEVICE_ID VPD page, so
we shouldn't print out an error message here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: disable volume status check for legacy boards
Hannes Reinecke [Tue, 15 Aug 2017 06:58:05 +0000 (08:58 +0200)]
scsi: hpsa: disable volume status check for legacy boards

Legacy boards might not support volume status, so assume
the volume is online here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hpsa: add support for legacy boards
Hannes Reinecke [Tue, 15 Aug 2017 06:58:04 +0000 (08:58 +0200)]
scsi: hpsa: add support for legacy boards

Add support for legacy boards, ensuring to enable the driver for
those boards only when 'hpsa_allow_any' is set.
The attribute 'legacy_board' is set to '1' if the device is
a legacy board, and '0' otherwise.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'
Christophe JAILLET [Tue, 15 Aug 2017 20:18:14 +0000 (22:18 +0200)]
scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

'rc' is known to be 0 at this point.  If 'create_context()' fails,
returns -ENOMEM instead of 0 which means success.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sym53c8xx: Avoid undefined behaviour
Helge Deller [Thu, 10 Aug 2017 19:08:49 +0000 (21:08 +0200)]
scsi: sym53c8xx: Avoid undefined behaviour

On parisc I see this UBSAN warning with a sym53c896:

 UBSAN: Undefined behaviour in ./drivers/scsi/sym53c8xx_2/sym_hipd.c:762:24
 index -1903078336 is out of range for type 'u32 [7]'

Avoid this warning by switching to div64_ul().

[mkp: fix typo]

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: make 'state' device attribute pollable
Hannes Reinecke [Fri, 11 Aug 2017 06:53:47 +0000 (08:53 +0200)]
scsi: make 'state' device attribute pollable

While the 'state' attribute can (and will) change occasionally,
calling 'poll()' or 'select()' on it fails as sysfs is never
notified that the state has changed.
With this patch calling 'poll()' or 'select()' will work
properly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: scsi_lib: rework scsi_internal_device_unblock_nowait()
Hannes Reinecke [Fri, 11 Aug 2017 06:53:46 +0000 (08:53 +0200)]
scsi: scsi_lib: rework scsi_internal_device_unblock_nowait()

Rework scsi_internal_device_unblock_nowait() into using a switch
statement. No functional changes.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: esas2r: constify pci_device_id.
Arvind Yadav [Sun, 30 Jul 2017 08:40:32 +0000 (14:10 +0530)]
scsi: esas2r: constify pci_device_id.

pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by <linux/pci.h> work with const
pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Bradley Grove <bgrove@attotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: virtio: virtio_scsi: Set can_queue to the length of the virtqueue.
Richard W.M. Jones [Thu, 10 Aug 2017 16:56:52 +0000 (17:56 +0100)]
scsi: virtio: virtio_scsi: Set can_queue to the length of the virtqueue.

Since switching to blk-mq as the default in commit 5c279bd9e406
("scsi: default to scsi-mq"), virtio-scsi LUNs consume about 10x as
much kernel memory.

qemu currently allocates a fixed 128 entry virtqueue.  can_queue
currently is set to 1024.  But with indirect descriptors, each command
in the queue takes 1 virtqueue entry, so the number of commands which
can be queued is equal to the length of the virtqueue.

Note I intend to send a patch to qemu to allow the virtqueue size to be
configured from the qemu command line.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.
Richard W.M. Jones [Thu, 10 Aug 2017 16:56:51 +0000 (17:56 +0100)]
scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.

If using indirect descriptors, you can make the total_sg as large as you
want.  If not, BUG is too serious because the function later returns
-ENOSPC.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedi: Limit number for CQ queues.
Manish Rangankar [Thu, 10 Aug 2017 13:32:17 +0000 (06:32 -0700)]
scsi: qedi: Limit number for CQ queues.

[qed_sp_iscsi_func_start:189(host_7-0)]Cannot satisfy CQ amount. Queues
requested 8, CQs available 4. Aborting function start

Above condition will resolve as management firmware is capable of
telling us the number of CQs available for a given PF, qed will
communicate the same number to qedi, So that qedi will know how much CQs
are allowed.

Signed-off-by: Manish Rangankar <manish.rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: remove driver versioning
John Garry [Thu, 10 Aug 2017 16:09:44 +0000 (00:09 +0800)]
scsi: hisi_sas: remove driver versioning

The driver version is not updated with changes to the driver, so it has
no value, so just get rid of it.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: replace kfree with scsi_host_put
John Garry [Thu, 10 Aug 2017 16:09:43 +0000 (00:09 +0800)]
scsi: hisi_sas: replace kfree with scsi_host_put

Instances of kfree(shost) should be replaced with scsi_host_put().

In addition, a missing scsi_host_put() is added for error path in
hisi_sas_shost_alloc_pci() and v3 driver removal.

Signed-off-by: Pan Bian <bianpan2016@163.com> # For main.c changes
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: remove phy_down_v3_hw() res variable
John Garry [Thu, 10 Aug 2017 16:09:42 +0000 (00:09 +0800)]
scsi: hisi_sas: remove phy_down_v3_hw() res variable

Variable res only holds value 0, so remove it.

This cleans up a coccicheck warning.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add phy_set_linkrate_v3_hw()
Xiang Chen [Thu, 10 Aug 2017 16:09:41 +0000 (00:09 +0800)]
scsi: hisi_sas: add phy_set_linkrate_v3_hw()

Add function to set linkrate for v3 hw.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: update some v3 register init settings
Xiang Chen [Thu, 10 Aug 2017 16:09:39 +0000 (00:09 +0800)]
scsi: hisi_sas: update some v3 register init settings

This patch updates some register setting according to recommendation
from HW designer and experiment.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add reset handler for v3 hw
Xiang Chen [Thu, 10 Aug 2017 16:09:40 +0000 (00:09 +0800)]
scsi: hisi_sas: add reset handler for v3 hw

Use ACPI "_RST" method to reset the controller, since FLR is not
supported.

Function hisi_sas_stop_phys() is introduced to remove some code
duplication.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: kill tasklet when destroying irq in v3 hw
Xiang Chen [Thu, 10 Aug 2017 16:09:38 +0000 (00:09 +0800)]
scsi: hisi_sas: kill tasklet when destroying irq in v3 hw

This patch adds calls to kill CQ takslets v3 hw during probe failure.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: fix v3 hw channel interrupt processing
Xiang Chen [Thu, 10 Aug 2017 16:09:37 +0000 (00:09 +0800)]
scsi: hisi_sas: fix v3 hw channel interrupt processing

The channel interrupt is to process all the interrupts except PHY
UP/DOWN and broadcast interrupt. So we need to clear all the interrupts
except those 3 interrupts after processing channel interrupts.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: Modify v3 hw STP_LINK_TIMER setting
Xiang Chen [Thu, 10 Aug 2017 16:09:36 +0000 (00:09 +0800)]
scsi: hisi_sas: Modify v3 hw STP_LINK_TIMER setting

Modify STP link timer from 10ms to 500ms. Also add the register address.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add status and command buffer for internal abort
Xiang Chen [Thu, 10 Aug 2017 16:09:35 +0000 (00:09 +0800)]
scsi: hisi_sas: add status and command buffer for internal abort

For v3 hw, internal abort function required status and command buffer to
be set, so add necessary code for 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>
7 years agoscsi: hisi_sas: support zone management commands
Xiaofei Tan [Thu, 10 Aug 2017 16:09:34 +0000 (00:09 +0800)]
scsi: hisi_sas: support zone management commands

Add two ATA commands, ATA_CMD_ZAC_MGMT_IN and ATA_CMD_ZAC_MGMT_OUT in
hisi_sas_get_ata_protocol(), to support SATA SMR disk.

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>
7 years agoscsi: hisi_sas: service interrupt ITCT_CLR interrupt in v2 hw
Xiang Chen [Thu, 10 Aug 2017 16:09:33 +0000 (00:09 +0800)]
scsi: hisi_sas: service interrupt ITCT_CLR interrupt in v2 hw

This patch is a fix related to freeing a device in v2 hw driver.

Before, we polled to ITCT CLR interrupt to check if a device is free.

This was error prone, as if the interrupt doesn't occur in 10us, we miss
processing it.

To avoid this situation, service this interrupt and sync the event with
a completion.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add irq and tasklet cleanup in v2 hw
Xiang Chen [Thu, 10 Aug 2017 16:09:32 +0000 (00:09 +0800)]
scsi: hisi_sas: add irq and tasklet cleanup in v2 hw

This patch adds support to clean-up allocated IRQs and kill tasklets
when probe fails and for driver removal.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: remove repeated device config in v2 hw
Xiang Chen [Thu, 10 Aug 2017 16:09:31 +0000 (00:09 +0800)]
scsi: hisi_sas: remove repeated device config in v2 hw

This patch removes some repeated configurations:

(1) The device id of the device is already set in the alloc function, so
    we don't need to modify in free device function.

(2) Field dev_type and dev_status are configured in hisi_sas_dev_gone(),
    so there is no need for repeated config in free_device_v3_hw.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: use array for v2 hw ECC errors
John Garry [Thu, 10 Aug 2017 16:09:30 +0000 (00:09 +0800)]
scsi: hisi_sas: use array for v2 hw ECC errors

The code to print ECC errors in v2 hw driver is very repetitive.  This
patch condensed the code by looping an array of errors.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: add v2 hw DFX feature
Xiaofei Tan [Thu, 10 Aug 2017 16:09:29 +0000 (00:09 +0800)]
scsi: hisi_sas: add v2 hw DFX feature

Add DFX feature for v2 hw. We are adding support for
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>
7 years agoscsi: hisi_sas: fix v2 hw underflow residual value
Xiang Chen [Thu, 10 Aug 2017 16:09:28 +0000 (00:09 +0800)]
scsi: hisi_sas: fix v2 hw underflow residual value

The value dw0 is the residual bytes when UNDERFLOW error happens, but we
filled the residual with the value of dw3 before. So change the residual
from dw3 to dw0.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: avoid potential v2 hw interrupt issue
Xiang Chen [Thu, 10 Aug 2017 16:09:27 +0000 (00:09 +0800)]
scsi: hisi_sas: avoid potential v2 hw interrupt issue

When some interrupts happen together, we need to process every interrupt
one-by-one, and should not return immediately when one interrupt process
is finished being processed.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: hisi_sas: fix reset and port ID refresh issues
Xiaofei Tan [Thu, 10 Aug 2017 16:09:26 +0000 (00:09 +0800)]
scsi: hisi_sas: fix reset and port ID refresh issues

This patch provides fixes for the following issues:

1. Fix issue of controller reset required to send commands. For reset
   process, it may be required to send commands to the controller, but
   not during soft reset.  So add HISI_SAS_NOT_ACCEPT_CMD_BIT to prevent
   executing a task during this period.

2. Send a broadcast event in rescan topology to detect any topology
   changes during reset.

3. Previously it was not ensured that libsas has processed the PHY up
   and down events after reset. Potentially this could cause an issue
   that we still process the PHY event after reset. So resolve this by
   flushing shot workqueue in LLDD reset.

4. Port ID requires refresh after reset. The port ID generated after
   reset is not guaranteed to be the same as before reset, so it needs
   to be refreshed for each device's ITCT.

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>
7 years agoscsi: smartpqi: change driver version to 1.1.2-125
Kevin Barnett [Thu, 10 Aug 2017 18:47:15 +0000 (13:47 -0500)]
scsi: smartpqi: change driver version to 1.1.2-125

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: add in new controller ids
Kevin Barnett [Thu, 10 Aug 2017 18:47:09 +0000 (13:47 -0500)]
scsi: smartpqi: add in new controller ids

Update the driver’s PCI IDs to match the latest Microsemi controllers

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: update kexec and power down support
Kevin Barnett [Thu, 10 Aug 2017 18:47:03 +0000 (13:47 -0500)]
scsi: smartpqi: update kexec and power down support

Add PQI reset to driver shutdown callback to work around controller bug.

During an 1.) OS shutdown or 2.) kexec outside of a kdump, the Linux
kernel will clear BME on our controller.

If BME is cleared during a controller/host PCIe transfer, the controller
will lock up.

So we perform a PQI reset in the driver's shutdown callback function to
eliminate the possibility of a controller/host PCIe transfer being
active when the kernel clears BME immediately after calling the driver's
shutdown callback.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: cleanup doorbell register usage.
Kevin Barnett [Thu, 10 Aug 2017 18:46:57 +0000 (13:46 -0500)]
scsi: smartpqi: cleanup doorbell register usage.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: update pqi passthru ioctl
Kevin Barnett [Thu, 10 Aug 2017 18:46:51 +0000 (13:46 -0500)]
scsi: smartpqi: update pqi passthru ioctl

 - make pass-thru requests bi-directional

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: enhance BMIC cache flush
Kevin Barnett [Thu, 10 Aug 2017 18:46:45 +0000 (13:46 -0500)]
scsi: smartpqi: enhance BMIC cache flush

 - distinguish between shutdown and non-shutdown.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: smartpqi: add pqi reset quiesce support
Kevin Barnett [Thu, 10 Aug 2017 18:46:39 +0000 (13:46 -0500)]
scsi: smartpqi: add pqi reset quiesce support

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
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>
7 years agoscsi: dpt_i2o: remove redundant null check on array device
Colin Ian King [Wed, 9 Aug 2017 10:17:41 +0000 (11:17 +0100)]
scsi: dpt_i2o: remove redundant null check on array device

The null check on pHba->channel[chan].device is redundant because
device is an array and hence can never be null. Remove the check.

Detected by CoverityScan, CID#115362 ("Array compared against 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: use dma_mapping_error to check map errors
Pan Bian [Tue, 8 Aug 2017 13:55:30 +0000 (21:55 +0800)]
scsi: qla2xxx: use dma_mapping_error to check map errors

The return value of dma_map_single() should be checked by
dma_mapping_error(). However, in function qla26xx_dport_diagnostics(), its
return value is checked against NULL, which could result in failures.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mvsas: replace kfree with scsi_host_put
Pan Bian [Tue, 8 Aug 2017 12:02:51 +0000 (20:02 +0800)]
scsi: mvsas: replace kfree with scsi_host_put

The return value of scsi_host_alloc() should be released by
scsi_host_put(). However, in function mvs_pci_init(), kfree()
is used. This patch replaces kfree() with scsi_host_put() to avoid
possible memory leaks.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: pm8001: fix double free in pm8001_pci_probe
Pan Bian [Tue, 8 Aug 2017 11:40:30 +0000 (19:40 +0800)]
scsi: pm8001: fix double free in pm8001_pci_probe

In function pm8001_pci_probe(), on errors that the control flow jumps to
label err_out_ha_free, function pm8001_free() is called. In pm8001_free(),
scsi_host_put() is called to release shost, which keeps the return value
of scsi_host_alloc(). After pm8001_free() returns, kfree() is called to
free shost again, resulting in a double free bug. This patch removes
scsi_host_put() from pm8001_free() and explicitly calls scsi_host_put()
to release Scsi_Host in need.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: fix allocate instance->pd_info twice
weiping [Tue, 8 Aug 2017 05:15:55 +0000 (13:15 +0800)]
scsi: megaraid_sas: fix allocate instance->pd_info twice

fix allocate instance->pd_info twice which was introduced by 96188a89cc6d.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: esp_scsi: Always clear msg_out_len after MESSAGE OUT phase
Finn Thain [Fri, 4 Aug 2017 05:43:20 +0000 (01:43 -0400)]
scsi: esp_scsi: Always clear msg_out_len after MESSAGE OUT phase

After sending a message, always clear esp->msg_out_len. Otherwise,
eh_abort_handler may subsequently fail to send an ABORT TASK SET
message.

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>
7 years agoscsi: esp_scsi: Avoid sending ABORT TASK SET messages
Finn Thain [Fri, 4 Aug 2017 05:43:20 +0000 (01:43 -0400)]
scsi: esp_scsi: Avoid sending ABORT TASK SET messages

If an LLD aborts a task set, it should complete the affected commands
with the appropriate result code. In a couple of cases esp_scsi doesn't
do so.

When the initiator receives an unhandled message, just respond by sending
a MESSAGE REJECT instead of ABORT TASK SET, and thus avoid the issue.

OTOH, a MESSAGE REJECT sent by a target can be taken as an indication
that the initiator messed up somehow. It isn't always possible to abort
correctly, so just fall back on a SCSI bus reset, which will complete the
affected commands with the appropriate result code.

For example, certain Apple (Sony) CD-ROM drives, when the non-existent
LUN 1 is scanned, can't handle the INQUIRY command. The problem is not
detected until the initiator gets a MESSAGE REJECT. Whenever esp_scsi
sees that message, it raises ATN and sends ABORT TASK SET -- but
neglects to complete the failed scmd.

The target then goes into DATA OUT phase (probably bogus), while the ESP
device goes into disconnected mode (surprising, given the bus phase).
The next Transfer Information command from esp_scsi then causes
an Invalid Command interrupt because that command is not valid when in
disconnected mode:

mac_esp: using PDMA for controller 0
mac_esp mac_esp.0: esp0: regs[50f10000:(null)] irq[19]
mac_esp mac_esp.0: esp0: is a ESP236, 16 MHz (ccf=4), SCSI ID 7
scsi host0: esp
scsi 0:0:0:0: Direct-Access     SEAGATE  ST318416N        0010 PQ: 0 ANSI: 3
scsi target0:0:0: Beginning Domain Validation
scsi target0:0:0: asynchronous
scsi target0:0:0: Domain Validation skipping write tests
scsi target0:0:0: Ending Domain Validation
scsi 0:0:3:0: CD-ROM            SONY     CD-ROM CDU-8003A 1.9a PQ: 0 ANSI: 2 CCS
scsi target0:0:3: Beginning Domain Validation
scsi target0:0:3: FAST-5 SCSI 2.0 MB/s ST (500 ns, offset 15)
scsi target0:0:3: Domain Validation skipping write tests
scsi target0:0:3: Ending Domain Validation
scsi host0: unexpected IREG 40
scsi host0: Dumping command log
scsi host0: ent[2] CMD val[c2] sreg[90] seqreg[cc] sreg2[00] ireg[20] ss[01] event[0c]
scsi host0: ent[3] CMD val[00] sreg[91] seqreg[04] sreg2[00] ireg[18] ss[00] event[0c]
scsi host0: ent[4] EVENT val[0d] sreg[91] seqreg[04] sreg2[00] ireg[18] ss[00] event[0c]
scsi host0: ent[5] EVENT val[03] sreg[91] seqreg[04] sreg2[00] ireg[18] ss[00] event[0d]
scsi host0: ent[6] CMD val[90] sreg[91] seqreg[04] sreg2[00] ireg[18] ss[00] event[03]
scsi host0: ent[7] EVENT val[05] sreg[91] seqreg[04] sreg2[00] ireg[18] ss[00] event[03]
scsi host0: ent[8] EVENT val[0d] sreg[93] seqreg[cc] sreg2[00] ireg[10] ss[00] event[05]
scsi host0: ent[9] CMD val[01] sreg[93] seqreg[cc] sreg2[00] ireg[10] ss[00] event[0d]
scsi host0: ent[10] CMD val[11] sreg[93] seqreg[cc] sreg2[00] ireg[10] ss[00] event[0d]
scsi host0: ent[11] EVENT val[0b] sreg[93] seqreg[cc] sreg2[00] ireg[10] ss[00] event[0d]
scsi host0: ent[12] CMD val[12] sreg[97] seqreg[cc] sreg2[00] ireg[08] ss[00] event[0b]
scsi host0: ent[13] EVENT val[0c] sreg[97] seqreg[cc] sreg2[00] ireg[08] ss[00] event[0b]
scsi host0: ent[14] CMD val[44] sreg[90] seqreg[cc] sreg2[00] ireg[20] ss[00] event[0c]
scsi host0: ent[15] CMD val[01] sreg[90] seqreg[cc] sreg2[00] ireg[20] ss[01] event[0c]
scsi host0: ent[16] CMD val[c2] sreg[90] seqreg[cc] sreg2[00] ireg[20] ss[01] event[0c]
scsi host0: ent[17] CMD val[00] sreg[87] seqreg[02] sreg2[00] ireg[18] ss[00] event[0c]
scsi host0: ent[18] EVENT val[0d] sreg[87] seqreg[02] sreg2[00] ireg[18] ss[00] event[0c]
scsi host0: ent[19] EVENT val[06] sreg[87] seqreg[02] sreg2[00] ireg[18] ss[00] event[0d]
scsi host0: ent[20] CMD val[01] sreg[87] seqreg[02] sreg2[00] ireg[18] ss[00] event[06]
scsi host0: ent[21] CMD val[10] sreg[87] seqreg[02] sreg2[00] ireg[18] ss[00] event[06]
scsi host0: ent[22] CMD val[1a] sreg[87] seqreg[ca] sreg2[00] ireg[08] ss[00] event[06]
scsi host0: ent[23] CMD val[12] sreg[87] seqreg[ca] sreg2[00] ireg[08] ss[00] event[06]
scsi host0: ent[24] EVENT val[0d] sreg[87] seqreg[ca] sreg2[00] ireg[08] ss[00] event[06]
scsi host0: ent[25] EVENT val[09] sreg[86] seqreg[ca] sreg2[00] ireg[10] ss[00] event[0d]
scsi host0: ent[26] CMD val[01] sreg[86] seqreg[ca] sreg2[00] ireg[10] ss[00] event[09]
scsi host0: ent[27] CMD val[10] sreg[86] seqreg[ca] sreg2[00] ireg[10] ss[00] event[09]
scsi host0: ent[28] EVENT val[0a] sreg[86] seqreg[ca] sreg2[00] ireg[10] ss[00] event[09]
scsi host0: ent[29] EVENT val[0d] sreg[80] seqreg[ca] sreg2[00] ireg[20] ss[00] event[0a]
scsi host0: ent[30] EVENT val[04] sreg[80] seqreg[ca] sreg2[00] ireg[20] ss[00] event[0d]
scsi host0: ent[31] CMD val[01] sreg[80] seqreg[ca] sreg2[00] ireg[20] ss[00] event[04]
scsi host0: ent[0] CMD val[90] sreg[80] seqreg[ca] sreg2[00] ireg[20] ss[00] event[04]
scsi host0: ent[1] EVENT val[05] sreg[80] seqreg[ca] sreg2[00] ireg[20] ss[00] event[04]
scsi target0:0:3: FAST-5 SCSI 2.0 MB/s ST (500 ns, offset 15)
scsi target0:0:0: asynchronous
sr 0:0:3:0: [sr0] scsi-1 drive
cdrom: Uniform CD-ROM driver Revision: 3.20
sd 0:0:0:0: Attached scsi generic sg0 type 0
sr 0:0:3:0: Attached scsi generic sg1 type 5

This patch resolves this issue because the bus reset causes the INQUIRY
command to fail earlier, and return the appropriate result code.

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>
7 years agoscsi: esp_scsi: Clean up control flow and dead code
Finn Thain [Fri, 4 Aug 2017 05:43:19 +0000 (01:43 -0400)]
scsi: esp_scsi: Clean up control flow and dead code

This patch improves readability. There are no functional changes.

Since this touches on a questionable ESP_INTR_DC conditional, add some
commentary to help others who may (as I did) find themselves chasing an
"Invalid Command" error after the device flags this condition.

This cleanup also eliminates a warning from "make W=1":
drivers/scsi/esp_scsi.c: In function 'esp_finish_select':
drivers/scsi/esp_scsi.c:1233:5: warning: variable 'orig_select_state' set but not used [-Wunused-but-set-variable]
  u8 orig_select_state;

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>
7 years agoscsi: mac_esp: Fix PIO transfers for MESSAGE IN phase
Finn Thain [Fri, 4 Aug 2017 05:43:19 +0000 (01:43 -0400)]
scsi: mac_esp: Fix PIO transfers for MESSAGE IN phase

When in MESSAGE IN phase, the ESP device does not automatically
acknowledge each byte that is transferred by PIO. The mac_esp driver
neglects to explicitly ack them, which causes a timeout during messages
larger than one byte (e.g. tag bytes during reconnect). Fix this with an
ESP_CMD_MOK command after each byte.

The MESSAGE IN phase is also different in that each byte transferred
raises ESP_INTR_FDONE. So don't exit the transfer loop for this interrupt,
for this phase.

That resolves the "Reconnect IRQ2 timeout" error on those Macs which use
PIO transfers instead of PDMA. This patch also improves on the weak tests
for unexpected interrupts and phase changes during PIO transfers.

Tested-by: Stan Johnson <userm57@yahoo.com>
Fixes: 02507a80b35e ("[PATCH] [SCSI] mac_esp: fix PIO mode, take 2")
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mac_esp: Avoid type warning from sparse
Finn Thain [Fri, 4 Aug 2017 05:43:19 +0000 (01:43 -0400)]
scsi: mac_esp: Avoid type warning from sparse

Avoid the following warning from "make C=1":

  CHECK   drivers/scsi/mac_esp.c
drivers/scsi/mac_esp.c:357:30: warning: incorrect type in initializer (different address spaces)
drivers/scsi/mac_esp.c:357:30:    expected unsigned char [usertype] *fifo
drivers/scsi/mac_esp.c:357:30:    got void [noderef] <asn:2>*

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>
7 years agoarcmsr: add const to bin_attribute structures
Bhumika Goyal [Tue, 1 Aug 2017 14:21:14 +0000 (19:51 +0530)]
arcmsr: add const to bin_attribute structures

Add const to bin_attribute structures as they are only passed to the
functions system_{remove/create}_bin_file. The arguments passed are of
type const, so declare the structures to be const.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: early returns for traces disabled via level
Martin Peschke [Fri, 28 Jul 2017 10:31:08 +0000 (12:31 +0200)]
scsi: zfcp: early returns for traces disabled via level

This patch adds early checks to avoid burning CPU cycles on
the assembly of trace entries which would be skipped anyway.

Introduce a static const variable to keep the trace level to check with
debug_level_enabled() in sync with the actual trace emit with
debug_event(). In order not to refactor the SAN tracing too much,
simply use a define instead.

This change is only for the non / semi hot paths,
while the actual (I/O) hot path was already improved earlier:
zfcp_dbf_scsi() is already guarded by its only caller _zfcp_dbf_scsi()
since commit dcd20e2316cd ("[SCSI] zfcp: Only collect SCSI debug data for
matching trace levels").
zfcp_dbf_hba_fsf_res() is already guarded by its only caller
zfcp_dbf_hba_fsf_response() since commit 2e261af84cdb ("[SCSI] zfcp: Only
collect FSF/HBA debug data for matching trace levels").

Signed-off-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
[maier@linux.vnet.ibm.com: rebase, reword, default level 3 branch prediction]
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: clean up unnecessary module_param_named() with no_auto_port_rescan
Martin Peschke [Fri, 28 Jul 2017 10:31:07 +0000 (12:31 +0200)]
scsi: zfcp: clean up unnecessary module_param_named() with no_auto_port_rescan

Improves commit 43f60cbd56c4 ("[SCSI] zfcp: No automatic port_rescan on
events")

Signed-off-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
[maier@linux.vnet.ibm.com: reword, underscore in description to match sysfs]
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: clean up a member of struct zfcp_qdio that was assigned but never used
Martin Peschke [Fri, 28 Jul 2017 10:31:06 +0000 (12:31 +0200)]
scsi: zfcp: clean up a member of struct zfcp_qdio that was assigned but never used

v2.6.38 commit a54ca0f62f95 ("[SCSI] zfcp: Redesign of the debug tracing
for HBA records.")
dropped trace information previously introduced with
v2.6.27 commit c3baa9a26c5a ("[SCSI] zfcp: Add information about interrupt
to trace.")
but kept and needlessly assigned a now no longer used struct field.

Signed-off-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
[maier@linux.vnet.ibm.com: reword, added git history]
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: clean up no longer existent prototype from zfcp API header
Steffen Maier [Fri, 28 Jul 2017 10:31:05 +0000 (12:31 +0200)]
scsi: zfcp: clean up no longer existent prototype from zfcp API header

Commit a54ca0f62f95 ("[SCSI] zfcp: Redesign of the debug tracing for HBA
records.") refactored zfcp_dbf_hba_berr into zfcp_dbf_hba_bit_err
but added the prototype for the latter without removing it for the former.

Suggested-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: clean up redundant code with fall through in link down SRB switch case
Martin Peschke [Fri, 28 Jul 2017 10:31:04 +0000 (12:31 +0200)]
scsi: zfcp: clean up redundant code with fall through in link down SRB switch case

Signed-off-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
[maier@linux.vnet.ibm.com: re-worded short description for more details]
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: fix kernel doc comment typos for struct zfcp_dbf_scsi
Steffen Maier [Fri, 28 Jul 2017 10:31:03 +0000 (12:31 +0200)]
scsi: zfcp: fix kernel doc comment typos for struct zfcp_dbf_scsi

Improves commit 250a1352b95e ("[SCSI] zfcp: Redesign of the debug tracing
for SCSI records.")

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: use endianness conversions with common FC(P) struct fields
Steffen Maier [Fri, 28 Jul 2017 10:31:02 +0000 (12:31 +0200)]
scsi: zfcp: use endianness conversions with common FC(P) struct fields

Just to silence sparse. Since zfcp only exists for s390 and
s390 is big endian, this has been working correctly without conversions
and all the new conversions are NOPs so no performance impact.

Nonetheless, use the conversion on the constant expression where possible.

NB: N_Port-IDs have always been handled with hton24 or ntoh24 conversions
because they also convert to / from character array.

Affected common code structs and .fields are:

HOT I/O PATH:
fcp_cmnd .fc_dl
   FCP command: regular SCSI I/O, including DIX case

SEMI-HOT I/O PATH:
fcp_cmnd .fc_dl
   recovery FCP command: task management function (LUN / target reset)
fcp_resp_ext
   FCP response having FCP_SNS_LEN_VAL with .fr_rsp_len .fr_sns_len
   FCP response having FCP_RESID_UNDER with .fr_resid

RECOVERY / DISCOVERY PATHS:
fc_ct_hdr .ct_cmd .ct_mr_size
   zfcp auto port scan [GPN_FT] with fc_gpn_ft_resp.fp_wwpn,
   recovery for returned port [GID_PN] with fc_ns_gid_pn.fn_wwpn,
   get symbolic port name [GSPN],
   register symbolic port name [RSPN] (NPIV only).
fc_els_rscn .rscn_plen
   incoming ELS (RSCN).
fc_els_flogi .fl_wwpn .fl_wwnn
   incoming ELS (PLOGI),
   port open response with .fl_csp.sp_bb_data .fl_cssp[0..3].cp_class,
   FCP channel physical port,
   point-to-point peer (P2P only).
fc_els_logo .fl_n_port_wwn
   incoming ELS (LOGO).
fc_els_adisc .adisc_wwnn .adisc_wwpn
   path test after RSCN for gone target port.

Since v4.10 commit 05de97003c77 ("linux/types.h: enable endian checks for
all sparse builds"), below sparse endianness reports appear by default.
Previously, one needed to pass argument CF="-D__CHECK_ENDIAN__" to make
as in: $ make C=1 CF="-D__CHECK_ENDIAN__" M=drivers/s390/scsi.

Silenced sparse warnings and one error:

$ make C=1 M=drivers/s390/scsi
...
  CHECK   drivers/s390/scsi/zfcp_dbf.c
drivers/s390/scsi/zfcp_dbf.c:463:22: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_dbf.c:476:28: warning: restricted __be16 degrades to integer
  CC      drivers/s390/scsi/zfcp_dbf.o
...
  CHECK   drivers/s390/scsi/zfcp_fc.c
drivers/s390/scsi/zfcp_fc.c:263:26: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:299:41: warning: incorrect type in argument 2 (different base types)
drivers/s390/scsi/zfcp_fc.c:299:41:    expected unsigned long long [unsigned] [usertype] wwpn
drivers/s390/scsi/zfcp_fc.c:299:41:    got restricted __be64 [usertype] fl_wwpn
drivers/s390/scsi/zfcp_fc.c:309:40: warning: incorrect type in argument 2 (different base types)
drivers/s390/scsi/zfcp_fc.c:309:40:    expected unsigned long long [unsigned] [usertype] wwpn
drivers/s390/scsi/zfcp_fc.c:309:40:    got restricted __be64 [usertype] fl_n_port_wwn
drivers/s390/scsi/zfcp_fc.c:338:31: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:355:24: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:355:24:    expected restricted __be16 [usertype] ct_cmd
drivers/s390/scsi/zfcp_fc.c:355:24:    got unsigned short [unsigned] [usertype] cmd
drivers/s390/scsi/zfcp_fc.c:356:28: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:356:28:    expected restricted __be16 [usertype] ct_mr_size
drivers/s390/scsi/zfcp_fc.c:356:28:    got int
drivers/s390/scsi/zfcp_fc.c:379:36: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:379:36:    expected restricted __be64 [usertype] fn_wwpn
drivers/s390/scsi/zfcp_fc.c:379:36:    got unsigned long long [unsigned] [usertype] wwpn
drivers/s390/scsi/zfcp_fc.c:463:18: warning: restricted __be64 degrades to integer
drivers/s390/scsi/zfcp_fc.c:465:17: warning: cast from restricted __be64
drivers/s390/scsi/zfcp_fc.c:473:20: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:473:20:    expected unsigned long long [unsigned] [usertype] wwnn
drivers/s390/scsi/zfcp_fc.c:473:20:    got restricted __be64 [usertype] fl_wwnn
drivers/s390/scsi/zfcp_fc.c:474:29: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:474:29:    expected unsigned int [unsigned] [usertype] maxframe_size
drivers/s390/scsi/zfcp_fc.c:474:29:    got restricted __be16 [usertype] sp_bb_data
drivers/s390/scsi/zfcp_fc.c:476:30: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:478:30: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:480:30: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:482:30: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:500:28: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:500:28:    expected unsigned long long [unsigned] [usertype] wwnn
drivers/s390/scsi/zfcp_fc.c:500:28:    got restricted __be64 [usertype] adisc_wwnn
drivers/s390/scsi/zfcp_fc.c:502:38: warning: restricted __be64 degrades to integer
drivers/s390/scsi/zfcp_fc.c:541:40: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:541:40:    expected restricted __be64 [usertype] adisc_wwpn
drivers/s390/scsi/zfcp_fc.c:541:40:    got unsigned long long [unsigned] [usertype] port_name
drivers/s390/scsi/zfcp_fc.c:542:40: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fc.c:542:40:    expected restricted __be64 [usertype] adisc_wwnn
drivers/s390/scsi/zfcp_fc.c:542:40:    got unsigned long long [unsigned] [usertype] node_name
drivers/s390/scsi/zfcp_fc.c:669:16: warning: restricted __be16 degrades to integer
drivers/s390/scsi/zfcp_fc.c:696:24: warning: restricted __be64 degrades to integer
drivers/s390/scsi/zfcp_fc.c:699:54: warning: incorrect type in argument 2 (different base types)
drivers/s390/scsi/zfcp_fc.c:699:54:    expected unsigned long long [unsigned] [usertype] <noident>
drivers/s390/scsi/zfcp_fc.c:699:54:    got restricted __be64 [usertype] fp_wwpn
  CC      drivers/s390/scsi/zfcp_fc.o
  CHECK   drivers/s390/scsi/zfcp_fsf.c
drivers/s390/scsi/zfcp_fsf.c:479:34: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fsf.c:479:34:    expected unsigned long long [unsigned] [usertype] port_name
drivers/s390/scsi/zfcp_fsf.c:479:34:    got restricted __be64 [usertype] fl_wwpn
drivers/s390/scsi/zfcp_fsf.c:480:34: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fsf.c:480:34:    expected unsigned long long [unsigned] [usertype] node_name
drivers/s390/scsi/zfcp_fsf.c:480:34:    got restricted __be64 [usertype] fl_wwnn
drivers/s390/scsi/zfcp_fsf.c:506:36: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fsf.c:506:36:    expected unsigned long long [unsigned] [usertype] peer_wwpn
drivers/s390/scsi/zfcp_fsf.c:506:36:    got restricted __be64 [usertype] fl_wwpn
drivers/s390/scsi/zfcp_fsf.c:507:36: warning: incorrect type in assignment (different base types)
drivers/s390/scsi/zfcp_fsf.c:507:36:    expected unsigned long long [unsigned] [usertype] peer_wwnn
drivers/s390/scsi/zfcp_fsf.c:507:36:    got restricted __be64 [usertype] fl_wwnn
drivers/s390/scsi/zfcp_fc.h:269:46: warning: restricted __be32 degrades to integer
drivers/s390/scsi/zfcp_fc.h:270:29: error: incompatible types in comparison expression (different base types)

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: zfcp: use common code fcp_cmnd and fcp_resp with union in fsf_qtcb_bottom_io
Steffen Maier [Fri, 28 Jul 2017 10:31:01 +0000 (12:31 +0200)]
scsi: zfcp: use common code fcp_cmnd and fcp_resp with union in fsf_qtcb_bottom_io

This eases crash dump analysis by automatically dissecting these
protocol headers at least somewhat rather than getting a string
interpretation of large unstructured character array buffer fields.

Also, we can get rid of some unnecessary and error-prone type casts.

This change is possible since v2.6.33 commit 4318e08c84e4
("[SCSI] zfcp: Update FCP protocol related code").

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>