platform/kernel/linux-rpi.git
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 years agoscsi: scsi: Export blacklist flags to sysfs
Hannes Reinecke [Mon, 2 Oct 2017 14:26:34 +0000 (16:26 +0200)]
scsi: scsi: Export blacklist flags to sysfs

Each scsi device is scanned according to the found blacklist flags, but
this information is never presented to sysfs.  This makes it quite hard
to figure out if blacklisting worked as expected.  With this patch we're
exporting an additional attribute 'blacklist' containing the blacklist
flags for this device.

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>
7 years agoscsi: scsi_debug: allow to specify inquiry vendor and model
Hannes Reinecke [Mon, 2 Oct 2017 14:26:33 +0000 (16:26 +0200)]
scsi: scsi_debug: allow to specify inquiry vendor and model

For testing purposes we need to be able to pass in the inquiry vendor
and model.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Doug Gilbert <dgilbert@interlog.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd_zbc: Fix sd_zbc_read_zoned_characteristics()
Damien Le Moal [Tue, 10 Oct 2017 20:54:25 +0000 (05:54 +0900)]
scsi: sd_zbc: Fix sd_zbc_read_zoned_characteristics()

The three values starting at byte 8 of the Zoned Block Device
Characteristics VPD page B6h are 32 bits values, not 64bits. So use
get_unaligned_be32() to retrieve the values and not get_unaligned_be64()

Fixes: 89d947561077 ("sd: Implement support for ZBC devices")
Cc: <stable@vger.kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd_zbc: Use well defined macros
Damien Le Moal [Tue, 10 Oct 2017 20:54:24 +0000 (05:54 +0900)]
scsi: sd_zbc: Use well defined macros

Instead of open coding, use the min() macro to calculate a report zones
reply buffer length in sd_zbc_check_zone_size() and the round_up() macro
for calculating the number of zones in sd_zbc_setup().

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd_zbc: Rearrange code
Damien Le Moal [Tue, 10 Oct 2017 20:54:23 +0000 (05:54 +0900)]
scsi: sd_zbc: Rearrange code

Rearrange sd_zbc_setup() to include use_16_for_rw and use_10_for_rw
assignments and move the calculation of sdkp->zone_shift together with
the assignment of the verified zone_blocks value in
sd_zbc_check_zone_size().

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd_zbc: Fix comments and indentation
Damien Le Moal [Tue, 10 Oct 2017 20:54:22 +0000 (05:54 +0900)]
scsi: sd_zbc: Fix comments and indentation

Fix comments style (use kernel-doc style) and content to clarify some
functions. Also fix some functions signature indentation and remove a
useless blank line in sd_zbc_read_zones().

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: sd_zbc: Move ZBC declarations to scsi_proto.h
Damien Le Moal [Tue, 10 Oct 2017 20:54:21 +0000 (05:54 +0900)]
scsi: sd_zbc: Move ZBC declarations to scsi_proto.h

Move standard macro definitions for the zone types and zone conditions
to scsi_proto.h together with the definitions related to the REPORT
ZONES command. While at it, define all values in the enums to be clear.

Also remove unnecessary includes in sd_zbc.c.

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: don't break the bsg-lib abstractions
Christoph Hellwig [Tue, 3 Oct 2017 10:48:40 +0000 (12:48 +0200)]
scsi: qla2xxx: don't break the bsg-lib abstractions

Always use bsg_job->reply instead of scsi_req(bsg_job->req)->sense), as
they always point to the same memory.

Never set scsi_req(bsg_job->req)->result and we'll set that value
through bsg_job_done.

[mkp: applied by hand, fixed whitespace]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Tested-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: scsi_transport_sas: check reply payload length instead of bidi request
Christoph Hellwig [Tue, 3 Oct 2017 10:48:41 +0000 (12:48 +0200)]
scsi: scsi_transport_sas: check reply payload length instead of bidi request

As a user of bsg-lib the SAS transport should not poke into request
internals but use the bsg_job fields instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: libfc: don't assign resid_len in fc_lport_bsg_request
Christoph Hellwig [Tue, 3 Oct 2017 10:48:39 +0000 (12:48 +0200)]
scsi: libfc: don't assign resid_len in fc_lport_bsg_request

bsg_job_done takes care of updating the scsi_request structure fields.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: bfa: don't reset max_segments for every bsg request
Christoph Hellwig [Tue, 3 Oct 2017 10:48:38 +0000 (12:48 +0200)]
scsi: bfa: don't reset max_segments for every bsg request

We already support 256 or more segments as long as the architecture
supports SG chaining (all the ones that matter do), so removed the weird
playing with limits from the job handler.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qedi: Delete redundant variables
Christos Gkekas [Sat, 14 Oct 2017 12:17:58 +0000 (13:17 +0100)]
scsi: qedi: Delete redundant variables

Remove redundant variables in quedi_fw.c that are set but not used.

Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Query FC4 type during RSCN processing
Giridhar Malavali [Fri, 13 Oct 2017 22:43:23 +0000 (15:43 -0700)]
scsi: qla2xxx: Query FC4 type during RSCN processing

Based on the FC4 type, login will proceed to either FCP or FC-NVMe
remote ports.

Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Use ql2xnvmeenable to enable Q-Pair for FC-NVMe
Himanshu Madhani [Fri, 13 Oct 2017 22:43:22 +0000 (15:43 -0700)]
scsi: qla2xxx: Use ql2xnvmeenable to enable Q-Pair for FC-NVMe

In some environments, user can choose to not enable SCSI-MQ but wants to
use FC-NVMe feature of the driver. Since driver relies on Q-Pairs to
allocate FC-NVMe resources, use existing module parameter to create
Q-Pairs when FC-NVMe is enabled.

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Update driver version to 10.00.00.02-k
Himanshu Madhani [Fri, 13 Oct 2017 16:34:07 +0000 (09:34 -0700)]
scsi: qla2xxx: Update driver version to 10.00.00.02-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Changes to support N2N logins
Duane Grigsby [Fri, 13 Oct 2017 16:34:06 +0000 (09:34 -0700)]
scsi: qla2xxx: Changes to support N2N logins

If we discovered a topology that is N2N then we will issue a login to
the target. If our WWPN is bigger than the target's WWPN then we will
initiate login, otherwise we will just wait for the target to initiate
login.

[mkp: many whitespace errors]

Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Michael Hernandez <michael.hernandez@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Tested-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Allow MBC_GET_PORT_DATABASE to query and save the port states
Duane Grigsby [Fri, 13 Oct 2017 16:34:05 +0000 (09:34 -0700)]
scsi: qla2xxx: Allow MBC_GET_PORT_DATABASE to query and save the port states

The MBC_GET_PORT_DATABASE command normally checks the port state
information. This patch allows it to save that info in the fcport
structure and ignore the check if the query flag is set.

[mkp: typo]

Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Add ATIO-Q processing for INTx mode
Himanshu Madhani [Fri, 13 Oct 2017 16:34:04 +0000 (09:34 -0700)]
scsi: qla2xxx: Add ATIO-Q processing for INTx mode

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: qla2xxx: Reinstate module parameter ql2xenablemsix
Himanshu Madhani [Fri, 13 Oct 2017 16:34:03 +0000 (09:34 -0700)]
scsi: qla2xxx: Reinstate module parameter ql2xenablemsix

[mkp: fixed whitespace]

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix a precedence bug in lpfc_nvme_io_cmd_wqe_cmpl()
Dan Carpenter [Thu, 12 Oct 2017 20:30:57 +0000 (23:30 +0300)]
scsi: lpfc: Fix a precedence bug in lpfc_nvme_io_cmd_wqe_cmpl()

The ! has higher precedence than the & operation.  I've added
parenthesis so this works as intended.

Fixes: 952c303b329c ("scsi: lpfc: Ensure io aborts interlocked with the target.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: aic7xxx: make a couple of functions static
Colin Ian King [Thu, 5 Oct 2017 12:01:53 +0000 (13:01 +0100)]
scsi: aic7xxx: make a couple of functions static

Functions ahc_devlimited_syncrate and ahc_linux_initialize_scsi_bus are
declared static in their prototypes but are missing in their
definitions, so add the missing static.

Cleans up sparse warnings: symbol 'ahc_devlimited_syncrate' was not
declared. Should it be static?  symbol 'ahc_linux_initialize_scsi_bus'
was not declared. Should it be static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: nsp32: fix logic bug in error handling
Arnd Bergmann [Tue, 5 Sep 2017 07:51:29 +0000 (09:51 +0200)]
scsi: nsp32: fix logic bug in error handling

gcc-8 points out a logic error that has existed since the start of the
git history:

drivers/scsi/nsp32.c: In function 'nsp32_selection_autoscsi':
drivers/scsi/nsp32.c:607:27: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
  if(((phase & BUSMON_BSY) == 1) || (phase & BUSMON_SEL) == 1) {
                           ^~

Presumably the author intended to check if one of two bits was set, so
that's what I'm changing the code to. This will obviously change the
behavior of the code, hopefully to do the right thing, but I have not
tested this or checked if the new "(phase & BUSMON_BSY) || (phase &
BUSMON_SEL)" condition should indeed be treated as a fatal error.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: GOTO Masanori <gotom@debian.or.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: bfa: integer overflow in debugfs
Dan Carpenter [Wed, 4 Oct 2017 07:50:37 +0000 (10:50 +0300)]
scsi: bfa: integer overflow in debugfs

We could allocate less memory than intended because we do:

bfad->regdata = kzalloc(len << 2, GFP_KERNEL);

The shift can overflow leading to a crash.  This is debugfs code so the
impact is very small.  I fixed the network version of this in March with
commit 13e2d5187f6b ("bna: integer overflow bug in debugfs").

Fixes: ab2a9ba189e8 ("[SCSI] bfa: add debugfs support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: libcxgbi: simplify task->hdr allocation for mgmt cmds
Varun Prakash [Wed, 11 Oct 2017 14:03:21 +0000 (19:33 +0530)]
scsi: libcxgbi: simplify task->hdr allocation for mgmt cmds

In case of mgmt cmds, task->hdr is dereferenced after transmitting the
pdu in iscsi_tcp_task_xmit(). To handle this case current code
increments the Tx skb reference count and frees the skb in
cxgbi_cleanup_task(). In some error cases this results in skb leak.

To fix this in case of mgmt cmds, allocate a separate buffer for iSCSI
hdr and free this buffer in cxgbi_cleanup_task().

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: cxgb4i: fix Tx skb leak
Varun Prakash [Wed, 11 Oct 2017 14:03:07 +0000 (19:33 +0530)]
scsi: cxgb4i: fix Tx skb leak

In case of connection reset Tx skb queue can have some skbs which are
not transmitted so purge Tx skb queue in release_offload_resources() to
avoid skb leak.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: libcxgbi: in case of vlan pass 0 as ifindex to find route
Varun Prakash [Tue, 10 Oct 2017 13:55:30 +0000 (19:25 +0530)]
scsi: libcxgbi: in case of vlan pass 0 as ifindex to find route

In case of vlan pass 0 as ifindex to find route instead of passing
real_dev ifindex, if we pass real_dev ifindex then
ip_route_output_ports() and ip6_route_output() will check for route
through real_dev not through vlan interface.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: update description of logging_level bits
Randy Dunlap [Wed, 11 Oct 2017 17:09:23 +0000 (10:09 -0700)]
scsi: update description of logging_level bits

Update the description of 'scsi_logging_level' from 8 4-bit nibbles to
the (pre-git) reality of 10 3-bit bitfields.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fix doc. typo for I2O
Randy Dunlap [Wed, 11 Oct 2017 00:16:26 +0000 (17:16 -0700)]
scsi: fix doc. typo for I2O

Fix typo: I20 should be I2O.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Update driver version
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:20 +0000 (16:18 +0530)]
scsi: be2iscsi: Update driver version

Version 11.4.0.1

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Remove A-circumflex character in copyright marking
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:19 +0000 (16:18 +0530)]
scsi: be2iscsi: Remove A-circumflex character in copyright marking

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Fix misc static analysis errors
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:18 +0000 (16:18 +0530)]
scsi: be2iscsi: Fix misc static analysis errors

The patch fixes errors reported by tools like smatch:
 - removes unused structure fields
 - removes dead code
 - fixes code identation

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Add cmd to set host data
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:17 +0000 (16:18 +0530)]
scsi: be2iscsi: Add cmd to set host data

Provide driver version in host data to FW.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Modify IOCTL to fetch user configured IQN
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:16 +0000 (16:18 +0530)]
scsi: be2iscsi: Modify IOCTL to fetch user configured IQN

Add version 1 of GET_HBA_NAME to fetch port specific IQN first.
If it fails use version 0 to get the IQN.

To use this old IQN names of interfaces needs to be cleared from
the iscsiadm database.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Fix _get_initname buffer overflow
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:15 +0000 (16:18 +0530)]
scsi: be2iscsi: Fix _get_initname buffer overflow

be_cmd_get_initname pulls GET_HBA_NAME response of 276 bytes in embedded
WRB buffer of 236 bytes.

Use non-embedded functions to issue the IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Fix _modify_eq_delay buffer overflow
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:14 +0000 (16:18 +0530)]
scsi: be2iscsi: Fix _modify_eq_delay buffer overflow

beiscsi_modify_eq_delay is using embedded command to send request of 788
bytes in 236 bytes buffer. Non-embedded command needs to be used in such
cases.

Use mgmt_alloc_cmd_data fn modified to allow passing of subsystem.  Use
mgmt_exec_nonemb_cmd fn modified to allow setting of callback.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Free msi_name and disable HW intr
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:13 +0000 (16:18 +0530)]
scsi: be2iscsi: Free msi_name and disable HW intr

In beiscsi_dev_probe, allocated msi_name does not get freed and enabled
HW interrupts are not disabled in iscsi_host_add error case.

Add beiscsi_free_irqs fn to handle the cleanup in probe and disable port.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Fix return value in mgmt_open_connection
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:12 +0000 (16:18 +0530)]
scsi: be2iscsi: Fix return value in mgmt_open_connection

mgmt_open_connection is expected to return tag not errno.

In error case, just return invalid tag 0.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: be2iscsi: Fix boot flags in sysfs
Jitendra Bhivare [Tue, 10 Oct 2017 10:48:11 +0000 (16:18 +0530)]
scsi: be2iscsi: Fix boot flags in sysfs

The boot flags exported through sysfs was wrongly reverted to 2.  Use
boot flag 3 required per spec.

Bit 0 Block valid flag
Bit 1 Firmware booting selected

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Bump mpt3sas driver version to v16.100.00.00
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:23 +0000 (18:41 +0530)]
scsi: mpt3sas: Bump mpt3sas driver version to v16.100.00.00

Bump mpt3sas driver version to v16.100.00.00

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Adding support for SAS3616 HBA device
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:22 +0000 (18:41 +0530)]
scsi: mpt3sas: Adding support for SAS3616 HBA device

Adding PNP ID of Mercator i.e. SAS3616 HBA device. Its device ID is
0xD1 and vendor ID is 0x1000.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Fix possibility of using invalid Enclosure Handle for SAS device after...
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:21 +0000 (18:41 +0530)]
scsi: mpt3sas: Fix possibility of using invalid Enclosure Handle for SAS device after host reset

Enclosure handles are not updated after host reset.  As a result, driver
device structure is holding previously assigned enclosure handle which
is different from the enclosure handle populated in the corresponding
device page.

Modified the driver to update devices enclosure handles after host reset
to current value by referring the enclosure handles from corresponding
device pages

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Display chassis slot information of the drive
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:20 +0000 (18:41 +0530)]
scsi: mpt3sas: Display chassis slot information of the drive

Display chassis slot information along with other drive location
parameters such as slot number and connector name in the logs if
chassis slot validity bit is set in 'SAS Enclosure Page 0'.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Updated MPI headers to v2.00.48
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:19 +0000 (18:41 +0530)]
scsi: mpt3sas: Updated MPI headers to v2.00.48

Updated MPI headers to v2.00.48

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Fix IO error occurs on pulling out a drive from RAID1 volume created...
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:18 +0000 (18:41 +0530)]
scsi: mpt3sas: Fix IO error occurs on pulling out a drive from RAID1 volume created on two SATA drive

Whenever an I/O for a RAID volume fails with IOCStatus
MPI2_IOCSTATUS_SCSI_IOC_TERMINATED and SCSIStatus equal to
(MPI2_SCSI_STATE_TERMINATED | MPI2_SCSI_STATE_NO_SCSI_STATUS) then
return the I/O to SCSI midlayer with "DID_RESET" (i.e. retry the IO
infinite times) set in the host byte.

Previously, the driver was completing the I/O with "DID_SOFT_ERROR"
which causes the I/O to be quickly retried. However, firmware needed
more time and hence I/Os were failing.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Fix removal and addition of vSES device during host reset
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:17 +0000 (18:41 +0530)]
scsi: mpt3sas: Fix removal and addition of vSES device during host reset

For Dev Handles whose value is less than HBA's phys count number, driver
would return HBA's SAS address value. As a result, for a Virtual SES
device the driver was returning the HBA's SAS address. Updated the
driver to return Virtual SES' SAS address.

[mkp: clarified commit message]

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Reduce memory footprint in kdump kernel
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:16 +0000 (18:41 +0530)]
scsi: mpt3sas: Reduce memory footprint in kdump kernel

To reduce the memory footprint of the driver in the kdump kernel, we
apply the following settings when reset_devices is set:

1. Use single MSI-x vector.
2. Disable RDPQ mode.
3. Set sg_table_size to 32 by default.
4) Set SCSI IO Queue depth to 200.

[mkp: fixed commit message]

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Fixed memory leaks in driver
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:15 +0000 (18:41 +0530)]
scsi: mpt3sas: Fixed memory leaks in driver

While removing Expander devices, we are removing expander device entry
from the list before freeing its child devices. While freeing child
device we are finding its parent device node as NULL and therefore we
are not freeing the child device's allocated data structures.  Updated
the driver to remove the expander device from the list only after
freeing all its child devices.

[mkp: clarified commit message]

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: mpt3sas: Processing of Cable Exception events
Sreekanth Reddy [Tue, 10 Oct 2017 13:11:14 +0000 (18:41 +0530)]
scsi: mpt3sas: Processing of Cable Exception events

Earlier Active Cable Exception event with reason code "Cable Degraded
(0x02))" was added only for Active Cable. Now this event is extended to
Passive cable too. Re-arranged display message accordingly.

Also added Cable Exception Event event for SAS3008 & SAS3108 HBAs
(i.e. MPI 2.5 spec supporting HBAs). Previously, this event was enabled
only for MPI 2.6 spec supporting HBA devices.

[mkp: typos]

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ufs: Remove unused UFS_BIT() macro
Alim Akhtar [Tue, 3 Oct 2017 15:21:25 +0000 (20:51 +0530)]
scsi: ufs: Remove unused UFS_BIT() macro

Since we have converted all the user of UFS_BIT() macro with the actual
bit position, let remove unused UFS_BIT()macro.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ufs: Remove unused #defines
Alim Akhtar [Tue, 3 Oct 2017 15:21:24 +0000 (20:51 +0530)]
scsi: ufs: Remove unused #defines

HOST_ERROR_INDICATOR and DEVICE_ERROR_INDICATOR are not used
anywhere. Also as per JESD223C specification, bit[7:4] are reserved.
Lets remove these #defines.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ufs-qcom: Remove uses of UFS_BIT() macro
Alim Akhtar [Tue, 3 Oct 2017 15:21:23 +0000 (20:51 +0530)]
scsi: ufs-qcom: Remove uses of UFS_BIT() macro

Use actual bit position instead of UFS_BIT() macro. This patch also
changes bit-17 to meaningful #define.

This change is as per discussion here [1]
[1] -> https://lkml.org/lkml/2017/8/28/786

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: ufs: Change HCI macro to actual bit position
Alim Akhtar [Tue, 3 Oct 2017 15:21:22 +0000 (20:51 +0530)]
scsi: ufs: Change HCI macro to actual bit position

Currently UFS HCI uses UFS_BIT() macro to get various bit position for
the hardware registers status bits. Which makes code longer instead of
shorter. This macro does not improve code readability as well.  Lets
re-write these macro definition with the actual bit position.

Suggested-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: change version to 11.4.0.4
Dick Kennedy [Sat, 30 Sep 2017 00:34:47 +0000 (17:34 -0700)]
scsi: lpfc: change version to 11.4.0.4

Change version to 11.4.0.4

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: correct nvme sg segment count check
James Smart [Sat, 30 Sep 2017 00:34:46 +0000 (17:34 -0700)]
scsi: lpfc: correct nvme sg segment count check

The internal cfg flag is actually smaller, by 1 (for a partial page
sge), than the sg list maintained by the driver. Thus the check on sg
segments errored out when it shouldn't have

Ensure the check is +1

Note: having a value that is less than what it really is is bogus.
Correcting it now would be a significant rework. Add this item to the
list to be refactored in the merge with efct.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix oops of nvme host during driver unload.
Dick Kennedy [Sat, 30 Sep 2017 00:34:45 +0000 (17:34 -0700)]
scsi: lpfc: Fix oops of nvme host during driver unload.

When running NVME io as a NVME host, if the driver is unloaded there
would be oops in lpfc_sli4_issue_wqe.

When unloading, controllers are torn down and the transport initiates
set_property commands to reset the controller and issues aborts to
terminate existing io.  The drivers nvme abort and fcp io submit
routines needed to recognize the driver is unloading and fail the new
requests. It didn't, resulting in the oops.

Revise the ls and fcp io submit routines to detect the unloading state
and properly handle their cleanup.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Extend RDP support
Dick Kennedy [Sat, 30 Sep 2017 00:34:44 +0000 (17:34 -0700)]
scsi: lpfc: Extend RDP support

Support RDP and Multiple Frames

If the remote Nport is not logged in, the driver would not populate all
the descriptors in the RDP response payload. Doing so would create a
payload length that requires multiple frames due to exceeding the
default rx buffer size without an explicit login. Currently FC-LS
explicitly states the RDP response must be a single frame sequence.
Thus we did not violate the standard.

Recently, a modification to FC-LS was accepted which allows multi-frame
sequences and all vendors have indicated they are interoperable with the
change. As such, extend RDP support with the additional fields and send
a multi-frame sequence.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Ensure io aborts interlocked with the target.
Dick Kennedy [Sat, 30 Sep 2017 00:34:43 +0000 (17:34 -0700)]
scsi: lpfc: Ensure io aborts interlocked with the target.

Before releasing nvme io back to the io stack for possible retry on
other paths, ensure the io termination is interlocked with the target
device by ensuring the entire ABTS-LS protocol is complete.

Additionally, FC-NVME ABTS-LS protocol does not use RRQ. Remove RRQ
behavior from ABTS-LS.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix secure firmware updates
Dick Kennedy [Sat, 30 Sep 2017 00:34:42 +0000 (17:34 -0700)]
scsi: lpfc: Fix secure firmware updates

Firmware update fails with: status x17 add_status x56 on the final write

If multiple DMA buffers are used for the download, some firmware revs
have difficulty with signatures and crcs split across the dma buffer
boundaries.  Resolve by making all writes be a single 4k page in length.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Fix crash in lpfc_nvme_fcp_io_submit during LIP
Dick Kennedy [Sat, 30 Sep 2017 00:34:41 +0000 (17:34 -0700)]
scsi: lpfc: Fix crash in lpfc_nvme_fcp_io_submit during LIP

The driver is seeing a NULL pointer in lpfc_nvme_fcp_io_submit.  This
was ultimately due to a transport AER being sent on a terminated
controller, thus some of the values were not set. In case we're in a
system without a corrected transport and in case a race condition occurs
where we enter the routine as the teardown is happening in a separate
thread, validate the parameters before starting the io.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: lpfc: Disable NPIV support if NVME is enabled
Dick Kennedy [Sat, 30 Sep 2017 00:34:40 +0000 (17:34 -0700)]
scsi: lpfc: Disable NPIV support if NVME is enabled

The initial implementation of NVME didn't merge with NPIV support.  As
such, there are several issues if NPIV is used with NVME. For now,
ensure that if NVME is enabled then NPIV is not enabled.

Support for NPIV with NVME will be added in the near future.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>