platform/kernel/linux-starfive.git
4 years agoscsi: aacraid: use scsi_host_(block,unblock) to block I/O
Hannes Reinecke [Fri, 28 Feb 2020 07:53:14 +0000 (08:53 +0100)]
scsi: aacraid: use scsi_host_(block,unblock) to block I/O

Use scsi_host_block() and scsi_host_unblock() instead of
scsi_block_requests()/scsi_unblock_requests() to block and unblock I/O.
This has the advantage that the block layer will stop sending I/O to the
adapter instead of having the SCSI midlayer requeueing I/O internally.

Link: https://lore.kernel.org/r/20200228075318.91255-10-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Balsundar P < Balsundar.P@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: add scsi_host_(block,unblock) helper function
Hannes Reinecke [Fri, 28 Feb 2020 07:53:13 +0000 (08:53 +0100)]
scsi: core: add scsi_host_(block,unblock) helper function

Add helper functions to call scsi_internal_device_block()/
scsi_internal_device_unblock() for all attached devices on a SCSI host.

Link: https://lore.kernel.org/r/20200228075318.91255-9-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aacraid: move scsi_(block,unblock)_requests out of _aac_reset_adapter()
Hannes Reinecke [Fri, 28 Feb 2020 07:53:12 +0000 (08:53 +0100)]
scsi: aacraid: move scsi_(block,unblock)_requests out of _aac_reset_adapter()

_aac_reset_adapter() only has one caller, and that one already calls
scsi_block_requests(). Move the calls out of _aac_reset_adapter() to avoid
calling scsi_block_requests() twice.

Link: https://lore.kernel.org/r/20200228075318.91255-8-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Balsundar P < Balsundar.P@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aacraid: replace aac_flush_ios() with midlayer helper
Hannes Reinecke [Fri, 28 Feb 2020 07:53:11 +0000 (08:53 +0100)]
scsi: aacraid: replace aac_flush_ios() with midlayer helper

Use the midlayer helper scsi_host_complete_all_commands() to flush all
outstanding commands.

Link: https://lore.kernel.org/r/20200228075318.91255-7-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Balsundar P <balsundar.p@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aacraid: use scsi_host_complete_all_commands() to terminate outstanding commands
Hannes Reinecke [Fri, 28 Feb 2020 07:53:10 +0000 (08:53 +0100)]
scsi: aacraid: use scsi_host_complete_all_commands() to terminate outstanding commands

Use scsi_host_complete_all_commands() to terminate all outstanding commands
and change the command result for terminated commands to the more common
'DID_RESET' instead of 'QUEUE_FULL'.

Link: https://lore.kernel.org/r/20200228075318.91255-6-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Balsundar P <balsundar.p@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: aacraid: Do not wait for outstanding write commands on synchronize_cache
Hannes Reinecke [Fri, 28 Feb 2020 07:53:09 +0000 (08:53 +0100)]
scsi: aacraid: Do not wait for outstanding write commands on synchronize_cache

There is no need to wait for outstanding write commands on synchronize
cache; the block layer is responsible for I/O scheduling, no need to
out-guess it in the driver layer.

Link: https://lore.kernel.org/r/20200228075318.91255-5-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Balsundar P <balsundar.b@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: dpt_i2o: use scsi_host_complete_all_commands() to abort outstanding commands
Hannes Reinecke [Fri, 28 Feb 2020 07:53:08 +0000 (08:53 +0100)]
scsi: dpt_i2o: use scsi_host_complete_all_commands() to abort outstanding commands

Rather than traversing all outstanding commands manually, use the
scsi_host_complete_all_commands() helper to terminate all commands during
reset.  With that we can drop the cmd_list usage from the midlayer.

Link: https://lore.kernel.org/r/20200228075318.91255-4-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: add scsi_host_complete_all_commands() helper
Hannes Reinecke [Fri, 28 Feb 2020 07:53:07 +0000 (08:53 +0100)]
scsi: core: add scsi_host_complete_all_commands() helper

Add a helper scsi_host_complete_all_commands() to terminate all outstanding
commands on a SCSI host.

Link: https://lore.kernel.org/r/20200228075318.91255-3-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: dpt_i2o: rename adpt_i2o_to_scsi() to adpt_i2o_scsi_complete()
Hannes Reinecke [Fri, 28 Feb 2020 07:53:06 +0000 (08:53 +0100)]
scsi: dpt_i2o: rename adpt_i2o_to_scsi() to adpt_i2o_scsi_complete()

Rename the badly named function into adpt_i2o_scsi_complete(), and make it
a void function as the return value is never used.  This also fixes a
potential use-after-free as the return value might be evaluated from the
command result after the command has been freed.

Link: https://lore.kernel.org/r/20200228075318.91255-2-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: use kobj_to_dev
Guosong Su [Tue, 25 Feb 2020 10:04:11 +0000 (18:04 +0800)]
scsi: core: use kobj_to_dev

Use kobj_to_dev to instead of open-coding it.

Link: https://lore.kernel.org/r/20200225100411.10250-1-guosongsu@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Guosong Su <suguosong@xiaomi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: ufs-mediatek: add waiting time for reference clock
Stanley Chu [Thu, 20 Feb 2020 13:48:48 +0000 (21:48 +0800)]
scsi: ufs: ufs-mediatek: add waiting time for reference clock

Some delays may be required either after gating or before ungating
reference clock for device according to vendor requirements.

Note that in UFS 3.0, the delay time after gating reference
clock can be defined by attribute bRefClkGatingWaitTime. Use the
formal value instead if it can be queried from device.

Link: https://lore.kernel.org/r/20200220134848.8807-2-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: Apply QUIRK_HOST_TACTIVATE for WDC UFS devices
Can Guo [Mon, 24 Feb 2020 04:09:22 +0000 (20:09 -0800)]
scsi: ufs-qcom: Apply QUIRK_HOST_TACTIVATE for WDC UFS devices

Western Digital UFS devices require host's PA_TACTIVATE to be lower than
device's PA_TACTIVATE, otherwise it may get stuck during hibern8 sequence.

Link: https://lore.kernel.org/r/1582517363-11536-3-git-send-email-cang@codeaurora.org
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Allow vendor device quirks to be applied early
Can Guo [Mon, 24 Feb 2020 04:09:21 +0000 (20:09 -0800)]
scsi: ufs: Allow vendor device quirks to be applied early

Currently ufshcd_vops_apply_dev_quirks() comes after all UniPro parameters
have been tuned. Move it up so that vendors have a chance to apply device
quirks in advance.

Link: https://lore.kernel.org/r/1582517363-11536-2-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufshcd: use an enum for quirks
Christoph Hellwig [Fri, 21 Feb 2020 14:08:12 +0000 (06:08 -0800)]
scsi: ufshcd: use an enum for quirks

Use an enum to specify the various quirks instead of #defines inside the
structure definition.

[mkp: fix typo]

Link: https://lore.kernel.org/r/20200221140812.476338-3-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufshcd: remove unused quirks
Christoph Hellwig [Fri, 21 Feb 2020 14:08:11 +0000 (06:08 -0800)]
scsi: ufshcd: remove unused quirks

Remove various quirks that don't have users, as well as the dead code keyed
off them.

Link: https://lore.kernel.org/r/20200221140812.476338-2-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Update driver version to 10.01.00.25-k
Himanshu Madhani [Wed, 26 Feb 2020 22:40:22 +0000 (14:40 -0800)]
scsi: qla2xxx: Update driver version to 10.01.00.25-k

Link: https://lore.kernel.org/r/20200226224022.24518-19-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Set Nport ID for N2N
Quinn Tran [Wed, 26 Feb 2020 22:40:21 +0000 (14:40 -0800)]
scsi: qla2xxx: Set Nport ID for N2N

When transitioning from loop to N2N, stale NPort ID is not
re-assigned. Stale ID can collide with remote device.  This patch will
re-assign NPort ID on N2N is detected.

Link: https://lore.kernel.org/r/20200226224022.24518-18-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Handle NVME status iocb correctly
Arun Easi [Wed, 26 Feb 2020 22:40:20 +0000 (14:40 -0800)]
scsi: qla2xxx: Handle NVME status iocb correctly

Certain state flags bit combinations are not checked and not handled
correctly. Plus, do not log a normal underrun situation where there is
no frame drop.

Link: https://lore.kernel.org/r/20200226224022.24518-17-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Remove restriction of FC T10-PI and FC-NVMe
Quinn Tran [Wed, 26 Feb 2020 22:40:19 +0000 (14:40 -0800)]
scsi: qla2xxx: Remove restriction of FC T10-PI and FC-NVMe

T10-PI and FC-NVMe are not mutually exclusive. This patch removes
restrictions where if FC-NVMe is enabled T10-PI defaults to disabled.

Link: https://lore.kernel.org/r/20200226224022.24518-16-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Serialize fc_port alloc in N2N
Quinn Tran [Wed, 26 Feb 2020 22:40:18 +0000 (14:40 -0800)]
scsi: qla2xxx: Serialize fc_port alloc in N2N

For N2N, fc_port struct is created during report id acquisition.  At
later time, the loop resync (fabric, n2n, loop) would trigger the rest
of the login using the created fc_port struct.  The loop resync logic
can trigger another fc_port allocation if the 1st allocation was not
able to execute.  This patch prevents the 2nd allocation trigger.

Link: https://lore.kernel.org/r/20200226224022.24518-15-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix NPIV instantiation after FW dump
Quinn Tran [Wed, 26 Feb 2020 22:40:17 +0000 (14:40 -0800)]
scsi: qla2xxx: Fix NPIV instantiation after FW dump

NPIV re-enable code was blocked after FW had been initialized.  The
blocking check was too broad. Reduce the check to make sure if FW is
initialized or not.

Link: https://lore.kernel.org/r/20200226224022.24518-14-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix RDP respond data format
Quinn Tran [Wed, 26 Feb 2020 22:40:16 +0000 (14:40 -0800)]
scsi: qla2xxx: Fix RDP respond data format

RPD information failed to display by switch cli command.  This is
caused by driver failure to properly format RDP response data with
data descriptor to allow switch to parse it correctly.

Link: https://lore.kernel.org/r/20200226224022.24518-13-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Force semaphore on flash validation failure
Quinn Tran [Wed, 26 Feb 2020 22:40:15 +0000 (14:40 -0800)]
scsi: qla2xxx: Force semaphore on flash validation failure

For single port 28XX adapter, the second core can still run in the
background.  The flash semaphore can be held by the non-active core.
This patch tell MPI FW to check for this case and clear the semaphore
from the non-active core.

Link: https://lore.kernel.org/r/20200226224022.24518-12-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: add more FW debug information
Quinn Tran [Wed, 26 Feb 2020 22:40:14 +0000 (14:40 -0800)]
scsi: qla2xxx: add more FW debug information

Per FW request, MB 1-7 should be logged for 8002 error.

Link: https://lore.kernel.org/r/20200226224022.24518-11-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Update BPM enablement semantics.
Andrew Vasquez [Wed, 26 Feb 2020 22:40:13 +0000 (14:40 -0800)]
scsi: qla2xxx: Update BPM enablement semantics.

commit e4e3a2ce9556 ("scsi: qla2xxx: Add ability to autodetect SFP
type") takes a heavy handed approach to BPM (Buffer Plus Management)
enablement:

1) During hardware initialization, if an LR-capable transceiver is
   recognized, the driver schedules a disruptive post-initialization
   chip-reset (ISP-ABORT) to allow the BPM settings to be sent to the
   firmware.  This chip-reset will result in (short-term) path-loss to
   all fc-rports and their attached SCSI devices.

2) LR-detection is triggered during any link-up event, resulting in a
   refresh and potential chip-reset

Based on firmware-team guidance, upon LR-capable transceiver
recognition, the driver's hardware initialization code will now
re-execute firmware with the new BPM settings, then continue on with
driver initialization.  To address the second issue, the driver
performs LR-capable detection upon the driver receiving a
transceiver-insertion asynchronous event from firmware.  No short-term
path loss is needed with this new semantic.

Link: https://lore.kernel.org/r/20200226224022.24518-10-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: fix FW resource count values
Quinn Tran [Wed, 26 Feb 2020 22:40:12 +0000 (14:40 -0800)]
scsi: qla2xxx: fix FW resource count values

This patch fixes issue where current and original exchanges count
were swapped for intiator and targets.

Also fix IOCB count for current and original which were swapped.

Link: https://lore.kernel.org/r/20200226224022.24518-9-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use a dedicated interrupt handler for 'handshake-required' ISPs
Andrew Vasquez [Wed, 26 Feb 2020 22:40:11 +0000 (14:40 -0800)]
scsi: qla2xxx: Use a dedicated interrupt handler for 'handshake-required' ISPs

There's no point checking flags.disable_msix_handshake in the
interrupt handler hot-path.  Instead perform the check during
queue-pair instantiation and use the proper interrupt handler.

Link: https://lore.kernel.org/r/20200226224022.24518-8-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Return appropriate failure through BSG Interface
Michael Hernandez [Wed, 26 Feb 2020 22:40:10 +0000 (14:40 -0800)]
scsi: qla2xxx: Return appropriate failure through BSG Interface

This patch ensures flash updates API calls return possible failure
status through BSG interface to the application.

Link: https://lore.kernel.org/r/20200226224022.24518-7-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Michael Hernandez <mhernandez@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Improved secure flash support messages
Michael Hernandez [Wed, 26 Feb 2020 22:40:09 +0000 (14:40 -0800)]
scsi: qla2xxx: Improved secure flash support messages

This patch improved message for Secure Flash support.  No
functionality has been changed.

Link: https://lore.kernel.org/r/20200226224022.24518-6-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Michael Hernandez <mhernandez@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix FCP-SCSI FC4 flag passing error
Quinn Tran [Wed, 26 Feb 2020 22:40:08 +0000 (14:40 -0800)]
scsi: qla2xxx: Fix FCP-SCSI FC4 flag passing error

This patch fixes issue where incorrect flag was used for sending
switch commands.

Link: https://lore.kernel.org/r/20200226224022.24518-5-hmadhani@marvell.com
Fixes: e8c72ba51a15 ("[SCSI] qla2xxx: Use GFF_ID to check FCP-SCSI FC4 type before logging into Nx_Ports")
Fixes: a4239945b8ad ("scsi: qla2xxx: Add switch command to simplify fabric discovery")
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use FC generic update firmware options routine for ISP27xx
Giridhar Malavali [Wed, 26 Feb 2020 22:40:07 +0000 (14:40 -0800)]
scsi: qla2xxx: Use FC generic update firmware options routine for ISP27xx

This patch uses generic firmware update options for FCoE based
adapters as well to reduce code duplication.

Link: https://lore.kernel.org/r/20200226224022.24518-4-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Avoid setting firmware options twice in 24xx_update_fw_options.
Giridhar Malavali [Wed, 26 Feb 2020 22:40:06 +0000 (14:40 -0800)]
scsi: qla2xxx: Avoid setting firmware options twice in 24xx_update_fw_options.

This patch moves ql2xrdpenable check earlier to avoids setting
fw_option once again before exiting qla24xx_update_fw_options.

Link: https://lore.kernel.org/r/20200226224022.24518-3-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add 16.0GT for PCI String
Himanshu Madhani [Wed, 26 Feb 2020 22:40:05 +0000 (14:40 -0800)]
scsi: qla2xxx: Add 16.0GT for PCI String

This patch adds 16.0GT for readable display string.

Link: https://lore.kernel.org/r/20200226224022.24518-2-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
Bart Van Assche [Thu, 20 Feb 2020 04:34:40 +0000 (20:34 -0800)]
scsi: qla2xxx: Convert MAKE_HANDLE() from a define into an inline function

This patch allows sparse to verify the endianness of the arguments passed
to make_handle().

Link: https://lore.kernel.org/r/20200220043441.20504-5-bvanassche@acm.org
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Quinn Tran <qutran@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix sparse warnings triggered by the PCI state checking code
Bart Van Assche [Thu, 20 Feb 2020 04:34:39 +0000 (20:34 -0800)]
scsi: qla2xxx: Fix sparse warnings triggered by the PCI state checking code

This patch fixes the following sparse warnings:

drivers/scsi/qla2xxx/qla_mbx.c:120:21: warning: restricted pci_channel_state_t degrades to integer
drivers/scsi/qla2xxx/qla_mbx.c:120:37: warning: restricted pci_channel_state_t degrades to integer

>From include/linux/pci.h:

enum pci_channel_state {
/* I/O channel is in normal state */
pci_channel_io_normal = (__force pci_channel_state_t) 1,

/* I/O to channel is blocked */
pci_channel_io_frozen = (__force pci_channel_state_t) 2,

/* PCI card is dead */
pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
};

Link: https://lore.kernel.org/r/20200220043441.20504-4-bvanassche@acm.org
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Quinn Tran <qutran@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Suppress endianness complaints in qla2x00_configure_local_loop()
Bart Van Assche [Thu, 20 Feb 2020 04:34:38 +0000 (20:34 -0800)]
scsi: qla2xxx: Suppress endianness complaints in qla2x00_configure_local_loop()

Instead of changing endianness in-place, write the data in CPU endian
format in another buffer and copy that buffer back. This patch does not
change any functionality but silences some sparse endianness warnings.

Link: https://lore.kernel.org/r/20200220043441.20504-3-bvanassche@acm.org
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Quinn Tran <qutran@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Simplify the code for aborting SCSI commands
Bart Van Assche [Thu, 20 Feb 2020 04:34:37 +0000 (20:34 -0800)]
scsi: qla2xxx: Simplify the code for aborting SCSI commands

Since the SCSI core does not reuse the tag of the SCSI command that is
being aborted by .eh_abort() before .eh_abort() has finished it is not
necessary to check from inside that callback whether or not the SCSI
command has already completed. Instead, rely on the firmware to return an
error code when attempting to abort a command that has already
completed. Additionally, rely on the firmware to return an error code when
attempting to abort an already aborted command.

In qla2x00_abort_srb(), use blk_mq_request_started() instead of
sp->completed and sp->aborted.

Link: https://lore.kernel.org/r/20200220043441.20504-2-bvanassche@acm.org
Cc: Martin Wilck <mwilck@suse.com>
Cc: Quinn Tran <qutran@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix sparse warning reported by kbuild bot
Himanshu Madhani [Thu, 27 Feb 2020 20:11:48 +0000 (12:11 -0800)]
scsi: qla2xxx: Fix sparse warning reported by kbuild bot

this patch fixes following sparse warnings

 >> drivers/scsi/qla2xxx/qla_tmpl.c:873:32: sparse: sparse: incorrect type in assignment (different base types)
 >> drivers/scsi/qla2xxx/qla_tmpl.c:873:32: sparse:    expected unsigned int [usertype] capture_timestamp
 >> drivers/scsi/qla2xxx/qla_tmpl.c:873:32: sparse:    got restricted __le32 [usertype]
    drivers/scsi/qla2xxx/qla_tmpl.c:885:29: sparse: sparse: incorrect type in assignment (different base types)
 >> drivers/scsi/qla2xxx/qla_tmpl.c:885:29: sparse:    expected unsigned int

  vim +873 drivers/scsi/qla2xxx/qla_tmpl.c

  869
  870 static void
  871 qla27xx_time_stamp(struct qla27xx_fwdt_template *tmp)
  872 {
> 873 tmp->capture_timestamp = cpu_to_le32(jiffies);
  874 }
  875
  876 static void
  877 qla27xx_driver_info(struct qla27xx_fwdt_template *tmp)
  878 {
  879 uint8_t v[] = { 0, 0, 0, 0, 0, 0 };
  880
  881 WARN_ON_ONCE(sscanf(qla2x00_version_str,
  882     "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
  883     v+0, v+1, v+2, v+3, v+4, v+5) != 6);
  884
> 885 tmp->driver_info[0] = cpu_to_le32(
  886 v[3] << 24 | v[2] << 16 | v[1] << 8 | v[0]);
  887 tmp->driver_info[1] = cpu_to_le32(v[5] << 8 | v[4]);
  888 tmp->driver_info[2] = __constant_cpu_to_le32(0x12345678);
  889 }
  890

Link: https://lore.kernel.org/r/20200227201148.13973-1-hmadhani@marvell.com
Fixes: a31056ddc665 ("scsi: qla2xxx: Use endian macros to assign static fields in fwdump header")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: fix spelling mistake "Notication" -> "Notification"
Colin Ian King [Fri, 21 Feb 2020 15:48:41 +0000 (15:48 +0000)]
scsi: lpfc: fix spelling mistake "Notication" -> "Notification"

There is a spelling mistake in a lpfc_printf_vlog info message. Fix it.

[mkp: fix spelling mistake in commit description]

Link: https://lore.kernel.org/linux-scsi/20200221154841.77791-1-colin.king@canonical.com
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: sr: get rid of sr global mutex
Merlijn Wajer [Tue, 18 Feb 2020 14:39:17 +0000 (15:39 +0100)]
scsi: sr: get rid of sr global mutex

When replacing the Big Kernel Lock in commit 2a48fc0ab242 ("block:
autoconvert trivial BKL users to private mutex"), the lock was replaced
with a sr-wide lock.

This causes very poor performance when using multiple sr devices, as the sr
driver was not able to execute more than one command to one drive at any
given time, even when there were many CD drives available.

Replace the global mutex with per-sr-device mutex.

Someone tried this patch at the time, but it never made it upstream, due to
possible concerns with race conditions, but it's not clear the patch
actually caused those:

https://www.spinics.net/lists/linux-scsi/msg63706.html
https://www.spinics.net/lists/linux-scsi/msg63750.html

Also see

http://lists.xiph.org/pipermail/paranoia/2019-December/001647.html

Link: https://lore.kernel.org/r/20200218143918.30267-1-merlijn@archive.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Merlijn Wajer <merlijn@archive.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: sr: remove references to BLK_DEV_SR_VENDOR, leave it enabled
Diego Elio Pettenò [Sun, 23 Feb 2020 19:11:44 +0000 (19:11 +0000)]
scsi: sr: remove references to BLK_DEV_SR_VENDOR, leave it enabled

This kernel configuration is basically enabling/disabling sr driver quirks
detection. While these quirks are for fairly rare devices (very old CD
burners, and a glucometer), the additional detection of these models is a
very minimal amount of code.

The logic behind the quirks is always built into the sr driver.

This also removes the config from all the defconfig files that are enabling
this already.

Link: https://lore.kernel.org/r/20200223191144.726-1-flameeyes@flameeyes.com
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ch: remove ch_mutex()
Hannes Reinecke [Thu, 13 Feb 2020 15:32:07 +0000 (16:32 +0100)]
scsi: ch: remove ch_mutex()

ch_mutex() was introduced with a mechanical conversion, but as we now have
correct locking we can remove it altogether.

Link: https://lore.kernel.org/r/20200213153207.123357-4-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ch: synchronize ch_probe() and ch_open()
Hannes Reinecke [Thu, 13 Feb 2020 15:32:06 +0000 (16:32 +0100)]
scsi: ch: synchronize ch_probe() and ch_open()

The 'ch' device node is created before the configuration is being read in,
which leads to a race window when ch_open() is called before that.

To avoid any races we should be taking the device mutex during
ch_readconfig() and ch_init_elem(), and also during ch_open().
That ensures ch_probe is finished before ch_open() completes.

Link: https://lore.kernel.org/r/20200213153207.123357-3-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ch: fixup refcounting imbalance for SCSI devices
Hannes Reinecke [Thu, 13 Feb 2020 15:32:05 +0000 (16:32 +0100)]
scsi: ch: fixup refcounting imbalance for SCSI devices

The SCSI device is required to be present during ch_probe() and ch_open().
But the SCSI device itself is only checked during ch_open(), so it's anyones
guess if it had been present during ch_probe(). And consequently we can't
reliably detach it during ch_release(), as ch_remove() might have been
called first.  So initialize the changer device during ch_probe(), and take
a reference to the SCSI device during both ch_probe() and ch_open().

[mkp: fixed checkpatch warning]

Link: https://lore.kernel.org/r/20200213153207.123357-2-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Update driver version to 10.01.00.24-k
Himanshu Madhani [Wed, 12 Feb 2020 21:44:36 +0000 (13:44 -0800)]
scsi: qla2xxx: Update driver version to 10.01.00.24-k

Link: https://lore.kernel.org/r/20200212214436.25532-26-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use QLA_FW_STOPPED macro to propagate flag
Himanshu Madhani [Wed, 12 Feb 2020 21:44:35 +0000 (13:44 -0800)]
scsi: qla2xxx: Use QLA_FW_STOPPED macro to propagate flag

This patch uses QLA_FW_STOPPED macro so that flag is propogated to all the
QPairs.

Link: https://lore.kernel.org/r/20200212214436.25532-25-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add fixes for mailbox command
Himanshu Madhani [Wed, 12 Feb 2020 21:44:34 +0000 (13:44 -0800)]
scsi: qla2xxx: Add fixes for mailbox command

This patch fixes:

- qla2x00_issue_iocb_timeout will now return if chip is down

- only check for sp->qpair in abort handling

Link: https://lore.kernel.org/r/20200212214436.25532-24-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix control flags for login/logout IOCB
Himanshu Madhani [Wed, 12 Feb 2020 21:44:33 +0000 (13:44 -0800)]
scsi: qla2xxx: Fix control flags for login/logout IOCB

This patch fixes control flag options for login/logout IOCB.

Link: https://lore.kernel.org/r/20200212214436.25532-23-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Save rscn_gen for new fcport
Himanshu Madhani [Wed, 12 Feb 2020 21:44:32 +0000 (13:44 -0800)]
scsi: qla2xxx: Save rscn_gen for new fcport

Add missing rscn_gen when creating new fcport.

Link: https://lore.kernel.org/r/20200212214436.25532-22-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use correct ISP28xx active FW region
Quinn Tran [Wed, 12 Feb 2020 21:44:31 +0000 (13:44 -0800)]
scsi: qla2xxx: Use correct ISP28xx active FW region

For ISP28xx, use 28xx call to retrieve active FW region.

Link: https://lore.kernel.org/r/20200212214436.25532-21-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Print portname for logging in qla24xx_logio_entry()
Joe Carnuccio [Wed, 12 Feb 2020 21:44:30 +0000 (13:44 -0800)]
scsi: qla2xxx: Print portname for logging in qla24xx_logio_entry()

Add port name in the messages file to help debugging of Login/Logout IOCBs

Link: https://lore.kernel.org/r/20200212214436.25532-20-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix qla2x00_echo_test() based on ISP type
Joe Carnuccio [Wed, 12 Feb 2020 21:44:29 +0000 (13:44 -0800)]
scsi: qla2xxx: Fix qla2x00_echo_test() based on ISP type

Ths patch fixes MBX in-direction for setting right bits for
qla2x00_echo_test()

Link: https://lore.kernel.org/r/20200212214436.25532-19-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Correction to selection of loopback/echo test
Joe Carnuccio [Wed, 12 Feb 2020 21:44:28 +0000 (13:44 -0800)]
scsi: qla2xxx: Correction to selection of loopback/echo test

This fixes loopback and echo test options.

Link: https://lore.kernel.org/r/20200212214436.25532-18-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Use endian macros to assign static fields in fwdump header
Joe Carnuccio [Wed, 12 Feb 2020 21:44:27 +0000 (13:44 -0800)]
scsi: qla2xxx: Use endian macros to assign static fields in fwdump header

This takes care of big endian architectures.

Link: https://lore.kernel.org/r/20200212214436.25532-17-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Fix RDP response size
Himanshu Madhani [Wed, 12 Feb 2020 21:44:26 +0000 (13:44 -0800)]
scsi: qla2xxx: Fix RDP response size

This patch fixes RDP length in case when driver needs to reduce length of
RDP response

Link: https://lore.kernel.org/r/20200212214436.25532-16-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Handle cases for limiting RDP response payload length
Joe Carnuccio [Wed, 12 Feb 2020 21:44:25 +0000 (13:44 -0800)]
scsi: qla2xxx: Handle cases for limiting RDP response payload length

This patch reduces RDP response payload length, if requesting port is a
domain controller (sid 0xfffc01) and fw is earlier than 8.09.00 and fw is
not 8.05.65 then limit the RDP response payload length to maximum of 256
bytes by terminating the response just before the optical element
descriptor.

Link: https://lore.kernel.org/r/20200212214436.25532-15-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add deferred queue for processing ABTS and RDP
Joe Carnuccio [Wed, 12 Feb 2020 21:44:24 +0000 (13:44 -0800)]
scsi: qla2xxx: Add deferred queue for processing ABTS and RDP

This patch adds deferred queue for processing aborts and RDP in the driver.

Link: https://lore.kernel.org/r/20200212214436.25532-14-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Cleanup ELS/PUREX iocb fields
Joe Carnuccio [Wed, 12 Feb 2020 21:44:23 +0000 (13:44 -0800)]
scsi: qla2xxx: Cleanup ELS/PUREX iocb fields

This patch does the following to improve RDP processing:

 - Rename field port_id to d_id in ELS and PUREX iocb structs to match FW
   spec.

 - Remove redundant comments from ELS and PUREX iocb structs.

 - Refactor fields in ELS iocb struct for error subcode common access.

 - Properly use error subcode fields in rdp processing routine.

 - Add print logs for alloc failure in purex rdp processing routine.

Link: https://lore.kernel.org/r/20200212214436.25532-13-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Show correct port speed capabilities for RDP command
Himanshu Madhani [Wed, 12 Feb 2020 21:44:22 +0000 (13:44 -0800)]
scsi: qla2xxx: Show correct port speed capabilities for RDP command

This patch correctly displays port speed capability and current speed for
RDP command.

Link: https://lore.kernel.org/r/20200212214436.25532-12-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Display message for FCE enabled
Himanshu Madhani [Wed, 12 Feb 2020 21:44:21 +0000 (13:44 -0800)]
scsi: qla2xxx: Display message for FCE enabled

During Link up phase and Data rate MBX command response, print message
indicating FCE is enabled.

Link: https://lore.kernel.org/r/20200212214436.25532-11-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add vendor extended FDMI commands
Joe Carnuccio [Wed, 12 Feb 2020 21:44:20 +0000 (13:44 -0800)]
scsi: qla2xxx: Add vendor extended FDMI commands

This patch adds support for extended FDMI commands and cleans up code to
reduce duplication.

Link: https://lore.kernel.org/r/20200212214436.25532-10-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add ql2xrdpenable module parameter for RDP
Joe Carnuccio [Wed, 12 Feb 2020 21:44:19 +0000 (13:44 -0800)]
scsi: qla2xxx: Add ql2xrdpenable module parameter for RDP

This patch provides separate module parameter ql2xrdpenable to turn on/off
RDP capability in the driver. However, if ql2xsmartsan parameter is
enabled, it will also turn on ql2xfdmienable parameter since it is required
for RDP to work.

Link: https://lore.kernel.org/r/20200212214436.25532-9-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add vendor extended RDP additions and amendments
Joe Carnuccio [Wed, 12 Feb 2020 21:44:18 +0000 (13:44 -0800)]
scsi: qla2xxx: Add vendor extended RDP additions and amendments

This patch adds RDP command support in the driver. With the help of new
ql2xsmartsan parameter, driver will use PUREX IOCB mode to send RDP command
to switch and will be able to receive various diagnostic data.

Link: https://lore.kernel.org/r/20200212214436.25532-8-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add changes in preparation for vendor extended FDMI/RDP
Joe Carnuccio [Wed, 12 Feb 2020 21:44:17 +0000 (13:44 -0800)]
scsi: qla2xxx: Add changes in preparation for vendor extended FDMI/RDP

This patch prepares code for implementing Vendor specific extended FDMI/RDP
commands. It also addes support for MBC_GET_PORT_DATABASE and
MBC_GET_RNID_PARAMS commands.

Link: https://lore.kernel.org/r/20200212214436.25532-7-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add endianizer macro calls to fc host stats
Joe Carnuccio [Wed, 12 Feb 2020 21:44:16 +0000 (13:44 -0800)]
scsi: qla2xxx: Add endianizer macro calls to fc host stats

This patch fixes endian warning for fc_host_stats.

Link: https://lore.kernel.org/r/20200212214436.25532-6-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add sysfs node for D-Port Diagnostics AEN data
Joe Carnuccio [Wed, 12 Feb 2020 21:44:14 +0000 (13:44 -0800)]
scsi: qla2xxx: Add sysfs node for D-Port Diagnostics AEN data

This patch adds sysfs node to show D-Port diag data.

Link: https://lore.kernel.org/r/20200212214436.25532-4-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Move free of fcport out of interrupt context
Joe Carnuccio [Wed, 12 Feb 2020 21:44:13 +0000 (13:44 -0800)]
scsi: qla2xxx: Move free of fcport out of interrupt context

This patch moves freeing of fcport out of interrupt context.

Link: https://lore.kernel.org/r/20200212214436.25532-3-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Add beacon LED config sysfs interface
Joe Carnuccio [Wed, 12 Feb 2020 21:44:12 +0000 (13:44 -0800)]
scsi: qla2xxx: Add beacon LED config sysfs interface

This patch provides an interface to do the following (using MBC 0x3B):

 - Displays (in hex) the LED config words for all three LEDs.

 - Programs the config words for one LED or for all three LEDs.

The sysfs node defined is named beacon_config.

First, to allow driver to gain LED control, do this:
 # echo 1 > /sys/class/scsi_host/host#/beacon

Then, to display config words for all three LEDs do this:
 # cat /sys/class/scsi_host/host#/beacon_config

To set config words for all three LEDs do this:
 # echo 3 xxxx yyyy zzzz > /sys/class/scsi_host/host#/beacon_config

Or, to set config word for a specific single LED n do this:
 # echo n xxxx > /sys/class/scsi_host/host#/beacon_config
  where n is the LED number (0, 1, 2)

Finally, to restore LED control back to firmware, do this:
 # echo 0 > /sys/class/scsi_host/host#/beacon

Link: https://lore.kernel.org/r/20200212214436.25532-2-hmadhani@marvell.com
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: target: use an enum to track emulate_ua_intlck_ctrl
David Disseldorp [Fri, 21 Feb 2020 09:44:01 +0000 (10:44 +0100)]
scsi: target: use an enum to track emulate_ua_intlck_ctrl

The emulate_ua_intlck_ctrl device attribute accepts values of 0, 1 or 2 via
ConfigFS, which map to unit attention interlocks control codes in the MODE
SENSE control Mode Page.  Use an enum to track these values so that it's
clear that, unlike the remaining emulate_X attributes,
emulate_ua_intlck_ctrl isn't boolean.

Link: https://marc.info/?l=target-devel&m=158227825428798
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: target: convert boolean se_dev_attrib types to bool
David Disseldorp [Wed, 19 Feb 2020 13:01:36 +0000 (14:01 +0100)]
scsi: target: convert boolean se_dev_attrib types to bool

This should harden us against configfs API regressions similar to the one
fixed by the previous commit.

Link: https://marc.info/?l=target-devel&m=158211731505174
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: target: fix unmap_zeroes_data boolean initialisation
David Disseldorp [Wed, 19 Feb 2020 13:01:35 +0000 (14:01 +0100)]
scsi: target: fix unmap_zeroes_data boolean initialisation

The LIO unmap_zeroes_data device attribute is mapped to the LBPRZ flag in
the READ CAPACITY(16) and Thin Provisioning VPD INQUIRY responses.

The unmap_zeroes_data attribute is exposed via configfs, where any write
value is correctly validated via strtobool(). However, when initialised via
target_configure_unmap_from_queue() it takes the value of the device's
max_write_zeroes_sectors queue limit, which is non-boolean.

A non-boolean value can be read from configfs, but attempting to write the
same value back results in -EINVAL, causing problems for configuration
utilities such as targetcli.

Link: https://marc.info/?l=target-devel&m=158213354011309
Fixes: 2237498f0b5c ("target/iblock: Convert WRITE_SAME to blkdev_issue_zeroout")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: advansys: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Thu, 13 Feb 2020 00:02:11 +0000 (18:02 -0600)]
scsi: advansys: Replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language extension
to the C90 standard, but the preferred mechanism to declare variable-length
types such as these ones is a flexible array member[1][2], introduced in
C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by this
change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Link: https://lore.kernel.org/r/20200213000211.GA23171@embeddedor.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: add RDF registration and Link Integrity FPIN logging
James Smart [Mon, 10 Feb 2020 17:31:55 +0000 (09:31 -0800)]
scsi: lpfc: add RDF registration and Link Integrity FPIN logging

This patch modifies lpfc to register for Link Integrity events via the use
of an RDF ELS and to perform Link Integrity FPIN logging.

Specifically, the driver was modified to:

 - Format and issue the RDF ELS immediately following SCR registration.
   This registers the ability of the driver to receive FPIN ELS.

 - Adds decoding of the FPIN els into the received descriptors, with
   logging of the Link Integrity event information. After decoding, the ELS
   is delivered to the scsi fc transport to be delivered to any user-space
   applications.

 - To aid in logging, simple helpers were added to create enum to name
   string lookup functions that utilize the initialization helpers from the
   fc_els.h header.

 - Note: base header definitions for the ELS's don't populate the
   descriptor payloads. As such, lpfc creates it's own version of the
   structures, using the base definitions (mostly headers) and additionally
   declaring the descriptors that will complete the population of the ELS.

Link: https://lore.kernel.org/r/20200210173155.547-3-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: fc: Update Descriptor definition and add RDF and Link Integrity FPINs
James Smart [Mon, 10 Feb 2020 17:31:54 +0000 (09:31 -0800)]
scsi: fc: Update Descriptor definition and add RDF and Link Integrity FPINs

Update the FC headers for the RDF ELS and populate out the FPIN ELS and the
Link integrity FPIN payload.

RDF is used to register for diagnostic events.
FPIN is how the fabric reports a diagnostic event.

Specifically, this patch:

 - Adds the formal definition of TLV descriptors that are now used in a lot
   of the FC spec. The simplistic fc_fn_desc structure, basically no more
   than the tlv definition, is removed.

 - Small tlv helper functions are added as defines.

 - The list of known Descriptor tags (identifying the TLV) is expanded and
   a name initializer introduced.

 - The LSRI descriptor, returned in many new ELS response payloads is
   added.

 - The RDF ELS code is added, and the RDF request response structures
   added.

 - The FPIN els definition is corrected.

 - A full definition of a Link Integrity Notification descriptor is added,

[mkp: rolled in kbuild warning fix]

Link: https://lore.kernel.org/r/20200210173155.547-2-jsmart2021@gmail.com
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: Delete scsi_use_blk_mq
John Garry [Mon, 10 Feb 2020 17:33:12 +0000 (01:33 +0800)]
scsi: core: Delete scsi_use_blk_mq

Module param scsi_use_blk_mq has not been referenced for some time, so zap
it.

Link: https://lore.kernel.org/r/1581355992-139274-1-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: zorro_esp: Restore devm_ioremap() alignment
Geert Uytterhoeven [Wed, 12 Feb 2020 08:51:38 +0000 (09:51 +0100)]
scsi: zorro_esp: Restore devm_ioremap() alignment

Restore alignment of the continuations of the ioremap() calls in
zorro_esp_probe().  Join lines where all parameters can fit on a single
line.

Link: https://lore.kernel.org/r/20200212085138.10009-1-geert+renesas@glider.be
Fixes: 4bdc0d676a643140 ("remove ioremap_nocache and devm_ioremap_nocache")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: Delay specific time before gate ref clk
Can Guo [Tue, 11 Feb 2020 03:40:50 +0000 (19:40 -0800)]
scsi: ufs-qcom: Delay specific time before gate ref clk

After enter hibern8, as UFS JEDEC ver 3.0 requires, a specific gating wait
time is required before disable the device reference clock. If it is not
specified, use the old delay.

Link: https://lore.kernel.org/r/1581392451-28743-8-git-send-email-cang@codeaurora.org
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Add dev ref clock gating wait time support
Can Guo [Tue, 11 Feb 2020 03:40:49 +0000 (19:40 -0800)]
scsi: ufs: Add dev ref clock gating wait time support

In UFS version 3.0, a newly added attribute bRefClkGatingWaitTime defines
the minimum time for which the reference clock is required by device during
transition to LS-MODE or HIBERN8 state. Make this change to reflect the new
requirement by adding delays before turning off the clock.

Link: https://lore.kernel.org/r/1581392451-28743-7-git-send-email-cang@codeaurora.org
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Fix ufshcd_hold() caused scheduling while atomic
Can Guo [Tue, 11 Feb 2020 03:40:48 +0000 (19:40 -0800)]
scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic

The async version of ufshcd_hold(async == true), which is only called in
queuecommand path as for now, is expected to work in atomic context, thus
it should not sleep or schedule out. When it runs into the condition that
clocks are ON but link is still in hibern8 state, it should bail out
without flushing the clock ungate work.

Fixes: f2a785ac2312 ("scsi: ufshcd: Fix race between clk scaling and ungate work")
Link: https://lore.kernel.org/r/1581392451-28743-6-git-send-email-cang@codeaurora.org
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Remove the check before call setup clock notify vops
Can Guo [Tue, 11 Feb 2020 03:40:47 +0000 (19:40 -0800)]
scsi: ufs: Remove the check before call setup clock notify vops

The functionality of vendor specific ops should be handled properly in
platform specific driver, but should not count on the UFS driver.

Link: https://lore.kernel.org/r/1581392451-28743-5-git-send-email-cang@codeaurora.org
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs-qcom: Adjust bus bandwidth voting and unvoting
Can Guo [Tue, 11 Feb 2020 03:40:46 +0000 (19:40 -0800)]
scsi: ufs-qcom: Adjust bus bandwidth voting and unvoting

The bus bandwidth voting is required to be done before the bus clocks are
enabled, and the unvoting is required to be done only after the bus clocks
are disabled.

Link: https://lore.kernel.org/r/1581392451-28743-4-git-send-email-cang@codeaurora.org
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: set load before setting voltage in regulators
Asutosh Das [Tue, 11 Feb 2020 03:40:45 +0000 (19:40 -0800)]
scsi: ufs: set load before setting voltage in regulators

This sequence change is required to avoid dips in voltage during boot-up.

Apparently, this dip is caused because in the original sequence, the
regulators are initialized in lpm mode.  And then when the load is set to
high, and more current is drawn, than is allowed in lpm, the dip is seen.

Link: https://lore.kernel.org/r/1581392451-28743-3-git-send-email-cang@codeaurora.org
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Flush exception event before suspend
Sayali Lokhande [Tue, 11 Feb 2020 03:40:44 +0000 (19:40 -0800)]
scsi: ufs: Flush exception event before suspend

Exception event can be raised by the device when system suspend is in
progress. This will result in unclocked register access in exception event
handler as clocks will be turned off during suspend. This change makes sure
to flush exception event handler work in suspend before disabling clocks to
avoid unclocked register access issue.

Link: https://lore.kernel.org/r/1581392451-28743-2-git-send-email-cang@codeaurora.org
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: Select INITIAL ADAPT type for HS Gear4
Can Guo [Wed, 12 Feb 2020 05:38:29 +0000 (21:38 -0800)]
scsi: ufs: Select INITIAL ADAPT type for HS Gear4

ADAPT is added specifically for HS Gear4 mode only. Select INITIAL ADAPT
before power mode change to G4 and select NO ADAPT before switch to non-G4
modes.

[mkp: fixed typo in header file]

Link: https://lore.kernel.org/r/1581485910-8307-3-git-send-email-cang@codeaurora.org
Signed-off-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: introduce common function to disable host TX LCC
Stanley Chu [Fri, 7 Feb 2020 07:03:57 +0000 (15:03 +0800)]
scsi: ufs: introduce common function to disable host TX LCC

Many vendors would like to disable host TX LCC during initialization
flow. Introduce a common function for all users to make drivers easier to
read and maintained. This patch does not change any functionality.

Link: https://lore.kernel.org/r/20200207070357.17169-3-stanley.chu@mediatek.com
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: ufs-mediatek: fix TX LCC disabling timing
Stanley Chu [Fri, 7 Feb 2020 07:03:56 +0000 (15:03 +0800)]
scsi: ufs: ufs-mediatek: fix TX LCC disabling timing

MediaTek UFS host requires TX LCC to be disabled on both host and device
sides. This can be done by disabling host's local TX LCC before link
startup. Correct TX LCC disabling timing in MediaTek UFS driver.

Link: https://lore.kernel.org/r/20200207070357.17169-2-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Copyright updates for 12.6.0.4 patches
James Smart [Tue, 28 Jan 2020 00:23:12 +0000 (16:23 -0800)]
scsi: lpfc: Copyright updates for 12.6.0.4 patches

Update copyrights to 2020 for files modified in the 12.6.0.4 patch set.

Link: https://lore.kernel.org/r/20200128002312.16346-13-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Update lpfc version to 12.6.0.4
James Smart [Tue, 28 Jan 2020 00:23:11 +0000 (16:23 -0800)]
scsi: lpfc: Update lpfc version to 12.6.0.4

Update lpfc version to 12.6.0.4

Link: https://lore.kernel.org/r/20200128002312.16346-12-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Clean up hba max_lun_queue_depth checks
James Smart [Tue, 28 Jan 2020 00:23:09 +0000 (16:23 -0800)]
scsi: lpfc: Clean up hba max_lun_queue_depth checks

The current code does some odd +1 over maximum xri count checks and
requires that the lun_queue_count can't be bigger than maximum xri count
divided by 8. These items are bogus.

Clean the code up to cap lun_queue_count to maximum xri count.

Link: https://lore.kernel.org/r/20200128002312.16346-10-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Remove handler for obsolete ELS - Read Port Status (RPS)
James Smart [Tue, 28 Jan 2020 00:23:08 +0000 (16:23 -0800)]
scsi: lpfc: Remove handler for obsolete ELS - Read Port Status (RPS)

There was report of an odd "Fix me..." log message, which was tracked down
to the lpfc_els_rcv_rps() routine. This was in handling of a very old and
obsolete ELS - Read Port Status. The RPS ELS was defined in FC-LS-1, but
deprecated in FC-LS-2, and removed from all later FC-LS revisions. It was
replaced by the Read Diagnostic Parameters (RDP) ELS and the Link Error
Status Block descriptor.

There should be no support for the RSP ELS.  Remove support from driver.

Link: https://lore.kernel.org/r/20200128002312.16346-9-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix coverity errors in fmdi attribute handling
James Smart [Tue, 28 Jan 2020 00:23:07 +0000 (16:23 -0800)]
scsi: lpfc: Fix coverity errors in fmdi attribute handling

Coverity reported a memory corruption error for the fdmi attributes
routines:

  CID 15768 [Memory Corruption] Out-of-bounds access on FDMI

Sloppy coding of the fmdi structures. In both the lpfc_fdmi_attr_def and
lpfc_fdmi_reg_port_list structures, a field was placed at the start of
payload that may have variable content. The field was given an arbitrary
type (uint32_t). The code then uses the field name to derive an address,
which it used in things such as memset and memcpy. The memset sizes or
memcpy lengths were larger than the arbitrary type, thus coverity reported
an error.

Fix by replacing the arbitrary fields with the real field structures
describing the payload.

Link: https://lore.kernel.org/r/20200128002312.16346-8-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix compiler warning on frame size
James Smart [Tue, 28 Jan 2020 00:23:06 +0000 (16:23 -0800)]
scsi: lpfc: Fix compiler warning on frame size

The following error is see from the compiler:

  drivers/scsi/lpfc/lpfc_init.c: In function
    ‘lpfc_cpuhp_get_eq’: drivers/scsi/lpfc/lpfc_init.c:12660:1:
      error: the frame size of 1032 bytes is larger than 1024 bytes
         [-Werror=frame-larger-than=]

The issue is due to allocating a cpumask on the stack.

Fix by converting to a dynamical allocation of the cpu mask.

Link: https://lore.kernel.org/r/20200128002312.16346-7-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix release of hwq to clear the eq relationship
James Smart [Tue, 28 Jan 2020 00:23:05 +0000 (16:23 -0800)]
scsi: lpfc: Fix release of hwq to clear the eq relationship

When performing reset testing, the eq's list for related hwqs was getting
corrupted.  In cases where there is not a 1:1 eq to hwq, the eq is
shared. The eq maintains a list of hwqs utilizing it in case of cpu
offlining and polling. During the reset, the hwqs are being torn down so
they can be recreated. The recreation was getting confused by seeing a
non-null eq assignment on the eq and the eq list became corrupt.

Correct by clearing the hdwq eq assignment when the hwq is cleaned up.

Link: https://lore.kernel.org/r/20200128002312.16346-6-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix registration of ELS type support in fdmi
James Smart [Tue, 28 Jan 2020 00:23:04 +0000 (16:23 -0800)]
scsi: lpfc: Fix registration of ELS type support in fdmi

Adjust FC4 Types in FDMI settings

The driver sets FDMI information registring ELS as a FC4 type.  ELS is a
fc3 type and should not be registered.

Fix by removing ELS type bit when we register for FDMI Port attributes.

Link: https://lore.kernel.org/r/20200128002312.16346-5-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix broken Credit Recovery after driver load
James Smart [Tue, 28 Jan 2020 00:23:03 +0000 (16:23 -0800)]
scsi: lpfc: Fix broken Credit Recovery after driver load

When driver is set to enable bb credit recovery, the switch displayed the
setting as inactive.  If the link bounces, it switches to Active.

During link up processing, the driver currently does a MBX_READ_SPARAM
followed by a MBX_CONFIG_LINK. These mbox commands are queued to be
executed, one at a time and the completion is processed by the worker
thread.  Since the MBX_READ_SPARAM is done BEFORE the MBX_CONFIG_LINK, the
BB_SC_N bit is never set the the returned values. BB Credit recovery status
only gets set after the driver requests the feature in CONFIG_LINK, which
is done after the link up. Thus the ordering of READ_SPARAM needs to follow
the CONFIG_LINK.

Fix by reordering so that READ_SPARAM is done after CONFIG_LINK.  Added a
HBA_DEFER_FLOGI flag so that any FLOGI handling waits until after the
READ_SPARAM is done so that the proper BB credit value is set in the FLOGI
payload.

Fixes: 6bfb16208298 ("scsi: lpfc: Fix configuration of BB credit recovery in service parameters")
Cc: <stable@vger.kernel.org> # v5.4+
Link: https://lore.kernel.org/r/20200128002312.16346-4-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
James Smart [Tue, 28 Jan 2020 00:23:02 +0000 (16:23 -0800)]
scsi: lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path

If a call to lpfc_get_cmd_rsp_buf_per_hdwq returns NULL (memory allocation
failure), a previously allocated lpfc_io_buf resource is leaked.

Fix by releasing the lpfc_io_buf resource in the failure path.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Cc: <stable@vger.kernel.org> # v5.4+
Link: https://lore.kernel.org/r/20200128002312.16346-3-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: lpfc: Fix RQ buffer leakage when no IOCBs available
James Smart [Tue, 28 Jan 2020 00:23:01 +0000 (16:23 -0800)]
scsi: lpfc: Fix RQ buffer leakage when no IOCBs available

The driver is occasionally seeing the following SLI Port error, requiring
reset and reinit:

 Port Status Event: ... error 1=0x52004a01, error 2=0x218

The failure means an RQ timeout. That is, the adapter had received
asynchronous receive frames, ran out of buffer slots to place the frames,
and the driver did not replenish the buffer slots before a timeout
occurred. The driver should not be so slow in replenishing buffers that a
timeout can occur.

When the driver received all the frames of a sequence, it allocates an IOCB
to put the frames in. In a situation where there was no IOCB available for
the frame of a sequence, the RQ buffer corresponding to the first frame of
the sequence was not returned to the FW. Eventually, with enough traffic
encountering the situation, the timeout occurred.

Fix by releasing the buffer back to firmware whenever there is no IOCB for
the first frame.

[mkp: typo]

Link: https://lore.kernel.org/r/20200128002312.16346-2-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb()
Bart Van Assche [Thu, 23 Jan 2020 04:23:40 +0000 (20:23 -0800)]
scsi: qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb()

Document the locking assumptions this function relies on and also verify
these locking assumptions at runtime.

Cc: Quinn Tran <qutran@marvell.com>
Cc: Daniel Wagner <dwagner@suse.de>
Link: https://lore.kernel.org/r/20200123042345.23886-2-bvanassche@acm.org
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: core: remove .for_blk_mq
Ming Lei [Sun, 19 Jan 2020 07:14:28 +0000 (15:14 +0800)]
scsi: core: remove .for_blk_mq

Not in use anymore. Remove the flag.

Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Chaitra P B <chaitra.basappa@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: Ewan D. Milne <emilne@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Link: https://lore.kernel.org/r/20200119071432.18558-3-ming.lei@redhat.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 years agoscsi: ufs: ufs-mediatek: gate ref-clk during Auto-Hibern8
Stanley Chu [Wed, 29 Jan 2020 10:52:51 +0000 (18:52 +0800)]
scsi: ufs: ufs-mediatek: gate ref-clk during Auto-Hibern8

In current UFS driver design, hba->uic_link_state will not be changed after
link enters Hibern8 state by Auto-Hibern8 mechanism.  In this case,
reference clock gating will be skipped unless special handling is
implemented in vendor's callbacks.

Support reference clock gating during Auto-Hibern8 period in MediaTek
Chipsets: If link state is already in Hibern8 while Auto-Hibern8 feature is
enabled, gate reference clock in setup_clocks callback.

Link: https://lore.kernel.org/r/20200129105251.12466-5-stanley.chu@mediatek.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>