Home Home > GIT Browse > SLE12-SP5-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2019-08-21 10:54:07 +0200
committerJohannes Thumshirn <jthumshirn@suse.de>2019-08-21 10:54:07 +0200
commit8c294605dd643b26b043ac3f5f3463c72dd13f0f (patch)
tree76261934d8c9e2740da7567d7fa9813a13b4a3c6
parentca392f3e13ff337809caed2f6e461ebb88c9580d (diff)
parent62b9ee69b0ce30c825db8cb84d00466aaf7235eb (diff)
Merge remote-tracking branch 'origin/SLE15-SP1' into SLE12-SP5
Conflicts: patches.kabi/qla2xxx-kABI-fixes-for-v10.01.00.15-k.patch series.conf
-rw-r--r--patches.drivers/qla2xxx-Enable-T10-DIF-with-FC-NVMe-enabled.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Add-cleanup-for-PCI-EEH-recovery.patch301
-rw-r--r--patches.drivers/scsi-qla2xxx-Allow-NVMe-IO-to-resume-with-short-cabl.patch38
-rw-r--r--patches.drivers/scsi-qla2xxx-Avoid-that-Coverity-complains-about-der.patch44
-rw-r--r--patches.drivers/scsi-qla2xxx-Avoid-that-lockdep-complains-about-unsa.patch256
-rw-r--r--patches.drivers/scsi-qla2xxx-Avoid-that-qla2x00_mem_free-crashes-if-.patch39
-rw-r--r--patches.drivers/scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corrupts-.patch48
-rw-r--r--patches.drivers/scsi-qla2xxx-Change-a-stack-variable-into-a-static-c.patch35
-rw-r--r--patches.drivers/scsi-qla2xxx-Change-abort-wait_loop-from-msleep-to-w.patch227
-rw-r--r--patches.drivers/scsi-qla2xxx-Check-the-size-of-firmware-data-structu.patch68
-rw-r--r--patches.drivers/scsi-qla2xxx-Cleanup-fcport-memory-to-prevent-leak.patch45
-rw-r--r--patches.drivers/scsi-qla2xxx-Cleanup-redundant-qla2x00_abort_all_cmd.patch28
-rw-r--r--patches.drivers/scsi-qla2xxx-Complain-if-a-command-is-released-that-.patch51
-rw-r--r--patches.drivers/scsi-qla2xxx-Complain-loudly-about-reference-count-u.patch95
-rw-r--r--patches.drivers/scsi-qla2xxx-Correct-error-handling-during-initializ.patch93
-rw-r--r--patches.drivers/scsi-qla2xxx-Declare-local-symbols-static.patch38
-rw-r--r--patches.drivers/scsi-qla2xxx-Declare-qla24xx_build_scsi_crc_2_iocbs-.patch44
-rw-r--r--patches.drivers/scsi-qla2xxx-Declare-qla2x00_find_new_loop_id-static.patch142
-rw-r--r--patches.drivers/scsi-qla2xxx-Disable-T10-DIF-feature-with-FC-NVMe-du.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-DMA-unmap-leak.patch48
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-stale-CPU.patch84
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-NVME-cmd-and-LS-cmd-timeout-race-co.patch329
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-NVMe-port-discovery-after-a-short-d.patch56
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-Relogin-to-prevent-modifying-scan_s.patch104
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-a-format-specifier.patch32
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-a-qla24xx_enable_msix-error-path.patch42
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-a-small-typo-in-qla_bsg.c.patch27
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-abort-timeout-race-condition.patch69
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-comment-alignment-in-qla_bsg.c.patch24
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-device-staying-in-blocked-state.patch46
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-different-size-DMA-Alloc-Unmap.patch39
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUNs-are.patch79
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-error-handling-in-qlt_alloc_qfull_c.patch45
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-formatting-of-pointer-types.patch82
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-fw-dump-corruption.patch139
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-hang-in-fcport-delete-path.patch44
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-hardirq-unsafe-locking.patch363
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-hardlockup-in-abort-command-during-.patch43
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-kernel-crash-after-disconnecting-NV.patch141
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-possible-fcport-null-pointer-derefe.patch43
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-premature-timer-expiration.patch108
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-race-conditions-in-the-code-for-abo.patch359
-rw-r--r--patches.drivers/scsi-qla2xxx-Fix-use-after-free-issues-in-qla2xxx_qp.patch85
-rw-r--r--patches.drivers/scsi-qla2xxx-Further-limit-FLASH-region-write-access.patch44
-rw-r--r--patches.drivers/scsi-qla2xxx-Increase-the-max_sgl_segments-to-1024.patch32
-rw-r--r--patches.drivers/scsi-qla2xxx-Increase-the-size-of-the-mailbox-arrays.patch82
-rw-r--r--patches.drivers/scsi-qla2xxx-Insert-spaces-where-required.patch224
-rw-r--r--patches.drivers/scsi-qla2xxx-Leave-a-blank-line-after-declarations.patch617
-rw-r--r--patches.drivers/scsi-qla2xxx-Log-the-status-code-if-a-firmware-comma.patch51
-rw-r--r--patches.drivers/scsi-qla2xxx-Make-qla24xx_async_abort_cmd-static.patch197
-rw-r--r--patches.drivers/scsi-qla2xxx-Make-qla2x00_mem_free-easier-to-verify.patch172
-rw-r--r--patches.drivers/scsi-qla2xxx-Make-qla2x00_process_response_queue-eas.patch128
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-qla2x00_clear_loop_id-from-qla_inl.patch74
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-qla2x00_is_reserved_id-from-qla_in.patch63
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-qla2x00_set_fcport_state-from-a-.h.patch88
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-qla2x00_set_reserved_loop_ids-defi.patch66
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-the-linux-io-64-nonatomic-lo-hi.h-.patch45
-rw-r--r--patches.drivers/scsi-qla2xxx-Move-the-port_state_str-definition-from.patch57
-rw-r--r--patches.drivers/scsi-qla2xxx-Pass-little-endian-values-to-the-firmwa.patch58
-rw-r--r--patches.drivers/scsi-qla2xxx-Reduce-the-number-of-forward-declaratio.patch122
-rw-r--r--patches.drivers/scsi-qla2xxx-Reject-EH_-abort-device_reset-target_re.patch51
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-a-comment-that-refers-to-the-SCS.patch32
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-a-set-but-not-used-variable-6eaa5f94.patch35
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.data_work-and-qla_tg.patch47
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.released.patch72
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-the-fcport-test-from-qla_nvme_ab.patch36
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-two-superfluous-casts.patch42
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-unnecessary-locking-from-the-tar.patch91
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-unnecessary-null-check.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Remove-useless-set-memory-to-zero-use-m.patch27
-rw-r--r--patches.drivers/scsi-qla2xxx-Replace-vmalloc-memset-with-vzalloc.patch55
-rw-r--r--patches.drivers/scsi-qla2xxx-Reset-the-FCF_ASYNC_-SENT-ACTIVE-flags.patch41
-rw-r--r--patches.drivers/scsi-qla2xxx-Retry-fabric-Scan-on-IOCB-queue-full.patch77
-rw-r--r--patches.drivers/scsi-qla2xxx-Set-the-SCSI-command-result-before-call.patch42
-rw-r--r--patches.drivers/scsi-qla2xxx-Set-the-qpair-in-SRB-to-NULL-when-SRB-i.patch28
-rw-r--r--patches.drivers/scsi-qla2xxx-Silence-Successful-ELS-IOCB-message.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Simplify-qlt_send_term_imm_notif.patch61
-rw-r--r--patches.drivers/scsi-qla2xxx-Skip-FW-dump-on-LOOP-initialization-err.patch30
-rw-r--r--patches.drivers/scsi-qla2xxx-Uninline-qla2x00_init_timer.patch78
-rw-r--r--patches.drivers/scsi-qla2xxx-Unregister-chrdev-if-module-initializat.patch93
-rw-r--r--patches.drivers/scsi-qla2xxx-Unregister-resources-in-the-opposite-or.patch43
-rw-r--r--patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.16-k.patch25
-rw-r--r--patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.18-k.patch26
-rw-r--r--patches.drivers/scsi-qla2xxx-Update-two-source-code-comments.patch46
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-ARRAY_SIZE-in-the-definition-of-QLA.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-Correct-index-for-Q-Pair-array.patch33
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-an-on-stack-completion-in-qla24xx_c.patch81
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-common-update-firmware-options-rout.patch31
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-get-put_unaligned-where-appropriate.patch124
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-mutex-protection-during-qla2x00_sys.patch93
-rw-r--r--patches.drivers/scsi-qla2xxx-Use-tabs-to-indent-code.patch88
-rw-r--r--patches.drivers/scsi-qla2xxx-fix-spelling-mistake-alredy-already.patch28
-rw-r--r--patches.drivers/scsi-qla2xxx-move-IO-flush-to-the-front-of-NVME-rpor.patch125
-rw-r--r--patches.drivers/scsi-qla2xxx-on-session-delete-return-nvme-cmd.patch98
-rw-r--r--patches.drivers/scsi-qla2xxx-qla2x00_alloc_fw_dump-set-ha-eft.patch38
-rw-r--r--patches.drivers/scsi-qla2xxx-remove-double-assignment-in-qla2x00_upd.patch27
-rw-r--r--patches.drivers/scsi-qla2xxx-target-Fix-offline-port-handling-and-ho.patch165
-rw-r--r--patches.drivers/scsi-scsi_transport_fc-nvme-display-FC-NVMe-port-rol.patch162
-rw-r--r--patches.drivers/scsi-tcm_qla2xxx-Minimize-include-directives.patch47
-rw-r--r--patches.drm/drm-amd-display-Remove-redundant-non-zero-and-overfl.patch50
-rw-r--r--patches.drm/drm-amd-display-num-of-sw-i2c-aux-engines-less-than-.patch258
-rw-r--r--patches.drm/drm-amdgpu-added-support-2nd-UVD-instance.patch63
-rw-r--r--patches.drm/drm-amdgpu-change-VEGA-booting-with-firmware-loaded-.patch58
-rw-r--r--patches.suse/mm-vmscan-do-not-special-case-slab-reclaim-when-watermarks-are-boosted.patch292
-rw-r--r--series.conf106
105 files changed, 9323 insertions, 20 deletions
diff --git a/patches.drivers/qla2xxx-Enable-T10-DIF-with-FC-NVMe-enabled.patch b/patches.drivers/qla2xxx-Enable-T10-DIF-with-FC-NVMe-enabled.patch
index 3fc01b6a89..ae2fef0173 100644
--- a/patches.drivers/qla2xxx-Enable-T10-DIF-with-FC-NVMe-enabled.patch
+++ b/patches.drivers/qla2xxx-Enable-T10-DIF-with-FC-NVMe-enabled.patch
@@ -7,16 +7,14 @@ References: bsc#1091264
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
---
- drivers/scsi/qla2xxx/qla_attr.c | 2 +-
- drivers/scsi/qla2xxx/qla_init.c | 2 +-
- drivers/scsi/qla2xxx/qla_os.c | 10 +++-------
+ drivers/scsi/qla2xxx/qla_attr.c | 2 +-
+ drivers/scsi/qla2xxx/qla_init.c | 2 +-
+ drivers/scsi/qla2xxx/qla_os.c | 10 +++-------
3 files changed, 5 insertions(+), 9 deletions(-)
-diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
-index 89a4999fa631..4a7f98893f51 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
-@@ -2041,7 +2041,7 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
+@@ -2824,7 +2824,7 @@ qla24xx_vport_create(struct fc_vport *fc
fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
}
@@ -24,12 +22,10 @@ index 89a4999fa631..4a7f98893f51 100644
+ if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif && !ql2xnvmeenable) {
if (ha->fw_attributes & BIT_4) {
int prot = 0, guard;
- vha->flags.difdix_supported = 1;
-diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
-index dbd718cc106d..c6a9c84d743f 100644
+
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
-@@ -8471,7 +8471,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
+@@ -8952,7 +8952,7 @@ struct qla_qpair *qla2xxx_create_qpair(s
/* init qpair to this cpu. Will adjust at run time. */
qla_cpu_update(qpair, smp_processor_id());
@@ -38,11 +34,9 @@ index dbd718cc106d..c6a9c84d743f 100644
if (ha->fw_attributes & BIT_4)
qpair->difdix_supported = 1;
}
-diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
-index 9b8a78a61da6..84c4d2c07cc5 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
-@@ -120,11 +120,7 @@ MODULE_PARM_DESC(ql2xmaxqdepth,
+@@ -139,11 +139,7 @@ MODULE_PARM_DESC(ql2xmaxqdepth,
"Maximum queue depth to set for each LUN. "
"Default is 64.");
@@ -54,7 +48,7 @@ index 9b8a78a61da6..84c4d2c07cc5 100644
module_param(ql2xenabledif, int, S_IRUGO);
MODULE_PARM_DESC(ql2xenabledif,
" Enable T10-CRC-DIF:\n"
-@@ -3078,7 +3074,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+@@ -3192,7 +3188,7 @@ qla2x00_probe_one(struct pci_dev *pdev,
host->max_id = ha->max_fibre_devices;
host->cmd_per_lun = 3;
host->unique_id = host->host_no;
@@ -63,7 +57,7 @@ index 9b8a78a61da6..84c4d2c07cc5 100644
host->max_cmd_len = 32;
else
host->max_cmd_len = MAX_CMDSZ;
-@@ -3303,7 +3299,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+@@ -3419,7 +3415,7 @@ skip_dpc:
"Detected hba at address=%p.\n",
ha);
@@ -71,8 +65,8 @@ index 9b8a78a61da6..84c4d2c07cc5 100644
+ if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif && !ql2xnvmeenable) {
if (ha->fw_attributes & BIT_4) {
int prot = 0, guard;
- base_vha->flags.difdix_supported = 1;
-@@ -3956,7 +3952,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
+
+@@ -4073,7 +4069,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha
"init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n",
ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool);
@@ -81,6 +75,3 @@ index 9b8a78a61da6..84c4d2c07cc5 100644
ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev,
DSD_LIST_DMA_POOL_SIZE, 8, 0);
if (!ha->dl_dma_pool) {
---
-2.16.1.72.g5be1f00a9a
-
diff --git a/patches.drivers/scsi-qla2xxx-Add-cleanup-for-PCI-EEH-recovery.patch b/patches.drivers/scsi-qla2xxx-Add-cleanup-for-PCI-EEH-recovery.patch
new file mode 100644
index 0000000000..eaafb2d5f3
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Add-cleanup-for-PCI-EEH-recovery.patch
@@ -0,0 +1,301 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Mon, 6 May 2019 13:52:19 -0700
+Subject: scsi: qla2xxx: Add cleanup for PCI EEH recovery
+Patch-mainline: v5.2-rc2
+Git-commit: 5386a4e6c7fecd282d265a24d930a74ba3c5917b
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+During EEH error recovery testing it was discovered that driver's reset()
+callback partially frees resources used by driver, leaving some stale
+memory. After reset() is done and when resume() callback in driver uses
+old data which results into error leaving adapter disabled due to PCIe
+error.
+
+This patch does cleanup for EEH recovery code path and prevents adapter
+from getting disabled.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Ewan D. Milne <emilne@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 221 +++++++++++++++---------------------------
+ 1 file changed, 82 insertions(+), 139 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -6837,6 +6837,78 @@ qla2x00_release_firmware(void)
+ mutex_unlock(&qla_fw_lock);
+ }
+
++static void qla_pci_error_cleanup(scsi_qla_host_t *vha)
++{
++ struct qla_hw_data *ha = vha->hw;
++ scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
++ struct qla_qpair *qpair = NULL;
++ struct scsi_qla_host *vp;
++ fc_port_t *fcport;
++ int i;
++ unsigned long flags;
++
++ ha->chip_reset++;
++
++ ha->base_qpair->chip_reset = ha->chip_reset;
++ for (i = 0; i < ha->max_qpairs; i++) {
++ if (ha->queue_pair_map[i])
++ ha->queue_pair_map[i]->chip_reset =
++ ha->base_qpair->chip_reset;
++ }
++
++ /* purge MBox commands */
++ if (atomic_read(&ha->num_pend_mbx_stage3)) {
++ clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
++ complete(&ha->mbx_intr_comp);
++ }
++
++ i = 0;
++
++ while (atomic_read(&ha->num_pend_mbx_stage3) ||
++ atomic_read(&ha->num_pend_mbx_stage2) ||
++ atomic_read(&ha->num_pend_mbx_stage1)) {
++ msleep(20);
++ i++;
++ if (i > 50)
++ break;
++ }
++
++ ha->flags.purge_mbox = 0;
++
++ mutex_lock(&ha->mq_lock);
++ list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem)
++ qpair->online = 0;
++ mutex_unlock(&ha->mq_lock);
++
++ qla2x00_mark_all_devices_lost(vha, 0);
++
++ spin_lock_irqsave(&ha->vport_slock, flags);
++ list_for_each_entry(vp, &ha->vp_list, list) {
++ atomic_inc(&vp->vref_count);
++ spin_unlock_irqrestore(&ha->vport_slock, flags);
++ qla2x00_mark_all_devices_lost(vp, 0);
++ spin_lock_irqsave(&ha->vport_slock, flags);
++ atomic_dec(&vp->vref_count);
++ }
++ spin_unlock_irqrestore(&ha->vport_slock, flags);
++
++ /* Clear all async request states across all VPs. */
++ list_for_each_entry(fcport, &vha->vp_fcports, list)
++ fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
++
++ spin_lock_irqsave(&ha->vport_slock, flags);
++ list_for_each_entry(vp, &ha->vp_list, list) {
++ atomic_inc(&vp->vref_count);
++ spin_unlock_irqrestore(&ha->vport_slock, flags);
++ list_for_each_entry(fcport, &vp->vp_fcports, list)
++ fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
++ spin_lock_irqsave(&ha->vport_slock, flags);
++ atomic_dec(&vp->vref_count);
++ }
++ spin_unlock_irqrestore(&ha->vport_slock, flags);
++}
++
++
+ static pci_ers_result_t
+ qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
+ {
+@@ -6862,20 +6934,7 @@ qla2xxx_pci_error_detected(struct pci_de
+ return PCI_ERS_RESULT_CAN_RECOVER;
+ case pci_channel_io_frozen:
+ ha->flags.eeh_busy = 1;
+- /* For ISP82XX complete any pending mailbox cmd */
+- if (IS_QLA82XX(ha)) {
+- ha->flags.isp82xx_fw_hung = 1;
+- ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n");
+- qla82xx_clear_pending_mbx(vha);
+- }
+- qla2x00_free_irqs(vha);
+- pci_disable_device(pdev);
+- /* Return back all IOs */
+- qla2x00_abort_all_cmds(vha, DID_RESET << 16);
+- if (ql2xmqsupport || ql2xnvmeenable) {
+- set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags);
+- qla2xxx_wake_dpc(vha);
+- }
++ qla_pci_error_cleanup(vha);
+ return PCI_ERS_RESULT_NEED_RESET;
+ case pci_channel_io_perm_failure:
+ ha->flags.pci_channel_io_perm_failure = 1;
+@@ -6929,122 +6988,14 @@ qla2xxx_pci_mmio_enabled(struct pci_dev
+ return PCI_ERS_RESULT_RECOVERED;
+ }
+
+-static uint32_t
+-qla82xx_error_recovery(scsi_qla_host_t *base_vha)
+-{
+- uint32_t rval = QLA_FUNCTION_FAILED;
+- uint32_t drv_active = 0;
+- struct qla_hw_data *ha = base_vha->hw;
+- int fn;
+- struct pci_dev *other_pdev = NULL;
+-
+- ql_dbg(ql_dbg_aer, base_vha, 0x9006,
+- "Entered %s.\n", __func__);
+-
+- set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
+-
+- if (base_vha->flags.online) {
+- /* Abort all outstanding commands,
+- * so as to be requeued later */
+- qla2x00_abort_isp_cleanup(base_vha);
+- }
+-
+-
+- fn = PCI_FUNC(ha->pdev->devfn);
+- while (fn > 0) {
+- fn--;
+- ql_dbg(ql_dbg_aer, base_vha, 0x9007,
+- "Finding pci device at function = 0x%x.\n", fn);
+- other_pdev =
+- pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus),
+- ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn),
+- fn));
+-
+- if (!other_pdev)
+- continue;
+- if (atomic_read(&other_pdev->enable_cnt)) {
+- ql_dbg(ql_dbg_aer, base_vha, 0x9008,
+- "Found PCI func available and enable at 0x%x.\n",
+- fn);
+- pci_dev_put(other_pdev);
+- break;
+- }
+- pci_dev_put(other_pdev);
+- }
+-
+- if (!fn) {
+- /* Reset owner */
+- ql_dbg(ql_dbg_aer, base_vha, 0x9009,
+- "This devfn is reset owner = 0x%x.\n",
+- ha->pdev->devfn);
+- qla82xx_idc_lock(ha);
+-
+- qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+- QLA8XXX_DEV_INITIALIZING);
+-
+- qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION,
+- QLA82XX_IDC_VERSION);
+-
+- drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE);
+- ql_dbg(ql_dbg_aer, base_vha, 0x900a,
+- "drv_active = 0x%x.\n", drv_active);
+-
+- qla82xx_idc_unlock(ha);
+- /* Reset if device is not already reset
+- * drv_active would be 0 if a reset has already been done
+- */
+- if (drv_active)
+- rval = qla82xx_start_firmware(base_vha);
+- else
+- rval = QLA_SUCCESS;
+- qla82xx_idc_lock(ha);
+-
+- if (rval != QLA_SUCCESS) {
+- ql_log(ql_log_info, base_vha, 0x900b,
+- "HW State: FAILED.\n");
+- qla82xx_clear_drv_active(ha);
+- qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+- QLA8XXX_DEV_FAILED);
+- } else {
+- ql_log(ql_log_info, base_vha, 0x900c,
+- "HW State: READY.\n");
+- qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+- QLA8XXX_DEV_READY);
+- qla82xx_idc_unlock(ha);
+- ha->flags.isp82xx_fw_hung = 0;
+- rval = qla82xx_restart_isp(base_vha);
+- qla82xx_idc_lock(ha);
+- /* Clear driver state register */
+- qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0);
+- qla82xx_set_drv_active(base_vha);
+- }
+- qla82xx_idc_unlock(ha);
+- } else {
+- ql_dbg(ql_dbg_aer, base_vha, 0x900d,
+- "This devfn is not reset owner = 0x%x.\n",
+- ha->pdev->devfn);
+- if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) ==
+- QLA8XXX_DEV_READY)) {
+- ha->flags.isp82xx_fw_hung = 0;
+- rval = qla82xx_restart_isp(base_vha);
+- qla82xx_idc_lock(ha);
+- qla82xx_set_drv_active(base_vha);
+- qla82xx_idc_unlock(ha);
+- }
+- }
+- clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
+-
+- return rval;
+-}
+-
+ static pci_ers_result_t
+ qla2xxx_pci_slot_reset(struct pci_dev *pdev)
+ {
+ pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
+ scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
+ struct qla_hw_data *ha = base_vha->hw;
+- struct rsp_que *rsp;
+- int rc, retries = 10;
++ int rc;
++ struct qla_qpair *qpair = NULL;
+
+ ql_dbg(ql_dbg_aer, base_vha, 0x9004,
+ "Slot Reset.\n");
+@@ -7073,24 +7024,16 @@ qla2xxx_pci_slot_reset(struct pci_dev *p
+ goto exit_slot_reset;
+ }
+
+- rsp = ha->rsp_q_map[0];
+- if (qla2x00_request_irqs(ha, rsp))
+- goto exit_slot_reset;
+
+ if (ha->isp_ops->pci_config(base_vha))
+ goto exit_slot_reset;
+
+- if (IS_QLA82XX(ha)) {
+- if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) {
+- ret = PCI_ERS_RESULT_RECOVERED;
+- goto exit_slot_reset;
+- } else
+- goto exit_slot_reset;
+- }
+-
+- while (ha->flags.mbox_busy && retries--)
+- msleep(1000);
++ mutex_lock(&ha->mq_lock);
++ list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem)
++ qpair->online = 1;
++ mutex_unlock(&ha->mq_lock);
+
++ base_vha->flags.online = 1;
+ set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
+ if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS)
+ ret = PCI_ERS_RESULT_RECOVERED;
+@@ -7114,6 +7057,8 @@ qla2xxx_pci_resume(struct pci_dev *pdev)
+ ql_dbg(ql_dbg_aer, base_vha, 0x900f,
+ "pci_resume.\n");
+
++ ha->flags.eeh_busy = 0;
++
+ ret = qla2x00_wait_for_hba_online(base_vha);
+ if (ret != QLA_SUCCESS) {
+ ql_log(ql_log_fatal, base_vha, 0x9002,
+@@ -7121,8 +7066,6 @@ qla2xxx_pci_resume(struct pci_dev *pdev)
+ }
+
+ pci_cleanup_aer_uncorrect_error_status(pdev);
+-
+- ha->flags.eeh_busy = 0;
+ }
+
+ static void
diff --git a/patches.drivers/scsi-qla2xxx-Allow-NVMe-IO-to-resume-with-short-cabl.patch b/patches.drivers/scsi-qla2xxx-Allow-NVMe-IO-to-resume-with-short-cabl.patch
new file mode 100644
index 0000000000..c4f4841465
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Allow-NVMe-IO-to-resume-with-short-cabl.patch
@@ -0,0 +1,38 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:39 -0700
+Subject: scsi: qla2xxx: Allow NVMe IO to resume with short cable pull
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 03cc44bf682af289d6536eb911e928b415bd0e1f
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Current driver report dev_loss_tmo to 0 for NVMe devices with short cable
+pull. This causes NVMe controller to be freed along with NVMe namespace.
+The side affect is IO would stop. By not setting dev_loss_tmo to 0, NVMe
+namespace would stay until cable is plugged back in. This allows IO to
+resume afterward.
+
+[mkp: commit desc]
+
+Signed-off-by: Arun Easi <aeasi@marvell.com>
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -671,7 +671,9 @@ void qla_nvme_unregister_remote_port(str
+ "%s: unregister remoteport on %p %8phN\n",
+ __func__, fcport, fcport->port_name);
+
+- nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
++ if (test_bit(PFLG_DRIVER_REMOVING, &fcport->vha->pci_flags))
++ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
++
+ init_completion(&fcport->nvme_del_done);
+ ret = nvme_fc_unregister_remoteport(fcport->nvme_remote_port);
+ if (ret)
diff --git a/patches.drivers/scsi-qla2xxx-Avoid-that-Coverity-complains-about-der.patch b/patches.drivers/scsi-qla2xxx-Avoid-that-Coverity-complains-about-der.patch
new file mode 100644
index 0000000000..c48d8ed970
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Avoid-that-Coverity-complains-about-der.patch
@@ -0,0 +1,44 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:19 -0700
+Subject: scsi: qla2xxx: Avoid that Coverity complains about dereferencing a
+ NULL rport pointer
+Patch-mainline: v5.2-rc1
+Git-commit: 2dbb02fd495c9b2e41ba37d6fec2aa713d328788
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since Coverity cannot know that rport != NULL in qla2xxx_queuecommand() and
+since there is code in that function that dereferences the rport pointer,
+modify qla2xxx_queuecommand() such that it fails SCSI commands if rport ==
+NULL.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -878,7 +878,8 @@ qla2xxx_queuecommand(struct Scsi_Host *h
+ uint32_t tag;
+ uint16_t hwq;
+
+- if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) {
++ if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) ||
++ WARN_ON_ONCE(!rport)) {
+ cmd->result = DID_NO_CONNECT << 16;
+ goto qc24_fail_command;
+ }
+@@ -1005,7 +1006,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host *
+ srb_t *sp;
+ int rval;
+
+- rval = fc_remote_port_chkready(rport);
++ rval = rport ? fc_remote_port_chkready(rport) : FC_PORTSTATE_OFFLINE;
+ if (rval) {
+ cmd->result = rval;
+ ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076,
diff --git a/patches.drivers/scsi-qla2xxx-Avoid-that-lockdep-complains-about-unsa.patch b/patches.drivers/scsi-qla2xxx-Avoid-that-lockdep-complains-about-unsa.patch
new file mode 100644
index 0000000000..790ad7e848
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Avoid-that-lockdep-complains-about-unsa.patch
@@ -0,0 +1,256 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:43 -0700
+Subject: scsi: qla2xxx: Avoid that lockdep complains about unsafe locking in
+ tcm_qla2xxx_close_session()
+Patch-mainline: v5.2-rc1
+Git-commit: d4023db71108375e4194e92730ba0d32d7f07813
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch avoids that lockdep reports the following warning:
+
+=====================================================
+WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
+5.1.0-rc1-dbg+ #11 Tainted: G W
+-----------------------------------------------------
+rmdir/1478 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
+00000000e7ac4607 (&(&k->k_lock)->rlock){+.+.}, at: klist_next+0x43/0x1d0
+
+and this task is already holding:
+00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx]
+which would create a new lock dependency:
+ (&(&ha->tgt.sess_lock)->rlock){-...} -> (&(&k->k_lock)->rlock){+.+.}
+
+but this new dependency connects a HARDIRQ-irq-safe lock:
+ (&(&ha->tgt.sess_lock)->rlock){-...}
+
+... which became HARDIRQ-irq-safe at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx]
+ qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx]
+ qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx]
+ qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx]
+ __handle_irq_event_percpu+0x79/0x3c0
+ handle_irq_event_percpu+0x70/0xf0
+ handle_irq_event+0x5a/0x8b
+ handle_edge_irq+0x12c/0x310
+ handle_irq+0x192/0x20a
+ do_IRQ+0x73/0x160
+ ret_from_intr+0x0/0x1d
+ default_idle+0x23/0x1f0
+ arch_cpu_idle+0x15/0x20
+ default_idle_call+0x35/0x40
+ do_idle+0x2bb/0x2e0
+ cpu_startup_entry+0x1d/0x20
+ start_secondary+0x24d/0x2d0
+ secondary_startup_64+0xa4/0xb0
+
+to a HARDIRQ-irq-unsafe lock:
+ (&(&k->k_lock)->rlock){+.+.}
+
+... which became HARDIRQ-irq-unsafe at:
+...
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7f4/0xb60
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+
+other info that might help us debug this:
+
+ Possible interrupt unsafe locking scenario:
+
+ CPU0 CPU1
+ ---- ----
+ lock(&(&k->k_lock)->rlock);
+ local_irq_disable();
+ lock(&(&ha->tgt.sess_lock)->rlock);
+ lock(&(&k->k_lock)->rlock);
+ <Interrupt>
+ lock(&(&ha->tgt.sess_lock)->rlock);
+
+ *** DEADLOCK ***
+
+4 locks held by rmdir/1478:
+ #0: 000000002c7f1ba4 (sb_writers#10){.+.+}, at: mnt_want_write+0x32/0x70
+ #1: 00000000c85eb147 (&default_group_class[depth - 1]#2/1){+.+.}, at: do_rmdir+0x217/0x2d0
+ #2: 000000002b164d6f (&sb->s_type->i_mutex_key#13){++++}, at: vfs_rmdir+0x7e/0x1d0
+ #3: 00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx]
+
+the dependencies between HARDIRQ-irq-safe lock and the holding lock:
+-> (&(&ha->tgt.sess_lock)->rlock){-...} ops: 127 {
+ IN-HARDIRQ-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx]
+ qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx]
+ qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx]
+ qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx]
+ __handle_irq_event_percpu+0x79/0x3c0
+ handle_irq_event_percpu+0x70/0xf0
+ handle_irq_event+0x5a/0x8b
+ handle_edge_irq+0x12c/0x310
+ handle_irq+0x192/0x20a
+ do_IRQ+0x73/0x160
+ ret_from_intr+0x0/0x1d
+ default_idle+0x23/0x1f0
+ arch_cpu_idle+0x15/0x20
+ default_idle_call+0x35/0x40
+ do_idle+0x2bb/0x2e0
+ cpu_startup_entry+0x1d/0x20
+ start_secondary+0x24d/0x2d0
+ secondary_startup_64+0xa4/0xb0
+ INITIAL USE at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla2x00_loop_resync+0xb3d/0x2690 [qla2xxx]
+ qla2x00_do_dpc+0xcee/0xf30 [qla2xxx]
+ kthread+0x1d2/0x1f0
+ ret_from_fork+0x3a/0x50
+ }
+ ... key at: [<ffffffffa125f700>] __key.62804+0x0/0xfffffffffff7e900 [qla2xxx]
+ ... acquired at:
+ __lock_acquire+0x11ed/0x1b60
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
+ qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
+ tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
+ target_shutdown_sessions+0x17b/0x190 [target_core_mod]
+ core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
+ target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
+ config_item_release+0x9f/0x120 [configfs]
+ config_item_put+0x29/0x2b [configfs]
+ configfs_rmdir+0x3d2/0x520 [configfs]
+ vfs_rmdir+0xb3/0x1d0
+ do_rmdir+0x25c/0x2d0
+ __x64_sys_rmdir+0x24/0x30
+ do_syscall_64+0x77/0x220
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+
+the dependencies between the lock to be acquired
+ and HARDIRQ-irq-unsafe lock:
+-> (&(&k->k_lock)->rlock){+.+.} ops: 14568 {
+ HARDIRQ-ON-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7f4/0xb60
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ SOFTIRQ-ON-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7f4/0xb60
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ INITIAL USE at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7f4/0xb60
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ }
+ ... key at: [<ffffffff83f3d900>] __key.15805+0x0/0x40
+ ... acquired at:
+ __lock_acquire+0x11ed/0x1b60
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
+ qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
+ tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
+ target_shutdown_sessions+0x17b/0x190 [target_core_mod]
+ core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
+ target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
+ config_item_release+0x9f/0x120 [configfs]
+ config_item_put+0x29/0x2b [configfs]
+ configfs_rmdir+0x3d2/0x520 [configfs]
+ vfs_rmdir+0xb3/0x1d0
+ do_rmdir+0x25c/0x2d0
+ __x64_sys_rmdir+0x24/0x30
+ do_syscall_64+0x77/0x220
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+
+stack backtrace:
+CPU: 7 PID: 1478 Comm: rmdir Tainted: G W 5.1.0-rc1-dbg+ #11
+Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
+Call Trace:
+ dump_stack+0x86/0xca
+ check_usage.cold.59+0x473/0x563
+ check_prev_add.constprop.43+0x1f1/0x1170
+ __lock_acquire+0x11ed/0x1b60
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
+ qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
+ tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
+ target_shutdown_sessions+0x17b/0x190 [target_core_mod]
+ core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
+ target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
+ config_item_release+0x9f/0x120 [configfs]
+ config_item_put+0x29/0x2b [configfs]
+ configfs_rmdir+0x3d2/0x520 [configfs]
+ vfs_rmdir+0xb3/0x1d0
+ do_rmdir+0x25c/0x2d0
+ __x64_sys_rmdir+0x24/0x30
+ do_syscall_64+0x77/0x220
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -364,8 +364,9 @@ static void tcm_qla2xxx_close_session(st
+
+ spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
+ target_sess_cmd_list_set_waiting(se_sess);
+- tcm_qla2xxx_put_sess(sess);
+ spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
++
++ tcm_qla2xxx_put_sess(sess);
+ }
+
+ static u32 tcm_qla2xxx_sess_get_index(struct se_session *se_sess)
diff --git a/patches.drivers/scsi-qla2xxx-Avoid-that-qla2x00_mem_free-crashes-if-.patch b/patches.drivers/scsi-qla2xxx-Avoid-that-qla2x00_mem_free-crashes-if-.patch
new file mode 100644
index 0000000000..aaa6fe8fb2
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Avoid-that-qla2x00_mem_free-crashes-if-.patch
@@ -0,0 +1,39 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:23 -0700
+Subject: scsi: qla2xxx: Avoid that qla2x00_mem_free() crashes if called twice
+Patch-mainline: v5.2-rc1
+Git-commit: dc035d4e934e586a663cbef0cf7ea3900e12bb7d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Clear each pointer after having freed memory such that it becomes safe to
+call qla2x00_mem_free() twice.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -4737,6 +4737,8 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ if (ha->flt)
+ dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
+ ha->flt, ha->flt_dma);
++ ha->flt = NULL;
++ ha->flt_dma = 0;
+
+ if (ha->ms_iocb)
+ dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
+@@ -4812,6 +4814,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+
+ if (ha->dif_bundl_pool)
+ dma_pool_destroy(ha->dif_bundl_pool);
++ ha->dif_bundl_pool = NULL;
+
+ qlt_mem_free(ha);
+
diff --git a/patches.drivers/scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corrupts-.patch b/patches.drivers/scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corrupts-.patch
new file mode 100644
index 0000000000..6c6d2e77e4
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corrupts-.patch
@@ -0,0 +1,48 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:42 -0700
+Subject: scsi: qla2xxx: Avoid that qlt_send_resp_ctio() corrupts memory
+Patch-mainline: v5.2-rc1
+Git-commit: a861b49273578e255426a499842cf7f465456351
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The "(&ctio->u.status1.sense_data)[i]" where i >= 0 expressions in
+qlt_send_resp_ctio() are probably typos and should have been
+"(&ctio->u.status1.sense_data[4 * i])" instead. Instead of only fixing
+these typos, modify the code for storing sense data such that it becomes
+easy to read. This patch fixes a Coverity complaint about accessing an
+array outside its bounds.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: be25152c0d9e ("qla2xxx: Improve T10-DIF/PI handling in driver.") # v4.11.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -2329,14 +2329,14 @@ void qlt_send_resp_ctio(struct qla_qpair
+ ctio->u.status1.scsi_status |=
+ cpu_to_le16(SS_RESIDUAL_UNDER);
+
+- /* Response code and sense key */
+- put_unaligned_le32(((0x70 << 24) | (sense_key << 8)),
+- (&ctio->u.status1.sense_data)[0]);
++ /* Fixed format sense data. */
++ ctio->u.status1.sense_data[0] = 0x70;
++ ctio->u.status1.sense_data[2] = sense_key;
+ /* Additional sense length */
+- put_unaligned_le32(0x0a, (&ctio->u.status1.sense_data)[1]);
++ ctio->u.status1.sense_data[7] = 0xa;
+ /* ASC and ASCQ */
+- put_unaligned_le32(((asc << 24) | (ascq << 16)),
+- (&ctio->u.status1.sense_data)[3]);
++ ctio->u.status1.sense_data[12] = asc;
++ ctio->u.status1.sense_data[13] = ascq;
+
+ /* Memory Barrier */
+ wmb();
diff --git a/patches.drivers/scsi-qla2xxx-Change-a-stack-variable-into-a-static-c.patch b/patches.drivers/scsi-qla2xxx-Change-a-stack-variable-into-a-static-c.patch
new file mode 100644
index 0000000000..b450b7d5d8
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Change-a-stack-variable-into-a-static-c.patch
@@ -0,0 +1,35 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:39 -0700
+Subject: scsi: qla2xxx: Change a stack variable into a static const variable
+Patch-mainline: v5.2-rc1
+Git-commit: c02ee1e5a946575feea01367f647c56e24525f22
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Make qla2x00_get_host_fabric_name() slightly faster by changing a stack
+array into a static array. Declare that array const now that the
+wwn_to_u64() argument pointer has been declared const.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -2723,8 +2723,9 @@ static void
+ qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
+ {
+ scsi_qla_host_t *vha = shost_priv(shost);
+- uint8_t node_name[WWN_SIZE] = { 0xFF, 0xFF, 0xFF, 0xFF, \
+- 0xFF, 0xFF, 0xFF, 0xFF};
++ static const uint8_t node_name[WWN_SIZE] = {
++ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
++ };
+ u64 fabric_name = wwn_to_u64(node_name);
+
+ if (vha->device_flags & SWITCH_FOUND)
diff --git a/patches.drivers/scsi-qla2xxx-Change-abort-wait_loop-from-msleep-to-w.patch b/patches.drivers/scsi-qla2xxx-Change-abort-wait_loop-from-msleep-to-w.patch
new file mode 100644
index 0000000000..cefd21f3d5
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Change-abort-wait_loop-from-msleep-to-w.patch
@@ -0,0 +1,227 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:33 -0700
+Subject: scsi: qla2xxx: Change abort wait_loop from msleep to
+ wait_event_timeout
+Patch-mainline: v5.2-rc1
+Git-commit: 711a08d79f718abcdd3f86f44ffa8473ef1486ef
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch converts driver wait time from using msleep to
+wair_event_timeout to prevent race condition.
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 2
+ drivers/scsi/qla2xxx/qla_os.c | 104 +++++++++++++++++++++++++----------------
+ 2 files changed, 65 insertions(+), 41 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -546,6 +546,7 @@ typedef struct srb {
+ int rc;
+ int retry_count;
+ struct completion comp;
++ wait_queue_head_t *cwaitq;
+ union {
+ struct srb_iocb iocb_cmd;
+ struct bsg_job *bsg_job;
+@@ -4792,5 +4793,4 @@ struct sff_8247_a0 {
+ #include "qla_gbl.h"
+ #include "qla_dbg.h"
+ #include "qla_inline.h"
+-
+ #endif
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -23,6 +23,23 @@
+
+ #include "qla_target.h"
+
++#define __wait_event_lock_irq_timeout(wq_head, condition, lock, timeout, state) \
++ ___wait_event(wq_head, ___wait_cond_timeout(condition), \
++ state, 0, timeout, \
++ spin_unlock_irq(&lock); \
++ __ret = schedule_timeout(__ret); \
++ spin_lock_irq(&lock));
++
++#define wait_event_lock_irq_timeout(wq_head, condition, lock, timeout) \
++({ \
++ long __ret = timeout; \
++ if (!___wait_cond_timeout(condition)) \
++ __ret = __wait_event_lock_irq_timeout( \
++ wq_head, condition, lock, timeout, \
++ TASK_UNINTERRUPTIBLE); \
++ __ret; \
++})
++
+ /*
+ * Driver version
+ */
+@@ -729,7 +746,7 @@ qla2x00_sp_free_dma(void *ptr)
+ }
+
+ if (!ctx)
+- goto end;
++ return;
+
+ if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
+ /* List assured to be having elements */
+@@ -754,12 +771,6 @@ qla2x00_sp_free_dma(void *ptr)
+ ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
+ mempool_free(ctx1, ha->ctx_mempool);
+ }
+-
+-end:
+- if (sp->type != SRB_NVME_CMD && sp->type != SRB_NVME_LS) {
+- CMD_SP(cmd) = NULL;
+- qla2x00_rel_sp(sp);
+- }
+ }
+
+ void
+@@ -767,6 +778,7 @@ qla2x00_sp_compl(void *ptr, int res)
+ {
+ srb_t *sp = ptr;
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
++ wait_queue_head_t *cwaitq = sp->cwaitq;
+
+ if (atomic_read(&sp->ref_count) == 0) {
+ ql_dbg(ql_dbg_io, sp->vha, 0x3015,
+@@ -781,7 +793,11 @@ qla2x00_sp_compl(void *ptr, int res)
+
+ sp->free(sp);
+ cmd->result = res;
++ CMD_SP(cmd) = NULL;
+ cmd->scsi_done(cmd);
++ if (cwaitq)
++ wake_up(cwaitq);
++ qla2x00_rel_sp(sp);
+ }
+
+ void
+@@ -804,7 +820,7 @@ qla2xxx_qpair_sp_free_dma(void *ptr)
+ }
+
+ if (!ctx)
+- goto end;
++ return;
+
+ if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
+ /* List assured to be having elements */
+@@ -864,10 +880,6 @@ qla2xxx_qpair_sp_free_dma(void *ptr)
+ }
+ sp->flags &= ~SRB_DIF_BUNDL_DMA_VALID;
+ }
+-
+-end:
+- CMD_SP(cmd) = NULL;
+- qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+ void
+@@ -875,8 +887,7 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ {
+ srb_t *sp = ptr;
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+-
+- cmd->result = res;
++ wait_queue_head_t *cwaitq = sp->cwaitq;
+
+ if (atomic_read(&sp->ref_count) == 0) {
+ ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079,
+@@ -890,7 +901,12 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ return;
+
+ sp->free(sp);
++ cmd->result = res;
++ CMD_SP(cmd) = NULL;
+ cmd->scsi_done(cmd);
++ if (cwaitq)
++ wake_up(cwaitq);
++ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+ /* If we are SP1 here, we need to still take and release the host_lock as SP1
+@@ -1384,7 +1400,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ vha->host_no, id, lun, sp, cmd, sp->handle);
+
+ /* Get a reference to the sp and drop the lock.*/
+-
+ rval = ha->isp_ops->abort_command(sp);
+ if (rval) {
+ if (rval == QLA_FUNCTION_PARAMETER_ERROR)
+@@ -1401,37 +1416,46 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ }
+
+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
+- /*
+- * Clear the slot in the oustanding_cmds array if we can't find the
+- * command to reclaim the resources.
+- */
+- if (rval == QLA_FUNCTION_PARAMETER_ERROR)
+- vha->req->outstanding_cmds[sp->handle] = NULL;
+
+ /*
+- * sp->done will do ref_count--
+- * sp_get() took an extra count above
++ * Releasing of the SRB and associated command resources
++ * is managed through ref_count.
++ * Whether we need to wait for the abort completion or complete
++ * the abort handler should be based on the ref_count.
+ */
+- sp->done(sp, DID_RESET << 16);
+-
+- /* Did the command return during mailbox execution? */
+- if (ret == FAILED && !CMD_SP(cmd))
+- ret = SUCCESS;
+-
+- if (!CMD_SP(cmd))
+- wait = 0;
+-
+- spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+-
+- /* Wait for the command to be returned. */
+- if (wait) {
+- if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) {
+- ql_log(ql_log_warn, vha, 0x8006,
+- "Abort handler timed out cmd=%p.\n", cmd);
++ if (atomic_read(&sp->ref_count) > 1) {
++ /*
++ * The command is not yet completed. We need to wait for either
++ * command completion or abort completion.
++ */
++ DECLARE_WAIT_QUEUE_HEAD_ONSTACK(eh_waitq);
++ uint32_t ratov = ha->r_a_tov/10;
++
++ /* Go ahead and release the extra ref_count obtained earlier */
++ sp->done(sp, DID_RESET << 16);
++ sp->cwaitq = &eh_waitq;
++
++ if (!wait_event_lock_irq_timeout(eh_waitq,
++ CMD_SP(cmd) == NULL, *qpair->qp_lock_ptr,
++ msecs_to_jiffies(4 * ratov * 1000))) {
++ /*
++ * The abort got dropped, LOGO will be sent and the
++ * original command will be completed with CS_TIMEOUT
++ * completion
++ */
++ ql_dbg(ql_dbg_taskm, vha, 0xffff,
++ "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n",
++ __func__, ha->r_a_tov);
++ sp->cwaitq = NULL;
+ ret = FAILED;
++ goto end;
+ }
++ } else {
++ /* Command completed while processing the abort */
++ sp->done(sp, DID_RESET << 16);
+ }
+-
++end:
++ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+ ql_log(ql_log_info, vha, 0x801c,
+ "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n",
+ vha->host_no, id, lun, wait, ret);
diff --git a/patches.drivers/scsi-qla2xxx-Check-the-size-of-firmware-data-structu.patch b/patches.drivers/scsi-qla2xxx-Check-the-size-of-firmware-data-structu.patch
new file mode 100644
index 0000000000..481cc33f43
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Check-the-size-of-firmware-data-structu.patch
@@ -0,0 +1,68 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:37 -0700
+Subject: scsi: qla2xxx: Check the size of firmware data structures at compile
+ time
+Patch-mainline: v5.2-rc1
+Git-commit: bc04459ce4e5d394d79fe2a0660d43c1a40b6eb8
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since the next patch will modify several firmware data structures, add
+compile time checks that verify that these structures have the correct
+size.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 24 ++++++++++++++++++++++++
+ drivers/scsi/qla2xxx/qla_target.c | 3 +++
+ 2 files changed, 27 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -7298,6 +7298,30 @@ qla2x00_module_init(void)
+ {
+ int ret = 0;
+
++ BUILD_BUG_ON(sizeof(cmd_entry_t) != 64);
++ BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64);
++ BUILD_BUG_ON(sizeof(cont_entry_t) != 64);
++ BUILD_BUG_ON(sizeof(init_cb_t) != 96);
++ BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64);
++ BUILD_BUG_ON(sizeof(request_t) != 64);
++ BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_type_7) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64);
++ BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64);
++ BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64);
++ BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
++ BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64);
++ BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64);
++ BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128);
++ BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128);
++ BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64);
++ BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064);
++ BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64);
++ BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56);
++
+ /* Allocate cache for SRBs. */
+ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
+ SLAB_HWCACHE_ALIGN, NULL);
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -7373,6 +7373,9 @@ int __init qlt_init(void)
+ {
+ int ret;
+
++ BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64);
++ BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
++
+ if (!qlt_parse_ini_mode()) {
+ ql_log(ql_log_fatal, NULL, 0xe06b,
+ "qlt_parse_ini_mode() failed\n");
diff --git a/patches.drivers/scsi-qla2xxx-Cleanup-fcport-memory-to-prevent-leak.patch b/patches.drivers/scsi-qla2xxx-Cleanup-fcport-memory-to-prevent-leak.patch
new file mode 100644
index 0000000000..3468774268
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Cleanup-fcport-memory-to-prevent-leak.patch
@@ -0,0 +1,45 @@
+From: Quinn Tran <qtran@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:29 -0700
+Subject: scsi: qla2xxx: Cleanup fcport memory to prevent leak
+Patch-mainline: v5.2-rc1
+Git-commit: ffbc64766683634d2c233519f2e70d2123580108
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Clean up fcport list and loopid in one place and iterate through for loop.
+
+Signed-off-by: Quinn Tran <qtran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 2 ++
+ drivers/scsi/qla2xxx/qla_os.c | 7 ++-----
+ 2 files changed, 4 insertions(+), 5 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -4821,6 +4821,8 @@ qla2x00_free_fcport(fc_port_t *fcport)
+
+ fcport->ct_desc.ct_sns = NULL;
+ }
++ list_del(&fcport->list);
++ qla2x00_clear_loop_id(fcport);
+ kfree(fcport);
+ }
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -3915,11 +3915,8 @@ void qla2x00_free_fcports(struct scsi_ql
+ {
+ fc_port_t *fcport, *tfcport;
+
+- list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) {
+- list_del(&fcport->list);
+- qla2x00_clear_loop_id(fcport);
+- kfree(fcport);
+- }
++ list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list)
++ qla2x00_free_fcport(fcport);
+ }
+
+ static inline void
diff --git a/patches.drivers/scsi-qla2xxx-Cleanup-redundant-qla2x00_abort_all_cmd.patch b/patches.drivers/scsi-qla2xxx-Cleanup-redundant-qla2x00_abort_all_cmd.patch
new file mode 100644
index 0000000000..64544a8766
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Cleanup-redundant-qla2x00_abort_all_cmd.patch
@@ -0,0 +1,28 @@
+From: Anil Gurumurthy <agurumurthy@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:31 -0700
+Subject: scsi: qla2xxx: Cleanup redundant qla2x00_abort_all_cmds during unload
+Patch-mainline: v5.2-rc1
+Git-commit: e39a6645d9ec3a9be6470adae1df0f924d1f0737
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch removes redundant qla2x00_abort_all_cmds() during driver unload.
+
+Signed-off-by: Anil Gurumurthy <agurumurthy@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -3824,8 +3824,6 @@ qla2x00_remove_one(struct pci_dev *pdev)
+
+ qla2x00_delete_all_vps(ha, base_vha);
+
+- qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
+-
+ qla2x00_dfs_remove(base_vha);
+
+ qla84xx_put_chip(base_vha);
diff --git a/patches.drivers/scsi-qla2xxx-Complain-if-a-command-is-released-that-.patch b/patches.drivers/scsi-qla2xxx-Complain-if-a-command-is-released-that-.patch
new file mode 100644
index 0000000000..5c5cb01850
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Complain-if-a-command-is-released-that-.patch
@@ -0,0 +1,51 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:30 -0700
+Subject: scsi: qla2xxx: Complain if a command is released that is owned by the
+ firmware
+Patch-mainline: v5.2-rc1
+Git-commit: b1e261d4a4b71d67b62f6649c5496810c28e7ac1
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The previous patch guarantees that a command is only released after the
+firmware has finished processing it. Hence complain if a command is
+released that is owned by the firmware.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -330,7 +330,6 @@ static int tcm_qla2xxx_check_stop_free(s
+ static void tcm_qla2xxx_release_cmd(struct se_cmd *se_cmd)
+ {
+ struct qla_tgt_cmd *cmd;
+- unsigned long flags;
+
+ if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) {
+ struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd,
+@@ -340,14 +339,10 @@ static void tcm_qla2xxx_release_cmd(stru
+ }
+ cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
+
+- spin_lock_irqsave(&cmd->cmd_lock, flags);
+- if (cmd->cmd_sent_to_fw) {
+- cmd->released = 1;
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+- } else {
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+- qlt_free_cmd(cmd);
+- }
++ if (WARN_ON(cmd->cmd_sent_to_fw))
++ return;
++
++ qlt_free_cmd(cmd);
+ }
+
+ static void tcm_qla2xxx_release_session(struct kref *kref)
diff --git a/patches.drivers/scsi-qla2xxx-Complain-loudly-about-reference-count-u.patch b/patches.drivers/scsi-qla2xxx-Complain-loudly-about-reference-count-u.patch
new file mode 100644
index 0000000000..93f4fbd6c9
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Complain-loudly-about-reference-count-u.patch
@@ -0,0 +1,95 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:40 -0700
+Subject: scsi: qla2xxx: Complain loudly about reference count underflow
+Patch-mainline: v5.2-rc1
+Git-commit: db4bf822c58cd2b4a6718c982ce48a5292f5cc6a
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+A reference count underflow is a severe bug. Hence complain loudly if a
+reference count underflow happens.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 15 +++++----------
+ drivers/scsi/qla2xxx/qla_os.c | 16 ++--------------
+ 2 files changed, 7 insertions(+), 24 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -131,11 +131,8 @@ static void qla_nvme_sp_ls_done(void *pt
+ struct nvmefc_ls_req *fd;
+ struct nvme_private *priv;
+
+- if (atomic_read(&sp->ref_count) == 0) {
+- ql_log(ql_log_warn, sp->fcport->vha, 0x2123,
+- "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp);
++ if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+ return;
+- }
+
+ atomic_dec(&sp->ref_count);
+
+@@ -160,6 +157,9 @@ static void qla_nvme_sp_done(void *ptr,
+ nvme = &sp->u.iocb_cmd;
+ fd = nvme->u.nvme.desc;
+
++ if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
++ return;
++
+ atomic_dec(&sp->ref_count);
+
+ if (res == QLA_SUCCESS) {
+@@ -199,13 +199,8 @@ static void qla_nvme_abort_work(struct w
+ return;
+ }
+
+- if (atomic_read(&sp->ref_count) == 0) {
+- WARN_ON(1);
+- ql_log(ql_log_info, fcport->vha, 0xffff,
+- "%s: command already aborted on sp: %p\n",
+- __func__, sp);
++ if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+ return;
+- }
+
+ rval = ha->isp_ops->abort_command(sp);
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -718,14 +718,8 @@ qla2x00_sp_compl(void *ptr, int res)
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+ struct completion *comp = sp->comp;
+
+- if (atomic_read(&sp->ref_count) == 0) {
+- ql_dbg(ql_dbg_io, sp->vha, 0x3015,
+- "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
+- sp, GET_CMD_SP(sp));
+- if (ql2xextended_error_logging & ql_dbg_io)
+- WARN_ON(atomic_read(&sp->ref_count) == 0);
++ if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+ return;
+- }
+
+ atomic_dec(&sp->ref_count);
+
+@@ -829,14 +823,8 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+ struct completion *comp = sp->comp;
+
+- if (atomic_read(&sp->ref_count) == 0) {
+- ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079,
+- "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
+- sp, GET_CMD_SP(sp));
+- if (ql2xextended_error_logging & ql_dbg_io)
+- WARN_ON(atomic_read(&sp->ref_count) == 0);
++ if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+ return;
+- }
+
+ atomic_dec(&sp->ref_count);
+
diff --git a/patches.drivers/scsi-qla2xxx-Correct-error-handling-during-initializ.patch b/patches.drivers/scsi-qla2xxx-Correct-error-handling-during-initializ.patch
new file mode 100644
index 0000000000..80aa495d64
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Correct-error-handling-during-initializ.patch
@@ -0,0 +1,93 @@
+From: Andrew Vasquez <andrewv@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:35 -0700
+Subject: scsi: qla2xxx: Correct error handling during initialization failures
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 26a77799195f4ff105f877042012c7fb355b3da1
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Current code misses or fails to account for proper recovery during early
+initialization failures:
+
+ - Properly unwind allocations during probe() failures.
+
+ - Protect against non-initialization memory allocations during
+ unwinding.
+
+ - Propagate error status during HW initialization.
+
+ - Release SCSI host reference when memory allocations fail.
+
+Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 4 ++++
+ drivers/scsi/qla2xxx/qla_os.c | 12 +++++++++---
+ 2 files changed, 13 insertions(+), 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -2295,6 +2295,10 @@ qla2x00_initialize_adapter(scsi_qla_host
+ if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha))
+ rval = qla2x00_init_rings(vha);
+
++ /* No point in continuing if firmware initialization failed. */
++ if (rval != QLA_SUCCESS)
++ return rval;
++
+ ha->flags.chip_reset_done = 1;
+
+ if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) {
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1811,8 +1811,13 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *
+ int que;
+ struct qla_hw_data *ha = vha->hw;
+
++ /* Continue only if initialization complete. */
++ if (!ha->base_qpair)
++ return;
+ __qla2x00_abort_all_cmds(ha->base_qpair, res);
+
++ if (!ha->queue_pair_map)
++ return;
+ for (que = 0; que < ha->max_qpairs; que++) {
+ if (!ha->queue_pair_map[que])
+ continue;
+@@ -3165,6 +3170,7 @@ qla2x00_probe_one(struct pci_dev *pdev,
+ ql_log(ql_log_fatal, base_vha, 0x003d,
+ "Failed to allocate memory for queue pointers..."
+ "aborting.\n");
++ ret = -ENODEV;
+ goto probe_failed;
+ }
+
+@@ -4726,7 +4732,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ mempool_destroy(ha->ctx_mempool);
+ ha->ctx_mempool = NULL;
+
+- if (ql2xenabledif) {
++ if (ql2xenabledif && ha->dif_bundl_pool) {
+ struct dsd_dma *dsd, *nxt;
+
+ if (!ha->pool.unusable.head.next)
+@@ -4828,7 +4834,7 @@ struct scsi_qla_host *qla2x00_create_hos
+ if (!vha->gnl.l) {
+ ql_log(ql_log_fatal, vha, 0xd04a,
+ "Alloc failed for name list.\n");
+- scsi_remove_host(vha->host);
++ scsi_host_put(vha->host);
+ return NULL;
+ }
+
+@@ -4840,7 +4846,7 @@ struct scsi_qla_host *qla2x00_create_hos
+ "Alloc failed for scan database.\n");
+ dma_free_coherent(&ha->pdev->dev, vha->gnl.size,
+ vha->gnl.l, vha->gnl.ldma);
+- scsi_remove_host(vha->host);
++ scsi_host_put(vha->host);
+ return NULL;
+ }
+ INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn);
diff --git a/patches.drivers/scsi-qla2xxx-Declare-local-symbols-static.patch b/patches.drivers/scsi-qla2xxx-Declare-local-symbols-static.patch
new file mode 100644
index 0000000000..f2a3bd005d
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Declare-local-symbols-static.patch
@@ -0,0 +1,38 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:42 -0700
+Subject: scsi: qla2xxx: Declare local symbols static
+Patch-mainline: v5.2-rc1
+Git-commit: b3ede8ea78e8f4c2377d89763e30b140b70f93c0
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch avoids that sparse complains that a declaration is missing.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -285,14 +285,14 @@ MODULE_PARM_DESC(qla2xuseresexchforels,
+ "Reserve 1/2 of emergency exchanges for ELS.\n"
+ " 0 (default): disabled");
+
+-int ql2xprotmask;
++static int ql2xprotmask;
+ module_param(ql2xprotmask, int, 0644);
+ MODULE_PARM_DESC(ql2xprotmask,
+ "Override DIF/DIX protection capabilities mask\n"
+ "Default is 0 which sets protection mask based on "
+ "capabilities reported by HBA firmware.\n");
+
+-int ql2xprotguard;
++static int ql2xprotguard;
+ module_param(ql2xprotguard, int, 0644);
+ MODULE_PARM_DESC(ql2xprotguard, "Override choice of DIX checksum\n"
+ " 0 -- Let HBA firmware decide\n"
diff --git a/patches.drivers/scsi-qla2xxx-Declare-qla24xx_build_scsi_crc_2_iocbs-.patch b/patches.drivers/scsi-qla2xxx-Declare-qla24xx_build_scsi_crc_2_iocbs-.patch
new file mode 100644
index 0000000000..58c8c1ec06
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Declare-qla24xx_build_scsi_crc_2_iocbs-.patch
@@ -0,0 +1,44 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:21 -0700
+Subject: scsi: qla2xxx: Declare qla24xx_build_scsi_crc_2_iocbs() static
+Patch-mainline: v5.2-rc1
+Git-commit: c20605edb38a1201d56ec83696b0b7a692a9f157
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla24xx_build_scsi_crc_2_iocbs() is only used inside a single source
+file, declare this function static.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 2 --
+ drivers/scsi/qla2xxx/qla_iocb.c | 2 +-
+ 2 files changed, 1 insertion(+), 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -294,8 +294,6 @@ extern int qla24xx_walk_and_build_prot_s
+ uint32_t *, uint16_t, struct qla_tgt_cmd *);
+ extern int qla24xx_get_one_block_sg(uint32_t, struct qla2_sgx *, uint32_t *);
+ extern int qla24xx_configure_prot_mode(srb_t *, uint16_t *);
+-extern int qla24xx_build_scsi_crc_2_iocbs(srb_t *,
+- struct cmd_type_crc_2 *, uint16_t, uint16_t, uint16_t);
+
+ /*
+ * Global Function Prototypes in qla_mbx.c source file.
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -1404,7 +1404,7 @@ qla24xx_walk_and_build_prot_sglist(struc
+ * @tot_prot_dsds: Total number of segments with protection information
+ * @fw_prot_opts: Protection options to be passed to firmware
+ */
+-inline int
++static inline int
+ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
+ uint16_t tot_dsds, uint16_t tot_prot_dsds, uint16_t fw_prot_opts)
+ {
diff --git a/patches.drivers/scsi-qla2xxx-Declare-qla2x00_find_new_loop_id-static.patch b/patches.drivers/scsi-qla2xxx-Declare-qla2x00_find_new_loop_id-static.patch
new file mode 100644
index 0000000000..87696a5e6f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Declare-qla2x00_find_new_loop_id-static.patch
@@ -0,0 +1,142 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:13 -0700
+Subject: scsi: qla2xxx: Declare qla2x00_find_new_loop_id() static
+Patch-mainline: v5.2-rc1
+Git-commit: 94f5b9167e902bf7f30ef09fc02a74a71498ffee
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since all qla2x00_find_new_loop_id() calls occur in the same source file as
+the definition of this function, move that function to just before its
+first caller and declare it static. Convert the header above this function
+into kernel-doc format.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 2
+ drivers/scsi/qla2xxx/qla_init.c | 92 ++++++++++++++++++----------------------
+ 2 files changed, 43 insertions(+), 51 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -39,8 +39,6 @@ extern int qla81xx_load_risc(scsi_qla_ho
+ extern int qla2x00_perform_loop_resync(scsi_qla_host_t *);
+ extern int qla2x00_loop_resync(scsi_qla_host_t *);
+
+-extern int qla2x00_find_new_loop_id(scsi_qla_host_t *, fc_port_t *);
+-
+ extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *);
+ extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *);
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -514,6 +514,49 @@ done:
+ return rval;
+ }
+
++/**
++ * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID
++ * @vha: adapter state pointer.
++ * @dev: port structure pointer.
++ *
++ * Returns:
++ * qla2x00 local function return status code.
++ *
++ * Context:
++ * Kernel context.
++ */
++static int qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
++{
++ int rval;
++ struct qla_hw_data *ha = vha->hw;
++ unsigned long flags = 0;
++
++ rval = QLA_SUCCESS;
++
++ spin_lock_irqsave(&ha->vport_slock, flags);
++
++ dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE);
++ if (dev->loop_id >= LOOPID_MAP_SIZE ||
++ qla2x00_is_reserved_id(vha, dev->loop_id)) {
++ dev->loop_id = FC_NO_LOOP_ID;
++ rval = QLA_FUNCTION_FAILED;
++ } else {
++ set_bit(dev->loop_id, ha->loop_id_map);
++ }
++ spin_unlock_irqrestore(&ha->vport_slock, flags);
++
++ if (rval == QLA_SUCCESS)
++ ql_dbg(ql_dbg_disc, dev->vha, 0x2086,
++ "Assigning new loopid=%x, portid=%x.\n",
++ dev->loop_id, dev->d_id.b24);
++ else
++ ql_log(ql_log_warn, dev->vha, 0x2087,
++ "No loop_id's available, portid=%x.\n",
++ dev->d_id.b24);
++
++ return rval;
++}
++
+ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
+ struct event_arg *ea)
+ {
+@@ -5886,55 +5929,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_ho
+ return (rval);
+ }
+
+-/*
+- * qla2x00_find_new_loop_id
+- * Scan through our port list and find a new usable loop ID.
+- *
+- * Input:
+- * ha: adapter state pointer.
+- * dev: port structure pointer.
+- *
+- * Returns:
+- * qla2x00 local function return status code.
+- *
+- * Context:
+- * Kernel context.
+- */
+-int
+-qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
+-{
+- int rval;
+- struct qla_hw_data *ha = vha->hw;
+- unsigned long flags = 0;
+-
+- rval = QLA_SUCCESS;
+-
+- spin_lock_irqsave(&ha->vport_slock, flags);
+-
+- dev->loop_id = find_first_zero_bit(ha->loop_id_map,
+- LOOPID_MAP_SIZE);
+- if (dev->loop_id >= LOOPID_MAP_SIZE ||
+- qla2x00_is_reserved_id(vha, dev->loop_id)) {
+- dev->loop_id = FC_NO_LOOP_ID;
+- rval = QLA_FUNCTION_FAILED;
+- } else
+- set_bit(dev->loop_id, ha->loop_id_map);
+-
+- spin_unlock_irqrestore(&ha->vport_slock, flags);
+-
+- if (rval == QLA_SUCCESS)
+- ql_dbg(ql_dbg_disc, dev->vha, 0x2086,
+- "Assigning new loopid=%x, portid=%x.\n",
+- dev->loop_id, dev->d_id.b24);
+- else
+- ql_log(ql_log_warn, dev->vha, 0x2087,
+- "No loop_id's available, portid=%x.\n",
+- dev->d_id.b24);
+-
+- return (rval);
+-}
+-
+-
+ /* FW does not set aside Loop id for MGMT Server/FFFFFAh */
+ int
+ qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha)
diff --git a/patches.drivers/scsi-qla2xxx-Disable-T10-DIF-feature-with-FC-NVMe-du.patch b/patches.drivers/scsi-qla2xxx-Disable-T10-DIF-feature-with-FC-NVMe-du.patch
new file mode 100644
index 0000000000..6752780724
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Disable-T10-DIF-feature-with-FC-NVMe-du.patch
@@ -0,0 +1,31 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:24 -0700
+Subject: scsi: qla2xxx: Disable T10-DIF feature with FC-NVMe during probe
+Patch-mainline: v5.2-rc1
+Git-commit: 5da05a26b8305a625bc9d537671b981795b46dab
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+With FC-NVMe enabled, driver does not support T10 DIF/DIX. This patch
+disables T10-PI information when ql2xnvmeenable is set.
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -2898,6 +2898,10 @@ qla2x00_probe_one(struct pci_dev *pdev,
+ /* This may fail but that's ok */
+ pci_enable_pcie_error_reporting(pdev);
+
++ /* Turn off T10-DIF when FC-NVMe is enabled */
++ if (ql2xnvmeenable)
++ ql2xenabledif = 0;
++
+ ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
+ if (!ha) {
+ ql_log_pci(ql_log_fatal, pdev, 0x0009,
diff --git a/patches.drivers/scsi-qla2xxx-Fix-DMA-unmap-leak.patch b/patches.drivers/scsi-qla2xxx-Fix-DMA-unmap-leak.patch
new file mode 100644
index 0000000000..a1c25eb683
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-DMA-unmap-leak.patch
@@ -0,0 +1,48 @@
+From: Himanshu Madhani <hmadhani@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:26 -0700
+Subject: scsi: qla2xxx: Fix DMA unmap leak
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 5d328de64d89400dcf9911125844d8adc0db697f
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+With debug kernel we see following wanings indicating memory leak.
+
+[28809.523959] WARNING: CPU: 3 PID: 6790 at lib/dma-debug.c:978
+dma_debug_device_change+0x166/0x1d0
+[28809.523964] pci 0000:0c:00.6: DMA-API: device driver has pending DMA
+allocations while released from device [count=5]
+[28809.523964] One of leaked entries details: [device
+address=0x00000002aefe4000] [size=8208 bytes] [mapped with DMA_BIDIRECTIONAL]
+[mapped as coherent]
+
+Fix this by unmapping DMA memory.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_bsg.c
++++ b/drivers/scsi/qla2xxx/qla_bsg.c
+@@ -341,6 +341,8 @@ qla2x00_process_els(struct bsg_job *bsg_
+ dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
+ bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
+ if (!req_sg_cnt) {
++ dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
++ bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
+ rval = -ENOMEM;
+ goto done_free_fcport;
+ }
+@@ -348,6 +350,8 @@ qla2x00_process_els(struct bsg_job *bsg_
+ rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
+ bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
+ if (!rsp_sg_cnt) {
++ dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
++ bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
+ rval = -ENOMEM;
+ goto done_free_fcport;
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-stale-CPU.patch b/patches.drivers/scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-stale-CPU.patch
new file mode 100644
index 0000000000..8ab79357a4
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-stale-CPU.patch
@@ -0,0 +1,84 @@
+From: Himanshu Madhani <hmadhani@marvell.com>
+Date: Fri, 15 Mar 2019 15:04:19 -0700
+Subject: scsi: qla2xxx: Fix NULL pointer crash due to stale CPUID
+Patch-mainline: v5.1-rc2
+Git-commit: ac444b4f0ace05d7c4c99f6b1e5b0cae0852f025
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch fixes crash due to NULL pointer derefrence because CPU pointer
+is not set and used by driver. Instead, driver is passes CPU as tag via
+ha->isp_ops->{lun_reset|target_reset}
+
+[ 30.160780] qla2xxx [0000:a0:00.1]-8038:9: Cable is unplugged...
+[ 69.984045] qla2xxx [0000:a0:00.0]-8009:8: DEVICE RESET ISSUED nexus=8:0:0 cmd=00000000b0d62f46.
+[ 69.992849] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040
+[ 70.000680] PGD 0 P4D 0
+[ 70.003232] Oops: 0000 [#1] SMP PTI
+[ 70.006727] CPU: 2 PID: 6714 Comm: sg_reset Kdump: loaded Not tainted 4.18.0-67.el8.x86_64 #1
+[ 70.015258] Hardware name: NEC Express5800/T110j [N8100-2758Y]/MX32-PH0-NJ, BIOS F11 02/13/2019
+[ 70.024016] RIP: 0010:blk_mq_rq_cpu+0x9/0x10
+[ 70.028315] Code: 01 58 01 00 00 48 83 c0 28 48 3d 80 02 00 00 75 ab c3 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48
+ 8b 47 08 <8b> 40 40 c3 0f 1f 00 0f 1f 44 00 00 48 83 ec 10 48 c7 c6 20 6e 7c
+[ 70.047087] RSP: 0018:ffff99a481487d58 EFLAGS: 00010246
+[ 70.052322] RAX: 0000000000000000 RBX: ffffffffc041b08b RCX: 0000000000000000
+[ 70.059466] RDX: 0000000000000000 RSI: ffff8d10b6b16898 RDI: ffff8d10b341e400
+[ 70.066615] RBP: ffffffffc03a6bd0 R08: 0000000000000415 R09: 0000000000aaaaaa
+[ 70.073765] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8d10b341e528
+[ 70.080914] R13: ffff8d10aadefc00 R14: ffff8d0f64efa998 R15: ffff8d0f64efa000
+[ 70.088083] FS: 00007f90a201e540(0000) GS:ffff8d10b6b00000(0000) knlGS:0000000000000000
+[ 70.096188] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[ 70.101959] CR2: 0000000000000040 CR3: 0000000268886005 CR4: 00000000003606e0
+[ 70.109127] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+[ 70.116277] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+[ 70.123425] Call Trace:
+[ 70.125896] __qla2xxx_eh_generic_reset+0xb1/0x220 [qla2xxx]
+[ 70.131572] scsi_ioctl_reset+0x1f5/0x2a0
+[ 70.135600] scsi_ioctl+0x18e/0x397
+[ 70.139099] ? sd_ioctl+0x7c/0x100 [sd_mod]
+[ 70.143287] blkdev_ioctl+0x32b/0x9f0
+[ 70.146954] ? __check_object_size+0xa3/0x181
+[ 70.151323] block_ioctl+0x39/0x40
+[ 70.154735] do_vfs_ioctl+0xa4/0x630
+[ 70.158322] ? syscall_trace_enter+0x1d3/0x2c0
+[ 70.162769] ksys_ioctl+0x60/0x90
+[ 70.166104] __x64_sys_ioctl+0x16/0x20
+[ 70.169859] do_syscall_64+0x5b/0x1b0
+[ 70.173532] entry_SYSCALL_64_after_hwframe+0x65/0xca
+[ 70.178587] RIP: 0033:0x7f90a1b3445b
+[ 70.182183] Code: 0f 1e fa 48 8b 05 2d aa 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00
+ 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d fd a9 2c 00 f7 d8 64 89 01 48
+[ 70.200956] RSP: 002b:00007fffdca88b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
+[ 70.208535] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f90a1b3445b
+[ 70.215684] RDX: 00007fffdca88b84 RSI: 0000000000002284 RDI: 0000000000000003
+[ 70.222833] RBP: 00007fffdca88ca8 R08: 00007fffdca88b84 R09: 0000000000000000
+[ 70.229981] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffdca88b84
+[ 70.237131] R13: 0000000000000000 R14: 000055ab09b0bd28 R15: 0000000000000000
+[ 70.244284] Modules linked in: nft_chain_route_ipv4 xt_CHECKSUM nft_chain_nat_ipv4 ipt_MASQUERADE nf_nat_ipv4 nf_nat nf_conntrack_ipv4
+ nf_defrag_ipv4 xt_conntrack nf_conntrack libcrc32c ipt_REJECT nf_reject_ipv4 nft_counter nft_compat tun bridge stp llc nf_tables nfnetli
+nk devlink sunrpc vfat fat intel_rapl intel_pmc_core x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm wmi_bmof iTCO_wdt iTCO_
+vendor_support irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel ipmi_ssif intel_cstate intel_uncore intel_rapl_perf ipmi_si jo
+ydev pcspkr ipmi_devintf sg wmi ipmi_msghandler video acpi_power_meter acpi_pad mei_me i2c_i801 mei ip_tables ext4 mbcache jbd2 sr_mod cd
+rom sd_mod qla2xxx ast i2c_algo_bit drm_kms_helper nvme_fc syscopyarea sysfillrect uas sysimgblt fb_sys_fops nvme_fabrics ttm
+[ 70.314805] usb_storage nvme_core crc32c_intel scsi_transport_fc ahci drm libahci tg3 libata megaraid_sas pinctrl_cannonlake pinctrl_
+intel
+[ 70.327335] CR2: 0000000000000040
+
+Fixes: 9cf2bab630765 ("block: kill request ->cpu member")
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1524,7 +1524,7 @@ __qla2xxx_eh_generic_reset(char *name, e
+ goto eh_reset_failed;
+ }
+ err = 2;
+- if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1)
++ if (do_reset(fcport, cmd->device->lun, 1)
+ != QLA_SUCCESS) {
+ ql_log(ql_log_warn, vha, 0x800c,
+ "do_reset failed for cmd=%p.\n", cmd);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-NVME-cmd-and-LS-cmd-timeout-race-co.patch b/patches.drivers/scsi-qla2xxx-Fix-NVME-cmd-and-LS-cmd-timeout-race-co.patch
new file mode 100644
index 0000000000..3a68cb23ff
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-NVME-cmd-and-LS-cmd-timeout-race-co.patch
@@ -0,0 +1,329 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 21 Jun 2019 09:50:24 -0700
+Subject: scsi: qla2xxx: Fix NVME cmd and LS cmd timeout race condition
+Patch-mainline: v5.3-rc1
+Git-commit: 4c2a2d0178d5d8006a6bc50c8dc0ed122e4e946e
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch uses kref to protect access between fcp_abort path and nvme
+command and LS command completion path. Stack trace below shows the abort
+path is accessing stale memory (nvme_private->sp).
+
+When command kref reaches 0, nvme_private & srb resource will be
+disconnected from each other. Any subsequence nvme abort request will not
+be able to reference the original srb.
+
+[ 5631.003998] BUG: unable to handle kernel paging request at 00000010000005d8
+[ 5631.004016] IP: [<ffffffffc087df92>] qla_nvme_abort_work+0x22/0x100 [qla2xxx]
+[ 5631.004086] Workqueue: events qla_nvme_abort_work [qla2xxx]
+[ 5631.004097] RIP: 0010:[<ffffffffc087df92>] [<ffffffffc087df92>] qla_nvme_abort_work+0x22/0x100 [qla2xxx]
+[ 5631.004109] Call Trace:
+[ 5631.004115] [<ffffffffaa4b8174>] ? pwq_dec_nr_in_flight+0x64/0xb0
+[ 5631.004117] [<ffffffffaa4b9d4f>] process_one_work+0x17f/0x440
+[ 5631.004120] [<ffffffffaa4bade6>] worker_thread+0x126/0x3c0
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 3
+ drivers/scsi/qla2xxx/qla_nvme.c | 163 +++++++++++++++++++++++++++-------------
+ drivers/scsi/qla2xxx/qla_nvme.h | 1
+ 3 files changed, 117 insertions(+), 50 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -531,6 +531,8 @@ typedef struct srb {
+ uint8_t cmd_type;
+ uint8_t pad[3];
+ atomic_t ref_count;
++ struct kref cmd_kref; /* need to migrate ref_count over to this */
++ void *priv;
+ wait_queue_head_t nvme_ls_waitq;
+ struct fc_port *fcport;
+ struct scsi_qla_host *vha;
+@@ -553,6 +555,7 @@ typedef struct srb {
+ } u;
+ void (*done)(void *, int);
+ void (*free)(void *);
++ void (*put_fn)(struct kref *kref);
+ } srb_t;
+
+ #define GET_CMD_SP(sp) (sp->u.scmd.cmd)
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -123,53 +123,91 @@ static int qla_nvme_alloc_queue(struct n
+ return 0;
+ }
+
++static void qla_nvme_release_fcp_cmd_kref(struct kref *kref)
++{
++ struct srb *sp = container_of(kref, struct srb, cmd_kref);
++ struct nvme_private *priv = (struct nvme_private *)sp->priv;
++ struct nvmefc_fcp_req *fd;
++ struct srb_iocb *nvme;
++ unsigned long flags;
++
++ if (!priv)
++ goto out;
++
++ nvme = &sp->u.iocb_cmd;
++ fd = nvme->u.nvme.desc;
++
++ spin_lock_irqsave(&priv->cmd_lock, flags);
++ priv->sp = NULL;
++ sp->priv = NULL;
++ if (priv->comp_status == QLA_SUCCESS) {
++ fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
++ } else {
++ fd->rcv_rsplen = 0;
++ fd->transferred_length = 0;
++ }
++ fd->status = 0;
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++
++ fd->done(fd);
++out:
++ qla2xxx_rel_qpair_sp(sp->qpair, sp);
++}
++
++static void qla_nvme_release_ls_cmd_kref(struct kref *kref)
++{
++ struct srb *sp = container_of(kref, struct srb, cmd_kref);
++ struct nvme_private *priv = (struct nvme_private *)sp->priv;
++ struct nvmefc_ls_req *fd;
++ unsigned long flags;
++
++ if (!priv)
++ goto out;
++
++ spin_lock_irqsave(&priv->cmd_lock, flags);
++ priv->sp = NULL;
++ sp->priv = NULL;
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++
++ fd = priv->fd;
++ fd->done(fd, priv->comp_status);
++out:
++ qla2x00_rel_sp(sp);
++}
++
++static void qla_nvme_ls_complete(struct work_struct *work)
++{
++ struct nvme_private *priv =
++ container_of(work, struct nvme_private, ls_work);
++
++ kref_put(&priv->sp->cmd_kref, qla_nvme_release_ls_cmd_kref);
++}
++
+ static void qla_nvme_sp_ls_done(void *ptr, int res)
+ {
+ srb_t *sp = ptr;
+- struct srb_iocb *nvme;
+- struct nvmefc_ls_req *fd;
+ struct nvme_private *priv;
+
+- if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
++ if (WARN_ON_ONCE(kref_read(&sp->cmd_kref) == 0))
+ return;
+
+- atomic_dec(&sp->ref_count);
+-
+ if (res)
+ res = -EINVAL;
+
+- nvme = &sp->u.iocb_cmd;
+- fd = nvme->u.nvme.desc;
+- priv = fd->private;
++ priv = (struct nvme_private *)sp->priv;
+ priv->comp_status = res;
++ INIT_WORK(&priv->ls_work, qla_nvme_ls_complete);
+ schedule_work(&priv->ls_work);
+- /* work schedule doesn't need the sp */
+- qla2x00_rel_sp(sp);
+ }
+
++/* it assumed that QPair lock is held. */
+ static void qla_nvme_sp_done(void *ptr, int res)
+ {
+ srb_t *sp = ptr;
+- struct srb_iocb *nvme;
+- struct nvmefc_fcp_req *fd;
++ struct nvme_private *priv = (struct nvme_private *)sp->priv;
+
+- nvme = &sp->u.iocb_cmd;
+- fd = nvme->u.nvme.desc;
+-
+- if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+- return;
+-
+- atomic_dec(&sp->ref_count);
+-
+- if (res == QLA_SUCCESS) {
+- fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
+- } else {
+- fd->rcv_rsplen = 0;
+- fd->transferred_length = 0;
+- }
+- fd->status = 0;
+- fd->done(fd);
+- qla2xxx_rel_qpair_sp(sp->qpair, sp);
++ priv->comp_status = res;
++ kref_put(&sp->cmd_kref, qla_nvme_release_fcp_cmd_kref);
+
+ return;
+ }
+@@ -188,44 +226,50 @@ static void qla_nvme_abort_work(struct w
+ __func__, sp, sp->handle, fcport, fcport->deleted);
+
+ if (!ha->flags.fw_started && (fcport && fcport->deleted))
+- return;
++ goto out;
+
+ if (ha->flags.host_shutting_down) {
+ ql_log(ql_log_info, sp->fcport->vha, 0xffff,
+ "%s Calling done on sp: %p, type: 0x%x, sp->ref_count: 0x%x\n",
+ __func__, sp, sp->type, atomic_read(&sp->ref_count));
+ sp->done(sp, 0);
+- return;
++ goto out;
+ }
+
+- if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
+- return;
+-
+ rval = ha->isp_ops->abort_command(sp);
+
+ ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
+ "%s: %s command for sp=%p, handle=%x on fcport=%p rval=%x\n",
+ __func__, (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
+ sp, sp->handle, fcport, rval);
++
++out:
++ /* kref_get was done before work was schedule. */
++ kref_put(&sp->cmd_kref, sp->put_fn);
+ }
+
+ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+ {
+ struct nvme_private *priv = fd->private;
++ unsigned long flags;
++
++ spin_lock_irqsave(&priv->cmd_lock, flags);
++ if (!priv->sp) {
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++ return;
++ }
++
++ if (!kref_get_unless_zero(&priv->sp->cmd_kref)) {
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++ return;
++ }
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
+
+ INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+ schedule_work(&priv->abort_work);
+ }
+
+-static void qla_nvme_ls_complete(struct work_struct *work)
+-{
+- struct nvme_private *priv =
+- container_of(work, struct nvme_private, ls_work);
+- struct nvmefc_ls_req *fd = priv->fd;
+-
+- fd->done(fd, priv->comp_status);
+-}
+
+ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+@@ -257,11 +301,13 @@ static int qla_nvme_ls_req(struct nvme_f
+ sp->type = SRB_NVME_LS;
+ sp->name = "nvme_ls";
+ sp->done = qla_nvme_sp_ls_done;
+- atomic_set(&sp->ref_count, 1);
+- nvme = &sp->u.iocb_cmd;
++ sp->put_fn = qla_nvme_release_ls_cmd_kref;
++ sp->priv = (void *)priv;
+ priv->sp = sp;
++ kref_init(&sp->cmd_kref);
++ spin_lock_init(&priv->cmd_lock);
++ nvme = &sp->u.iocb_cmd;
+ priv->fd = fd;
+- INIT_WORK(&priv->ls_work, qla_nvme_ls_complete);
+ nvme->u.nvme.desc = fd;
+ nvme->u.nvme.dir = 0;
+ nvme->u.nvme.dl = 0;
+@@ -278,9 +324,10 @@ static int qla_nvme_ls_req(struct nvme_f
+ if (rval != QLA_SUCCESS) {
+ ql_log(ql_log_warn, vha, 0x700e,
+ "qla2x00_start_sp failed = %d\n", rval);
+- atomic_dec(&sp->ref_count);
+ wake_up(&sp->nvme_ls_waitq);
+- sp->free(sp);
++ sp->priv = NULL;
++ priv->sp = NULL;
++ qla2x00_rel_sp(sp);
+ return rval;
+ }
+
+@@ -292,6 +339,18 @@ static void qla_nvme_fcp_abort(struct nv
+ struct nvmefc_fcp_req *fd)
+ {
+ struct nvme_private *priv = fd->private;
++ unsigned long flags;
++
++ spin_lock_irqsave(&priv->cmd_lock, flags);
++ if (!priv->sp) {
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++ return;
++ }
++ if (!kref_get_unless_zero(&priv->sp->cmd_kref)) {
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
++ return;
++ }
++ spin_unlock_irqrestore(&priv->cmd_lock, flags);
+
+ INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+ schedule_work(&priv->abort_work);
+@@ -532,12 +591,15 @@ static int qla_nvme_post_cmd(struct nvme
+ if (!sp)
+ return -EBUSY;
+
+- atomic_set(&sp->ref_count, 1);
+ init_waitqueue_head(&sp->nvme_ls_waitq);
++ kref_init(&sp->cmd_kref);
++ spin_lock_init(&priv->cmd_lock);
++ sp->priv = (void *)priv;
+ priv->sp = sp;
+ sp->type = SRB_NVME_CMD;
+ sp->name = "nvme_cmd";
+ sp->done = qla_nvme_sp_done;
++ sp->put_fn = qla_nvme_release_fcp_cmd_kref;
+ sp->qpair = qpair;
+ sp->vha = vha;
+ nvme = &sp->u.iocb_cmd;
+@@ -547,9 +609,10 @@ static int qla_nvme_post_cmd(struct nvme
+ if (rval != QLA_SUCCESS) {
+ ql_log(ql_log_warn, vha, 0x212d,
+ "qla2x00_start_nvme_mq failed = %d\n", rval);
+- atomic_dec(&sp->ref_count);
+ wake_up(&sp->nvme_ls_waitq);
+- sp->free(sp);
++ sp->priv = NULL;
++ priv->sp = NULL;
++ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+ return rval;
+--- a/drivers/scsi/qla2xxx/qla_nvme.h
++++ b/drivers/scsi/qla2xxx/qla_nvme.h
+@@ -33,6 +33,7 @@ struct nvme_private {
+ struct work_struct ls_work;
+ struct work_struct abort_work;
+ int comp_status;
++ spinlock_t cmd_lock;
+ };
+
+ struct qla_nvme_rport {
diff --git a/patches.drivers/scsi-qla2xxx-Fix-NVMe-port-discovery-after-a-short-d.patch b/patches.drivers/scsi-qla2xxx-Fix-NVMe-port-discovery-after-a-short-d.patch
new file mode 100644
index 0000000000..1a0d90d23d
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-NVMe-port-discovery-after-a-short-d.patch
@@ -0,0 +1,56 @@
+From: Arun Easi <aeasi@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:36 -0700
+Subject: scsi: qla2xxx: Fix NVMe port discovery after a short device port loss
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 9e744591ef1b8df27c25c68dac858dada8688f77
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The following sequence of event leads to NVME port disappearing:
+
+ - device port shut
+ - nvme_fc_unregister_remoteport
+ - device port online
+ - remote port delete completes
+ - relogin is scheduled
+ - "post gidpn" message appears due to rscn generation # mismatch
+
+In short, if a device comes back online sooner than an unregister
+completion, a mismatch in rscn generation number occurs, which is not
+handled correctly during device relogin. Fix this by starting with a redo
+of GNL.
+
+When ql2xextended_error_logging is enabled, the re-plugged device's
+discovery stops with the following messages printed:
+
+--8<--
+qla2xxx [0000:41:00.0]-480d:3: Relogin scheduled.
+qla2xxx [0000:41:00.0]-4800:3: DPC handler sleeping.
+qla2xxx [0000:41:00.0]-2902:3: qla24xx_handle_relogin_event 21:00:00:24:ff:17:9e:91 DS 0 LS 7 P 0 del 2 cnfl
+ (null) rscn 1|2 login 1|2 fl 1
+qla2xxx [0000:41:00.0]-28e9:3: qla24xx_handle_relogin_event 1666 21:00:00:24:ff:17:9e:91 post gidpn
+qla2xxx [0000:41:00.0]-480e:3: Relogin end.
+--8<--
+
+Signed-off-by: Arun Easi <aeasi@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -1665,9 +1665,9 @@ void qla24xx_handle_relogin_event(scsi_q
+ }
+
+ if (fcport->last_rscn_gen != fcport->rscn_gen) {
+- ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gidpn\n",
++ ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gnl\n",
+ __func__, __LINE__, fcport->port_name);
+-
++ qla24xx_post_gnl_work(vha, fcport);
+ return;
+ }
+
diff --git a/patches.drivers/scsi-qla2xxx-Fix-Relogin-to-prevent-modifying-scan_s.patch b/patches.drivers/scsi-qla2xxx-Fix-Relogin-to-prevent-modifying-scan_s.patch
new file mode 100644
index 0000000000..888f811f38
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-Relogin-to-prevent-modifying-scan_s.patch
@@ -0,0 +1,104 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:32 -0700
+Subject: scsi: qla2xxx: Fix Relogin to prevent modifying scan_state flag
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 8b5292bcfcacf15182a77a973a98d310e76fd58b
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Relogin fails to move forward due to scan_state flag indicating device is
+not there. Before relogin process, Session delete process accidently
+modified the scan_state flag.
+
+[mkp: typos plus corrected Fixes: sha as reported by sfr]
+
+Fixes: 2dee5521028c ("scsi: qla2xxx: Fix login state machine freeze")
+Cc: stable@vger.kernel.org
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 25 ++++++++++++++++++++-----
+ drivers/scsi/qla2xxx/qla_os.c | 1 +
+ drivers/scsi/qla2xxx/qla_target.c | 1 -
+ 3 files changed, 21 insertions(+), 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -289,8 +289,13 @@ qla2x00_async_login(struct scsi_qla_host
+ struct srb_iocb *lio;
+ int rval = QLA_FUNCTION_FAILED;
+
+- if (!vha->flags.online)
+- goto done;
++ if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
++ fcport->loop_id == FC_NO_LOOP_ID) {
++ ql_log(ql_log_warn, vha, 0xffff,
++ "%s: %8phC - not sending command.\n",
++ __func__, fcport->port_name);
++ return rval;
++ }
+
+ sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
+ if (!sp)
+@@ -1264,8 +1269,13 @@ int qla24xx_async_gpdb(struct scsi_qla_h
+ struct port_database_24xx *pd;
+ struct qla_hw_data *ha = vha->hw;
+
+- if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
++ if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
++ fcport->loop_id == FC_NO_LOOP_ID) {
++ ql_log(ql_log_warn, vha, 0xffff,
++ "%s: %8phC - not sending command.\n",
++ __func__, fcport->port_name);
+ return rval;
++ }
+
+ fcport->disc_state = DSC_GPDB;
+
+@@ -1955,8 +1965,11 @@ qla24xx_handle_plogi_done_event(struct s
+ return;
+ }
+
+- if (fcport->disc_state == DSC_DELETE_PEND)
++ if ((fcport->disc_state == DSC_DELETE_PEND) ||
++ (fcport->disc_state == DSC_DELETED)) {
++ set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+ return;
++ }
+
+ if (ea->sp->gen2 != fcport->login_gen) {
+ /* target side must have changed it. */
+@@ -6703,8 +6716,10 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_
+ }
+
+ /* Clear all async request states across all VPs. */
+- list_for_each_entry(fcport, &vha->vp_fcports, list)
++ list_for_each_entry(fcport, &vha->vp_fcports, list) {
+ fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
++ fcport->scan_state = 0;
++ }
+ spin_lock_irqsave(&ha->vport_slock, flags);
+ list_for_each_entry(vp, &ha->vp_list, list) {
+ atomic_inc(&vp->vref_count);
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -5089,6 +5089,7 @@ void qla24xx_create_new_sess(struct scsi
+ if (fcport) {
+ fcport->id_changed = 1;
+ fcport->scan_state = QLA_FCPORT_FOUND;
++ fcport->chip_reset = vha->hw->base_qpair->chip_reset;
+ memcpy(fcport->node_name, e->u.new_sess.node_name, WWN_SIZE);
+
+ if (pla) {
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -1218,7 +1218,6 @@ static void qla24xx_chk_fcp_state(struct
+ sess->logout_on_delete = 0;
+ sess->logo_ack_needed = 0;
+ sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
+- sess->scan_state = 0;
+ }
+ }
+
diff --git a/patches.drivers/scsi-qla2xxx-Fix-a-format-specifier.patch b/patches.drivers/scsi-qla2xxx-Fix-a-format-specifier.patch
new file mode 100644
index 0000000000..d8aff03bec
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-a-format-specifier.patch
@@ -0,0 +1,32 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:11 -0700
+Subject: scsi: qla2xxx: Fix a format specifier
+Patch-mainline: v5.2-rc1
+Git-commit: 19ce192cd718e02f880197c0983404ca48236807
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since mcmd->sess->port_name is eight bytes long, use %8phC to format that
+port name instead of %phC.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery") # v4.11.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -2391,7 +2391,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt
+ case ELS_PRLO:
+ case ELS_TPRLO:
+ ql_dbg(ql_dbg_disc, vha, 0x2106,
+- "TM response logo %phC status %#x state %#x",
++ "TM response logo %8phC status %#x state %#x",
+ mcmd->sess->port_name, mcmd->fc_tm_rsp,
+ mcmd->flags);
+ qlt_schedule_sess_for_deletion(mcmd->sess);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-a-qla24xx_enable_msix-error-path.patch b/patches.drivers/scsi-qla2xxx-Fix-a-qla24xx_enable_msix-error-path.patch
new file mode 100644
index 0000000000..6c3a9f6af8
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-a-qla24xx_enable_msix-error-path.patch
@@ -0,0 +1,42 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:24 -0700
+Subject: scsi: qla2xxx: Fix a qla24xx_enable_msix() error path
+Patch-mainline: v5.2-rc1
+Git-commit: 24afabdbd0b3553963a2bbf465895492b14d1107
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Make sure that the allocated interrupts are freed if allocating memory for
+the msix_entries array fails.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -3497,7 +3497,7 @@ qla24xx_enable_msix(struct qla_hw_data *
+ ql_log(ql_log_fatal, vha, 0x00c8,
+ "Failed to allocate memory for ha->msix_entries.\n");
+ ret = -ENOMEM;
+- goto msix_out;
++ goto free_irqs;
+ }
+ ha->flags.msix_enabled = 1;
+
+@@ -3580,6 +3580,10 @@ msix_register_fail:
+
+ msix_out:
+ return ret;
++
++free_irqs:
++ pci_free_irq_vectors(ha->pdev);
++ goto msix_out;
+ }
+
+ int
diff --git a/patches.drivers/scsi-qla2xxx-Fix-a-small-typo-in-qla_bsg.c.patch b/patches.drivers/scsi-qla2xxx-Fix-a-small-typo-in-qla_bsg.c.patch
new file mode 100644
index 0000000000..f4dd784d6e
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-a-small-typo-in-qla_bsg.c.patch
@@ -0,0 +1,27 @@
+From: "Milan P. Gandhi" <mgandhi@redhat.com>
+Date: Tue, 12 Mar 2019 18:23:15 +0530
+Subject: scsi: qla2xxx: Fix a small typo in qla_bsg.c
+Patch-mainline: v5.2-rc1
+Git-commit: 62439b4800419520bbb278beec2b6f06afa8b5ec
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Fixed a typo for 'iiDMA' cmd in qla_bsg.c.
+
+Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_bsg.c
++++ b/drivers/scsi/qla2xxx/qla_bsg.c
+@@ -1354,7 +1354,7 @@ qla24xx_iidma(struct bsg_job *bsg_job)
+
+ if (rval) {
+ ql_log(ql_log_warn, vha, 0x704c,
+- "iIDMA cmd failed for %8phN -- "
++ "iiDMA cmd failed for %8phN -- "
+ "%04x %x %04x %04x.\n", fcport->port_name,
+ rval, fcport->fp_speed, mb[0], mb[1]);
+ rval = (DID_ERROR << 16);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-abort-timeout-race-condition.patch b/patches.drivers/scsi-qla2xxx-Fix-abort-timeout-race-condition.patch
new file mode 100644
index 0000000000..e1b1326770
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-abort-timeout-race-condition.patch
@@ -0,0 +1,69 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:28 -0700
+Subject: scsi: qla2xxx: Fix abort timeout race condition.
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 0c6df59061b23c7a951836d23977be34e896d3da
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+If an abort times out, the Abort IOCB completion and Abort timer can race
+against each other. This patch provides unique error code for timer path to
+allow proper cleanup.
+
+[mkp: typo]
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1 +
+ drivers/scsi/qla2xxx/qla_init.c | 18 ++++++++++++++++--
+ 2 files changed, 17 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -4658,6 +4658,7 @@ struct secure_flash_update_block_pk {
+ #define QLA_SUSPENDED 0x106
+ #define QLA_BUSY 0x107
+ #define QLA_ALREADY_REGISTERED 0x109
++#define QLA_OS_TIMER_EXPIRED 0x10a
+
+ #define NVRAM_DELAY() udelay(10)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -99,9 +99,22 @@ static void qla24xx_abort_iocb_timeout(v
+ {
+ srb_t *sp = data;
+ struct srb_iocb *abt = &sp->u.iocb_cmd;
++ struct qla_qpair *qpair = sp->qpair;
++ u32 handle;
++ unsigned long flags;
++
++ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
++ for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) {
++ /* removing the abort */
++ if (qpair->req->outstanding_cmds[handle] == sp) {
++ qpair->req->outstanding_cmds[handle] = NULL;
++ break;
++ }
++ }
++ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+
+ abt->u.abt.comp_status = CS_TIMEOUT;
+- sp->done(sp, QLA_FUNCTION_TIMEOUT);
++ sp->done(sp, QLA_OS_TIMER_EXPIRED);
+ }
+
+ static void qla24xx_abort_sp_done(void *ptr, int res)
+@@ -109,7 +122,8 @@ static void qla24xx_abort_sp_done(void *
+ srb_t *sp = ptr;
+ struct srb_iocb *abt = &sp->u.iocb_cmd;
+
+- if (del_timer(&sp->u.iocb_cmd.timer)) {
++ if ((res == QLA_OS_TIMER_EXPIRED) ||
++ del_timer(&sp->u.iocb_cmd.timer)) {
+ if (sp->flags & SRB_WAKEUP_ON_COMP)
+ complete(&abt->u.abt.comp);
+ else
diff --git a/patches.drivers/scsi-qla2xxx-Fix-comment-alignment-in-qla_bsg.c.patch b/patches.drivers/scsi-qla2xxx-Fix-comment-alignment-in-qla_bsg.c.patch
new file mode 100644
index 0000000000..2543f697f1
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-comment-alignment-in-qla_bsg.c.patch
@@ -0,0 +1,24 @@
+From: "Milan P. Gandhi" <mgandhi@redhat.com>
+Date: Tue, 12 Mar 2019 18:21:11 +0530
+Subject: scsi: qla2xxx: Fix comment alignment in qla_bsg.c
+Patch-mainline: v5.2-rc1
+Git-commit: f65c33890b95ce24f12f88c30625d678443020bb
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Fixed a minor formatting issue with comment section in qla_bsg.c
+
+Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_bsg.c
++++ b/drivers/scsi/qla2xxx/qla_bsg.c
+@@ -1,4 +1,4 @@
+- /*
++/*
+ * QLogic Fibre Channel HBA Driver
+ * Copyright (c) 2003-2014 QLogic Corporation
+ *
diff --git a/patches.drivers/scsi-qla2xxx-Fix-device-staying-in-blocked-state.patch b/patches.drivers/scsi-qla2xxx-Fix-device-staying-in-blocked-state.patch
new file mode 100644
index 0000000000..da222125ff
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-device-staying-in-blocked-state.patch
@@ -0,0 +1,46 @@
+From: Quinn Tran <qtran@marvell.com>
+Date: Tue, 23 Apr 2019 14:52:35 -0700
+Subject: scsi: qla2xxx: Fix device staying in blocked state
+Patch-mainline: v5.2-rc1
+Git-commit: 2137490f2147a8d0799b72b9a1023efb012d40c7
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch fixes issue reported by some of the customers, who discovered
+that after cable pull scenario the devices disappear and path seems to
+remain in blocked state. Once the device reappears, driver does not seem to
+update path to online. This issue appears because of the defer flag
+creating race condition where the same session reappears. This patch fixes
+this issue by indicating SCSI-ML of device lost when
+qlt_free_session_done() is called from qlt_unreg_sess().
+
+Fixes: 41dc529a4602a ("qla2xxx: Improve RSCN handling in driver")
+Signed-off-by: Quinn Tran <qtran@marvell.com>
+Cc: stable@vger.kernel.org #4.19
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Ewan D. Milne <emilne@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -982,6 +982,8 @@ void qlt_free_session_done(struct work_s
+ sess->send_els_logo);
+
+ if (!IS_SW_RESV_ADDR(sess->d_id)) {
++ qla2x00_mark_device_lost(vha, sess, 0, 0);
++
+ if (sess->send_els_logo) {
+ qlt_port_logo_t logo;
+
+@@ -1163,8 +1165,6 @@ void qlt_unreg_sess(struct fc_port *sess
+ if (sess->se_sess)
+ vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
+
+- qla2x00_mark_device_lost(vha, sess, 0, 0);
+-
+ sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
+ sess->disc_state = DSC_DELETE_PEND;
+ sess->last_rscn_gen = sess->rscn_gen;
diff --git a/patches.drivers/scsi-qla2xxx-Fix-different-size-DMA-Alloc-Unmap.patch b/patches.drivers/scsi-qla2xxx-Fix-different-size-DMA-Alloc-Unmap.patch
new file mode 100644
index 0000000000..eb0178baf5
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-different-size-DMA-Alloc-Unmap.patch
@@ -0,0 +1,39 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:27 -0700
+Subject: scsi: qla2xxx: Fix different size DMA Alloc/Unmap
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: d376dbda187317d06d3a2d495b43a7983e4a3250
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+[ 17.177276] qla2xxx 0000:05:00.0: DMA-API: device driver frees DMA memory
+ with different size [device address=0x00000006198b0000] [map size=32784 bytes]
+ [unmap size=8208 bytes]
+[ 17.177390] RIP: 0010:check_unmap+0x7a2/0x1750
+[ 17.177425] Call Trace:
+[ 17.177438] debug_dma_free_coherent+0x1b5/0x2d5
+[ 17.177470] dma_free_attrs+0x7f/0x140
+[ 17.177489] qla24xx_sp_unmap+0x1e2/0x610 [qla2xxx]
+[ 17.177509] qla24xx_async_gnnft_done+0x9c6/0x17d0 [qla2xxx]
+[ 17.177535] qla2x00_do_work+0x514/0x2200 [qla2xxx]
+
+Fixes: b5f3bc39a0e8 ("scsi: qla2xxx: Fix inconsistent DMA mem alloc/free")
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -4159,7 +4159,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t
+ sp->u.iocb_cmd.u.ctarg.rsp = dma_zalloc_coherent(
+ &vha->hw->pdev->dev, rspsz,
+ &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL);
+- sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
++ sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = rspsz;
+ if (!sp->u.iocb_cmd.u.ctarg.rsp) {
+ ql_log(ql_log_warn, vha, 0xffff,
+ "Failed to allocate ct_sns request.\n");
diff --git a/patches.drivers/scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUNs-are.patch b/patches.drivers/scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUNs-are.patch
new file mode 100644
index 0000000000..51abdee953
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUNs-are.patch
@@ -0,0 +1,79 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:32 -0700
+Subject: scsi: qla2xxx: Fix driver unload when FC-NVMe LUNs are connected
+Patch-mainline: v5.2-rc1
+Git-commit: b2d1453a45aa8477b1d33ee94a7694146bb8b340
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch allows driver to unload using "modprobe -r" when FC-NVMe LUNs
+are connected.
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 29 +++++++++++++++++++++++------
+ drivers/scsi/qla2xxx/qla_os.c | 6 ++++--
+ 2 files changed, 27 insertions(+), 8 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -164,12 +164,13 @@ static void qla_nvme_sp_done(void *ptr,
+ if (!atomic_dec_and_test(&sp->ref_count))
+ return;
+
+- if (res == QLA_SUCCESS)
+- fd->status = 0;
+- else
+- fd->status = NVME_SC_INTERNAL;
+-
+- fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
++ if (res == QLA_SUCCESS) {
++ fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
++ } else {
++ fd->rcv_rsplen = 0;
++ fd->transferred_length = 0;
++ }
++ fd->status = 0;
+ fd->done(fd);
+ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+
+@@ -193,6 +194,22 @@ static void qla_nvme_abort_work(struct w
+ if (!ha->flags.fw_started && (fcport && fcport->deleted))
+ return;
+
++ if (ha->flags.host_shutting_down) {
++ ql_log(ql_log_info, sp->fcport->vha, 0xffff,
++ "%s Calling done on sp: %p, type: 0x%x, sp->ref_count: 0x%x\n",
++ __func__, sp, sp->type, atomic_read(&sp->ref_count));
++ sp->done(sp, 0);
++ return;
++ }
++
++ if (atomic_read(&sp->ref_count) == 0) {
++ WARN_ON(1);
++ ql_log(ql_log_info, fcport->vha, 0xffff,
++ "%s: command alredy aborted on sp: %p\n",
++ __func__, sp);
++ return;
++ }
++
+ rval = ha->isp_ops->abort_command(sp);
+
+ ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -6746,8 +6746,10 @@ qla2x00_timer(scsi_qla_host_t *vha)
+ * FC-NVME
+ * see if the active AEN count has changed from what was last reported.
+ */
+- if (!vha->vp_idx && (atomic_read(&ha->nvme_active_aen_cnt) !=
+- ha->nvme_last_rptd_aen) && ha->zio_mode == QLA_ZIO_MODE_6) {
++ if (!vha->vp_idx &&
++ (atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen) &&
++ ha->zio_mode == QLA_ZIO_MODE_6 &&
++ !ha->flags.host_shutting_down) {
+ ql_log(ql_log_info, vha, 0x3002,
+ "nvme: Sched: Set ZIO exchange threshold to %d.\n",
+ ha->nvme_last_rptd_aen);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-error-handling-in-qlt_alloc_qfull_c.patch b/patches.drivers/scsi-qla2xxx-Fix-error-handling-in-qlt_alloc_qfull_c.patch
new file mode 100644
index 0000000000..1f9588fb56
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-error-handling-in-qlt_alloc_qfull_c.patch
@@ -0,0 +1,45 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:27 -0700
+Subject: scsi: qla2xxx: Fix error handling in qlt_alloc_qfull_cmd()
+Patch-mainline: v5.2-rc1
+Git-commit: c04466c17142d5eb566984372b9a5003d1900fe3
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The test "if (!cmd)" is not useful because it is guaranteed that cmd !=
+NULL. Instead of testing the cmd pointer, rely on the tag to decide
+whether or not command allocation failed.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: 33e799775593 ("qla2xxx: Add support for QFull throttling and Term Exchange retry") # v3.18.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -5485,11 +5485,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host
+ se_sess = sess->se_sess;
+
+ tag = percpu_ida_alloc(&se_sess->sess_tag_pool, TASK_RUNNING);
+- if (tag < 0)
+- return;
+-
+- cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag];
+- if (!cmd) {
++ if (tag < 0) {
+ ql_dbg(ql_dbg_io, vha, 0x3009,
+ "qla_target(%d): %s: Allocation of cmd failed\n",
+ vha->vp_idx, __func__);
+@@ -5504,6 +5500,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host
+ return;
+ }
+
++ cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag];
+ memset(cmd, 0, sizeof(struct qla_tgt_cmd));
+
+ qlt_incr_num_pend_cmds(vha);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-formatting-of-pointer-types.patch b/patches.drivers/scsi-qla2xxx-Fix-formatting-of-pointer-types.patch
new file mode 100644
index 0000000000..941e65d8a5
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-formatting-of-pointer-types.patch
@@ -0,0 +1,82 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:18 -0700
+Subject: scsi: qla2xxx: Fix formatting of pointer types
+Patch-mainline: v5.2-rc1
+Git-commit: 845bbb09b54c1f712d4b1c9a0500cc62d6215398
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Improve source code readability by following the Linux kernel coding style
+for pointer types. This patch only changes whitespace.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 2 +-
+ drivers/scsi/qla2xxx/qla_gbl.h | 2 +-
+ drivers/scsi/qla2xxx/qla_isr.c | 4 ++--
+ drivers/scsi/qla2xxx/qla_os.c | 2 +-
+ drivers/scsi/qla2xxx/qla_target.c | 2 +-
+ 5 files changed, 6 insertions(+), 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -3189,7 +3189,7 @@ struct isp_operations {
+ int (*start_scsi) (srb_t *);
+ int (*start_scsi_mq) (srb_t *);
+ int (*abort_isp) (struct scsi_qla_host *);
+- int (*iospace_config)(struct qla_hw_data*);
++ int (*iospace_config)(struct qla_hw_data *);
+ int (*initialize_adapter)(struct scsi_qla_host *);
+ };
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -243,7 +243,7 @@ extern void qla24xx_report_id_acquisitio
+ struct vp_rpt_id_entry_24xx *);
+ extern void qla2x00_do_dpc_all_vps(scsi_qla_host_t *);
+ extern int qla24xx_vport_create_req_sanity_check(struct fc_vport *);
+-extern scsi_qla_host_t * qla24xx_create_vhost(struct fc_vport *);
++extern scsi_qla_host_t *qla24xx_create_vhost(struct fc_vport *);
+
+ extern void qla2x00_sp_free_dma(void *);
+ extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -1595,8 +1595,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vh
+ }
+
+ comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status);
+- fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1);
+- fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2);
++ fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_1);
++ fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_2);
+
+ if (iocb_type == ELS_IOCB_TYPE) {
+ els = &sp->u.iocb_cmd;
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1246,7 +1246,7 @@ qla2x00_wait_for_chip_reset(scsi_qla_hos
+ static int
+ sp_get(struct srb *sp)
+ {
+- if (!refcount_inc_not_zero((refcount_t*)&sp->ref_count))
++ if (!refcount_inc_not_zero((refcount_t *)&sp->ref_count))
+ /* kref get fail */
+ return ENXIO;
+ else
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -703,7 +703,7 @@ void qla24xx_do_nack_work(struct scsi_ql
+ break;
+ }
+ qla24xx_async_notify_ack(vha, e->u.nack.fcport,
+- (struct imm_ntfy_from_isp*)e->u.nack.iocb, e->u.nack.type);
++ (struct imm_ntfy_from_isp *)e->u.nack.iocb, e->u.nack.type);
+ }
+
+ void qla24xx_delete_sess_fn(struct work_struct *work)
diff --git a/patches.drivers/scsi-qla2xxx-Fix-fw-dump-corruption.patch b/patches.drivers/scsi-qla2xxx-Fix-fw-dump-corruption.patch
new file mode 100644
index 0000000000..5b5de7a0bc
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-fw-dump-corruption.patch
@@ -0,0 +1,139 @@
+From: Quinn Tran <quinn.tran@cavium.com>
+Date: Tue, 2 Apr 2019 14:24:27 -0700
+Subject: scsi: qla2xxx: Fix fw dump corruption
+Patch-mainline: v5.2-rc1
+Git-commit: a4226ec3ef1214b0973abdba64db66e10f6b0a1c
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+If fw dump buffer size changes and there is an existing fw dump, then save
+the old dump in the newly allocated buffer.
+
+Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1
+ drivers/scsi/qla2xxx/qla_init.c | 84 ++++++++++++++++++++++++----------------
+ 2 files changed, 53 insertions(+), 32 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -4046,6 +4046,7 @@ struct qla_hw_data {
+ } fwdt[2];
+ struct qla2xxx_fw_dump *fw_dump;
+ uint32_t fw_dump_len;
++ u32 fw_dump_alloc_len;
+ bool fw_dumped;
+ bool fw_dump_mpi;
+ unsigned long fw_dump_cap_flags;
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -3143,12 +3143,12 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v
+ !IS_QLA28XX(ha))
+ mq_size = sizeof(struct qla2xxx_mq_chain);
+ /*
+- * Allocate maximum buffer size for all queues.
++ * Allocate maximum buffer size for all queues - Q0.
+ * Resizing must be done at end-of-dump processing.
+ */
+- mq_size += ha->max_req_queues *
++ mq_size += (ha->max_req_queues - 1) *
+ (req->length * sizeof(request_t));
+- mq_size += ha->max_rsp_queues *
++ mq_size += (ha->max_rsp_queues - 1) *
+ (rsp->length * sizeof(response_t));
+ }
+ if (ha->tgt.atio_ring)
+@@ -3223,42 +3223,62 @@ try_eft:
+ ha->exlogin_size;
+
+ allocate:
+- if (!ha->fw_dump_len || dump_size != ha->fw_dump_len) {
++ if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) {
++
++ ql_dbg(ql_dbg_init, vha, 0x00c5,
++ "%s dump_size %d fw_dump_len %d fw_dump_alloc_len %d\n",
++ __func__, dump_size, ha->fw_dump_len,
++ ha->fw_dump_alloc_len);
++
+ fw_dump = vmalloc(dump_size);
+ if (!fw_dump) {
+ ql_log(ql_log_warn, vha, 0x00c4,
+ "Unable to allocate (%d KB) for firmware dump.\n",
+ dump_size / 1024);
+ } else {
+- if (ha->fw_dump)
++ if (ha->fw_dumped) {
++ memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len);
+ vfree(ha->fw_dump);
+- ha->fw_dump = fw_dump;
+-
+- ha->fw_dump_len = dump_size;
+- ql_dbg(ql_dbg_init, vha, 0x00c5,
+- "Allocated (%d KB) for firmware dump.\n",
+- dump_size / 1024);
+-
+- if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
+- return;
+-
+- ha->fw_dump->signature[0] = 'Q';
+- ha->fw_dump->signature[1] = 'L';
+- ha->fw_dump->signature[2] = 'G';
+- ha->fw_dump->signature[3] = 'C';
+- ha->fw_dump->version = htonl(1);
+-
+- ha->fw_dump->fixed_size = htonl(fixed_size);
+- ha->fw_dump->mem_size = htonl(mem_size);
+- ha->fw_dump->req_q_size = htonl(req_q_size);
+- ha->fw_dump->rsp_q_size = htonl(rsp_q_size);
+-
+- ha->fw_dump->eft_size = htonl(eft_size);
+- ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma));
+- ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma));
+-
+- ha->fw_dump->header_size =
+- htonl(offsetof(struct qla2xxx_fw_dump, isp));
++ ha->fw_dump = fw_dump;
++ ha->fw_dump_alloc_len = dump_size;
++ ql_dbg(ql_dbg_init, vha, 0x00c5,
++ "Re-Allocated (%d KB) and save firmware dump.\n",
++ dump_size / 1024);
++ } else {
++ if (ha->fw_dump)
++ vfree(ha->fw_dump);
++ ha->fw_dump = fw_dump;
++
++ ha->fw_dump_len = ha->fw_dump_alloc_len =
++ dump_size;
++ ql_dbg(ql_dbg_init, vha, 0x00c5,
++ "Allocated (%d KB) for firmware dump.\n",
++ dump_size / 1024);
++
++ if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
++ return;
++
++ ha->fw_dump->signature[0] = 'Q';
++ ha->fw_dump->signature[1] = 'L';
++ ha->fw_dump->signature[2] = 'G';
++ ha->fw_dump->signature[3] = 'C';
++ ha->fw_dump->version = htonl(1);
++
++ ha->fw_dump->fixed_size = htonl(fixed_size);
++ ha->fw_dump->mem_size = htonl(mem_size);
++ ha->fw_dump->req_q_size = htonl(req_q_size);
++ ha->fw_dump->rsp_q_size = htonl(rsp_q_size);
++
++ ha->fw_dump->eft_size = htonl(eft_size);
++ ha->fw_dump->eft_addr_l =
++ htonl(LSD(ha->eft_dma));
++ ha->fw_dump->eft_addr_h =
++ htonl(MSD(ha->eft_dma));
++
++ ha->fw_dump->header_size =
++ htonl(offsetof
++ (struct qla2xxx_fw_dump, isp));
++ }
+ }
+ }
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Fix-hang-in-fcport-delete-path.patch b/patches.drivers/scsi-qla2xxx-Fix-hang-in-fcport-delete-path.patch
new file mode 100644
index 0000000000..31fa81cad9
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-hang-in-fcport-delete-path.patch
@@ -0,0 +1,44 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:38 -0700
+Subject: scsi: qla2xxx: Fix hang in fcport delete path
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: f00b3428a801758243693e046b34226e92bc56b3
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+A hang was observed in the fcport delete path when the device was
+responding slow and an issue-lip path (results in session termination) was
+taken.
+
+Fix this by issuing logo requests unconditionally.
+
+PID: 19491 TASK: ffff8e23e67bb150 CPU: 0 COMMAND: "kworker/0:0"
+ #0 [ffff8e2370297bf8] __schedule at ffffffffb4f7dbb0
+ #1 [ffff8e2370297c88] schedule at ffffffffb4f7e199
+ #2 [ffff8e2370297c98] schedule_timeout at ffffffffb4f7ba68
+ #3 [ffff8e2370297d40] msleep at ffffffffb48ad9ff
+ #4 [ffff8e2370297d58] qlt_free_session_done at ffffffffc0c32052 [qla2xxx]
+ #5 [ffff8e2370297e20] process_one_work at ffffffffb48bcfdf
+ #6 [ffff8e2370297e68] worker_thread at ffffffffb48bdca6
+ #7 [ffff8e2370297ec8] kthread at ffffffffb48c4f81
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -359,9 +359,6 @@ qla2x00_async_logout(struct scsi_qla_hos
+ struct srb_iocb *lio;
+ int rval = QLA_FUNCTION_FAILED;
+
+- if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
+- return rval;
+-
+ fcport->flags |= FCF_ASYNC_SENT;
+ sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
+ if (!sp)
diff --git a/patches.drivers/scsi-qla2xxx-Fix-hardirq-unsafe-locking.patch b/patches.drivers/scsi-qla2xxx-Fix-hardirq-unsafe-locking.patch
new file mode 100644
index 0000000000..49279d8811
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-hardirq-unsafe-locking.patch
@@ -0,0 +1,363 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:41 -0700
+Subject: scsi: qla2xxx: Fix hardirq-unsafe locking
+Patch-mainline: v5.2-rc1
+Git-commit: 300ec7415c1fed5c73660f50c8e14a67e236dc0a
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since fc_remote_port_delete() must be called with interrupts enabled, do
+not disable interrupts when calling that function. Remove the lockin calls
+from around the put_sess() call. This is safe because the function that is
+called when the final reference is dropped, qlt_unreg_sess(), grabs the
+proper locks. This patch avoids that lockdep reports the following:
+
+WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
+kworker/2:1/62 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
+0000000009e679b3 (&(&k->k_lock)->rlock){+.+.}, at: klist_next+0x43/0x1d0
+
+and this task is already holding:
+00000000a033b71c (&(&ha->tgt.sess_lock)->rlock){-...}, at: qla24xx_delete_sess_fn+0x55/0xf0 [qla2xxx_scst]
+which would create a new lock dependency:
+ (&(&ha->tgt.sess_lock)->rlock){-...} -> (&(&k->k_lock)->rlock){+.+.}
+
+but this new dependency connects a HARDIRQ-irq-safe lock:
+ (&(&ha->tgt.sess_lock)->rlock){-...}
+
+... which became HARDIRQ-irq-safe at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst]
+ qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst]
+ qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst]
+ __handle_irq_event_percpu+0x79/0x3c0
+ handle_irq_event_percpu+0x70/0xf0
+ handle_irq_event+0x5a/0x8b
+ handle_edge_irq+0x12c/0x310
+ handle_irq+0x192/0x20a
+ do_IRQ+0x73/0x160
+ ret_from_intr+0x0/0x1d
+ default_idle+0x23/0x1f0
+ arch_cpu_idle+0x15/0x20
+ default_idle_call+0x35/0x40
+ do_idle+0x2bb/0x2e0
+ cpu_startup_entry+0x1d/0x20
+ start_secondary+0x2a8/0x320
+ secondary_startup_64+0xa4/0xb0
+
+to a HARDIRQ-irq-unsafe lock:
+ (&(&k->k_lock)->rlock){+.+.}
+
+... which became HARDIRQ-irq-unsafe at:
+...
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7e1/0xb50
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+
+other info that might help us debug this:
+
+ Possible interrupt unsafe locking scenario:
+
+ CPU0 CPU1
+ ---- ----
+ lock(&(&k->k_lock)->rlock);
+ local_irq_disable();
+ lock(&(&ha->tgt.sess_lock)->rlock);
+ lock(&(&k->k_lock)->rlock);
+ <Interrupt>
+ lock(&(&ha->tgt.sess_lock)->rlock);
+
+ *** DEADLOCK ***
+
+3 locks held by kworker/2:1/62:
+ #0: 00000000a4319c16 ((wq_completion)"qla2xxx_wq"){+.+.}, at: process_one_work+0x437/0xa80
+ #1: 00000000ffa34c42 ((work_completion)(&sess->del_work)){+.+.}, at: process_one_work+0x437/0xa80
+ #2: 00000000a033b71c (&(&ha->tgt.sess_lock)->rlock){-...}, at: qla24xx_delete_sess_fn+0x55/0xf0 [qla2xxx_scst]
+
+the dependencies between HARDIRQ-irq-safe lock and the holding lock:
+-> (&(&ha->tgt.sess_lock)->rlock){-...} ops: 8 {
+ IN-HARDIRQ-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst]
+ qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst]
+ qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst]
+ __handle_irq_event_percpu+0x79/0x3c0
+ handle_irq_event_percpu+0x70/0xf0
+ handle_irq_event+0x5a/0x8b
+ handle_edge_irq+0x12c/0x310
+ handle_irq+0x192/0x20a
+ do_IRQ+0x73/0x160
+ ret_from_intr+0x0/0x1d
+ default_idle+0x23/0x1f0
+ arch_cpu_idle+0x15/0x20
+ default_idle_call+0x35/0x40
+ do_idle+0x2bb/0x2e0
+ cpu_startup_entry+0x1d/0x20
+ start_secondary+0x2a8/0x320
+ secondary_startup_64+0xa4/0xb0
+ INITIAL USE at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst]
+ qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst]
+ qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst]
+ __handle_irq_event_percpu+0x79/0x3c0
+ handle_irq_event_percpu+0x70/0xf0
+ handle_irq_event+0x5a/0x8b
+ handle_edge_irq+0x12c/0x310
+ handle_irq+0x192/0x20a
+ do_IRQ+0x73/0x160
+ ret_from_intr+0x0/0x1d
+ default_idle+0x23/0x1f0
+ arch_cpu_idle+0x15/0x20
+ default_idle_call+0x35/0x40
+ do_idle+0x2bb/0x2e0
+ cpu_startup_entry+0x1d/0x20
+ start_secondary+0x2a8/0x320
+ secondary_startup_64+0xa4/0xb0
+ }
+ ... key at: [<ffffffffa0c0d080>] __key.85462+0x0/0xfffffffffff7df80 [qla2xxx_scst]
+ ... acquired at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst]
+ qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst]
+ qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst]
+ process_one_work+0x511/0xa80
+ worker_thread+0x67/0x5b0
+ kthread+0x1d2/0x1f0
+ ret_from_fork+0x3a/0x50
+
+the dependencies between the lock to be acquired
+ and HARDIRQ-irq-unsafe lock:
+-> (&(&k->k_lock)->rlock){+.+.} ops: 13831 {
+ HARDIRQ-ON-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7e1/0xb50
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ SOFTIRQ-ON-W at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7e1/0xb50
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ INITIAL USE at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock+0x32/0x50
+ klist_add_tail+0x33/0xb0
+ device_add+0x7e1/0xb50
+ device_create_groups_vargs+0x11c/0x150
+ device_create_with_groups+0x89/0xb0
+ vtconsole_class_init+0xb2/0x124
+ do_one_initcall+0xc5/0x3ce
+ kernel_init_freeable+0x295/0x32e
+ kernel_init+0x11/0x11b
+ ret_from_fork+0x3a/0x50
+ }
+ ... key at: [<ffffffff83ed8780>] __key.15491+0x0/0x40
+ ... acquired at:
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst]
+ qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst]
+ qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst]
+ process_one_work+0x511/0xa80
+ worker_thread+0x67/0x5b0
+ kthread+0x1d2/0x1f0
+ ret_from_fork+0x3a/0x50
+
+stack backtrace:
+CPU: 2 PID: 62 Comm: kworker/2:1 Tainted: G O 5.0.7-dbg+ #8
+Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
+Workqueue: qla2xxx_wq qla24xx_delete_sess_fn [qla2xxx_scst]
+Call Trace:
+ dump_stack+0x86/0xca
+ check_usage.cold.52+0x473/0x563
+ __lock_acquire+0x11c0/0x23e0
+ lock_acquire+0xe3/0x200
+ _raw_spin_lock_irqsave+0x3d/0x60
+ klist_next+0x43/0x1d0
+ device_for_each_child+0x96/0x110
+ scsi_target_block+0x3c/0x40 [scsi_mod]
+ fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
+ qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst]
+ qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst]
+ qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst]
+ process_one_work+0x511/0xa80
+ worker_thread+0x67/0x5b0
+ kthread+0x1d2/0x1f0
+ ret_from_fork+0x3a/0x50
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 25 ++++++++-----------------
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 --
+ 2 files changed, 8 insertions(+), 19 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -682,7 +682,6 @@ done:
+ void qla24xx_do_nack_work(struct scsi_qla_host *vha, struct qla_work_evt *e)
+ {
+ fc_port_t *t;
+- unsigned long flags;
+
+ switch (e->u.nack.type) {
+ case SRB_NACK_PRLI:
+@@ -695,10 +694,8 @@ void qla24xx_do_nack_work(struct scsi_ql
+ if (t) {
+ ql_log(ql_log_info, vha, 0xd034,
+ "%s create sess success %p", __func__, t);
+- spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
+ /* create sess has an extra kref */
+ vha->hw->tgt.tgt_ops->put_sess(e->u.nack.fcport);
+- spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
+ }
+ break;
+ }
+@@ -710,9 +707,6 @@ void qla24xx_delete_sess_fn(struct work_
+ {
+ fc_port_t *fcport = container_of(work, struct fc_port, del_work);
+ struct qla_hw_data *ha = fcport->vha->hw;
+- unsigned long flags;
+-
+- spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+
+ if (fcport->se_sess) {
+ ha->tgt.tgt_ops->shutdown_sess(fcport);
+@@ -720,7 +714,6 @@ void qla24xx_delete_sess_fn(struct work_
+ } else {
+ qlt_unreg_sess(fcport);
+ }
+- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+ }
+
+ /*
+@@ -789,8 +782,9 @@ void qlt_fc_port_added(struct scsi_qla_h
+ fcport->port_name, sess->loop_id);
+ sess->local = 0;
+ }
+- ha->tgt.tgt_ops->put_sess(sess);
+ spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
++
++ ha->tgt.tgt_ops->put_sess(sess);
+ }
+
+ /*
+@@ -4194,9 +4188,7 @@ static void __qlt_do_work(struct qla_tgt
+ /*
+ * Drop extra session reference from qlt_handle_cmd_for_atio().
+ */
+- spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+ ha->tgt.tgt_ops->put_sess(sess);
+- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+ return;
+
+ out_term:
+@@ -4213,9 +4205,7 @@ out_term:
+ percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
+ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+
+- spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+ ha->tgt.tgt_ops->put_sess(sess);
+- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+ }
+
+ static void qlt_do_work(struct work_struct *work)
+@@ -4423,9 +4413,7 @@ static int qlt_handle_cmd_for_atio(struc
+ if (!cmd) {
+ ql_dbg(ql_dbg_io, vha, 0x3062,
+ "qla_target(%d): Allocation of cmd failed\n", vha->vp_idx);
+- spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+ ha->tgt.tgt_ops->put_sess(sess);
+- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+ return -EBUSY;
+ }
+
+@@ -6275,17 +6263,19 @@ static void qlt_abort_work(struct qla_tg
+ }
+
+ rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess);
+- ha->tgt.tgt_ops->put_sess(sess);
+ spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2);
+
++ ha->tgt.tgt_ops->put_sess(sess);
++
+ if (rc != 0)
+ goto out_term;
+ return;
+
+ out_term2:
++ spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2);
++
+ if (sess)
+ ha->tgt.tgt_ops->put_sess(sess);
+- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2);
+
+ out_term:
+ spin_lock_irqsave(&ha->hardware_lock, flags);
+@@ -6343,9 +6333,10 @@ static void qlt_tmr_work(struct qla_tgt
+ scsilun_to_int((struct scsi_lun *)&a->u.isp24.fcp_cmnd.lun);
+
+ rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
+- ha->tgt.tgt_ops->put_sess(sess);
+ spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+
++ ha->tgt.tgt_ops->put_sess(sess);
++
+ if (rc != 0)
+ goto out_term;
+ return;
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -350,7 +350,6 @@ static void tcm_qla2xxx_put_sess(struct
+ if (!sess)
+ return;
+
+- assert_spin_locked(&sess->vha->hw->tgt.sess_lock);
+ kref_put(&sess->sess_kref, tcm_qla2xxx_release_session);
+ }
+
+@@ -837,7 +836,6 @@ static void tcm_qla2xxx_clear_nacl_from_
+
+ static void tcm_qla2xxx_shutdown_sess(struct fc_port *sess)
+ {
+- assert_spin_locked(&sess->vha->hw->tgt.sess_lock);
+ target_sess_cmd_list_set_waiting(sess->se_sess);
+ }
+
diff --git a/patches.drivers/scsi-qla2xxx-Fix-hardlockup-in-abort-command-during-.patch b/patches.drivers/scsi-qla2xxx-Fix-hardlockup-in-abort-command-during-.patch
new file mode 100644
index 0000000000..9a422228aa
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-hardlockup-in-abort-command-during-.patch
@@ -0,0 +1,43 @@
+From: Arun Easi <aeasi@marvell.com>
+Date: Fri, 14 Jun 2019 07:36:27 -0700
+Subject: scsi: qla2xxx: Fix hardlockup in abort command during driver remove
+Patch-mainline: v5.2-rc6
+Git-commit: 5589b08e5be47e426158f659a892153b4a831921
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+[436194.555537] NMI watchdog: Watchdog detected hard LOCKUP on cpu 5
+[436194.555558] RIP: 0010:native_queued_spin_lock_slowpath+0x63/0x1e0
+
+[436194.555563] Call Trace:
+[436194.555564] _raw_spin_lock_irqsave+0x30/0x40
+[436194.555564] qla24xx_async_abort_command+0x29/0xd0 [qla2xxx]
+[436194.555565] qla24xx_abort_command+0x208/0x2d0 [qla2xxx]
+[436194.555565] __qla2x00_abort_all_cmds+0x16b/0x290 [qla2xxx]
+[436194.555565] qla2x00_abort_all_cmds+0x42/0x60 [qla2xxx]
+[436194.555566] qla2x00_abort_isp_cleanup+0x2bd/0x3a0 [qla2xxx]
+[436194.555566] qla2x00_remove_one+0x1ad/0x360 [qla2xxx]
+[436194.555566] pci_device_remove+0x3b/0xb0
+
+Fixes: 219d27d7147e (scsi: qla2xxx: Fix race conditions in the code for aborting SCSI commands)
+Cc: stable@vger.kernel.org # 5.2
+Signed-off-by: Arun Easi <aeasi@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1737,8 +1737,8 @@ static void qla2x00_abort_srb(struct qla
+ !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
+ !qla2x00_isp_reg_stat(ha))) {
+ sp->comp = &comp;
+- rval = ha->isp_ops->abort_command(sp);
+ spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
++ rval = ha->isp_ops->abort_command(sp);
+
+ switch (rval) {
+ case QLA_SUCCESS:
diff --git a/patches.drivers/scsi-qla2xxx-Fix-kernel-crash-after-disconnecting-NV.patch b/patches.drivers/scsi-qla2xxx-Fix-kernel-crash-after-disconnecting-NV.patch
new file mode 100644
index 0000000000..34a15225e0
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-kernel-crash-after-disconnecting-NV.patch
@@ -0,0 +1,141 @@
+From: Arun Easi <aeasi@marvell.com>
+Date: Fri, 21 Jun 2019 09:50:22 -0700
+Subject: scsi: qla2xxx: Fix kernel crash after disconnecting NVMe devices
+Patch-mainline: v5.3-rc1
+Git-commit: 6a81533d616fe581b0d421ee6db3319eeac9486d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+BUG: unable to handle kernel NULL pointer dereference at (null)
+IP: [<ffffffffc050d10c>] qla_nvme_unregister_remote_port+0x6c/0xf0 [qla2xxx]
+PGD 800000084cf41067 PUD 84d288067 PMD 0
+Oops: 0000 [#1] SMP
+Call Trace:
+ [<ffffffff98abcfdf>] process_one_work+0x17f/0x440
+ [<ffffffff98abdca6>] worker_thread+0x126/0x3c0
+ [<ffffffff98abdb80>] ? manage_workers.isra.26+0x2a0/0x2a0
+ [<ffffffff98ac4f81>] kthread+0xd1/0xe0
+ [<ffffffff98ac4eb0>] ? insert_kthread_work+0x40/0x40
+ [<ffffffff9918ad37>] ret_from_fork_nospec_begin+0x21/0x21
+ [<ffffffff98ac4eb0>] ? insert_kthread_work+0x40/0x40
+RIP [<ffffffffc050d10c>] qla_nvme_unregister_remote_port+0x6c/0xf0 [qla2xxx]
+
+The crash is due to a bad entry in the nvme_rport_list. This list is not
+protected, and when a remoteport_delete callback is called, driver
+traverses the list and crashes.
+
+Actually, the list could be removed and driver could traverse the main
+fcport list instead. Fix does exactly that.
+
+Signed-off-by: Arun Easi <aeasi@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1 -
+ drivers/scsi/qla2xxx/qla_nvme.c | 37 ++++++++++---------------------------
+ drivers/scsi/qla2xxx/qla_nvme.h | 1 -
+ drivers/scsi/qla2xxx/qla_os.c | 1 -
+ 4 files changed, 10 insertions(+), 30 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -4408,7 +4408,6 @@ typedef struct scsi_qla_host {
+
+ struct nvme_fc_local_port *nvme_local_port;
+ struct completion nvme_del_done;
+- struct list_head nvme_rport_list;
+
+ uint16_t fcoe_vlan_id;
+ uint16_t fcoe_fcf_idx;
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -74,7 +74,6 @@ int qla_nvme_register_remote(struct scsi
+
+ rport = fcport->nvme_remote_port->private;
+ rport->fcport = fcport;
+- list_add_tail(&rport->list, &vha->nvme_rport_list);
+
+ fcport->nvme_flag |= NVME_FLAG_REGISTERED;
+ return 0;
+@@ -559,19 +558,12 @@ static void qla_nvme_localport_delete(st
+ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
+ {
+ fc_port_t *fcport;
+- struct qla_nvme_rport *qla_rport = rport->private, *trport;
++ struct qla_nvme_rport *qla_rport = rport->private;
+
+ fcport = qla_rport->fcport;
+ fcport->nvme_remote_port = NULL;
+ fcport->nvme_flag &= ~NVME_FLAG_REGISTERED;
+
+- list_for_each_entry_safe(qla_rport, trport,
+- &fcport->vha->nvme_rport_list, list) {
+- if (qla_rport->fcport == fcport) {
+- list_del(&qla_rport->list);
+- break;
+- }
+- }
+ complete(&fcport->nvme_del_done);
+
+ if (!test_bit(UNLOADING, &fcport->vha->dpc_flags)) {
+@@ -608,7 +600,7 @@ static void qla_nvme_unregister_remote_p
+ {
+ struct fc_port *fcport = container_of(work, struct fc_port,
+ nvme_del_work);
+- struct qla_nvme_rport *qla_rport, *trport;
++ int ret;
+
+ if (!IS_ENABLED(CONFIG_NVME_FC))
+ return;
+@@ -616,23 +608,14 @@ static void qla_nvme_unregister_remote_p
+ ql_log(ql_log_warn, NULL, 0x2112,
+ "%s: unregister remoteport on %p\n",__func__, fcport);
+
+- list_for_each_entry_safe(qla_rport, trport,
+- &fcport->vha->nvme_rport_list, list) {
+- if (qla_rport->fcport == fcport) {
+- ql_log(ql_log_info, fcport->vha, 0x2113,
+- "%s: fcport=%p\n", __func__, fcport);
+- nvme_fc_set_remoteport_devloss
+- (fcport->nvme_remote_port, 0);
+- init_completion(&fcport->nvme_del_done);
+- if (nvme_fc_unregister_remoteport
+- (fcport->nvme_remote_port))
+- ql_log(ql_log_info, fcport->vha, 0x2114,
+- "%s: Failed to unregister nvme_remote_port\n",
+- __func__);
+- wait_for_completion(&fcport->nvme_del_done);
+- break;
+- }
+- }
++ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
++ init_completion(&fcport->nvme_del_done);
++ ret = nvme_fc_unregister_remoteport(fcport->nvme_remote_port);
++ if (ret)
++ ql_log(ql_log_info, fcport->vha, 0x2114,
++ "%s: Failed to unregister nvme_remote_port (%d)\n",
++ __func__, ret);
++ wait_for_completion(&fcport->nvme_del_done);
+ }
+
+ void qla_nvme_delete(struct scsi_qla_host *vha)
+--- a/drivers/scsi/qla2xxx/qla_nvme.h
++++ b/drivers/scsi/qla2xxx/qla_nvme.h
+@@ -36,7 +36,6 @@ struct nvme_private {
+ };
+
+ struct qla_nvme_rport {
+- struct list_head list;
+ struct fc_port *fcport;
+ };
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -4802,7 +4802,6 @@ struct scsi_qla_host *qla2x00_create_hos
+ INIT_LIST_HEAD(&vha->plogi_ack_list);
+ INIT_LIST_HEAD(&vha->qp_list);
+ INIT_LIST_HEAD(&vha->gnl.fcports);
+- INIT_LIST_HEAD(&vha->nvme_rport_list);
+ INIT_LIST_HEAD(&vha->gpnid_list);
+ INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn);
+
diff --git a/patches.drivers/scsi-qla2xxx-Fix-possible-fcport-null-pointer-derefe.patch b/patches.drivers/scsi-qla2xxx-Fix-possible-fcport-null-pointer-derefe.patch
new file mode 100644
index 0000000000..78ecc3e549
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-possible-fcport-null-pointer-derefe.patch
@@ -0,0 +1,43 @@
+From: Jia-Ju Bai <baijiaju1990@gmail.com>
+Date: Mon, 29 Jul 2019 16:44:51 +0800
+Subject: scsi: qla2xxx: Fix possible fcport null-pointer dereferences
+Patch-mainline: v5.3-rc3
+Git-commit: e82f04ec6ba91065fd33a6201ffd7cab840e1475
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+In qla2x00_alloc_fcport(), fcport is assigned to NULL in the error
+handling code on line 4880:
+ fcport = NULL;
+
+Then fcport is used on lines 4883-4886:
+ INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
+ INIT_WORK(&fcport->reg_work, qla_register_fcport_fn);
+ INIT_LIST_HEAD(&fcport->gnl_entry);
+ INIT_LIST_HEAD(&fcport->list);
+
+Thus, possible null-pointer dereferences may occur.
+
+To fix these bugs, qla2x00_alloc_fcport() directly returns NULL
+in the error handling code.
+
+These bugs are found by a static analysis tool STCheck written by us.
+
+Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -4882,7 +4882,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vh
+ ql_log(ql_log_warn, vha, 0xd049,
+ "Failed to allocate ct_sns request.\n");
+ kfree(fcport);
+- fcport = NULL;
++ return NULL;
+ }
+
+ INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
diff --git a/patches.drivers/scsi-qla2xxx-Fix-premature-timer-expiration.patch b/patches.drivers/scsi-qla2xxx-Fix-premature-timer-expiration.patch
new file mode 100644
index 0000000000..c6d6e3ec0b
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-premature-timer-expiration.patch
@@ -0,0 +1,108 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:33 -0700
+Subject: scsi: qla2xxx: Fix premature timer expiration
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 3a4b6cc7332130ac5cbf3b505d8cddf0aa2ea745
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+For any qla2xxx async command, the SRB buffer is used to send it. In
+setting up the SRB buffer, the timer for this command is started before all
+memory allocation has finished. Under low memory pressure, memory alloc
+can go to sleep and not wake up before the timer expires. Once timer has
+expired, the timer thread will access uninitialize fields resulting into
+NULL pointer crash.
+
+This patch fixes this crash by moving the start of timer after everything
+is setup.
+
+backtrace shows following
+
+PID: 3720 TASK: ffff996928401040 CPU: 0 COMMAND: "qla2xxx_1_dpc"
+0 [ffff99652751b698] __schedule at ffffffff965676c7
+1 [ffff99652751b728] schedule at ffffffff96567bc9
+2 [ffff99652751b738] schedule_timeout at ffffffff965655e8
+3 [ffff99652751b7e0] io_schedule_timeout at ffffffff9656726d
+4 [ffff99652751b810] congestion_wait at ffffffff95fd8d12
+5 [ffff99652751b870] isolate_migratepages_range at ffffffff95fddaf3
+6 [ffff99652751b930] compact_zone at ffffffff95fdde96
+7 [ffff99652751b980] compact_zone_order at ffffffff95fde0bc
+8 [ffff99652751ba20] try_to_compact_pages at ffffffff95fde481
+9 [ffff99652751ba80] __alloc_pages_direct_compact at ffffffff9655cc31
+10 [ffff99652751bae0] __alloc_pages_slowpath at ffffffff9655d101
+11 [ffff99652751bbd0] __alloc_pages_nodemask at ffffffff95fc0e95
+12 [ffff99652751bc80] dma_generic_alloc_coherent at ffffffff95e3217f
+13 [ffff99652751bcc8] x86_swiotlb_alloc_coherent at ffffffff95e6b7a1
+14 [ffff99652751bcf8] qla2x00_rft_id at ffffffffc055b5e0 [qla2xxx]
+15 [ffff99652751bd50] qla2x00_loop_resync at ffffffffc0533e71 [qla2xxx]
+16 [ffff99652751be68] qla2x00_do_dpc at ffffffffc05210ca [qla2xxx]
+
+PID: 0 TASK: ffffffff96a18480 CPU: 0 COMMAND: "swapper/0"
+ 0 [ffff99652fc03ae0] machine_kexec at ffffffff95e63674
+ 1 [ffff99652fc03b40] __crash_kexec at ffffffff95f1ce12
+ 2 [ffff99652fc03c10] crash_kexec at ffffffff95f1cf00
+ 3 [ffff99652fc03c28] oops_end at ffffffff9656c758
+ 4 [ffff99652fc03c50] no_context at ffffffff9655aa7e
+ 5 [ffff99652fc03ca0] __bad_area_nosemaphore at ffffffff9655ab15
+ 6 [ffff99652fc03cf0] bad_area_nosemaphore at ffffffff9655ac86
+ 7 [ffff99652fc03d00] __do_page_fault at ffffffff9656f6b0
+ 8 [ffff99652fc03d70] do_page_fault at ffffffff9656f915
+ 9 [ffff99652fc03da0] page_fault at ffffffff9656b758
+ [exception RIP: unknown or invalid address]
+ RIP: 0000000000000000 RSP: ffff99652fc03e50 RFLAGS: 00010202
+ RAX: 0000000000000000 RBX: ffff99652b79a600 RCX: ffff99652b79a760
+ RDX: ffff99652b79a600 RSI: ffffffffc0525ad0 RDI: ffff99652b79a600
+ RBP: ffff99652fc03e60 R8: ffffffff96a18a18 R9: ffffffff96ee3c00
+ R10: 0000000000000002 R11: ffff99652fc03de8 R12: ffff99652b79a760
+ R13: 0000000000000100 R14: ffffffffc0525ad0 R15: ffff99652b79a600
+ ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
+10 [ffff99652fc03e50] qla2x00_sp_timeout at ffffffffc0525af8 [qla2xxx]
+11 [ffff99652fc03e68] call_timer_fn at ffffffff95ea7f58
+12 [ffff99652fc03ea0] run_timer_softirq at ffffffff95eaa3bd
+13 [ffff99652fc03f18] __do_softirq at ffffffff95ea0f05
+14 [ffff99652fc03f88] call_softirq at ffffffff9657832c
+15 [ffff99652fc03fa0] do_softirq at ffffffff95e2e675
+16 [ffff99652fc03fc0] irq_exit at ffffffff95ea1285
+17 [ffff99652fc03fd8] smp_apic_timer_interrupt at ffffffff965796c8
+18 [ffff99652fc03ff0] apic_timer_interrupt at ffffffff96575df2
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1 +
+ drivers/scsi/qla2xxx/qla_iocb.c | 5 ++++-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -536,6 +536,7 @@ typedef struct srb {
+ wait_queue_head_t nvme_ls_waitq;
+ struct fc_port *fcport;
+ struct scsi_qla_host *vha;
++ unsigned int start_timer:1;
+ uint32_t handle;
+ uint16_t flags;
+ uint16_t type;
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -2580,7 +2580,7 @@ qla2x00_init_timer(srb_t *sp, unsigned l
+ sp->free = qla2x00_sp_free;
+ if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
+ init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
+- add_timer(&sp->u.iocb_cmd.timer);
++ sp->start_timer = 1;
+ }
+
+ static void
+@@ -3745,6 +3745,9 @@ qla2x00_start_sp(srb_t *sp)
+ break;
+ }
+
++ if (sp->start_timer)
++ add_timer(&sp->u.iocb_cmd.timer);
++
+ wmb();
+ qla2x00_start_iocbs(vha, qp->req);
+ done:
diff --git a/patches.drivers/scsi-qla2xxx-Fix-race-conditions-in-the-code-for-abo.patch b/patches.drivers/scsi-qla2xxx-Fix-race-conditions-in-the-code-for-abo.patch
new file mode 100644
index 0000000000..d0c630d7ed
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-race-conditions-in-the-code-for-abo.patch
@@ -0,0 +1,359 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:35 -0700
+Subject: scsi: qla2xxx: Fix race conditions in the code for aborting SCSI
+ commands
+Patch-mainline: v5.2-rc1
+Git-commit: 219d27d7147e07fe899a781bd72f9180b78c3852
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+In the *_done() functions, instead of returning early if sp->ref_count >=
+2, only decrement sp->ref_count. In qla2xxx_eh_abort(), instead of deciding
+what to do based on the value of sp->ref_count, decide which action to take
+depending on the completion status of the firmware abort. Remove srb.cwaitq
+and use srb.comp instead. In qla2x00_abort_srb(), call
+isp_ops->abort_command() directly instead of calling qla2xxx_eh_abort().
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1
+ drivers/scsi/qla2xxx/qla_nvme.c | 34 --------
+ drivers/scsi/qla2xxx/qla_nvme.h | 1
+ drivers/scsi/qla2xxx/qla_os.c | 161 +++++++++++++---------------------------
+ 4 files changed, 56 insertions(+), 141 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -546,7 +546,6 @@ typedef struct srb {
+ int rc;
+ int retry_count;
+ struct completion *comp;
+- wait_queue_head_t *cwaitq;
+ union {
+ struct srb_iocb iocb_cmd;
+ struct bsg_job *bsg_job;
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -137,8 +137,7 @@ static void qla_nvme_sp_ls_done(void *pt
+ return;
+ }
+
+- if (!atomic_dec_and_test(&sp->ref_count))
+- return;
++ atomic_dec(&sp->ref_count);
+
+ if (res)
+ res = -EINVAL;
+@@ -161,8 +160,7 @@ static void qla_nvme_sp_done(void *ptr,
+ nvme = &sp->u.iocb_cmd;
+ fd = nvme->u.nvme.desc;
+
+- if (!atomic_dec_and_test(&sp->ref_count))
+- return;
++ atomic_dec(&sp->ref_count);
+
+ if (res == QLA_SUCCESS) {
+ fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
+@@ -611,34 +609,6 @@ static struct nvme_fc_port_template qla_
+ .fcprqst_priv_sz = sizeof(struct nvme_private),
+ };
+
+-#define NVME_ABORT_POLLING_PERIOD 2
+-static int qla_nvme_wait_on_command(srb_t *sp)
+-{
+- int ret = QLA_SUCCESS;
+-
+- wait_event_timeout(sp->nvme_ls_waitq, (atomic_read(&sp->ref_count) > 1),
+- NVME_ABORT_POLLING_PERIOD*HZ);
+-
+- if (atomic_read(&sp->ref_count) > 1)
+- ret = QLA_FUNCTION_FAILED;
+-
+- return ret;
+-}
+-
+-void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res)
+-{
+- int rval;
+-
+- if (ha->flags.fw_started) {
+- rval = ha->isp_ops->abort_command(sp);
+- if (!rval && !qla_nvme_wait_on_command(sp))
+- ql_log(ql_log_warn, NULL, 0x2112,
+- "timed out waiting on sp=%p\n", sp);
+- } else {
+- sp->done(sp, res);
+- }
+-}
+-
+ static void qla_nvme_unregister_remote_port(struct work_struct *work)
+ {
+ struct fc_port *fcport = container_of(work, struct fc_port,
+--- a/drivers/scsi/qla2xxx/qla_nvme.h
++++ b/drivers/scsi/qla2xxx/qla_nvme.h
+@@ -145,7 +145,6 @@ struct pt_ls4_rx_unsol {
+ int qla_nvme_register_hba(struct scsi_qla_host *);
+ int qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *);
+ void qla_nvme_delete(struct scsi_qla_host *);
+-void qla_nvme_abort(struct qla_hw_data *, struct srb *sp, int res);
+ void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
+ struct req_que *);
+ void qla24xx_async_gffid_sp_done(void *, int);
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -23,23 +23,6 @@
+
+ #include "qla_target.h"
+
+-#define __wait_event_lock_irq_timeout(wq_head, condition, lock, timeout, state) \
+- ___wait_event(wq_head, ___wait_cond_timeout(condition), \
+- state, 0, timeout, \
+- spin_unlock_irq(&lock); \
+- __ret = schedule_timeout(__ret); \
+- spin_lock_irq(&lock));
+-
+-#define wait_event_lock_irq_timeout(wq_head, condition, lock, timeout) \
+-({ \
+- long __ret = timeout; \
+- if (!___wait_cond_timeout(condition)) \
+- __ret = __wait_event_lock_irq_timeout( \
+- wq_head, condition, lock, timeout, \
+- TASK_UNINTERRUPTIBLE); \
+- __ret; \
+-})
+-
+ /*
+ * Driver version
+ */
+@@ -733,7 +716,7 @@ qla2x00_sp_compl(void *ptr, int res)
+ {
+ srb_t *sp = ptr;
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+- wait_queue_head_t *cwaitq = sp->cwaitq;
++ struct completion *comp = sp->comp;
+
+ if (atomic_read(&sp->ref_count) == 0) {
+ ql_dbg(ql_dbg_io, sp->vha, 0x3015,
+@@ -743,15 +726,15 @@ qla2x00_sp_compl(void *ptr, int res)
+ WARN_ON(atomic_read(&sp->ref_count) == 0);
+ return;
+ }
+- if (!atomic_dec_and_test(&sp->ref_count))
+- return;
++
++ atomic_dec(&sp->ref_count);
+
+ sp->free(sp);
+ cmd->result = res;
+ CMD_SP(cmd) = NULL;
+ cmd->scsi_done(cmd);
+- if (cwaitq)
+- wake_up(cwaitq);
++ if (comp)
++ complete(comp);
+ qla2x00_rel_sp(sp);
+ }
+
+@@ -844,7 +827,7 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ {
+ srb_t *sp = ptr;
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+- wait_queue_head_t *cwaitq = sp->cwaitq;
++ struct completion *comp = sp->comp;
+
+ if (atomic_read(&sp->ref_count) == 0) {
+ ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079,
+@@ -854,15 +837,15 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ WARN_ON(atomic_read(&sp->ref_count) == 0);
+ return;
+ }
+- if (!atomic_dec_and_test(&sp->ref_count))
+- return;
++
++ atomic_dec(&sp->ref_count);
+
+ sp->free(sp);
+ cmd->result = res;
+ CMD_SP(cmd) = NULL;
+ cmd->scsi_done(cmd);
+- if (cwaitq)
+- wake_up(cwaitq);
++ if (comp)
++ complete(comp);
+ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+@@ -1309,7 +1292,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ unsigned int id;
+ uint64_t lun;
+ unsigned long flags;
+- int rval, wait = 0;
++ int rval;
+ struct qla_hw_data *ha = vha->hw;
+ struct qla_qpair *qpair;
+
+@@ -1322,7 +1305,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ ret = fc_block_scsi_eh(cmd);
+ if (ret != 0)
+ return ret;
+- ret = SUCCESS;
+
+ sp = (srb_t *) CMD_SP(cmd);
+ if (!sp)
+@@ -1333,7 +1315,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ return SUCCESS;
+
+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
+- if (!CMD_SP(cmd)) {
++ if (sp->type != SRB_SCSI_CMD || GET_CMD_SP(sp) != cmd) {
+ /* there's a chance an interrupt could clear
+ the ptr as part of done & free */
+ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+@@ -1354,66 +1336,31 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n",
+ vha->host_no, id, lun, sp, cmd, sp->handle);
+
+- /* Get a reference to the sp and drop the lock.*/
+ rval = ha->isp_ops->abort_command(sp);
+- if (rval) {
+- if (rval == QLA_FUNCTION_PARAMETER_ERROR)
+- ret = SUCCESS;
+- else
+- ret = FAILED;
+-
+- ql_dbg(ql_dbg_taskm, vha, 0x8003,
+- "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval);
+- } else {
+- ql_dbg(ql_dbg_taskm, vha, 0x8004,
+- "Abort command mbx success cmd=%p.\n", cmd);
+- wait = 1;
+- }
++ ql_dbg(ql_dbg_taskm, vha, 0x8003,
++ "Abort command mbx cmd=%p, rval=%x.\n", cmd, rval);
+
+- spin_lock_irqsave(qpair->qp_lock_ptr, flags);
+-
+- /*
+- * Releasing of the SRB and associated command resources
+- * is managed through ref_count.
+- * Whether we need to wait for the abort completion or complete
+- * the abort handler should be based on the ref_count.
+- */
+- if (atomic_read(&sp->ref_count) > 1) {
++ switch (rval) {
++ case QLA_SUCCESS:
+ /*
+- * The command is not yet completed. We need to wait for either
+- * command completion or abort completion.
++ * The command has been aborted. That means that the firmware
++ * won't report a completion.
+ */
+- DECLARE_WAIT_QUEUE_HEAD_ONSTACK(eh_waitq);
+- uint32_t ratov = ha->r_a_tov/10;
+-
+- /* Go ahead and release the extra ref_count obtained earlier */
+- sp->done(sp, DID_RESET << 16);
+- sp->cwaitq = &eh_waitq;
+-
+- if (!wait_event_lock_irq_timeout(eh_waitq,
+- CMD_SP(cmd) == NULL, *qpair->qp_lock_ptr,
+- msecs_to_jiffies(4 * ratov * 1000))) {
+- /*
+- * The abort got dropped, LOGO will be sent and the
+- * original command will be completed with CS_TIMEOUT
+- * completion
+- */
+- ql_dbg(ql_dbg_taskm, vha, 0xffff,
+- "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n",
+- __func__, ha->r_a_tov);
+- sp->cwaitq = NULL;
+- ret = FAILED;
+- goto end;
+- }
+- } else {
+- /* Command completed while processing the abort */
+- sp->done(sp, DID_RESET << 16);
++ sp->done(sp, DID_ABORT << 16);
++ ret = SUCCESS;
++ break;
++ default:
++ /*
++ * Either abort failed or abort and completion raced. Let
++ * the SCSI core retry the abort in the former case.
++ */
++ ret = FAILED;
++ break;
+ }
+-end:
+- spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
++
+ ql_log(ql_log_info, vha, 0x801c,
+- "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n",
+- vha->host_no, id, lun, wait, ret);
++ "Abort command issued nexus=%ld:%d:%llu -- %x.\n",
++ vha->host_no, id, lun, ret);
+
+ return ret;
+ }
+@@ -1789,34 +1736,34 @@ static void qla2x00_abort_srb(struct qla
+ __releases(qp->qp_lock_ptr)
+ __acquires(qp->qp_lock_ptr)
+ {
++ DECLARE_COMPLETION_ONSTACK(comp);
+ scsi_qla_host_t *vha = qp->vha;
+ struct qla_hw_data *ha = vha->hw;
++ int rval;
+
+- if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) {
+- if (!sp_get(sp)) {
+- /* got sp */
+- spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
+- qla_nvme_abort(ha, sp, res);
+- spin_lock_irqsave(qp->qp_lock_ptr, *flags);
+- }
+- } else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
+- !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
+- !qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) {
+- /*
+- * Don't abort commands in adapter during EEH recovery as it's
+- * not accessible/responding.
+- *
+- * Get a reference to the sp and drop the lock. The reference
+- * ensures this sp->done() call and not the call in
+- * qla2xxx_eh_abort() ends the SCSI cmd (with result 'res').
+- */
+- if (!sp_get(sp)) {
+- spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
+- qla2xxx_eh_abort(GET_CMD_SP(sp));
+- spin_lock_irqsave(qp->qp_lock_ptr, *flags);
++ if (sp_get(sp))
++ return;
++
++ if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS ||
++ (sp->type == SRB_SCSI_CMD && !ha->flags.eeh_busy &&
++ !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
++ !qla2x00_isp_reg_stat(ha))) {
++ sp->comp = &comp;
++ rval = ha->isp_ops->abort_command(sp);
++ spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
++
++ switch (rval) {
++ case QLA_SUCCESS:
++ sp->done(sp, res);
++ break;
++ case QLA_FUNCTION_PARAMETER_ERROR:
++ wait_for_completion(&comp);
++ break;
+ }
++
++ spin_lock_irqsave(qp->qp_lock_ptr, *flags);
++ sp->comp = NULL;
+ }
+- sp->done(sp, res);
+ }
+
+ static void
diff --git a/patches.drivers/scsi-qla2xxx-Fix-use-after-free-issues-in-qla2xxx_qp.patch b/patches.drivers/scsi-qla2xxx-Fix-use-after-free-issues-in-qla2xxx_qp.patch
new file mode 100644
index 0000000000..18b38e4227
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Fix-use-after-free-issues-in-qla2xxx_qp.patch
@@ -0,0 +1,85 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:25 -0700
+Subject: scsi: qla2xxx: Fix use-after-free issues in
+ qla2xxx_qpair_sp_free_dma()
+Patch-mainline: v5.2-rc1
+Git-commit: d8f945bf8096375f458683b5718722a2d5dda2f0
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The current order for freeing memory is as follows:
+- struct crc_context itself.
+- struct crc_context member pointers.
+
+Change the freeing order into the following:
+- struct crc_context member pointers.
+- struct crc_context itself.
+
+Detected by Coverity.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: 50b812755e97 ("scsi: qla2xxx: Fix DMA error when the DIF sg buffer crosses 4GB boundary") # v5.1-rc1.
+Fixes: d74595278f4a ("scsi: qla2xxx: Add multiple queue pair functionality.") # v4.10.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 38 ++++++++++++++++++++------------------
+ 1 file changed, 20 insertions(+), 18 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -783,25 +783,8 @@ qla2xxx_qpair_sp_free_dma(void *ptr)
+ sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
+ }
+
+- if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
+- struct crc_context *ctx0 = ctx;
+-
+- dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma);
+- sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
+- }
+-
+- if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
+- struct ct6_dsd *ctx1 = ctx;
+- dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
+- ctx1->fcp_cmnd_dma);
+- list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
+- ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
+- ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
+- mempool_free(ctx1, ha->ctx_mempool);
+- sp->flags &= ~SRB_FCP_CMND_DMA_VALID;
+- }
+ if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) {
+- struct crc_context *difctx = sp->u.scmd.ctx;
++ struct crc_context *difctx = ctx;
+ struct dsd_dma *dif_dsd, *nxt_dsd;
+
+ list_for_each_entry_safe(dif_dsd, nxt_dsd,
+@@ -835,6 +818,25 @@ qla2xxx_qpair_sp_free_dma(void *ptr)
+ }
+ sp->flags &= ~SRB_DIF_BUNDL_DMA_VALID;
+ }
++
++ if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
++ struct ct6_dsd *ctx1 = ctx;
++
++ dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
++ ctx1->fcp_cmnd_dma);
++ list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
++ ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
++ ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
++ mempool_free(ctx1, ha->ctx_mempool);
++ sp->flags &= ~SRB_FCP_CMND_DMA_VALID;
++ }
++
++ if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
++ struct crc_context *ctx0 = ctx;
++
++ dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma);
++ sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
++ }
+ }
+
+ void
diff --git a/patches.drivers/scsi-qla2xxx-Further-limit-FLASH-region-write-access.patch b/patches.drivers/scsi-qla2xxx-Further-limit-FLASH-region-write-access.patch
new file mode 100644
index 0000000000..c5ed00dba7
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Further-limit-FLASH-region-write-access.patch
@@ -0,0 +1,44 @@
+From: Andrew Vasquez <andrewv@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:26 -0700
+Subject: scsi: qla2xxx: Further limit FLASH region write access from SysFS
+Patch-mainline: v5.2-rc1
+Git-commit: e81d1bcbde06ad2b6413b1d75630a1a8c19175d0
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Recent ISPs have larger and more complex flash-write semantics
+(secure-access and signing). The BSG interfaces support these semantics for
+all ISPs and is exclusively used by QLogic user-space tools. Limit
+flash-write operations to ISPs <= 25xx.
+
+Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -430,6 +430,10 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ * 0x000000 -> 0x07ffff -- Boot code.
+ * 0x080000 -> 0x0fffff -- Firmware.
+ * 0x120000 -> 0x12ffff -- VPD and HBA parameters.
++ *
++ * > ISP25xx type boards:
++ *
++ * None -- should go through BSG.
+ */
+ valid = 0;
+ if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
+@@ -437,9 +441,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ else if (start == (ha->flt_region_boot * 4) ||
+ start == (ha->flt_region_fw * 4))
+ valid = 1;
+- else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)
+- || IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)
+- || IS_QLA27XX(ha) || IS_QLA28XX(ha))
++ else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha))
+ valid = 1;
+ if (!valid) {
+ ql_log(ql_log_warn, vha, 0x7065,
diff --git a/patches.drivers/scsi-qla2xxx-Increase-the-max_sgl_segments-to-1024.patch b/patches.drivers/scsi-qla2xxx-Increase-the-max_sgl_segments-to-1024.patch
new file mode 100644
index 0000000000..01f334a822
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Increase-the-max_sgl_segments-to-1024.patch
@@ -0,0 +1,32 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:23 -0700
+Subject: scsi: qla2xxx: Increase the max_sgl_segments to 1024
+Patch-mainline: v5.2-rc1
+Git-commit: 6b1f44466d9b3d7de04e4988a680f0e1a0850360
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch increases max_sgl_segments value from 128 to the maximum
+supported which is 1024. Increasing max_sgl_segments will allow the driver
+to support larger I/O sizes
+
+[mkp: commit desc tweak]
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -585,7 +585,7 @@ static struct nvme_fc_port_template qla_
+ .fcp_abort = qla_nvme_fcp_abort,
+ .poll_queue = qla_nvme_poll,
+ .max_hw_queues = 8,
+- .max_sgl_segments = 128,
++ .max_sgl_segments = 1024,
+ .max_dif_sgl_segments = 64,
+ .dma_boundary = 0xFFFFFFFF,
+ .local_priv_sz = 8,
diff --git a/patches.drivers/scsi-qla2xxx-Increase-the-size-of-the-mailbox-arrays.patch b/patches.drivers/scsi-qla2xxx-Increase-the-size-of-the-mailbox-arrays.patch
new file mode 100644
index 0000000000..1afdc02601
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Increase-the-size-of-the-mailbox-arrays.patch
@@ -0,0 +1,82 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:21 -0700
+Subject: scsi: qla2xxx: Increase the size of the mailbox arrays from 4 to 8
+Patch-mainline: v5.2-rc1
+Git-commit: 0a59cea487e4d3c04364f29df241c9f7001ac6ff
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch avoids that Coverity complains that qla2x00_async_event() writes
+outside the bounds of the mb[] arrays (MBA_IDC_AEN case).
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 4 ++--
+ drivers/scsi/qla2xxx/qla_nx.c | 6 +++---
+ drivers/scsi/qla2xxx/qla_nx2.c | 2 +-
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -49,7 +49,7 @@ qla2100_intr_handler(int irq, void *dev_
+ int status;
+ unsigned long iter;
+ uint16_t hccr;
+- uint16_t mb[4];
++ uint16_t mb[8];
+ struct rsp_que *rsp;
+ unsigned long flags;
+
+@@ -168,7 +168,7 @@ qla2300_intr_handler(int irq, void *dev_
+ unsigned long iter;
+ uint32_t stat;
+ uint16_t hccr;
+- uint16_t mb[4];
++ uint16_t mb[8];
+ struct rsp_que *rsp;
+ struct qla_hw_data *ha;
+ unsigned long flags;
+--- a/drivers/scsi/qla2xxx/qla_nx.c
++++ b/drivers/scsi/qla2xxx/qla_nx.c
+@@ -2039,7 +2039,7 @@ qla82xx_intr_handler(int irq, void *dev_
+ unsigned long flags;
+ unsigned long iter;
+ uint32_t stat = 0;
+- uint16_t mb[4];
++ uint16_t mb[8];
+
+ rsp = (struct rsp_que *) dev_id;
+ if (!rsp) {
+@@ -2123,7 +2123,7 @@ qla82xx_msix_default(int irq, void *dev_
+ unsigned long flags;
+ uint32_t stat = 0;
+ uint32_t host_int = 0;
+- uint16_t mb[4];
++ uint16_t mb[8];
+
+ rsp = (struct rsp_que *) dev_id;
+ if (!rsp) {
+@@ -2219,7 +2219,7 @@ qla82xx_poll(int irq, void *dev_id)
+ int status = 0;
+ uint32_t stat;
+ uint32_t host_int = 0;
+- uint16_t mb[4];
++ uint16_t mb[8];
+ unsigned long flags;
+
+ rsp = (struct rsp_que *) dev_id;
+--- a/drivers/scsi/qla2xxx/qla_nx2.c
++++ b/drivers/scsi/qla2xxx/qla_nx2.c
+@@ -3895,7 +3895,7 @@ qla8044_intr_handler(int irq, void *dev_
+ unsigned long flags;
+ unsigned long iter;
+ uint32_t stat;
+- uint16_t mb[4];
++ uint16_t mb[8];
+ uint32_t leg_int_ptr = 0, pf_bit;
+
+ rsp = (struct rsp_que *) dev_id;
diff --git a/patches.drivers/scsi-qla2xxx-Insert-spaces-where-required.patch b/patches.drivers/scsi-qla2xxx-Insert-spaces-where-required.patch
new file mode 100644
index 0000000000..e674041bd3
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Insert-spaces-where-required.patch
@@ -0,0 +1,224 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:19 -0700
+Subject: scsi: qla2xxx: Insert spaces where required
+Patch-mainline: v5.2-rc1
+Git-commit: 58e2753c1163ebce9be0c8938cac2f237716eda1
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Improve source code readability by inserting spaces where these are
+required according to the coding standard. This patch only inserts
+whitespace and does not make any other changes.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 6 +++---
+ drivers/scsi/qla2xxx/qla_dbg.c | 2 +-
+ drivers/scsi/qla2xxx/qla_gs.c | 2 +-
+ drivers/scsi/qla2xxx/qla_init.c | 22 +++++++++++-----------
+ drivers/scsi/qla2xxx/qla_iocb.c | 2 +-
+ drivers/scsi/qla2xxx/qla_mbx.c | 4 ++--
+ drivers/scsi/qla2xxx/qla_os.c | 4 ++--
+ drivers/scsi/qla2xxx/qla_sup.c | 2 +-
+ drivers/scsi/qla2xxx/qla_target.h | 2 +-
+ 9 files changed, 23 insertions(+), 23 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -888,7 +888,7 @@ do_read:
+ count = 0;
+ }
+
+- count = actual_size > count ? count: actual_size;
++ count = actual_size > count ? count : actual_size;
+ memcpy(buf, ha->xgmac_data, count);
+
+ return count;
+@@ -2811,8 +2811,8 @@ qla24xx_vport_create(struct fc_vport *fc
+
+ /* initialized vport states */
+ atomic_set(&vha->loop_state, LOOP_DOWN);
+- vha->vp_err_state= VP_ERR_PORTDWN;
+- vha->vp_prev_err_state= VP_ERR_UNKWN;
++ vha->vp_err_state = VP_ERR_PORTDWN;
++ vha->vp_prev_err_state = VP_ERR_UNKWN;
+ /* Check if physical ha port is Up */
+ if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
+ atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
+--- a/drivers/scsi/qla2xxx/qla_dbg.c
++++ b/drivers/scsi/qla2xxx/qla_dbg.c
+@@ -445,7 +445,7 @@ qla2xxx_dump_ram(struct qla_hw_data *ha,
+ }
+ }
+
+- *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL;
++ *nxt = rval == QLA_SUCCESS ? &ram[cnt] : NULL;
+ return rval;
+ }
+
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -2448,7 +2448,7 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha)
+ eiter->type = cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
+ eiter->len = cpu_to_be16(4 + 4);
+ eiter->a.max_frame_size = IS_FWI2_CAPABLE(ha) ?
+- le16_to_cpu(icb24->frame_payload_size):
++ le16_to_cpu(icb24->frame_payload_size) :
+ le16_to_cpu(ha->init_cb->frame_payload_size);
+ eiter->a.max_frame_size = cpu_to_be32(eiter->a.max_frame_size);
+ size += 4 + 4;
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -4711,7 +4711,7 @@ qla2x00_nvram_config(scsi_qla_host_t *vh
+ ha->zio_mode = icb->add_firmware_options[0] &
+ (BIT_3 | BIT_2 | BIT_1 | BIT_0);
+ ha->zio_timer = icb->interrupt_delay_timer ?
+- icb->interrupt_delay_timer: 2;
++ icb->interrupt_delay_timer : 2;
+ }
+ icb->add_firmware_options[0] &=
+ ~(BIT_3 | BIT_2 | BIT_1 | BIT_0);
+@@ -4744,7 +4744,7 @@ qla2x00_rport_del(void *data)
+ unsigned long flags;
+
+ spin_lock_irqsave(fcport->vha->host->host_lock, flags);
+- rport = fcport->drport ? fcport->drport: fcport->rport;
++ rport = fcport->drport ? fcport->drport : fcport->rport;
+ fcport->drport = NULL;
+ spin_unlock_irqrestore(fcport->vha->host->host_lock, flags);
+ if (rport) {
+@@ -7208,11 +7208,11 @@ qla24xx_nvram_config(scsi_qla_host_t *vh
+ ha->flags.disable_risc_code_load = 0;
+ ha->flags.enable_lip_reset = 0;
+ ha->flags.enable_lip_full_login =
+- le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0;
++ le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0;
+ ha->flags.enable_target_reset =
+- le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0;
++ le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0;
+ ha->flags.enable_led_scheme = 0;
+- ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0;
++ ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0;
+
+ ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) &
+ (BIT_6 | BIT_5 | BIT_4)) >> 4;
+@@ -7286,7 +7286,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vh
+ ha->zio_mode = le32_to_cpu(icb->firmware_options_2) &
+ (BIT_3 | BIT_2 | BIT_1 | BIT_0);
+ ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
+- le16_to_cpu(icb->interrupt_delay_timer): 2;
++ le16_to_cpu(icb->interrupt_delay_timer) : 2;
+ }
+ icb->firmware_options_2 &= cpu_to_le32(
+ ~(BIT_3 | BIT_2 | BIT_1 | BIT_0));
+@@ -8232,7 +8232,7 @@ qla84xx_init_chip(scsi_qla_host_t *vha)
+
+ mutex_unlock(&ha->cs84xx->fw_update_mutex);
+
+- return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED:
++ return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED :
+ QLA_SUCCESS;
+ }
+
+@@ -8428,11 +8428,11 @@ qla81xx_nvram_config(scsi_qla_host_t *vh
+ ha->flags.disable_risc_code_load = 0;
+ ha->flags.enable_lip_reset = 0;
+ ha->flags.enable_lip_full_login =
+- le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0;
++ le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0;
+ ha->flags.enable_target_reset =
+- le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0;
++ le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0;
+ ha->flags.enable_led_scheme = 0;
+- ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0;
++ ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0;
+
+ ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) &
+ (BIT_6 | BIT_5 | BIT_4)) >> 4;
+@@ -8505,7 +8505,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vh
+ ha->zio_mode = le32_to_cpu(icb->firmware_options_2) &
+ (BIT_3 | BIT_2 | BIT_1 | BIT_0);
+ ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
+- le16_to_cpu(icb->interrupt_delay_timer): 2;
++ le16_to_cpu(icb->interrupt_delay_timer) : 2;
+ }
+ icb->firmware_options_2 &= cpu_to_le32(
+ ~(BIT_3 | BIT_2 | BIT_1 | BIT_0));
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -2499,7 +2499,7 @@ qla2x00_logout_iocb(srb_t *sp, struct mb
+ SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id);
+ mbx->mb0 = cpu_to_le16(MBC_LOGOUT_FABRIC_PORT);
+ mbx->mb1 = HAS_EXTENDED_IDS(ha) ?
+- cpu_to_le16(sp->fcport->loop_id):
++ cpu_to_le16(sp->fcport->loop_id) :
+ cpu_to_le16(sp->fcport->loop_id << 8);
+ mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain);
+ mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 |
+--- a/drivers/scsi/qla2xxx/qla_mbx.c
++++ b/drivers/scsi/qla2xxx/qla_mbx.c
+@@ -2033,7 +2033,7 @@ qla2x00_get_port_database(scsi_qla_host_
+
+ /* Passback COS information. */
+ fcport->supported_classes = (pd->options & BIT_4) ?
+- FC_COS_CLASS2: FC_COS_CLASS3;
++ FC_COS_CLASS2 : FC_COS_CLASS3;
+ }
+
+ gpd_error_out:
+@@ -3277,7 +3277,7 @@ __qla24xx_issue_tmf(char *name, uint32_t
+
+ /* Issue marker IOCB. */
+ rval2 = qla2x00_marker(vha, ha->base_qpair, fcport->loop_id, l,
+- type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
++ type == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
+ if (rval2 != QLA_SUCCESS) {
+ ql_dbg(ql_dbg_mbx, vha, 0x1099,
+ "Failed to issue marker IOCB (%x).\n", rval2);
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -125,7 +125,7 @@ MODULE_PARM_DESC(ql2xshiftctondsd,
+ "Set to control shifting of command type processing "
+ "based on total number of SG elements.");
+
+-int ql2xfdmienable=1;
++int ql2xfdmienable = 1;
+ module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR);
+ module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR);
+ MODULE_PARM_DESC(ql2xfdmienable,
+@@ -171,7 +171,7 @@ MODULE_PARM_DESC(ql2xenablehba_err_chk,
+ " 1 -- Error isolation enabled only for DIX Type 0\n"
+ " 2 -- Error isolation enabled for all Types\n");
+
+-int ql2xiidmaenable=1;
++int ql2xiidmaenable = 1;
+ module_param(ql2xiidmaenable, int, S_IRUGO);
+ MODULE_PARM_DESC(ql2xiidmaenable,
+ "Enables iIDMA settings "
+--- a/drivers/scsi/qla2xxx/qla_sup.c
++++ b/drivers/scsi/qla2xxx/qla_sup.c
+@@ -987,7 +987,7 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *vh
+ ha->fdt_unprotect_sec_cmd = flash_conf_addr(ha, 0x0300 |
+ fdt->unprotect_sec_cmd);
+ ha->fdt_protect_sec_cmd = fdt->protect_sec_cmd ?
+- flash_conf_addr(ha, 0x0300 | fdt->protect_sec_cmd):
++ flash_conf_addr(ha, 0x0300 | fdt->protect_sec_cmd) :
+ flash_conf_addr(ha, 0x0336);
+ }
+ goto done;
+--- a/drivers/scsi/qla2xxx/qla_target.h
++++ b/drivers/scsi/qla2xxx/qla_target.h
+@@ -855,7 +855,7 @@ enum trace_flags {
+ TRC_CTIO_ERR = BIT_11,
+ TRC_CTIO_DONE = BIT_12,
+ TRC_CTIO_ABORTED = BIT_13,
+- TRC_CTIO_STRANGE= BIT_14,
++ TRC_CTIO_STRANGE = BIT_14,
+ TRC_CMD_DONE = BIT_15,
+ TRC_CMD_CHK_STOP = BIT_16,
+ TRC_CMD_FREE = BIT_17,
diff --git a/patches.drivers/scsi-qla2xxx-Leave-a-blank-line-after-declarations.patch b/patches.drivers/scsi-qla2xxx-Leave-a-blank-line-after-declarations.patch
new file mode 100644
index 0000000000..a9892f4b41
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Leave-a-blank-line-after-declarations.patch
@@ -0,0 +1,617 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:17 -0700
+Subject: scsi: qla2xxx: Leave a blank line after declarations
+Patch-mainline: v5.2-rc1
+Git-commit: bd432bb53cffeae1ec3f77338d69bd89d9d45bb2
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch improves readability of the qla2xxx source code.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 9 +++++++++
+ drivers/scsi/qla2xxx/qla_bsg.c | 5 +++++
+ drivers/scsi/qla2xxx/qla_dfs.c | 3 +++
+ drivers/scsi/qla2xxx/qla_gs.c | 2 ++
+ drivers/scsi/qla2xxx/qla_init.c | 5 +++++
+ drivers/scsi/qla2xxx/qla_iocb.c | 2 ++
+ drivers/scsi/qla2xxx/qla_isr.c | 3 +++
+ drivers/scsi/qla2xxx/qla_mbx.c | 1 +
+ drivers/scsi/qla2xxx/qla_mr.c | 2 ++
+ drivers/scsi/qla2xxx/qla_nvme.c | 1 +
+ drivers/scsi/qla2xxx/qla_nx.c | 12 ++++++++++++
+ drivers/scsi/qla2xxx/qla_nx2.c | 3 +--
+ drivers/scsi/qla2xxx/qla_os.c | 5 +++++
+ drivers/scsi/qla2xxx/qla_target.c | 18 ++++++++++++++++++
+ 14 files changed, 69 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -674,6 +674,7 @@ qla2x00_sysfs_write_reset(struct file *f
+ int type;
+ uint32_t idc_control;
+ uint8_t *tmp_data = NULL;
++
+ if (off != 0)
+ return -EINVAL;
+
+@@ -1079,6 +1080,7 @@ qla2x00_isp_name_show(struct device *dev
+ char *buf)
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
++
+ return scnprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
+ }
+
+@@ -1112,6 +1114,7 @@ qla2x00_model_desc_show(struct device *d
+ char *buf)
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
++
+ return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc);
+ }
+
+@@ -1324,6 +1327,7 @@ qla2x00_optrom_bios_version_show(struct
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+ struct qla_hw_data *ha = vha->hw;
++
+ return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
+ ha->bios_revision[0]);
+ }
+@@ -1334,6 +1338,7 @@ qla2x00_optrom_efi_version_show(struct d
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+ struct qla_hw_data *ha = vha->hw;
++
+ return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
+ ha->efi_revision[0]);
+ }
+@@ -1344,6 +1349,7 @@ qla2x00_optrom_fcode_version_show(struct
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+ struct qla_hw_data *ha = vha->hw;
++
+ return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
+ ha->fcode_revision[0]);
+ }
+@@ -1354,6 +1360,7 @@ qla2x00_optrom_fw_version_show(struct de
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+ struct qla_hw_data *ha = vha->hw;
++
+ return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
+ ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
+ ha->fw_revision[3]);
+@@ -1380,6 +1387,7 @@ qla2x00_total_isp_aborts_show(struct dev
+ struct device_attribute *attr, char *buf)
+ {
+ scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
++
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ vha->qla_stats.total_isp_aborts);
+ }
+@@ -2819,6 +2827,7 @@ qla24xx_vport_create(struct fc_vport *fc
+ if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
+ if (ha->fw_attributes & BIT_4) {
+ int prot = 0, guard;
++
+ vha->flags.difdix_supported = 1;
+ ql_dbg(ql_dbg_user, vha, 0x7082,
+ "Registered for DIF/DIX type 1 and 3 protection.\n");
+--- a/drivers/scsi/qla2xxx/qla_bsg.c
++++ b/drivers/scsi/qla2xxx/qla_bsg.c
+@@ -1535,6 +1535,7 @@ qla2x00_update_fru_versions(struct bsg_j
+ uint32_t count;
+ dma_addr_t sfp_dma;
+ void *sfp = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &sfp_dma);
++
+ if (!sfp) {
+ bsg_reply->reply_data.vendor_reply.vendor_rsp[0] =
+ EXT_STATUS_NO_MEMORY;
+@@ -1585,6 +1586,7 @@ qla2x00_read_fru_status(struct bsg_job *
+ struct qla_status_reg *sr = (void *)bsg;
+ dma_addr_t sfp_dma;
+ uint8_t *sfp = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &sfp_dma);
++
+ if (!sfp) {
+ bsg_reply->reply_data.vendor_reply.vendor_rsp[0] =
+ EXT_STATUS_NO_MEMORY;
+@@ -1635,6 +1637,7 @@ qla2x00_write_fru_status(struct bsg_job
+ struct qla_status_reg *sr = (void *)bsg;
+ dma_addr_t sfp_dma;
+ uint8_t *sfp = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &sfp_dma);
++
+ if (!sfp) {
+ bsg_reply->reply_data.vendor_reply.vendor_rsp[0] =
+ EXT_STATUS_NO_MEMORY;
+@@ -1681,6 +1684,7 @@ qla2x00_write_i2c(struct bsg_job *bsg_jo
+ struct qla_i2c_access *i2c = (void *)bsg;
+ dma_addr_t sfp_dma;
+ uint8_t *sfp = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &sfp_dma);
++
+ if (!sfp) {
+ bsg_reply->reply_data.vendor_reply.vendor_rsp[0] =
+ EXT_STATUS_NO_MEMORY;
+@@ -1726,6 +1730,7 @@ qla2x00_read_i2c(struct bsg_job *bsg_job
+ struct qla_i2c_access *i2c = (void *)bsg;
+ dma_addr_t sfp_dma;
+ uint8_t *sfp = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &sfp_dma);
++
+ if (!sfp) {
+ bsg_reply->reply_data.vendor_reply.vendor_rsp[0] =
+ EXT_STATUS_NO_MEMORY;
+--- a/drivers/scsi/qla2xxx/qla_dfs.c
++++ b/drivers/scsi/qla2xxx/qla_dfs.c
+@@ -41,6 +41,7 @@ static int
+ qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
+ {
+ scsi_qla_host_t *vha = inode->i_private;
++
+ return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
+ }
+
+@@ -161,6 +162,7 @@ static int
+ qla_dfs_fw_resource_cnt_open(struct inode *inode, struct file *file)
+ {
+ struct scsi_qla_host *vha = inode->i_private;
++
+ return single_open(file, qla_dfs_fw_resource_cnt_show, vha);
+ }
+
+@@ -250,6 +252,7 @@ static int
+ qla_dfs_tgt_counters_open(struct inode *inode, struct file *file)
+ {
+ struct scsi_qla_host *vha = inode->i_private;
++
+ return single_open(file, qla_dfs_tgt_counters_show, vha);
+ }
+
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -1385,6 +1385,7 @@ qla2x00_mgmt_svr_login(scsi_qla_host_t *
+ int ret, rval;
+ uint16_t mb[MAILBOX_REGISTER_COUNT];
+ struct qla_hw_data *ha = vha->hw;
++
+ ret = QLA_SUCCESS;
+ if (vha->flags.management_server_logged_in)
+ return ret;
+@@ -1423,6 +1424,7 @@ qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_
+ {
+ ms_iocb_entry_t *ms_pkt;
+ struct qla_hw_data *ha = vha->hw;
++
+ ms_pkt = ha->ms_iocb;
+ memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -1484,6 +1484,7 @@ int qla24xx_post_newsess_work(struct scs
+ u8 *port_name, u8 *node_name, void *pla, u8 fc4_type)
+ {
+ struct qla_work_evt *e;
++
+ e = qla2x00_alloc_work(vha, QLA_EVT_NEW_SESS);
+ if (!e)
+ return QLA_FUNCTION_FAILED;
+@@ -1560,6 +1561,7 @@ void qla2x00_fcport_event_handler(scsi_q
+ return;
+ {
+ unsigned long flags;
++
+ fcport = qla2x00_find_fcport_by_nportid
+ (vha, &ea->id, 1);
+ if (fcport) {
+@@ -4844,6 +4846,7 @@ qla2x00_configure_loop(scsi_qla_host_t *
+ int rval;
+ unsigned long flags, save_flags;
+ struct qla_hw_data *ha = vha->hw;
++
+ rval = QLA_SUCCESS;
+
+ /* Get Initiator ID */
+@@ -6406,6 +6409,7 @@ qla83xx_initiating_reset(scsi_qla_host_t
+ qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP);
+ } else {
+ const char *state = qla83xx_dev_state_to_string(dev_state);
++
+ ql_log(ql_log_info, vha, 0xb057, "HW State: %s.\n", state);
+
+ /* SV: XXX: Is timeout required here? */
+@@ -8210,6 +8214,7 @@ void
+ qla84xx_put_chip(struct scsi_qla_host *vha)
+ {
+ struct qla_hw_data *ha = vha->hw;
++
+ if (ha->cs84xx)
+ kref_put(&ha->cs84xx->kref, __qla84xx_chip_release);
+ }
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -1107,6 +1107,7 @@ qla24xx_walk_and_build_prot_sglist(struc
+
+ if (sp) {
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
++
+ sgl = scsi_prot_sglist(cmd);
+ vha = sp->vha;
+ difctx = sp->u.scmd.ctx;
+@@ -3393,6 +3394,7 @@ sufficient_dsds:
+ cmd_pkt->entry_status = (uint8_t) rsp->id;
+ } else {
+ struct cmd_type_7 *cmd_pkt;
++
+ req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
+ if (req->cnt < (req_cnt + 2)) {
+ cnt = (uint16_t)RD_REG_DWORD_RELAXED(
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -840,6 +840,7 @@ skip_rio:
+ if (ha->flags.fawwpn_enabled &&
+ (ha->current_topology == ISP_CFG_F)) {
+ void *wwpn = ha->init_cb->port_name;
++
+ memcpy(vha->port_name, wwpn, WWN_SIZE);
+ fc_host_port_name(vha->host) =
+ wwn_to_u64(vha->port_name);
+@@ -2250,6 +2251,7 @@ qla25xx_process_bidir_status_iocb(scsi_q
+ struct fc_bsg_reply *bsg_reply;
+ sts_entry_t *sts;
+ struct sts_entry_24xx *sts24;
++
+ sts = (sts_entry_t *) pkt;
+ sts24 = (struct sts_entry_24xx *) pkt;
+
+@@ -3085,6 +3087,7 @@ process_err:
+ /* Adjust ring index */
+ if (IS_P3P_TYPE(ha)) {
+ struct device_reg_82xx __iomem *reg = &ha->iobase->isp82;
++
+ WRT_REG_DWORD(&reg->rsp_q_out[0], rsp->ring_index);
+ } else {
+ WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index);
+--- a/drivers/scsi/qla2xxx/qla_mbx.c
++++ b/drivers/scsi/qla2xxx/qla_mbx.c
+@@ -5730,6 +5730,7 @@ qla8044_md_get_template(scsi_qla_host_t
+ mbx_cmd_t *mcp = &mc;
+ int rval = QLA_FUNCTION_FAILED;
+ int offset = 0, size = MINIDUMP_SIZE_36K;
++
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f,
+ "Entered %s.\n", __func__);
+
+--- a/drivers/scsi/qla2xxx/qla_mr.c
++++ b/drivers/scsi/qla2xxx/qla_mr.c
+@@ -1323,6 +1323,7 @@ qlafx00_configure_devices(scsi_qla_host_
+ {
+ int rval;
+ unsigned long flags;
++
+ rval = QLA_SUCCESS;
+
+ flags = vha->dpc_flags;
+@@ -3308,6 +3309,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fx
+ fx_iocb.flags = fxio->u.fxiocb.flags;
+ } else {
+ struct scatterlist *sg;
++
+ bsg_job = sp->u.bsg_job;
+ bsg_request = bsg_job->request;
+ piocb_rqst = (struct qla_mt_iocb_rqst_fx00 *)
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -368,6 +368,7 @@ static inline int qla2x00_start_nvme_mq(
+
+ if (unlikely(!fd->sqid)) {
+ struct nvme_fc_cmd_iu *cmd = fd->cmdaddr;
++
+ if (cmd->sqe.common.opcode == nvme_admin_async_event) {
+ nvme->u.nvme.aen_op = 1;
+ atomic_inc(&ha->nvme_active_aen_cnt);
+--- a/drivers/scsi/qla2xxx/qla_nx.c
++++ b/drivers/scsi/qla2xxx/qla_nx.c
+@@ -608,6 +608,7 @@ qla82xx_pci_set_window(struct qla_hw_dat
+ } else if (addr_in_range(addr, QLA82XX_ADDR_OCM0,
+ QLA82XX_ADDR_OCM0_MAX)) {
+ unsigned int temp1;
++
+ if ((addr & 0x00ff800) == 0xff800) {
+ ql_log(ql_log_warn, vha, 0xb004,
+ "%s: QM access not handled.\n", __func__);
+@@ -990,6 +991,7 @@ static int
+ qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_RDSR);
+ qla82xx_wait_rom_busy(ha);
+ if (qla82xx_wait_rom_done(ha)) {
+@@ -1030,6 +1032,7 @@ static int
+ qla82xx_flash_set_write_enable(struct qla_hw_data *ha)
+ {
+ uint32_t val;
++
+ qla82xx_wait_rom_busy(ha);
+ qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ABYTE_CNT, 0);
+ qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_WREN);
+@@ -1047,6 +1050,7 @@ static int
+ qla82xx_write_status_reg(struct qla_hw_data *ha, uint32_t val)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ if (qla82xx_flash_set_write_enable(ha))
+ return -1;
+ qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_WDATA, val);
+@@ -1063,6 +1067,7 @@ static int
+ qla82xx_write_disable_flash(struct qla_hw_data *ha)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_WRDI);
+ if (qla82xx_wait_rom_done(ha)) {
+ ql_log(ql_log_warn, vha, 0xb00f,
+@@ -1435,6 +1440,7 @@ qla82xx_fw_load_from_flash(struct qla_hw
+ long memaddr = BOOTLD_START;
+ u64 data;
+ u32 high, low;
++
+ size = (IMAGE_START - BOOTLD_START) / 8;
+
+ for (i = 0; i < size; i++) {
+@@ -1761,6 +1767,7 @@ int
+ qla82xx_reset_chip(scsi_qla_host_t *vha)
+ {
+ struct qla_hw_data *ha = vha->hw;
++
+ ha->isp_ops->disable_intrs(ha);
+
+ return QLA_SUCCESS;
+@@ -1994,6 +2001,7 @@ qla82xx_mbx_completion(scsi_qla_host_t *
+ uint16_t __iomem *wptr;
+ struct qla_hw_data *ha = vha->hw;
+ struct device_reg_82xx __iomem *reg = &ha->iobase->isp82;
++
+ wptr = (uint16_t __iomem *)&reg->mailbox_out[1];
+
+ /* Load return mailbox registers. */
+@@ -2264,6 +2272,7 @@ void
+ qla82xx_enable_intrs(struct qla_hw_data *ha)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ qla82xx_mbx_intr_enable(vha);
+ spin_lock_irq(&ha->hardware_lock);
+ if (IS_QLA8044(ha))
+@@ -2278,6 +2287,7 @@ void
+ qla82xx_disable_intrs(struct qla_hw_data *ha)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ qla82xx_mbx_intr_disable(vha);
+ spin_lock_irq(&ha->hardware_lock);
+ if (IS_QLA8044(ha))
+@@ -4465,6 +4475,7 @@ qla82xx_beacon_on(struct scsi_qla_host *
+
+ int rval;
+ struct qla_hw_data *ha = vha->hw;
++
+ qla82xx_idc_lock(ha);
+ rval = qla82xx_mbx_beacon_ctl(vha, 1);
+
+@@ -4485,6 +4496,7 @@ qla82xx_beacon_off(struct scsi_qla_host
+
+ int rval;
+ struct qla_hw_data *ha = vha->hw;
++
+ qla82xx_idc_lock(ha);
+ rval = qla82xx_mbx_beacon_ctl(vha, 0);
+
+--- a/drivers/scsi/qla2xxx/qla_nx2.c
++++ b/drivers/scsi/qla2xxx/qla_nx2.c
+@@ -3007,10 +3007,9 @@ qla8044_minidump_process_rddfe(struct sc
+ uint16_t count;
+ uint32_t poll, mask, modify_mask;
+ uint32_t wait_count = 0;
+-
+ uint32_t *data_ptr = *d_ptr;
+-
+ struct qla8044_minidump_entry_rddfe *rddfe;
++
+ rddfe = (struct qla8044_minidump_entry_rddfe *) entry_hdr;
+
+ addr1 = rddfe->addr_1;
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -384,6 +384,7 @@ static void qla_init_base_qpair(struct s
+ struct rsp_que *rsp)
+ {
+ struct qla_hw_data *ha = vha->hw;
++
+ rsp->qpair = ha->base_qpair;
+ rsp->req = req;
+ ha->base_qpair->hw = ha;
+@@ -408,6 +409,7 @@ static int qla2x00_alloc_queues(struct q
+ struct rsp_que *rsp)
+ {
+ scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
++
+ ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
+ GFP_KERNEL);
+ if (!ha->req_q_map) {
+@@ -3420,6 +3422,7 @@ skip_dpc:
+ if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
+ if (ha->fw_attributes & BIT_4) {
+ int prot = 0, guard;
++
+ base_vha->flags.difdix_supported = 1;
+ ql_dbg(ql_dbg_init, base_vha, 0x00f1,
+ "Registering for DIF/DIX type 1 and 3 protection.\n");
+@@ -3913,6 +3916,7 @@ qla2x00_schedule_rport_del(struct scsi_q
+ qla2xxx_wake_dpc(base_vha);
+ } else {
+ int now;
++
+ if (rport) {
+ ql_dbg(ql_dbg_disc, fcport->vha, 0x2109,
+ "%s %8phN. rport %p roles %x\n",
+@@ -5652,6 +5656,7 @@ qla83xx_force_lock_recovery(scsi_qla_hos
+ uint32_t idc_lck_rcvry_stage_mask = 0x3;
+ uint32_t idc_lck_rcvry_owner_mask = 0x3c;
+ struct qla_hw_data *ha = base_vha->hw;
++
+ ql_dbg(ql_dbg_p3p, base_vha, 0xb086,
+ "Trying force recovery of the IDC lock.\n");
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -184,6 +184,7 @@ static inline int qlt_issue_marker(struc
+ /* Send marker if required */
+ if (unlikely(vha->marker_needed != 0)) {
+ int rc = qla2x00_issue_marker(vha, vha_locked);
++
+ if (rc != QLA_SUCCESS) {
+ ql_dbg(ql_dbg_tgt, vha, 0xe03d,
+ "qla_target(%d): issue_marker() failed\n",
+@@ -557,6 +558,7 @@ static int qla24xx_post_nack_work(struct
+ struct imm_ntfy_from_isp *ntfy, int type)
+ {
+ struct qla_work_evt *e;
++
+ e = qla2x00_alloc_work(vha, QLA_EVT_NACK);
+ if (!e)
+ return QLA_FUNCTION_FAILED;
+@@ -1076,6 +1078,7 @@ void qlt_free_session_done(struct work_s
+ struct qlt_plogi_ack_t *con =
+ sess->plogi_link[QLT_PLOGI_LINK_CONFLICT];
+ struct imm_ntfy_from_isp *iocb;
++
+ own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN];
+
+ if (con) {
+@@ -1329,6 +1332,7 @@ static int qla24xx_get_loop_id(struct sc
+ res = -ENOENT;
+ for (i = 0; i < entries; i++) {
+ struct gid_list_info *gid = (struct gid_list_info *)id_iter;
++
+ if ((gid->al_pa == s_id[2]) &&
+ (gid->area == s_id[1]) &&
+ (gid->domain == s_id[0])) {
+@@ -2485,6 +2489,7 @@ static void qlt_unmap_sg(struct scsi_qla
+ {
+ struct qla_hw_data *ha;
+ struct qla_qpair *qpair;
++
+ if (!cmd->sg_mapped)
+ return;
+
+@@ -3918,6 +3923,7 @@ static int qlt_term_ctio_exchange(struct
+
+ if (ctio != NULL) {
+ struct ctio7_from_24xx *c = (struct ctio7_from_24xx *)ctio;
++
+ term = !(c->flags &
+ cpu_to_le16(OF_TERM_EXCH));
+ } else
+@@ -4777,6 +4783,7 @@ static int abort_cmds_for_s_id(struct sc
+
+ list_for_each_entry(op, &vha->unknown_atio_list, cmd_list) {
+ uint32_t op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id);
++
+ if (op_key == key) {
+ op->aborted = true;
+ count++;
+@@ -4785,6 +4792,7 @@ static int abort_cmds_for_s_id(struct sc
+
+ list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
+ uint32_t cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
++
+ if (cmd_key == key) {
+ cmd->aborted = 1;
+ count++;
+@@ -5055,6 +5063,7 @@ static int qlt_24xx_handle_els(struct sc
+ if (sess != NULL) {
+ bool delete = false;
+ int sec;
++
+ spin_lock_irqsave(&tgt->ha->tgt.sess_lock, flags);
+ switch (sess->fw_login_state) {
+ case DSC_LS_PLOGI_PEND:
+@@ -5207,6 +5216,7 @@ static int qlt_24xx_handle_els(struct sc
+ case ELS_ADISC:
+ {
+ struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
++
+ if (tgt->link_reinit_iocb_pending) {
+ qlt_send_notify_ack(ha->base_qpair,
+ &tgt->link_reinit_iocb, 0, 0, 0, 0, 0, 0);
+@@ -5270,6 +5280,7 @@ static void qlt_handle_imm_notify(struct
+ case IMM_NTFY_LIP_LINK_REINIT:
+ {
+ struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
++
+ ql_dbg(ql_dbg_tgt_mgt, vha, 0xf033,
+ "qla_target(%d): LINK REINIT (loop %#x, "
+ "subcode %x)\n", vha->vp_idx,
+@@ -5886,6 +5897,7 @@ static void qlt_response_pkt(struct scsi
+ case CTIO_TYPE7:
+ {
+ struct ctio7_from_24xx *entry = (struct ctio7_from_24xx *)pkt;
++
+ qlt_do_ctio_completion(vha, rsp, entry->handle,
+ le16_to_cpu(entry->status)|(pkt->entry_status << 16),
+ entry);
+@@ -5896,6 +5908,7 @@ static void qlt_response_pkt(struct scsi
+ {
+ struct atio_from_isp *atio = (struct atio_from_isp *)pkt;
+ int rc;
++
+ if (atio->u.isp2x.status !=
+ cpu_to_le16(ATIO_CDB_VALID)) {
+ ql_dbg(ql_dbg_tgt, vha, 0xe05e,
+@@ -5944,6 +5957,7 @@ static void qlt_response_pkt(struct scsi
+ case CONTINUE_TGT_IO_TYPE:
+ {
+ struct ctio_to_2xxx *entry = (struct ctio_to_2xxx *)pkt;
++
+ qlt_do_ctio_completion(vha, rsp, entry->handle,
+ le16_to_cpu(entry->status)|(pkt->entry_status << 16),
+ entry);
+@@ -5953,6 +5967,7 @@ static void qlt_response_pkt(struct scsi
+ case CTIO_A64_TYPE:
+ {
+ struct ctio_to_2xxx *entry = (struct ctio_to_2xxx *)pkt;
++
+ qlt_do_ctio_completion(vha, rsp, entry->handle,
+ le16_to_cpu(entry->status)|(pkt->entry_status << 16),
+ entry);
+@@ -5967,6 +5982,7 @@ static void qlt_response_pkt(struct scsi
+ case NOTIFY_ACK_TYPE:
+ if (tgt->notify_ack_expected > 0) {
+ struct nack_to_isp *entry = (struct nack_to_isp *)pkt;
++
+ ql_dbg(ql_dbg_tgt, vha, 0xe036,
+ "NOTIFY_ACK seq %08x status %x\n",
+ le16_to_cpu(entry->u.isp2x.seq_id),
+@@ -6242,6 +6258,7 @@ retry:
+
+ if (rc == -ENOENT) {
+ qlt_port_logo_t logo;
++
+ sid_to_portid(s_id, &logo.id);
+ logo.cmd_count = 1;
+ qlt_send_first_logo(vha, &logo);
+@@ -6501,6 +6518,7 @@ int qlt_add_target(struct qla_hw_data *h
+ unsigned long flags;
+
+ struct qla_qpair *qpair = ha->queue_pair_map[i];
++
+ h = &tgt->qphints[i + 1];
+ INIT_LIST_HEAD(&h->hint_elem);
+ if (qpair) {
diff --git a/patches.drivers/scsi-qla2xxx-Log-the-status-code-if-a-firmware-comma.patch b/patches.drivers/scsi-qla2xxx-Log-the-status-code-if-a-firmware-comma.patch
new file mode 100644
index 0000000000..20fd0b304e
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Log-the-status-code-if-a-firmware-comma.patch
@@ -0,0 +1,51 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:20 -0700
+Subject: scsi: qla2xxx: Log the status code if a firmware command fails
+Patch-mainline: v5.2-rc1
+Git-commit: 3f918ffae8e788d70e6488598d00e0bf717d7737
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+It is important to know why a firmware command failed. Hence log 'rval'
+together with the values of the mailbox registers if a firwmare command
+fails.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_mbx.c | 4 ++--
+ drivers/scsi/qla2xxx/qla_mr.c | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_mbx.c
++++ b/drivers/scsi/qla2xxx/qla_mbx.c
+@@ -567,9 +567,9 @@ mbx_done:
+ mcp->mb[0]);
+ } else if (rval) {
+ if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) {
+- pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR,
++ pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR,
+ dev_name(&ha->pdev->dev), 0x1020+0x800,
+- vha->host_no);
++ vha->host_no, rval);
+ mboxes = mcp->in_mb;
+ cnt = 4;
+ for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1)
+--- a/drivers/scsi/qla2xxx/qla_mr.c
++++ b/drivers/scsi/qla2xxx/qla_mr.c
+@@ -273,9 +273,9 @@ premature_exit:
+
+ if (rval) {
+ ql_log(ql_log_warn, base_vha, 0x1163,
+- "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, "
+- "mb[3]=%x, cmd=%x ****.\n",
+- mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], command);
++ "**** Failed=%x mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n",
++ rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3],
++ command);
+ } else {
+ ql_dbg(ql_dbg_mbx, base_vha, 0x1164, "Done %s.\n", __func__);
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Make-qla24xx_async_abort_cmd-static.patch b/patches.drivers/scsi-qla2xxx-Make-qla24xx_async_abort_cmd-static.patch
new file mode 100644
index 0000000000..c42ddde032
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Make-qla24xx_async_abort_cmd-static.patch
@@ -0,0 +1,197 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:33 -0700
+Subject: scsi: qla2xxx: Make qla24xx_async_abort_cmd() static
+Patch-mainline: v5.2-rc1
+Git-commit: 1956eee58872e622cfe03f060a5d8a20d24afe47
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla24xx_async_abort_cmd() is only called from inside qla_init.c,
+declare that function static. Reorder a few functions to avoid that any
+forward declarations are needed.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 1
+ drivers/scsi/qla2xxx/qla_init.c | 149 +++++++++++++++++++---------------------
+ 2 files changed, 73 insertions(+), 77 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -220,7 +220,6 @@ extern void qla24xx_sched_upd_fcport(fc_
+ void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
+ uint16_t *);
+ int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *);
+-int qla24xx_async_abort_cmd(srb_t *, bool);
+ int qla24xx_post_relogin_work(struct scsi_qla_host *vha);
+ void qla2x00_wait_for_sess_deletion(scsi_qla_host_t *);
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -95,6 +95,79 @@ qla2x00_get_async_timeout(struct scsi_ql
+ return tmo;
+ }
+
++static void qla24xx_abort_iocb_timeout(void *data)
++{
++ srb_t *sp = data;
++ struct srb_iocb *abt = &sp->u.iocb_cmd;
++
++ abt->u.abt.comp_status = CS_TIMEOUT;
++ sp->done(sp, QLA_FUNCTION_TIMEOUT);
++}
++
++static void qla24xx_abort_sp_done(void *ptr, int res)
++{
++ srb_t *sp = ptr;
++ struct srb_iocb *abt = &sp->u.iocb_cmd;
++
++ if (del_timer(&sp->u.iocb_cmd.timer)) {
++ if (sp->flags & SRB_WAKEUP_ON_COMP)
++ complete(&abt->u.abt.comp);
++ else
++ sp->free(sp);
++ }
++}
++
++static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
++{
++ scsi_qla_host_t *vha = cmd_sp->vha;
++ struct srb_iocb *abt_iocb;
++ srb_t *sp;
++ int rval = QLA_FUNCTION_FAILED;
++
++ sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport,
++ GFP_ATOMIC);
++ if (!sp)
++ goto done;
++
++ abt_iocb = &sp->u.iocb_cmd;
++ sp->type = SRB_ABT_CMD;
++ sp->name = "abort";
++ sp->qpair = cmd_sp->qpair;
++ if (wait)
++ sp->flags = SRB_WAKEUP_ON_COMP;
++
++ abt_iocb->timeout = qla24xx_abort_iocb_timeout;
++ init_completion(&abt_iocb->u.abt.comp);
++ /* FW can send 2 x ABTS's timeout/20s */
++ qla2x00_init_timer(sp, 42);
++
++ abt_iocb->u.abt.cmd_hndl = cmd_sp->handle;
++ abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id);
++
++ sp->done = qla24xx_abort_sp_done;
++
++ ql_dbg(ql_dbg_async, vha, 0x507c,
++ "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle,
++ cmd_sp->type);
++
++ rval = qla2x00_start_sp(sp);
++ if (rval != QLA_SUCCESS)
++ goto done_free_sp;
++
++ if (wait) {
++ wait_for_completion(&abt_iocb->u.abt.comp);
++ rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ?
++ QLA_SUCCESS : QLA_FUNCTION_FAILED;
++ } else {
++ goto done;
++ }
++
++done_free_sp:
++ sp->free(sp);
++done:
++ return rval;
++}
++
+ void
+ qla2x00_async_iocb_timeout(void *data)
+ {
+@@ -1786,82 +1859,6 @@ done_free_sp:
+ done:
+ return rval;
+ }
+-
+-static void
+-qla24xx_abort_iocb_timeout(void *data)
+-{
+- srb_t *sp = data;
+- struct srb_iocb *abt = &sp->u.iocb_cmd;
+-
+- abt->u.abt.comp_status = CS_TIMEOUT;
+- sp->done(sp, QLA_FUNCTION_TIMEOUT);
+-}
+-
+-static void
+-qla24xx_abort_sp_done(void *ptr, int res)
+-{
+- srb_t *sp = ptr;
+- struct srb_iocb *abt = &sp->u.iocb_cmd;
+-
+- if (del_timer(&sp->u.iocb_cmd.timer)) {
+- if (sp->flags & SRB_WAKEUP_ON_COMP)
+- complete(&abt->u.abt.comp);
+- else
+- sp->free(sp);
+- }
+-}
+-
+-int
+-qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
+-{
+- scsi_qla_host_t *vha = cmd_sp->vha;
+- struct srb_iocb *abt_iocb;
+- srb_t *sp;
+- int rval = QLA_FUNCTION_FAILED;
+-
+- sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport,
+- GFP_ATOMIC);
+- if (!sp)
+- goto done;
+-
+- abt_iocb = &sp->u.iocb_cmd;
+- sp->type = SRB_ABT_CMD;
+- sp->name = "abort";
+- sp->qpair = cmd_sp->qpair;
+- if (wait)
+- sp->flags = SRB_WAKEUP_ON_COMP;
+-
+- abt_iocb->timeout = qla24xx_abort_iocb_timeout;
+- init_completion(&abt_iocb->u.abt.comp);
+- /* FW can send 2 x ABTS's timeout/20s */
+- qla2x00_init_timer(sp, 42);
+-
+- abt_iocb->u.abt.cmd_hndl = cmd_sp->handle;
+- abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id);
+-
+- sp->done = qla24xx_abort_sp_done;
+-
+- ql_dbg(ql_dbg_async, vha, 0x507c,
+- "Abort command issued - hdl=%x, type=%x\n",
+- cmd_sp->handle, cmd_sp->type);
+-
+- rval = qla2x00_start_sp(sp);
+- if (rval != QLA_SUCCESS)
+- goto done_free_sp;
+-
+- if (wait) {
+- wait_for_completion(&abt_iocb->u.abt.comp);
+- rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ?
+- QLA_SUCCESS : QLA_FUNCTION_FAILED;
+- } else {
+- goto done;
+- }
+-
+-done_free_sp:
+- sp->free(sp);
+-done:
+- return rval;
+-}
+
+ int
+ qla24xx_async_abort_command(srb_t *sp)
diff --git a/patches.drivers/scsi-qla2xxx-Make-qla2x00_mem_free-easier-to-verify.patch b/patches.drivers/scsi-qla2xxx-Make-qla2x00_mem_free-easier-to-verify.patch
new file mode 100644
index 0000000000..cdc9e3b532
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Make-qla2x00_mem_free-easier-to-verify.patch
@@ -0,0 +1,172 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:22 -0700
+Subject: scsi: qla2xxx: Make qla2x00_mem_free() easier to verify
+Patch-mainline: v5.2-rc1
+Git-commit: 5365bf99e360bf3c31f2d5ba8f20f60dd47f6a86
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Instead of clearing all freed pointers at the end of qla2x00_mem_free(),
+clear freed pointers immediately after having freed the memory these
+pointers point at.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 61 ++++++++++++++++----------------------
+ drivers/scsi/qla2xxx/qla_target.c | 3 +
+ 2 files changed, 30 insertions(+), 34 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -4702,28 +4702,37 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ if (ha->mctp_dump)
+ dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump,
+ ha->mctp_dump_dma);
++ ha->mctp_dump = NULL;
+
+ mempool_destroy(ha->srb_mempool);
++ ha->srb_mempool = NULL;
+
+ if (ha->dcbx_tlv)
+ dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
+ ha->dcbx_tlv, ha->dcbx_tlv_dma);
++ ha->dcbx_tlv = NULL;
+
+ if (ha->xgmac_data)
+ dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
+ ha->xgmac_data, ha->xgmac_data_dma);
++ ha->xgmac_data = NULL;
+
+ if (ha->sns_cmd)
+ dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
+ ha->sns_cmd, ha->sns_cmd_dma);
++ ha->sns_cmd = NULL;
++ ha->sns_cmd_dma = 0;
+
+ if (ha->ct_sns)
+ dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
+ ha->ct_sns, ha->ct_sns_dma);
++ ha->ct_sns = NULL;
++ ha->ct_sns_dma = 0;
+
+ if (ha->sfp_data)
+ dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data,
+ ha->sfp_data_dma);
++ ha->sfp_data = NULL;
+
+ if (ha->flt)
+ dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
+@@ -4731,19 +4740,28 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+
+ if (ha->ms_iocb)
+ dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
++ ha->ms_iocb = NULL;
++ ha->ms_iocb_dma = 0;
+
+ if (ha->ex_init_cb)
+ dma_pool_free(ha->s_dma_pool,
+ ha->ex_init_cb, ha->ex_init_cb_dma);
++ ha->ex_init_cb = NULL;
++ ha->ex_init_cb_dma = 0;
+
+ if (ha->async_pd)
+ dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
++ ha->async_pd = NULL;
++ ha->async_pd_dma = 0;
+
+ dma_pool_destroy(ha->s_dma_pool);
++ ha->s_dma_pool = NULL;
+
+ if (ha->gid_list)
+ dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
+ ha->gid_list, ha->gid_list_dma);
++ ha->gid_list = NULL;
++ ha->gid_list_dma = 0;
+
+ if (IS_QLA82XX(ha)) {
+ if (!list_empty(&ha->gbl_dsd_list)) {
+@@ -4761,10 +4779,13 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ }
+
+ dma_pool_destroy(ha->dl_dma_pool);
++ ha->dl_dma_pool = NULL;
+
+ dma_pool_destroy(ha->fcp_cmnd_dma_pool);
++ ha->fcp_cmnd_dma_pool = NULL;
+
+ mempool_destroy(ha->ctx_mempool);
++ ha->ctx_mempool = NULL;
+
+ if (ql2xenabledif) {
+ struct dsd_dma *dsd, *nxt;
+@@ -4797,47 +4818,19 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ if (ha->init_cb)
+ dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
+ ha->init_cb, ha->init_cb_dma);
++ ha->init_cb = NULL;
++ ha->init_cb_dma = 0;
+
+ vfree(ha->optrom_buffer);
++ ha->optrom_buffer = NULL;
+ kfree(ha->nvram);
++ ha->nvram = NULL;
+ kfree(ha->npiv_info);
++ ha->npiv_info = NULL;
+ kfree(ha->swl);
++ ha->swl = NULL;
+ kfree(ha->loop_id_map);
+-
+- ha->srb_mempool = NULL;
+- ha->ctx_mempool = NULL;
+- ha->sns_cmd = NULL;
+- ha->sns_cmd_dma = 0;
+- ha->ct_sns = NULL;
+- ha->ct_sns_dma = 0;
+- ha->ms_iocb = NULL;
+- ha->ms_iocb_dma = 0;
+- ha->init_cb = NULL;
+- ha->init_cb_dma = 0;
+- ha->ex_init_cb = NULL;
+- ha->ex_init_cb_dma = 0;
+- ha->async_pd = NULL;
+- ha->async_pd_dma = 0;
+ ha->loop_id_map = NULL;
+- ha->npiv_info = NULL;
+- ha->optrom_buffer = NULL;
+- ha->swl = NULL;
+- ha->nvram = NULL;
+- ha->mctp_dump = NULL;
+- ha->dcbx_tlv = NULL;
+- ha->xgmac_data = NULL;
+- ha->sfp_data = NULL;
+-
+- ha->s_dma_pool = NULL;
+- ha->dl_dma_pool = NULL;
+- ha->fcp_cmnd_dma_pool = NULL;
+-
+- ha->gid_list = NULL;
+- ha->gid_list_dma = 0;
+-
+- ha->tgt.atio_ring = NULL;
+- ha->tgt.atio_dma = 0;
+- ha->tgt.tgt_vp_map = NULL;
+ }
+
+ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -7348,7 +7348,10 @@ qlt_mem_free(struct qla_hw_data *ha)
+ sizeof(struct atio_from_isp), ha->tgt.atio_ring,
+ ha->tgt.atio_dma);
+ }
++ ha->tgt.atio_ring = NULL;
++ ha->tgt.atio_dma = 0;
+ kfree(ha->tgt.tgt_vp_map);
++ ha->tgt.tgt_vp_map = NULL;
+ }
+
+ /* vport_slock to be held by the caller */
diff --git a/patches.drivers/scsi-qla2xxx-Make-qla2x00_process_response_queue-eas.patch b/patches.drivers/scsi-qla2xxx-Make-qla2x00_process_response_queue-eas.patch
new file mode 100644
index 0000000000..d6c8e7ec9a
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Make-qla2x00_process_response_queue-eas.patch
@@ -0,0 +1,128 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:44 -0700
+Subject: scsi: qla2xxx: Make qla2x00_process_response_queue() easier to read
+Patch-mainline: v5.2-rc1
+Git-commit: 7b006b9755ac099f0e5b414425534353f620d585
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Make qla2x00_process_response_queue() easier to read by splitting this
+function. This patch does not change any functionality.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 85 ++++++++++++++++++++++-------------------
+ 1 file changed, 47 insertions(+), 38 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -1972,6 +1972,52 @@ static void qla_ctrlvp_completed(scsi_ql
+ sp->done(sp, rval);
+ }
+
++/* Process a single response queue entry. */
++static void qla2x00_process_response_entry(struct scsi_qla_host *vha,
++ struct rsp_que *rsp,
++ sts_entry_t *pkt)
++{
++ sts21_entry_t *sts21_entry;
++ sts22_entry_t *sts22_entry;
++ uint16_t handle_cnt;
++ uint16_t cnt;
++
++ switch (pkt->entry_type) {
++ case STATUS_TYPE:
++ qla2x00_status_entry(vha, rsp, pkt);
++ break;
++ case STATUS_TYPE_21:
++ sts21_entry = (sts21_entry_t *)pkt;
++ handle_cnt = sts21_entry->handle_count;
++ for (cnt = 0; cnt < handle_cnt; cnt++)
++ qla2x00_process_completed_request(vha, rsp->req,
++ sts21_entry->handle[cnt]);
++ break;
++ case STATUS_TYPE_22:
++ sts22_entry = (sts22_entry_t *)pkt;
++ handle_cnt = sts22_entry->handle_count;
++ for (cnt = 0; cnt < handle_cnt; cnt++)
++ qla2x00_process_completed_request(vha, rsp->req,
++ sts22_entry->handle[cnt]);
++ break;
++ case STATUS_CONT_TYPE:
++ qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt);
++ break;
++ case MBX_IOCB_TYPE:
++ qla2x00_mbx_iocb_entry(vha, rsp->req, (struct mbx_entry *)pkt);
++ break;
++ case CT_IOCB_TYPE:
++ qla2x00_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE);
++ break;
++ default:
++ /* Type Not Supported. */
++ ql_log(ql_log_warn, vha, 0x504a,
++ "Received unknown response pkt type %x entry status=%x.\n",
++ pkt->entry_type, pkt->entry_status);
++ break;
++ }
++}
++
+ /**
+ * qla2x00_process_response_queue() - Process response queue entries.
+ * @rsp: response queue
+@@ -1983,8 +2029,6 @@ qla2x00_process_response_queue(struct rs
+ struct qla_hw_data *ha = rsp->hw;
+ struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
+ sts_entry_t *pkt;
+- uint16_t handle_cnt;
+- uint16_t cnt;
+
+ vha = pci_get_drvdata(ha->pdev);
+
+@@ -2009,42 +2053,7 @@ qla2x00_process_response_queue(struct rs
+ continue;
+ }
+
+- switch (pkt->entry_type) {
+- case STATUS_TYPE:
+- qla2x00_status_entry(vha, rsp, pkt);
+- break;
+- case STATUS_TYPE_21:
+- handle_cnt = ((sts21_entry_t *)pkt)->handle_count;
+- for (cnt = 0; cnt < handle_cnt; cnt++) {
+- qla2x00_process_completed_request(vha, rsp->req,
+- ((sts21_entry_t *)pkt)->handle[cnt]);
+- }
+- break;
+- case STATUS_TYPE_22:
+- handle_cnt = ((sts22_entry_t *)pkt)->handle_count;
+- for (cnt = 0; cnt < handle_cnt; cnt++) {
+- qla2x00_process_completed_request(vha, rsp->req,
+- ((sts22_entry_t *)pkt)->handle[cnt]);
+- }
+- break;
+- case STATUS_CONT_TYPE:
+- qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt);
+- break;
+- case MBX_IOCB_TYPE:
+- qla2x00_mbx_iocb_entry(vha, rsp->req,
+- (struct mbx_entry *)pkt);
+- break;
+- case CT_IOCB_TYPE:
+- qla2x00_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE);
+- break;
+- default:
+- /* Type Not Supported. */
+- ql_log(ql_log_warn, vha, 0x504a,
+- "Received unknown response pkt type %x "
+- "entry status=%x.\n",
+- pkt->entry_type, pkt->entry_status);
+- break;
+- }
++ qla2x00_process_response_entry(vha, rsp, pkt);
+ ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
+ wmb();
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Move-qla2x00_clear_loop_id-from-qla_inl.patch b/patches.drivers/scsi-qla2xxx-Move-qla2x00_clear_loop_id-from-qla_inl.patch
new file mode 100644
index 0000000000..6536b5c43e
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-qla2x00_clear_loop_id-from-qla_inl.patch
@@ -0,0 +1,74 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:15 -0700
+Subject: scsi: qla2xxx: Move qla2x00_clear_loop_id() from qla_inline.h into
+ qla_init.c
+Patch-mainline: v5.2-rc1
+Git-commit: ef1eb688b86ca3052131e8dc3ae85edb9fdca4a3
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla2x00_clear_loop_id() is not in the hot path, uninline it.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 1 +
+ drivers/scsi/qla2xxx/qla_init.c | 12 ++++++++++++
+ drivers/scsi/qla2xxx/qla_inline.h | 12 ------------
+ 3 files changed, 13 insertions(+), 12 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -38,6 +38,7 @@ extern int qla81xx_load_risc(scsi_qla_ho
+
+ extern int qla2x00_perform_loop_resync(scsi_qla_host_t *);
+ extern int qla2x00_loop_resync(scsi_qla_host_t *);
++extern void qla2x00_clear_loop_id(fc_port_t *fcport);
+
+ extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *);
+ extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *);
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -557,6 +557,18 @@ static int qla2x00_find_new_loop_id(scsi
+ return rval;
+ }
+
++void qla2x00_clear_loop_id(fc_port_t *fcport)
++{
++ struct qla_hw_data *ha = fcport->vha->hw;
++
++ if (fcport->loop_id == FC_NO_LOOP_ID ||
++ qla2x00_is_reserved_id(fcport->vha, fcport->loop_id))
++ return;
++
++ clear_bit(fcport->loop_id, ha->loop_id_map);
++ fcport->loop_id = FC_NO_LOOP_ID;
++}
++
+ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
+ struct event_arg *ea)
+ {
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -102,18 +102,6 @@ qla2x00_is_reserved_id(scsi_qla_host_t *
+ }
+
+ static inline void
+-qla2x00_clear_loop_id(fc_port_t *fcport) {
+- struct qla_hw_data *ha = fcport->vha->hw;
+-
+- if (fcport->loop_id == FC_NO_LOOP_ID ||
+- qla2x00_is_reserved_id(fcport->vha, fcport->loop_id))
+- return;
+-
+- clear_bit(fcport->loop_id, ha->loop_id_map);
+- fcport->loop_id = FC_NO_LOOP_ID;
+-}
+-
+-static inline void
+ qla2x00_clean_dsd_pool(struct qla_hw_data *ha, struct crc_context *ctx)
+ {
+ struct dsd_dma *dsd, *tdsd;
diff --git a/patches.drivers/scsi-qla2xxx-Move-qla2x00_is_reserved_id-from-qla_in.patch b/patches.drivers/scsi-qla2xxx-Move-qla2x00_is_reserved_id-from-qla_in.patch
new file mode 100644
index 0000000000..5d3c595236
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-qla2x00_is_reserved_id-from-qla_in.patch
@@ -0,0 +1,63 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:16 -0700
+Subject: scsi: qla2xxx: Move qla2x00_is_reserved_id() from qla_inline.h into
+ qla_init.c
+Patch-mainline: v5.2-rc1
+Git-commit: 0c6660b27feb9034fc7c9f85ec2fb6cc2395b49d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The previous patch moved all qla2x00_is_reserved_id() callers into
+qla_init.c. Hence also move the qla2x00_is_reserved_id() definition into
+qla_init.c.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 11 +++++++++++
+ drivers/scsi/qla2xxx/qla_inline.h | 11 -----------
+ 2 files changed, 11 insertions(+), 11 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -514,6 +514,17 @@ done:
+ return rval;
+ }
+
++static bool qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
++{
++ struct qla_hw_data *ha = vha->hw;
++
++ if (IS_FWI2_CAPABLE(ha))
++ return loop_id > NPH_LAST_HANDLE;
++
++ return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
++ loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST;
++}
++
+ /**
+ * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID
+ * @vha: adapter state pointer.
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -90,17 +90,6 @@ host_to_adap(uint8_t *src, uint8_t *dst,
+ *odest++ = cpu_to_le32(*isrc);
+ }
+
+-static inline int
+-qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
+-{
+- struct qla_hw_data *ha = vha->hw;
+- if (IS_FWI2_CAPABLE(ha))
+- return (loop_id > NPH_LAST_HANDLE);
+-
+- return ((loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
+- loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
+-}
+-
+ static inline void
+ qla2x00_clean_dsd_pool(struct qla_hw_data *ha, struct crc_context *ctx)
+ {
diff --git a/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_fcport_state-from-a-.h.patch b/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_fcport_state-from-a-.h.patch
new file mode 100644
index 0000000000..1781a0a43f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_fcport_state-from-a-.h.patch
@@ -0,0 +1,88 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:25 -0700
+Subject: scsi: qla2xxx: Move qla2x00_set_fcport_state() from a .h into a .c
+ file
+Patch-mainline: v5.2-rc1
+Git-commit: a630bdc54f6d41a525694766168ddb9b8ffe8392
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The qla2x00_set_fcport_state() function is not in the hot path so move its
+definition from a .h into a .c file.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 1 +
+ drivers/scsi/qla2xxx/qla_init.c | 17 +++++++++++++++++
+ drivers/scsi/qla2xxx/qla_inline.h | 19 -------------------
+ 3 files changed, 18 insertions(+), 19 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -80,6 +80,7 @@ int qla2x00_post_work(struct scsi_qla_ho
+ extern void *qla2x00_alloc_iocbs_ready(struct qla_qpair *, srb_t *);
+ extern int qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *, fc_port_t *);
+
++extern void qla2x00_set_fcport_state(fc_port_t *fcport, int state);
+ extern fc_port_t *
+ qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t );
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -4757,6 +4757,23 @@ qla2x00_rport_del(void *data)
+ }
+ }
+
++void qla2x00_set_fcport_state(fc_port_t *fcport, int state)
++{
++ int old_state;
++
++ old_state = atomic_read(&fcport->state);
++ atomic_set(&fcport->state, state);
++
++ /* Don't print state transitions during initial allocation of fcport */
++ if (old_state && old_state != state) {
++ ql_dbg(ql_dbg_disc, fcport->vha, 0x207d,
++ "FCPort %8phC state transitioned from %s to %s - portid=%02x%02x%02x.\n",
++ fcport->port_name, port_state_str[old_state],
++ port_state_str[state], fcport->d_id.b.domain,
++ fcport->d_id.b.area, fcport->d_id.b.al_pa);
++ }
++}
++
+ /**
+ * qla2x00_alloc_fcport() - Allocate a generic fcport.
+ * @vha: HA context
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -142,25 +142,6 @@ qla2x00_clean_dsd_pool(struct qla_hw_dat
+ INIT_LIST_HEAD(&ctx->dsd_list);
+ }
+
+-static inline void
+-qla2x00_set_fcport_state(fc_port_t *fcport, int state)
+-{
+- int old_state;
+-
+- old_state = atomic_read(&fcport->state);
+- atomic_set(&fcport->state, state);
+-
+- /* Don't print state transitions during initial allocation of fcport */
+- if (old_state && old_state != state) {
+- ql_dbg(ql_dbg_disc, fcport->vha, 0x207d,
+- "FCPort %8phC state transitioned from %s to %s - "
+- "portid=%02x%02x%02x.\n", fcport->port_name,
+- port_state_str[old_state], port_state_str[state],
+- fcport->d_id.b.domain, fcport->d_id.b.area,
+- fcport->d_id.b.al_pa);
+- }
+-}
+-
+ static inline int
+ qla2x00_hba_err_chk_enabled(srb_t *sp)
+ {
diff --git a/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_reserved_loop_ids-defi.patch b/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_reserved_loop_ids-defi.patch
new file mode 100644
index 0000000000..29080a3944
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-qla2x00_set_reserved_loop_ids-defi.patch
@@ -0,0 +1,66 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:12 -0700
+Subject: scsi: qla2xxx: Move qla2x00_set_reserved_loop_ids() definition
+Patch-mainline: v5.2-rc1
+Git-commit: 0e145a595d4113caee8c1d9d3345781567c43826
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla2x00_set_reserved_loop_ids() only has a single caller, move it
+into the source file from where it is called.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_inline.h | 14 --------------
+ drivers/scsi/qla2xxx/qla_os.c | 13 +++++++++++++
+ 2 files changed, 13 insertions(+), 14 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -90,20 +90,6 @@ host_to_adap(uint8_t *src, uint8_t *dst,
+ *odest++ = cpu_to_le32(*isrc);
+ }
+
+-static inline void
+-qla2x00_set_reserved_loop_ids(struct qla_hw_data *ha)
+-{
+- int i;
+-
+- if (IS_FWI2_CAPABLE(ha))
+- return;
+-
+- for (i = 0; i < SNS_FIRST_LOOP_ID; i++)
+- set_bit(i, ha->loop_id_map);
+- set_bit(MANAGEMENT_SERVER, ha->loop_id_map);
+- set_bit(BROADCAST, ha->loop_id_map);
+-}
+-
+ static inline int
+ qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
+ {
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -4008,6 +4008,19 @@ qla2x00_mark_all_devices_lost(scsi_qla_h
+ }
+ }
+
++static void qla2x00_set_reserved_loop_ids(struct qla_hw_data *ha)
++{
++ int i;
++
++ if (IS_FWI2_CAPABLE(ha))
++ return;
++
++ for (i = 0; i < SNS_FIRST_LOOP_ID; i++)
++ set_bit(i, ha->loop_id_map);
++ set_bit(MANAGEMENT_SERVER, ha->loop_id_map);
++ set_bit(BROADCAST, ha->loop_id_map);
++}
++
+ /*
+ * qla2x00_mem_alloc
+ * Allocates adapter memory.
diff --git a/patches.drivers/scsi-qla2xxx-Move-the-linux-io-64-nonatomic-lo-hi.h-.patch b/patches.drivers/scsi-qla2xxx-Move-the-linux-io-64-nonatomic-lo-hi.h-.patch
new file mode 100644
index 0000000000..a448285fe3
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-the-linux-io-64-nonatomic-lo-hi.h-.patch
@@ -0,0 +1,45 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:22 -0700
+Subject: scsi: qla2xxx: Move the <linux/io-64-nonatomic-lo-hi.h> include
+ directive
+Patch-mainline: v5.2-rc1
+Git-commit: 9dfb59a00881a5acbaafdb75ff98f518b9a382bf
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The <linux/io-64-nonatomic-lo-hi.h> header file is included because of the
+readq() macro. Since that macro is only used in qla_nx.c, move that include
+statement into qla_nx.c.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nx.c | 1 +
+ drivers/scsi/qla2xxx/qla_nx.h | 2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nx.c
++++ b/drivers/scsi/qla2xxx/qla_nx.c
+@@ -6,6 +6,7 @@
+ */
+ #include "qla_def.h"
+ #include <linux/delay.h>
++#include <linux/io-64-nonatomic-lo-hi.h>
+ #include <linux/pci.h>
+ #include <linux/ratelimit.h>
+ #include <linux/vmalloc.h>
+--- a/drivers/scsi/qla2xxx/qla_nx.h
++++ b/drivers/scsi/qla2xxx/qla_nx.h
+@@ -7,7 +7,7 @@
+ #ifndef __QLA_NX_H
+ #define __QLA_NX_H
+
+-#include <linux/io-64-nonatomic-lo-hi.h>
++#include <scsi/scsi.h>
+
+ /*
+ * Following are the states of the Phantom. Phantom will set them and
diff --git a/patches.drivers/scsi-qla2xxx-Move-the-port_state_str-definition-from.patch b/patches.drivers/scsi-qla2xxx-Move-the-port_state_str-definition-from.patch
new file mode 100644
index 0000000000..1acebb7459
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Move-the-port_state_str-definition-from.patch
@@ -0,0 +1,57 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:20 -0700
+Subject: scsi: qla2xxx: Move the port_state_str[] definition from a .h to a .c
+ file
+Patch-mainline: v5.2-rc1
+Git-commit: c4dc7cd314398f03c1c6e5034b8913aeb40b2646
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Reduce the size of the qla2xxx kernel module by moving an array definition
+from a .h into a .c file.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 8 +-------
+ drivers/scsi/qla2xxx/qla_isr.c | 8 ++++++++
+ 2 files changed, 9 insertions(+), 7 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -2472,13 +2472,7 @@ struct event_arg {
+ #define FCS_DEVICE_LOST 3
+ #define FCS_ONLINE 4
+
+-static const char * const port_state_str[] = {
+- "Unknown",
+- "UNCONFIGURED",
+- "DEAD",
+- "LOST",
+- "ONLINE"
+-};
++extern const char *const port_state_str[5];
+
+ /*
+ * FC port flags.
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -23,6 +23,14 @@ static void qla2x00_status_cont_entry(st
+ static int qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *,
+ sts_entry_t *);
+
++const char *const port_state_str[] = {
++ "Unknown",
++ "UNCONFIGURED",
++ "DEAD",
++ "LOST",
++ "ONLINE"
++};
++
+ /**
+ * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
+ * @irq: interrupt number
diff --git a/patches.drivers/scsi-qla2xxx-Pass-little-endian-values-to-the-firmwa.patch b/patches.drivers/scsi-qla2xxx-Pass-little-endian-values-to-the-firmwa.patch
new file mode 100644
index 0000000000..c20b0f458b
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Pass-little-endian-values-to-the-firmwa.patch
@@ -0,0 +1,58 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:36 -0700
+Subject: scsi: qla2xxx: Pass little-endian values to the firmware
+Patch-mainline: v5.2-rc1
+Git-commit: 6e73985a9dea627114531723bdae6f8c1f59d5e8
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Pass dsd_list_len in little endian format to the firmware instead of in CPU
+endian format.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_iocb.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -973,7 +973,7 @@ alloc_and_fill:
+ /* add new list to cmd iocb or last list */
+ *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma));
+ *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma));
+- *cur_dsd++ = dsd_list_len;
++ *cur_dsd++ = cpu_to_le32(dsd_list_len);
+ cur_dsd = (uint32_t *)next_dsd;
+ }
+ *cur_dsd++ = cpu_to_le32(LSD(sle_dma));
+@@ -1072,7 +1072,7 @@ qla24xx_walk_and_build_sglist(struct qla
+ /* add new list to cmd iocb or last list */
+ *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma));
+ *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma));
+- *cur_dsd++ = dsd_list_len;
++ *cur_dsd++ = cpu_to_le32(dsd_list_len);
+ cur_dsd = (uint32_t *)next_dsd;
+ }
+ sle_dma = sg_dma_address(sg);
+@@ -1317,7 +1317,7 @@ qla24xx_walk_and_build_prot_sglist(struc
+ cpu_to_le32(LSD(dsd_ptr->dsd_list_dma));
+ *cur_dsd++ =
+ cpu_to_le32(MSD(dsd_ptr->dsd_list_dma));
+- *cur_dsd++ = dsd_list_len;
++ *cur_dsd++ = cpu_to_le32(dsd_list_len);
+ cur_dsd = dsd_ptr->dsd_addr;
+ }
+ *cur_dsd++ = cpu_to_le32(LSD(dif_dsd->dsd_list_dma));
+@@ -1378,7 +1378,7 @@ qla24xx_walk_and_build_prot_sglist(struc
+ cpu_to_le32(LSD(dsd_ptr->dsd_list_dma));
+ *cur_dsd++ =
+ cpu_to_le32(MSD(dsd_ptr->dsd_list_dma));
+- *cur_dsd++ = dsd_list_len;
++ *cur_dsd++ = cpu_to_le32(dsd_list_len);
+ cur_dsd = dsd_ptr->dsd_addr;
+ }
+ sle_dma = sg_dma_address(sg);
diff --git a/patches.drivers/scsi-qla2xxx-Reduce-the-number-of-forward-declaratio.patch b/patches.drivers/scsi-qla2xxx-Reduce-the-number-of-forward-declaratio.patch
new file mode 100644
index 0000000000..852f27e98f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Reduce-the-number-of-forward-declaratio.patch
@@ -0,0 +1,122 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:43 -0700
+Subject: scsi: qla2xxx: Reduce the number of forward declarations
+Patch-mainline: v5.2-rc1
+Git-commit: 6515ad717bd723f7564581ffdfd5d8064602f29f
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Move the SCSI host template definition after the definition of the
+functions that it references. Remove the forward declarations that became
+unnecessary by that change. This patch does not change any functionality.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 79 +++++++++++++++++-------------------------
+ 1 file changed, 32 insertions(+), 47 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -306,59 +306,12 @@ MODULE_PARM_DESC(ql2xdifbundlinginternal
+ "0 (Default). Based on check.\n"
+ "1 Force using internal buffers\n");
+
+-/*
+- * SCSI host template entry points
+- */
+-static int qla2xxx_slave_configure(struct scsi_device * device);
+-static int qla2xxx_slave_alloc(struct scsi_device *);
+-static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
+-static void qla2xxx_scan_start(struct Scsi_Host *);
+-static void qla2xxx_slave_destroy(struct scsi_device *);
+-static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
+-static int qla2xxx_eh_abort(struct scsi_cmnd *);
+-static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
+-static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
+-static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
+-static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
+-
+ static void qla2x00_clear_drv_active(struct qla_hw_data *);
+ static void qla2x00_free_device(scsi_qla_host_t *);
+ static int qla2xxx_map_queues(struct Scsi_Host *shost);
+ static void qla2x00_destroy_deferred_work(struct qla_hw_data *);
+
+
+-struct scsi_host_template qla2xxx_driver_template = {
+- .module = THIS_MODULE,
+- .name = QLA2XXX_DRIVER_NAME,
+- .queuecommand = qla2xxx_queuecommand,
+-
+- .eh_timed_out = fc_eh_timed_out,
+- .eh_abort_handler = qla2xxx_eh_abort,
+- .eh_device_reset_handler = qla2xxx_eh_device_reset,
+- .eh_target_reset_handler = qla2xxx_eh_target_reset,
+- .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
+- .eh_host_reset_handler = qla2xxx_eh_host_reset,
+-
+- .slave_configure = qla2xxx_slave_configure,
+-
+- .slave_alloc = qla2xxx_slave_alloc,
+- .slave_destroy = qla2xxx_slave_destroy,
+- .scan_finished = qla2xxx_scan_finished,
+- .scan_start = qla2xxx_scan_start,
+- .change_queue_depth = scsi_change_queue_depth,
+- .map_queues = qla2xxx_map_queues,
+- .this_id = -1,
+- .cmd_per_lun = 3,
+- .use_clustering = ENABLE_CLUSTERING,
+- .sg_tablesize = SG_ALL,
+-
+- .max_sectors = 0xFFFF,
+- .shost_attrs = qla2x00_host_attrs,
+-
+- .supported_mode = MODE_INITIATOR,
+- .track_queue_depth = 1,
+-};
+-
+ static struct scsi_transport_template *qla2xxx_transport_template = NULL;
+ struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
+
+@@ -7271,6 +7224,38 @@ static int qla2xxx_map_queues(struct Scs
+ return rc;
+ }
+
++struct scsi_host_template qla2xxx_driver_template = {
++ .module = THIS_MODULE,
++ .name = QLA2XXX_DRIVER_NAME,
++ .queuecommand = qla2xxx_queuecommand,
++
++ .eh_timed_out = fc_eh_timed_out,
++ .eh_abort_handler = qla2xxx_eh_abort,
++ .eh_device_reset_handler = qla2xxx_eh_device_reset,
++ .eh_target_reset_handler = qla2xxx_eh_target_reset,
++ .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
++ .eh_host_reset_handler = qla2xxx_eh_host_reset,
++
++ .slave_configure = qla2xxx_slave_configure,
++
++ .slave_alloc = qla2xxx_slave_alloc,
++ .slave_destroy = qla2xxx_slave_destroy,
++ .scan_finished = qla2xxx_scan_finished,
++ .scan_start = qla2xxx_scan_start,
++ .change_queue_depth = scsi_change_queue_depth,
++ .map_queues = qla2xxx_map_queues,
++ .this_id = -1,
++ .cmd_per_lun = 3,
++ .use_clustering = ENABLE_CLUSTERING,
++ .sg_tablesize = SG_ALL,
++
++ .max_sectors = 0xFFFF,
++ .shost_attrs = qla2x00_host_attrs,
++
++ .supported_mode = MODE_INITIATOR,
++ .track_queue_depth = 1,
++};
++
+ static const struct pci_error_handlers qla2xxx_err_handler = {
+ .error_detected = qla2xxx_pci_error_detected,
+ .mmio_enabled = qla2xxx_pci_mmio_enabled,
diff --git a/patches.drivers/scsi-qla2xxx-Reject-EH_-abort-device_reset-target_re.patch b/patches.drivers/scsi-qla2xxx-Reject-EH_-abort-device_reset-target_re.patch
new file mode 100644
index 0000000000..85a75e0584
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Reject-EH_-abort-device_reset-target_re.patch
@@ -0,0 +1,51 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:31 -0700
+Subject: scsi: qla2xxx: Reject EH_{abort|device_reset|target_request}
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 7f4374e67b3046c9628cf0ab93a117704a38e95d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Reject eh_{abort|device_reset|target_reset} when rport is being torn down
+or chip is down.
+
+Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1302,6 +1302,9 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+ if (!qpair)
+ return SUCCESS;
+
++ if (sp->fcport && sp->fcport->deleted)
++ return SUCCESS;
++
+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
+ if (sp->type != SRB_SCSI_CMD || GET_CMD_SP(sp) != cmd) {
+ /* there's a chance an interrupt could clear
+@@ -1426,6 +1429,9 @@ __qla2xxx_eh_generic_reset(char *name, e
+ if (err != 0)
+ return err;
+
++ if (fcport->deleted)
++ return SUCCESS;
++
+ ql_log(ql_log_info, vha, 0x8009,
+ "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no,
+ cmd->device->id, cmd->device->lun, cmd);
+@@ -1540,6 +1546,9 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *c
+ return ret;
+ ret = FAILED;
+
++ if (qla2x00_chip_is_down(vha))
++ return ret;
++
+ ql_log(ql_log_info, vha, 0x8012,
+ "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
+
diff --git a/patches.drivers/scsi-qla2xxx-Remove-a-comment-that-refers-to-the-SCS.patch b/patches.drivers/scsi-qla2xxx-Remove-a-comment-that-refers-to-the-SCS.patch
new file mode 100644
index 0000000000..0cfc9c12f3
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-a-comment-that-refers-to-the-SCS.patch
@@ -0,0 +1,32 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:40 -0700
+Subject: scsi: qla2xxx: Remove a comment that refers to the SCSI host lock
+Patch-mainline: v5.2-rc1
+Git-commit: abe5706dcf47cfdf0b929fff727279614df3c263
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla2xxx_queuecommand() no longer takes the SCSI host lock, remove a
+comment that refers to the host lock.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -892,9 +892,6 @@ qla2xxx_qpair_sp_compl(void *ptr, int re
+ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+-/* If we are SP1 here, we need to still take and release the host_lock as SP1
+- * does not have the changes necessary to avoid taking host->host_lock.
+- */
+ static int
+ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
+ {
diff --git a/patches.drivers/scsi-qla2xxx-Remove-a-set-but-not-used-variable-6eaa5f94.patch b/patches.drivers/scsi-qla2xxx-Remove-a-set-but-not-used-variable-6eaa5f94.patch
new file mode 100644
index 0000000000..350761f40e
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-a-set-but-not-used-variable-6eaa5f94.patch
@@ -0,0 +1,35 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:14 -0700
+Subject: scsi: qla2xxx: Remove a set-but-not-used variable
+Patch-mainline: v5.2-rc1
+Git-commit: 6eaa5f9448a7e0fb6bfecf17f47ce9f186d1e264
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_iocb.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -3011,7 +3011,6 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry
+ scsi_qla_host_t *vha = sp->vha;
+ struct qla_hw_data *ha = vha->hw;
+ struct bsg_job *bsg_job = sp->u.bsg_job;
+- int loop_iterartion = 0;
+ int entry_count = 1;
+
+ memset(ct_iocb, 0, sizeof(ms_iocb_entry_t));
+@@ -3069,7 +3068,6 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry
+ *cur_dsd++ = cpu_to_le32(LSD(sle_dma));
+ *cur_dsd++ = cpu_to_le32(MSD(sle_dma));
+ *cur_dsd++ = cpu_to_le32(sg_dma_len(sg));
+- loop_iterartion++;
+ avail_dsds--;
+ }
+ ct_iocb->entry_count = entry_count;
diff --git a/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.data_work-and-qla_tg.patch b/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.data_work-and-qla_tg.patch
new file mode 100644
index 0000000000..7882aefe25
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.data_work-and-qla_tg.patch
@@ -0,0 +1,47 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:23 -0700
+Subject: scsi: qla2xxx: Remove qla_tgt_cmd.data_work and
+ qla_tgt_cmd.data_work_free
+Patch-mainline: v5.2-rc1
+Git-commit: bb63e47b6f6832f1eb5be4207c65a6f268e01059
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The 'data_work' and 'data_work_free' member variables are set but never
+used. Hence remove both member variables. See also commit 6bcbb3174caa
+("qla2xxx: Fix incorrect tcm_qla2xxx_free_cmd use during TMR ABORT (v2)").
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.h | 2 --
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 --
+ 2 files changed, 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.h
++++ b/drivers/scsi/qla2xxx/qla_target.h
+@@ -890,8 +890,6 @@ struct qla_tgt_cmd {
+ unsigned int cmd_sent_to_fw:1;
+ unsigned int cmd_in_wq:1;
+ unsigned int aborted:1;
+- unsigned int data_work:1;
+- unsigned int data_work_free:1;
+ unsigned int released:1;
+
+ struct scatterlist *sg; /* cmd data buffer SG vector */
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -529,9 +529,7 @@ static void tcm_qla2xxx_handle_data_work
+ return;
+ }
+
+- cmd->data_work = 1;
+ if (cmd->aborted) {
+- cmd->data_work_free = 1;
+ spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+ tcm_qla2xxx_free_cmd(cmd);
diff --git a/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.released.patch b/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.released.patch
new file mode 100644
index 0000000000..4567f21216
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.released.patch
@@ -0,0 +1,72 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:31 -0700
+Subject: scsi: qla2xxx: Remove qla_tgt_cmd.released
+Patch-mainline: v5.2-rc1
+Git-commit: 4c374596d7eb80a901c8adc532ae9760e9df9fde
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since the previous patch removed the only statement that sets
+qla_tgt_cmd.released, remove the code that depends on that member variable
+being set and the member variable itself.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.h | 1 -
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 15 +--------------
+ 2 files changed, 1 insertion(+), 15 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.h
++++ b/drivers/scsi/qla2xxx/qla_target.h
+@@ -889,7 +889,6 @@ struct qla_tgt_cmd {
+ unsigned int term_exchg:1;
+ unsigned int cmd_sent_to_fw:1;
+ unsigned int cmd_in_wq:1;
+- unsigned int released:1;
+
+ /*
+ * This variable may be set from outside the LIO and I/O completion
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -271,7 +271,6 @@ static void tcm_qla2xxx_free_mcmd(struct
+ static void tcm_qla2xxx_complete_free(struct work_struct *work)
+ {
+ struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+- bool released = false;
+ unsigned long flags;
+
+ cmd->cmd_in_wq = 0;
+@@ -282,14 +281,9 @@ static void tcm_qla2xxx_complete_free(st
+ cmd->qpair->tgt_counters.qla_core_ret_sta_ctio++;
+ cmd->trc_flags |= TRC_CMD_FREE;
+ cmd->cmd_sent_to_fw = 0;
+- if (cmd->released)
+- released = true;
+ spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+- if (released)
+- qlt_free_cmd(cmd);
+- else
+- transport_generic_free_cmd(&cmd->se_cmd, 0);
++ transport_generic_free_cmd(&cmd->se_cmd, 0);
+ }
+
+ /*
+@@ -519,13 +513,6 @@ static void tcm_qla2xxx_handle_data_work
+
+ spin_lock_irqsave(&cmd->cmd_lock, flags);
+ cmd->cmd_sent_to_fw = 0;
+-
+- if (cmd->released) {
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+- qlt_free_cmd(cmd);
+- return;
+- }
+-
+ if (cmd->aborted) {
+ spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
diff --git a/patches.drivers/scsi-qla2xxx-Remove-the-fcport-test-from-qla_nvme_ab.patch b/patches.drivers/scsi-qla2xxx-Remove-the-fcport-test-from-qla_nvme_ab.patch
new file mode 100644
index 0000000000..9100a03556
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-the-fcport-test-from-qla_nvme_ab.patch
@@ -0,0 +1,36 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:18 -0700
+Subject: scsi: qla2xxx: Remove the fcport test from qla_nvme_abort_work()
+Patch-mainline: v5.2-rc1
+Git-commit: dafbe56f6e338c7f583a524c714942f892c1f50a
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Testing whether a pointer is not NULL after it has been dereferenced is not
+useful. Hence remove the if (fcport) test. This was detected by Coverity.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -186,10 +186,9 @@ static void qla_nvme_abort_work(struct w
+ struct qla_hw_data *ha = fcport->vha->hw;
+ int rval;
+
+- if (fcport)
+- ql_dbg(ql_dbg_io, fcport->vha, 0xffff,
+- "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n",
+- __func__, sp, sp->handle, fcport, fcport->deleted);
++ ql_dbg(ql_dbg_io, fcport->vha, 0xffff,
++ "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n",
++ __func__, sp, sp->handle, fcport, fcport->deleted);
+
+ if (!ha->flags.fw_started && (fcport && fcport->deleted))
+ return;
diff --git a/patches.drivers/scsi-qla2xxx-Remove-two-superfluous-casts.patch b/patches.drivers/scsi-qla2xxx-Remove-two-superfluous-casts.patch
new file mode 100644
index 0000000000..6b7c533d7b
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-two-superfluous-casts.patch
@@ -0,0 +1,42 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:24 -0700
+Subject: scsi: qla2xxx: Remove two superfluous casts
+Patch-mainline: v5.2-rc1
+Git-commit: 81bcf1c5cf0ee875de3f3b0c930194dcf56969ee
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Casting a void pointer into another pointer before assigning the pointer to
+a variable is not useful. Hence remove such casts.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -4042,7 +4042,7 @@ static void qlt_do_ctio_completion(struc
+ return;
+ }
+
+- cmd = (struct qla_tgt_cmd *)qlt_ctio_to_cmd(vha, rsp, handle, ctio);
++ cmd = qlt_ctio_to_cmd(vha, rsp, handle, ctio);
+ if (cmd == NULL)
+ return;
+
+@@ -5834,8 +5834,7 @@ static void qlt_handle_abts_completion(s
+ struct qla_tgt_mgmt_cmd *mcmd;
+ struct qla_hw_data *ha = vha->hw;
+
+- mcmd = (struct qla_tgt_mgmt_cmd *)qlt_ctio_to_cmd(vha, rsp,
+- pkt->handle, pkt);
++ mcmd = qlt_ctio_to_cmd(vha, rsp, pkt->handle, pkt);
+ if (mcmd == NULL && h != QLA_TGT_SKIP_HANDLE) {
+ ql_dbg(ql_dbg_async, vha, 0xe064,
+ "qla_target(%d): ABTS Comp without mcmd\n",
diff --git a/patches.drivers/scsi-qla2xxx-Remove-unnecessary-locking-from-the-tar.patch b/patches.drivers/scsi-qla2xxx-Remove-unnecessary-locking-from-the-tar.patch
new file mode 100644
index 0000000000..44e49d2d74
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-unnecessary-locking-from-the-tar.patch
@@ -0,0 +1,91 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:32 -0700
+Subject: scsi: qla2xxx: Remove unnecessary locking from the target code
+Patch-mainline: v5.2-rc1
+Git-commit: 1b1e68d2a940827725dbf666dd3e73ff12434b0c
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+All callbacks from the target core into the qla2xxx driver and also all I/O
+completion functions are serialized per command. Since .cmd_sent_to_fw and
+.trc_flags are only modified from inside these functions it is not
+necessary to protect it with locking. Remove the superfluous locking.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 4 ----
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 10 +---------
+ 2 files changed, 1 insertion(+), 13 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -3392,9 +3392,7 @@ int qlt_xmit_response(struct qla_tgt_cmd
+
+
+ cmd->state = QLA_TGT_STATE_PROCESSED; /* Mid-level is done processing */
+- spin_lock(&cmd->cmd_lock);
+ cmd->cmd_sent_to_fw = 1;
+- spin_unlock(&cmd->cmd_lock);
+ cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags);
+
+ /* Memory Barrier */
+@@ -3475,9 +3473,7 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *
+ qlt_load_data_segments(&prm);
+
+ cmd->state = QLA_TGT_STATE_NEED_DATA;
+- spin_lock(&cmd->cmd_lock);
+ cmd->cmd_sent_to_fw = 1;
+- spin_unlock(&cmd->cmd_lock);
+ cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags);
+
+ /* Memory Barrier */
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -271,17 +271,15 @@ static void tcm_qla2xxx_free_mcmd(struct
+ static void tcm_qla2xxx_complete_free(struct work_struct *work)
+ {
+ struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+- unsigned long flags;
+
+ cmd->cmd_in_wq = 0;
+
+ WARN_ON(cmd->trc_flags & TRC_CMD_FREE);
+
+- spin_lock_irqsave(&cmd->cmd_lock, flags);
++ /* To do: protect all tgt_counters manipulations with proper locking. */
+ cmd->qpair->tgt_counters.qla_core_ret_sta_ctio++;
+ cmd->trc_flags |= TRC_CMD_FREE;
+ cmd->cmd_sent_to_fw = 0;
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+ transport_generic_free_cmd(&cmd->se_cmd, 0);
+ }
+@@ -503,24 +501,18 @@ static int tcm_qla2xxx_handle_cmd(scsi_q
+ static void tcm_qla2xxx_handle_data_work(struct work_struct *work)
+ {
+ struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+- unsigned long flags;
+
+ /*
+ * Ensure that the complete FCP WRITE payload has been received.
+ * Otherwise return an exception via CHECK_CONDITION status.
+ */
+ cmd->cmd_in_wq = 0;
+-
+- spin_lock_irqsave(&cmd->cmd_lock, flags);
+ cmd->cmd_sent_to_fw = 0;
+ if (cmd->aborted) {
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+-
+ transport_generic_request_failure(&cmd->se_cmd,
+ TCM_CHECK_CONDITION_ABORT_CMD);
+ return;
+ }
+- spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+ cmd->qpair->tgt_counters.qla_core_ret_ctio++;
+ if (!cmd->write_data_transferred) {
diff --git a/patches.drivers/scsi-qla2xxx-Remove-unnecessary-null-check.patch b/patches.drivers/scsi-qla2xxx-Remove-unnecessary-null-check.patch
new file mode 100644
index 0000000000..a13275e733
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-unnecessary-null-check.patch
@@ -0,0 +1,31 @@
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Thu, 11 Jul 2019 22:13:17 +0800
+Subject: scsi: qla2xxx: Remove unnecessary null check
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 0b3b6fe299c471e44ed8713b7a602882626e693f
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+A null check before dma_pool_destroy is redundant, so remove it. This is
+detected by coccinelle.
+
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -4747,8 +4747,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
+ }
+ }
+
+- if (ha->dif_bundl_pool)
+- dma_pool_destroy(ha->dif_bundl_pool);
++ dma_pool_destroy(ha->dif_bundl_pool);
+ ha->dif_bundl_pool = NULL;
+
+ qlt_mem_free(ha);
diff --git a/patches.drivers/scsi-qla2xxx-Remove-useless-set-memory-to-zero-use-m.patch b/patches.drivers/scsi-qla2xxx-Remove-useless-set-memory-to-zero-use-m.patch
new file mode 100644
index 0000000000..ab166e2660
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Remove-useless-set-memory-to-zero-use-m.patch
@@ -0,0 +1,27 @@
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Sat, 23 Mar 2019 21:27:53 +0800
+Subject: scsi: qla2xxx: Remove useless set memory to zero use memset()
+Patch-mainline: v5.2-rc1
+Git-commit: 25ea6b19db54a76879e388ff4dfd67be48890f0d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+The memory return by kzalloc() has already be set to zero, so remove
+useless memset(0).
+
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -8878,7 +8878,6 @@ struct qla_qpair *qla2xxx_create_qpair(s
+ "Failed to allocate memory for queue pair.\n");
+ return NULL;
+ }
+- memset(qpair, 0, sizeof(struct qla_qpair));
+
+ qpair->hw = vha->hw;
+ qpair->vha = vha;
diff --git a/patches.drivers/scsi-qla2xxx-Replace-vmalloc-memset-with-vzalloc.patch b/patches.drivers/scsi-qla2xxx-Replace-vmalloc-memset-with-vzalloc.patch
new file mode 100644
index 0000000000..82b336b3e5
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Replace-vmalloc-memset-with-vzalloc.patch
@@ -0,0 +1,55 @@
+From: Chuhong Yuan <hslester96@gmail.com>
+Date: Thu, 18 Jul 2019 15:45:18 +0800
+Subject: scsi: qla2xxx: Replace vmalloc + memset with vzalloc
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 56cc8fae5f7e9f38cb367754c52491ba1645d1bf
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Use vzalloc instead of using vmalloc to allocate memory and then zeroing it
+with memset. This simplifies the code.
+
+Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -382,7 +382,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ ha->optrom_region_size = size;
+
+ ha->optrom_state = QLA_SREADING;
+- ha->optrom_buffer = vmalloc(ha->optrom_region_size);
++ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
+ if (ha->optrom_buffer == NULL) {
+ ql_log(ql_log_warn, vha, 0x7062,
+ "Unable to allocate memory for optrom retrieval "
+@@ -404,7 +404,6 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ "Reading flash region -- 0x%x/0x%x.\n",
+ ha->optrom_region_start, ha->optrom_region_size);
+
+- memset(ha->optrom_buffer, 0, ha->optrom_region_size);
+ ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
+ ha->optrom_region_start, ha->optrom_region_size);
+ break;
+@@ -457,7 +456,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ ha->optrom_region_size = size;
+
+ ha->optrom_state = QLA_SWRITING;
+- ha->optrom_buffer = vmalloc(ha->optrom_region_size);
++ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
+ if (ha->optrom_buffer == NULL) {
+ ql_log(ql_log_warn, vha, 0x7066,
+ "Unable to allocate memory for optrom update "
+@@ -472,7 +471,6 @@ qla2x00_sysfs_write_optrom_ctl(struct fi
+ "Staging flash region write -- 0x%x/0x%x.\n",
+ ha->optrom_region_start, ha->optrom_region_size);
+
+- memset(ha->optrom_buffer, 0, ha->optrom_region_size);
+ break;
+ case 3:
+ if (ha->optrom_state != QLA_SWRITING) {
diff --git a/patches.drivers/scsi-qla2xxx-Reset-the-FCF_ASYNC_-SENT-ACTIVE-flags.patch b/patches.drivers/scsi-qla2xxx-Reset-the-FCF_ASYNC_-SENT-ACTIVE-flags.patch
new file mode 100644
index 0000000000..0e015e8c8b
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Reset-the-FCF_ASYNC_-SENT-ACTIVE-flags.patch
@@ -0,0 +1,41 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:22 -0700
+Subject: scsi: qla2xxx: Reset the FCF_ASYNC_{SENT|ACTIVE} flags
+Patch-mainline: v5.2-rc1
+Git-commit: 0257eda08e806b82ee1fc90ef73583b6f022845c
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Driver maintains state machine for processing and completing switch
+commands. This patch resets FCF_ASYNC_{SENT|ACTIVE} flag to indicate if the
+previous command is active or sent, in order for next GPSC command to
+advance the state machine.
+
+[mkp: commit desc typo]
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gs.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -3033,6 +3033,8 @@ static void qla24xx_async_gpsc_sp_done(v
+ "Async done-%s res %x, WWPN %8phC \n",
+ sp->name, res, fcport->port_name);
+
++ fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
++
+ if (res == QLA_FUNCTION_TIMEOUT)
+ return;
+
+@@ -4349,6 +4351,7 @@ int qla24xx_async_gnnid(scsi_qla_host_t
+
+ done_free_sp:
+ sp->free(sp);
++ fcport->flags &= ~FCF_ASYNC_SENT;
+ done:
+ return rval;
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Retry-fabric-Scan-on-IOCB-queue-full.patch b/patches.drivers/scsi-qla2xxx-Retry-fabric-Scan-on-IOCB-queue-full.patch
new file mode 100644
index 0000000000..5a4aac81c6
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Retry-fabric-Scan-on-IOCB-queue-full.patch
@@ -0,0 +1,77 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:34 -0700
+Subject: scsi: qla2xxx: Retry fabric Scan on IOCB queue full
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: f0cecc1eec0c24e790a4daac71858f1f14e6f7b5
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+when fabric scan thread encounters IOCB Q Full, schedule a delayed work to
+retry fabric scan.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gs.c | 28 ++++++++++++++++++++++------
+ 1 file changed, 22 insertions(+), 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -4062,9 +4062,6 @@ static int qla24xx_async_gnnft(scsi_qla_
+
+ rval = qla2x00_start_sp(sp);
+ if (rval != QLA_SUCCESS) {
+- spin_lock_irqsave(&vha->work_lock, flags);
+- vha->scan.scan_flags &= ~SF_SCANNING;
+- spin_unlock_irqrestore(&vha->work_lock, flags);
+ goto done_free_sp;
+ }
+
+@@ -4088,6 +4085,17 @@ done_free_sp:
+
+ sp->free(sp);
+
++ spin_lock_irqsave(&vha->work_lock, flags);
++ vha->scan.scan_flags &= ~SF_SCANNING;
++ if (vha->scan.scan_flags == 0) {
++ ql_dbg(ql_dbg_disc, vha, 0xffff,
++ "%s: schedule\n", __func__);
++ vha->scan.scan_flags |= SF_QUEUED;
++ schedule_delayed_work(&vha->scan.scan_work, 5);
++ }
++ spin_unlock_irqrestore(&vha->work_lock, flags);
++
++
+ return rval;
+ } /* GNNFT */
+
+@@ -4215,9 +4223,6 @@ int qla24xx_async_gpnft(scsi_qla_host_t
+
+ rval = qla2x00_start_sp(sp);
+ if (rval != QLA_SUCCESS) {
+- spin_lock_irqsave(&vha->work_lock, flags);
+- vha->scan.scan_flags &= ~SF_SCANNING;
+- spin_unlock_irqrestore(&vha->work_lock, flags);
+ goto done_free_sp;
+ }
+
+@@ -4241,6 +4246,17 @@ done_free_sp:
+
+ sp->free(sp);
+
++ spin_lock_irqsave(&vha->work_lock, flags);
++ vha->scan.scan_flags &= ~SF_SCANNING;
++ if (vha->scan.scan_flags == 0) {
++ ql_dbg(ql_dbg_disc, vha, 0xffff,
++ "%s: schedule\n", __func__);
++ vha->scan.scan_flags |= SF_QUEUED;
++ schedule_delayed_work(&vha->scan.scan_work, 5);
++ }
++ spin_unlock_irqrestore(&vha->work_lock, flags);
++
++
+ return rval;
+ }
+
diff --git a/patches.drivers/scsi-qla2xxx-Set-the-SCSI-command-result-before-call.patch b/patches.drivers/scsi-qla2xxx-Set-the-SCSI-command-result-before-call.patch
new file mode 100644
index 0000000000..b085df4517
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Set-the-SCSI-command-result-before-call.patch
@@ -0,0 +1,42 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:20 -0700
+Subject: scsi: qla2xxx: Set the SCSI command result before calling the command
+ done
+Patch-mainline: v5.2-rc1
+Git-commit: 740e29358e350077d18ee08700199e37b206edad
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch tries to address race condition between abort handler and
+completion handler. When scsi command result is set by both abort and
+completion handler, scsi_done() is only called after refcount on SRB
+structure goes to zero. The abort handler sets this result prematurely even
+when the refcount is non-zero value. Fix this by setting SCSI cmd->result
+before scsi_done() is called.
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -768,8 +768,6 @@ qla2x00_sp_compl(void *ptr, int res)
+ srb_t *sp = ptr;
+ struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+
+- cmd->result = res;
+-
+ if (atomic_read(&sp->ref_count) == 0) {
+ ql_dbg(ql_dbg_io, sp->vha, 0x3015,
+ "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
+@@ -782,6 +780,7 @@ qla2x00_sp_compl(void *ptr, int res)
+ return;
+
+ sp->free(sp);
++ cmd->result = res;
+ cmd->scsi_done(cmd);
+ }
+
diff --git a/patches.drivers/scsi-qla2xxx-Set-the-qpair-in-SRB-to-NULL-when-SRB-i.patch b/patches.drivers/scsi-qla2xxx-Set-the-qpair-in-SRB-to-NULL-when-SRB-i.patch
new file mode 100644
index 0000000000..efcf4a69ef
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Set-the-qpair-in-SRB-to-NULL-when-SRB-i.patch
@@ -0,0 +1,28 @@
+From: Giridhar Malavali <gmalavali@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:21 -0700
+Subject: scsi: qla2xxx: Set the qpair in SRB to NULL when SRB is released
+Patch-mainline: v5.2-rc1
+Git-commit: ae6ccb0f8153fe9e3b9287a74aa9742ea212e89c
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch sets QPair pointer to NULL to prevent abort command racing ahead
+of normal command completion handling during scsi_done call.
+
+Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_inline.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -240,6 +240,7 @@ done:
+ static inline void
+ qla2xxx_rel_qpair_sp(struct qla_qpair *qpair, srb_t *sp)
+ {
++ sp->qpair = NULL;
+ mempool_free(sp, qpair->srb_mempool);
+ QLA_QPAIR_MARK_NOT_BUSY(qpair);
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Silence-Successful-ELS-IOCB-message.patch b/patches.drivers/scsi-qla2xxx-Silence-Successful-ELS-IOCB-message.patch
new file mode 100644
index 0000000000..f688bfe417
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Silence-Successful-ELS-IOCB-message.patch
@@ -0,0 +1,31 @@
+From: Himanshu Madhani <hmadhani@marvell.com>
+Date: Tue, 23 Apr 2019 14:52:36 -0700
+Subject: scsi: qla2xxx: Silence Successful ELS IOCB message
+Patch-mainline: v5.2-rc1
+Git-commit: a1f9ab4844acdd8415dddd588f4fcac4d5b05c8e
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+ELS IOCB done message should be moved to verbose logging to prevent
+confusion about the error case v/s successful submission case.
+
+[mkp: typos]
+
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Ewan D. Milne <emilne@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -1625,7 +1625,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vh
+ res = DID_ERROR << 16;
+ }
+ }
+- ql_log(ql_log_info, vha, 0x503f,
++ ql_dbg(ql_dbg_user, vha, 0x503f,
+ "ELS IOCB Done -%s error hdl=%x comp_status=0x%x error subcode 1=0x%x error subcode 2=0x%x total_byte=0x%x\n",
+ type, sp->handle, comp_status, fw_status[1], fw_status[2],
+ le16_to_cpu(((struct els_sts_entry_24xx *)
diff --git a/patches.drivers/scsi-qla2xxx-Simplify-qlt_send_term_imm_notif.patch b/patches.drivers/scsi-qla2xxx-Simplify-qlt_send_term_imm_notif.patch
new file mode 100644
index 0000000000..dad4f6599e
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Simplify-qlt_send_term_imm_notif.patch
@@ -0,0 +1,61 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:26 -0700
+Subject: scsi: qla2xxx: Simplify qlt_send_term_imm_notif()
+Patch-mainline: v5.2-rc1
+Git-commit: e65449aa23fbeaba5b358f23a0c790cef6a77969
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+All qlt_send_term_imm_notif() callers pass '1' as second argument to this
+function. Hence remove the (broken) code that depends on that second
+argument having another value. Add a pr_debug() statement that prints rc to
+avoid that the compiler would complain that rc has been set but is not
+used.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 26 ++------------------------
+ 1 file changed, 2 insertions(+), 24 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -3656,33 +3656,11 @@ static int __qlt_send_term_imm_notif(str
+ static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
+ struct imm_ntfy_from_isp *imm, int ha_locked)
+ {
+- unsigned long flags = 0;
+ int rc;
+
+- if (ha_locked) {
+- rc = __qlt_send_term_imm_notif(vha, imm);
+-
+-#if 0 /* Todo */
+- if (rc == -ENOMEM)
+- qlt_alloc_qfull_cmd(vha, imm, 0, 0);
+-#else
+- if (rc) {
+- }
+-#endif
+- goto done;
+- }
+-
+- spin_lock_irqsave(&vha->hw->hardware_lock, flags);
++ WARN_ON_ONCE(!ha_locked);
+ rc = __qlt_send_term_imm_notif(vha, imm);
+-
+-#if 0 /* Todo */
+- if (rc == -ENOMEM)
+- qlt_alloc_qfull_cmd(vha, imm, 0, 0);
+-#endif
+-
+-done:
+- if (!ha_locked)
+- spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
++ pr_debug("rc = %d\n", rc);
+ }
+
+ /*
diff --git a/patches.drivers/scsi-qla2xxx-Skip-FW-dump-on-LOOP-initialization-err.patch b/patches.drivers/scsi-qla2xxx-Skip-FW-dump-on-LOOP-initialization-err.patch
new file mode 100644
index 0000000000..04f30f52d4
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Skip-FW-dump-on-LOOP-initialization-err.patch
@@ -0,0 +1,30 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:30 -0700
+Subject: scsi: qla2xxx: Skip FW dump on LOOP initialization error
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 5e5402c147083786db2238302e25c44b7a7dc5e9
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Firmware dump captured during LOOP Init error does not yield any
+significant information. This patch removes call to trigger firmware dump
+collection during Loop Initialization.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -776,7 +776,6 @@ skip_rio:
+ case MBA_LOOP_INIT_ERR:
+ ql_log(ql_log_warn, vha, 0x5090,
+ "LOOP INIT ERROR (%x).\n", mb[1]);
+- ha->isp_ops->fw_dump(vha, 1);
+ set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+ break;
+
diff --git a/patches.drivers/scsi-qla2xxx-Uninline-qla2x00_init_timer.patch b/patches.drivers/scsi-qla2xxx-Uninline-qla2x00_init_timer.patch
new file mode 100644
index 0000000000..72566e9946
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Uninline-qla2x00_init_timer.patch
@@ -0,0 +1,78 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:17 -0700
+Subject: scsi: qla2xxx: Uninline qla2x00_init_timer()
+Patch-mainline: v5.2-rc1
+Git-commit: 12975426d8889ce42821e9e0348f9a2da343779a
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Since qla2x00_init_timer() is not used for I/O commands there is no need to
+inline this function. Hence uninline this function.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_gbl.h | 1 +
+ drivers/scsi/qla2xxx/qla_inline.h | 14 --------------
+ drivers/scsi/qla2xxx/qla_iocb.c | 14 ++++++++++++++
+ 3 files changed, 15 insertions(+), 14 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -281,6 +281,7 @@ extern int qla2x00_start_sp(srb_t *);
+ extern int qla24xx_dif_start_scsi(srb_t *);
+ extern int qla2x00_start_bidir(srb_t *, struct scsi_qla_host *, uint32_t);
+ extern int qla2xxx_dif_start_scsi_mq(srb_t *);
++extern void qla2x00_init_timer(srb_t *sp, unsigned long tmo);
+ extern unsigned long qla2x00_get_async_timeout(struct scsi_qla_host *);
+
+ extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *);
+--- a/drivers/scsi/qla2xxx/qla_inline.h
++++ b/drivers/scsi/qla2xxx/qla_inline.h
+@@ -219,20 +219,6 @@ qla2x00_rel_sp(srb_t *sp)
+ qla2xxx_rel_qpair_sp(sp->qpair, sp);
+ }
+
+-static inline void
+-qla2x00_init_timer(srb_t *sp, unsigned long tmo)
+-{
+- init_timer(&sp->u.iocb_cmd.timer);
+- sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;
+- sp->u.iocb_cmd.timer.data = (unsigned long)sp;
+- sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
+- sp->free = qla2x00_sp_free;
+- init_completion(&sp->comp);
+- if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
+- init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
+- add_timer(&sp->u.iocb_cmd.timer);
+-}
+-
+ static inline int
+ qla2x00_gid_list_size(struct qla_hw_data *ha)
+ {
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -2570,6 +2570,20 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mg
+ }
+ }
+
++void
++qla2x00_init_timer(srb_t *sp, unsigned long tmo)
++{
++ init_timer(&sp->u.iocb_cmd.timer);
++ sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;
++ sp->u.iocb_cmd.timer.data = (unsigned long)sp;
++ sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
++ sp->free = qla2x00_sp_free;
++ init_completion(&sp->comp);
++ if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
++ init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
++ add_timer(&sp->u.iocb_cmd.timer);
++}
++
+ static void
+ qla2x00_els_dcmd_sp_free(void *data)
+ {
diff --git a/patches.drivers/scsi-qla2xxx-Unregister-chrdev-if-module-initializat.patch b/patches.drivers/scsi-qla2xxx-Unregister-chrdev-if-module-initializat.patch
new file mode 100644
index 0000000000..2ba5026d0f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Unregister-chrdev-if-module-initializat.patch
@@ -0,0 +1,93 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:46 -0700
+Subject: scsi: qla2xxx: Unregister chrdev if module initialization fails
+Patch-mainline: v5.2-rc1
+Git-commit: c794d24ec9eb6658909955772e70f34bef5b5b91
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+If module initialization fails after the character device has been
+registered, unregister the character device. Additionally, avoid
+duplicating error path code.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
+Fixes: 6a03b4cd78f3 ("[SCSI] qla2xxx: Add char device to increase driver use count") # v2.6.35.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 34 +++++++++++++++++++++-------------
+ 1 file changed, 21 insertions(+), 13 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -7334,8 +7334,7 @@ qla2x00_module_init(void)
+ /* Initialize target kmem_cache and mem_pools */
+ ret = qlt_init();
+ if (ret < 0) {
+- kmem_cache_destroy(srb_cachep);
+- return ret;
++ goto destroy_cache;
+ } else if (ret > 0) {
+ /*
+ * If initiator mode is explictly disabled by qlt_init(),
+@@ -7359,11 +7358,10 @@ qla2x00_module_init(void)
+ qla2xxx_transport_template =
+ fc_attach_transport(&qla2xxx_transport_functions);
+ if (!qla2xxx_transport_template) {
+- kmem_cache_destroy(srb_cachep);
+ ql_log(ql_log_fatal, NULL, 0x0002,
+ "fc_attach_transport failed...Failing load!.\n");
+- qlt_exit();
+- return -ENODEV;
++ ret = -ENODEV;
++ goto qlt_exit;
+ }
+
+ apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops);
+@@ -7375,27 +7373,37 @@ qla2x00_module_init(void)
+ qla2xxx_transport_vport_template =
+ fc_attach_transport(&qla2xxx_transport_vport_functions);
+ if (!qla2xxx_transport_vport_template) {
+- kmem_cache_destroy(srb_cachep);
+- qlt_exit();
+- fc_release_transport(qla2xxx_transport_template);
+ ql_log(ql_log_fatal, NULL, 0x0004,
+ "fc_attach_transport vport failed...Failing load!.\n");
+- return -ENODEV;
++ ret = -ENODEV;
++ goto unreg_chrdev;
+ }
+ ql_log(ql_log_info, NULL, 0x0005,
+ "QLogic Fibre Channel HBA Driver: %s.\n",
+ qla2x00_version_str);
+ ret = pci_register_driver(&qla2xxx_pci_driver);
+ if (ret) {
+- kmem_cache_destroy(srb_cachep);
+- qlt_exit();
+- fc_release_transport(qla2xxx_transport_template);
+- fc_release_transport(qla2xxx_transport_vport_template);
+ ql_log(ql_log_fatal, NULL, 0x0006,
+ "pci_register_driver failed...ret=%d Failing load!.\n",
+ ret);
++ goto release_vport_transport;
+ }
+ return ret;
++
++release_vport_transport:
++ fc_release_transport(qla2xxx_transport_vport_template);
++
++unreg_chrdev:
++ if (apidev_major >= 0)
++ unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
++ fc_release_transport(qla2xxx_transport_template);
++
++qlt_exit:
++ qlt_exit();
++
++destroy_cache:
++ kmem_cache_destroy(srb_cachep);
++ return ret;
+ }
+
+ /**
diff --git a/patches.drivers/scsi-qla2xxx-Unregister-resources-in-the-opposite-or.patch b/patches.drivers/scsi-qla2xxx-Unregister-resources-in-the-opposite-or.patch
new file mode 100644
index 0000000000..3667f085c2
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Unregister-resources-in-the-opposite-or.patch
@@ -0,0 +1,43 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:47 -0700
+Subject: scsi: qla2xxx: Unregister resources in the opposite order of the
+ registration order
+Patch-mainline: v5.2-rc1
+Git-commit: 59c209a689a66190e6eba7286e9be18ddb3df85b
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Make sure that resources are only unregistered after the users of these
+resources have been unregistered. Only unregister the character device if
+registration of it succeeded.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -7412,14 +7412,15 @@ destroy_cache:
+ static void __exit
+ qla2x00_module_exit(void)
+ {
+- unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
+ pci_unregister_driver(&qla2xxx_pci_driver);
+ qla2x00_release_firmware();
+- kmem_cache_destroy(srb_cachep);
+- qlt_exit();
+ kmem_cache_destroy(ctx_cachep);
+- fc_release_transport(qla2xxx_transport_template);
+ fc_release_transport(qla2xxx_transport_vport_template);
++ if (apidev_major >= 0)
++ unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
++ fc_release_transport(qla2xxx_transport_template);
++ qlt_exit();
++ kmem_cache_destroy(srb_cachep);
+ }
+
+ module_init(qla2x00_module_init);
diff --git a/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.16-k.patch b/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.16-k.patch
new file mode 100644
index 0000000000..f7b4cbbff1
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.16-k.patch
@@ -0,0 +1,25 @@
+From: Himanshu Madhani <hmadhani@marvell.com>
+Date: Tue, 2 Apr 2019 14:24:34 -0700
+Subject: scsi: qla2xxx: Update driver version to 10.01.00.16-k
+Patch-mainline: v5.2-rc1
+Git-commit: f99b77e0bf4d4e53b81b6b0d16fdd34835891f7c
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_version.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_version.h
++++ b/drivers/scsi/qla2xxx/qla_version.h
+@@ -7,7 +7,7 @@
+ /*
+ * Driver version
+ */
+-#define QLA2XXX_VERSION "10.01.00.15-k"
++#define QLA2XXX_VERSION "10.01.00.16-k"
+
+ #define QLA_DRIVER_MAJOR_VER 10
+ #define QLA_DRIVER_MINOR_VER 1
diff --git a/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.18-k.patch b/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.18-k.patch
new file mode 100644
index 0000000000..93a7c32965
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.18-k.patch
@@ -0,0 +1,26 @@
+From: Himanshu Madhani <hmadhani@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:40 -0700
+Subject: scsi: qla2xxx: Update driver version to 10.01.00.18-k
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 4d0b32b853f52760bf70288f2751d2ca86581352
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_version.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_version.h
++++ b/drivers/scsi/qla2xxx/qla_version.h
+@@ -7,7 +7,7 @@
+ /*
+ * Driver version
+ */
+-#define QLA2XXX_VERSION "10.01.00.16-k"
++#define QLA2XXX_VERSION "10.01.00.18-k"
+
+ #define QLA_DRIVER_MAJOR_VER 10
+ #define QLA_DRIVER_MINOR_VER 1
diff --git a/patches.drivers/scsi-qla2xxx-Update-two-source-code-comments.patch b/patches.drivers/scsi-qla2xxx-Update-two-source-code-comments.patch
new file mode 100644
index 0000000000..d4d2e50a6f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Update-two-source-code-comments.patch
@@ -0,0 +1,46 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:10 -0700
+Subject: scsi: qla2xxx: Update two source code comments
+Patch-mainline: v5.2-rc1
+Git-commit: 67eb4a60782a0e1142a3789fbb49617bbbe32796
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Change one occurrence of "*(" into "()" and change one occurrence of
+"lcoate" into "locate". Fix the reference to qla_tgt_handle_cmd_for_atio():
+there has never been a function with that name.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: 75f8c1f693ee ("[SCSI] tcm_qla2xxx: Add >= 24xx series fabric module for target-core") # v3.5.
+Fixes: 2d70c103fd2a ("[SCSI] qla2xxx: Add LLD target-mode infrastructure for >= 24xx series") # v3.5.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 2 +-
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -4251,7 +4251,7 @@ static void __qlt_do_work(struct qla_tgt
+ if (ret != 0)
+ goto out_term;
+ /*
+- * Drop extra session reference from qla_tgt_handle_cmd_for_atio*(
++ * Drop extra session reference from qlt_handle_cmd_for_atio().
+ */
+ spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+ ha->tgt.tgt_ops->put_sess(sess);
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -1525,7 +1525,7 @@ static int tcm_qla2xxx_check_initiator_n
+ */
+ tpg = lport->tpg_1;
+ if (!tpg) {
+- pr_err("Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n");
++ pr_err("Unable to locate struct tcm_qla2xxx_lport->tpg_1\n");
+ return -EINVAL;
+ }
+ /*
diff --git a/patches.drivers/scsi-qla2xxx-Use-ARRAY_SIZE-in-the-definition-of-QLA.patch b/patches.drivers/scsi-qla2xxx-Use-ARRAY_SIZE-in-the-definition-of-QLA.patch
new file mode 100644
index 0000000000..e8d462e3cc
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-ARRAY_SIZE-in-the-definition-of-QLA.patch
@@ -0,0 +1,31 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:41 -0700
+Subject: scsi: qla2xxx: Use ARRAY_SIZE() in the definition of QLA_LAST_SPEED
+Patch-mainline: v5.2-rc1
+Git-commit: b0a1c5b5c38ad6ee813875a28472774474d72589
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Make the code easier to read by avoiding to use a hard-coded constant. This
+patch does not change any functionality.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_isr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_isr.c
++++ b/drivers/scsi/qla2xxx/qla_isr.c
+@@ -366,7 +366,7 @@ qla2x00_get_link_speed_str(struct qla_hw
+ static const char *const link_speeds[] = {
+ "1", "2", "?", "4", "8", "16", "32", "10"
+ };
+-#define QLA_LAST_SPEED 7
++#define QLA_LAST_SPEED (ARRAY_SIZE(link_speeds) - 1)
+
+ if (IS_QLA2100(ha) || IS_QLA2200(ha))
+ return link_speeds[0];
diff --git a/patches.drivers/scsi-qla2xxx-Use-Correct-index-for-Q-Pair-array.patch b/patches.drivers/scsi-qla2xxx-Use-Correct-index-for-Q-Pair-array.patch
new file mode 100644
index 0000000000..c82bca3612
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-Correct-index-for-Q-Pair-array.patch
@@ -0,0 +1,33 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:29 -0700
+Subject: scsi: qla2xxx: Use Correct index for Q-Pair array
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 178235f43ea142cf0f07dba67657494fcec21254
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+For target mode, the default number of Q-Pairs allowed to use is 2. If the
+number of Q-Pairs allocated is lower than the default Q-Pairs, then lower
+value should be the set as default.
+
+[mkp: typo]
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_target.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -6696,6 +6696,8 @@ qlt_enable_vha(struct scsi_qla_host *vha
+ if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED)
+ return;
+
++ if (ha->tgt.num_act_qpairs > ha->max_qpairs)
++ ha->tgt.num_act_qpairs = ha->max_qpairs;
+ spin_lock_irqsave(&ha->hardware_lock, flags);
+ tgt->tgt_stopped = 0;
+ qlt_set_mode(vha);
diff --git a/patches.drivers/scsi-qla2xxx-Use-an-on-stack-completion-in-qla24xx_c.patch b/patches.drivers/scsi-qla2xxx-Use-an-on-stack-completion-in-qla24xx_c.patch
new file mode 100644
index 0000000000..7e5db456ce
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-an-on-stack-completion-in-qla24xx_c.patch
@@ -0,0 +1,81 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:34 -0700
+Subject: scsi: qla2xxx: Use an on-stack completion in qla24xx_control_vp()
+Patch-mainline: v5.2-rc1
+Git-commit: 982cc4be05d6d0d8b15b1340416737ad60bddcae
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch reduces the size of struct srb.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 2 +-
+ drivers/scsi/qla2xxx/qla_iocb.c | 1 -
+ drivers/scsi/qla2xxx/qla_mid.c | 9 +++++++--
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -545,7 +545,7 @@ typedef struct srb {
+ u32 gen2; /* scratch */
+ int rc;
+ int retry_count;
+- struct completion comp;
++ struct completion *comp;
+ wait_queue_head_t *cwaitq;
+ union {
+ struct srb_iocb iocb_cmd;
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -2578,7 +2578,6 @@ qla2x00_init_timer(srb_t *sp, unsigned l
+ sp->u.iocb_cmd.timer.data = (unsigned long)sp;
+ sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
+ sp->free = qla2x00_sp_free;
+- init_completion(&sp->comp);
+ if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
+ init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
+ add_timer(&sp->u.iocb_cmd.timer);
+--- a/drivers/scsi/qla2xxx/qla_mid.c
++++ b/drivers/scsi/qla2xxx/qla_mid.c
+@@ -905,7 +905,8 @@ static void qla_ctrlvp_sp_done(void *s,
+ {
+ struct srb *sp = s;
+
+- complete(&sp->comp);
++ if (sp->comp)
++ complete(sp->comp);
+ /* don't free sp here. Let the caller do the free */
+ }
+
+@@ -922,6 +923,7 @@ int qla24xx_control_vp(scsi_qla_host_t *
+ struct qla_hw_data *ha = vha->hw;
+ int vp_index = vha->vp_idx;
+ struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
++ DECLARE_COMPLETION_ONSTACK(comp);
+ srb_t *sp;
+
+ ql_dbg(ql_dbg_vport, vha, 0x10c1,
+@@ -936,6 +938,7 @@ int qla24xx_control_vp(scsi_qla_host_t *
+
+ sp->type = SRB_CTRL_VP;
+ sp->name = "ctrl_vp";
++ sp->comp = &comp;
+ sp->done = qla_ctrlvp_sp_done;
+ sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
+ qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
+@@ -953,7 +956,9 @@ int qla24xx_control_vp(scsi_qla_host_t *
+ ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n",
+ sp->name, sp->handle);
+
+- wait_for_completion(&sp->comp);
++ wait_for_completion(&comp);
++ sp->comp = NULL;
++
+ rval = sp->rc;
+ switch (rval) {
+ case QLA_FUNCTION_TIMEOUT:
diff --git a/patches.drivers/scsi-qla2xxx-Use-common-update-firmware-options-rout.patch b/patches.drivers/scsi-qla2xxx-Use-common-update-firmware-options-rout.patch
new file mode 100644
index 0000000000..1cfae178a8
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-common-update-firmware-options-rout.patch
@@ -0,0 +1,31 @@
+From: Andrew Vasquez <andrewv@marvell.com>
+Date: Fri, 26 Jul 2019 09:07:37 -0700
+Subject: scsi: qla2xxx: Use common update-firmware-options routine for
+ ISP27xx+
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: a36f1443e6fc738c1bcfc4be80d6f1609163c614
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Leverage the generic routine, qla24xx_update_fw_options(), for the
+configuration of firmware options for ISP27xx/ISP28xx.
+
+Signed-off-by: Andrew Vasquez <andrewv@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -2483,7 +2483,7 @@ static struct isp_operations qla27xx_isp
+ .config_rings = qla24xx_config_rings,
+ .reset_adapter = qla24xx_reset_adapter,
+ .nvram_config = qla81xx_nvram_config,
+- .update_fw_options = qla81xx_update_fw_options,
++ .update_fw_options = qla24xx_update_fw_options,
+ .load_risc = qla81xx_load_risc,
+ .pci_info_str = qla24xx_pci_info_str,
+ .fw_version_str = qla24xx_fw_version_str,
diff --git a/patches.drivers/scsi-qla2xxx-Use-get-put_unaligned-where-appropriate.patch b/patches.drivers/scsi-qla2xxx-Use-get-put_unaligned-where-appropriate.patch
new file mode 100644
index 0000000000..827f993e9f
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-get-put_unaligned-where-appropriate.patch
@@ -0,0 +1,124 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:45 -0700
+Subject: scsi: qla2xxx: Use get/put_unaligned where appropriate
+Patch-mainline: v5.2-rc1
+Git-commit: 2c26348c4d090caeb308530ea893b37897e4a58d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+This patch makes the code easier to read but does not change any
+functionality.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
+ drivers/scsi/qla2xxx/qla_iocb.c | 21 +++++++++------------
+ drivers/scsi/qla2xxx/qla_nvme.c | 4 ++--
+ 3 files changed, 12 insertions(+), 15 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_bsg.c
++++ b/drivers/scsi/qla2xxx/qla_bsg.c
+@@ -1043,7 +1043,7 @@ qla84xx_updatefw(struct bsg_job *bsg_job
+ }
+
+ flag = bsg_request->rqst_data.h_vendor.vendor_cmd[1];
+- fw_ver = le32_to_cpu(*((uint32_t *)((uint32_t *)fw_buf + 2)));
++ fw_ver = get_unaligned_le32((uint32_t *)fw_buf + 2);
+
+ memset(mn, 0, sizeof(struct access_chip_84xx));
+ mn->entry_type = VERIFY_CHIP_IOCB_TYPE;
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -107,7 +107,7 @@ qla2x00_prep_cont_type0_iocb(struct scsi
+ cont_pkt = (cont_entry_t *)req->ring_ptr;
+
+ /* Load packet defaults. */
+- *((uint32_t *)(&cont_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE);
++ put_unaligned_le32(CONTINUE_TYPE, &cont_pkt->entry_type);
+
+ return (cont_pkt);
+ }
+@@ -136,9 +136,8 @@ qla2x00_prep_cont_type1_iocb(scsi_qla_ho
+ cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
+
+ /* Load packet defaults. */
+- *((uint32_t *)(&cont_pkt->entry_type)) = IS_QLAFX00(vha->hw) ?
+- cpu_to_le32(CONTINUE_A64_TYPE_FX00) :
+- cpu_to_le32(CONTINUE_A64_TYPE);
++ put_unaligned_le32(IS_QLAFX00(vha->hw) ? CONTINUE_A64_TYPE_FX00 :
++ CONTINUE_A64_TYPE, &cont_pkt->entry_type);
+
+ return (cont_pkt);
+ }
+@@ -202,8 +201,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *
+ cmd = GET_CMD_SP(sp);
+
+ /* Update entry type to indicate Command Type 2 IOCB */
+- *((uint32_t *)(&cmd_pkt->entry_type)) =
+- cpu_to_le32(COMMAND_TYPE);
++ put_unaligned_le32(COMMAND_TYPE, &cmd_pkt->entry_type);
+
+ /* No data transfer */
+ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
+@@ -260,7 +258,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *
+ cmd = GET_CMD_SP(sp);
+
+ /* Update entry type to indicate Command Type 3 IOCB */
+- *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_A64_TYPE);
++ put_unaligned_le32(COMMAND_A64_TYPE, &cmd_pkt->entry_type);
+
+ /* No data transfer */
+ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
+@@ -596,7 +594,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *s
+ cmd = GET_CMD_SP(sp);
+
+ /* Update entry type to indicate Command Type 3 IOCB */
+- *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_6);
++ put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
+
+ /* No data transfer */
+ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
+@@ -711,7 +709,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, stru
+ cmd = GET_CMD_SP(sp);
+
+ /* Update entry type to indicate Command Type 3 IOCB */
+- *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_7);
++ put_unaligned_le32(COMMAND_TYPE_7, &cmd_pkt->entry_type);
+
+ /* No data transfer */
+ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
+@@ -1428,7 +1426,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp
+ cmd = GET_CMD_SP(sp);
+
+ /* Update entry type to indicate Command Type CRC_2 IOCB */
+- *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_CRC_2);
++ put_unaligned_le32(COMMAND_TYPE_CRC_2, &cmd_pkt->entry_type);
+
+ vha = sp->vha;
+ ha = vha->hw;
+@@ -3755,8 +3753,7 @@ qla25xx_build_bidir_iocb(srb_t *sp, stru
+ struct bsg_job *bsg_job = sp->u.bsg_job;
+
+ /*Update entry type to indicate bidir command */
+- *((uint32_t *)(&cmd_pkt->entry_type)) =
+- cpu_to_le32(COMMAND_BIDIRECTIONAL);
++ put_unaligned_le32(COMMAND_BIDIRECTIONAL, &cmd_pkt->entry_type);
+
+ /* Set the transfer direction, in this set both flags
+ * Also set the BD_WRAP_BACK flag, firmware will take care
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -460,8 +460,8 @@ static inline int qla2x00_start_nvme_mq(
+ req->ring_ptr++;
+ }
+ cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
+- *((uint32_t *)(&cont_pkt->entry_type)) =
+- cpu_to_le32(CONTINUE_A64_TYPE);
++ put_unaligned_le32(CONTINUE_A64_TYPE,
++ &cont_pkt->entry_type);
+
+ cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
+ avail_dsds = 5;
diff --git a/patches.drivers/scsi-qla2xxx-Use-mutex-protection-during-qla2x00_sys.patch b/patches.drivers/scsi-qla2xxx-Use-mutex-protection-during-qla2x00_sys.patch
new file mode 100644
index 0000000000..2cbb22a2ce
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-mutex-protection-during-qla2x00_sys.patch
@@ -0,0 +1,93 @@
+From: Quinn Tran <quinn.tran@cavium.com>
+Date: Tue, 2 Apr 2019 14:24:28 -0700
+Subject: scsi: qla2xxx: Use mutex protection during
+ qla2x00_sysfs_read_fw_dump()
+Patch-mainline: v5.2-rc1
+Git-commit: a6b95d1c71e9adef5ab5ba77c42a50d0b7b409d6
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Add mutex protection to prevent driver from freeing the FW dump buffer
+while the extraction is in progress.
+
+[mkp: commit desc]
+
+Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_attr.c | 25 ++++++++++++++-----------
+ drivers/scsi/qla2xxx/qla_init.c | 6 +++++-
+ 2 files changed, 19 insertions(+), 12 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_attr.c
++++ b/drivers/scsi/qla2xxx/qla_attr.c
+@@ -29,24 +29,27 @@ qla2x00_sysfs_read_fw_dump(struct file *
+ if (!(ha->fw_dump_reading || ha->mctp_dump_reading))
+ return 0;
+
++ mutex_lock(&ha->optrom_mutex);
+ if (IS_P3P_TYPE(ha)) {
+ if (off < ha->md_template_size) {
+ rval = memory_read_from_buffer(buf, count,
+ &off, ha->md_tmplt_hdr, ha->md_template_size);
+- return rval;
++ } else {
++ off -= ha->md_template_size;
++ rval = memory_read_from_buffer(buf, count,
++ &off, ha->md_dump, ha->md_dump_size);
+ }
+- off -= ha->md_template_size;
+- rval = memory_read_from_buffer(buf, count,
+- &off, ha->md_dump, ha->md_dump_size);
+- return rval;
+- } else if (ha->mctp_dumped && ha->mctp_dump_reading)
+- return memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
++ } else if (ha->mctp_dumped && ha->mctp_dump_reading) {
++ rval = memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
+ MCTP_DUMP_SIZE);
+- else if (ha->fw_dump_reading)
+- return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
++ } else if (ha->fw_dump_reading) {
++ rval = memory_read_from_buffer(buf, count, &off, ha->fw_dump,
+ ha->fw_dump_len);
+- else
+- return 0;
++ } else {
++ rval = 0;
++ }
++ mutex_unlock(&ha->optrom_mutex);
++ return rval;
+ }
+
+ static ssize_t
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -3236,6 +3236,7 @@ allocate:
+ "Unable to allocate (%d KB) for firmware dump.\n",
+ dump_size / 1024);
+ } else {
++ mutex_lock(&ha->optrom_mutex);
+ if (ha->fw_dumped) {
+ memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len);
+ vfree(ha->fw_dump);
+@@ -3255,8 +3256,10 @@ allocate:
+ "Allocated (%d KB) for firmware dump.\n",
+ dump_size / 1024);
+
+- if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
++ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
++ mutex_unlock(&ha->optrom_mutex);
+ return;
++ }
+
+ ha->fw_dump->signature[0] = 'Q';
+ ha->fw_dump->signature[1] = 'L';
+@@ -3279,6 +3282,7 @@ allocate:
+ htonl(offsetof
+ (struct qla2xxx_fw_dump, isp));
+ }
++ mutex_unlock(&ha->optrom_mutex);
+ }
+ }
+ }
diff --git a/patches.drivers/scsi-qla2xxx-Use-tabs-to-indent-code.patch b/patches.drivers/scsi-qla2xxx-Use-tabs-to-indent-code.patch
new file mode 100644
index 0000000000..65c1b72d65
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-Use-tabs-to-indent-code.patch
@@ -0,0 +1,88 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 11 Apr 2019 14:53:16 -0700
+Subject: scsi: qla2xxx: Use tabs to indent code
+Patch-mainline: v5.2-rc1
+Git-commit: 2703eaaf4eae64a742fdcf888c8fcf4de567fb7d
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Most but not all code in the qla2xxx driver uses tabs for indentation.
+Make the qla2xxx code easier to read by using tabs consistently for
+indentation. This patch improves conformance with the Linux kernel coding
+style.
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+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>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 26 +++++++++++++-------------
+ drivers/scsi/qla2xxx/qla_iocb.c | 12 ++++++------
+ 2 files changed, 19 insertions(+), 19 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -1622,21 +1622,21 @@ void qla2x00_fcport_event_handler(scsi_q
+ */
+ void qla_rscn_replay(fc_port_t *fcport)
+ {
+- struct event_arg ea;
++ struct event_arg ea;
+
+- switch (fcport->disc_state) {
+- case DSC_DELETE_PEND:
+- return;
+- default:
+- break;
+- }
++ switch (fcport->disc_state) {
++ case DSC_DELETE_PEND:
++ return;
++ default:
++ break;
++ }
+
+- if (fcport->scan_needed) {
+- memset(&ea, 0, sizeof(ea));
+- ea.event = FCME_RSCN;
+- ea.id = fcport->d_id;
+- ea.id.b.rsvd_1 = RSCN_PORT_ADDR;
+- qla2x00_fcport_event_handler(fcport->vha, &ea);
++ if (fcport->scan_needed) {
++ memset(&ea, 0, sizeof(ea));
++ ea.event = FCME_RSCN;
++ ea.id = fcport->d_id;
++ ea.id.b.rsvd_1 = RSCN_PORT_ADDR;
++ qla2x00_fcport_event_handler(fcport->vha, &ea);
+ }
+ }
+
+--- a/drivers/scsi/qla2xxx/qla_iocb.c
++++ b/drivers/scsi/qla2xxx/qla_iocb.c
+@@ -1523,18 +1523,18 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp
+ switch (scsi_get_prot_op(GET_CMD_SP(sp))) {
+ case SCSI_PROT_READ_INSERT:
+ case SCSI_PROT_WRITE_STRIP:
+- total_bytes = data_bytes;
+- data_bytes += dif_bytes;
+- break;
++ total_bytes = data_bytes;
++ data_bytes += dif_bytes;
++ break;
+
+ case SCSI_PROT_READ_STRIP:
+ case SCSI_PROT_WRITE_INSERT:
+ case SCSI_PROT_READ_PASS:
+ case SCSI_PROT_WRITE_PASS:
+- total_bytes = data_bytes + dif_bytes;
+- break;
++ total_bytes = data_bytes + dif_bytes;
++ break;
+ default:
+- BUG();
++ BUG();
+ }
+
+ if (!qla2x00_hba_err_chk_enabled(sp))
diff --git a/patches.drivers/scsi-qla2xxx-fix-spelling-mistake-alredy-already.patch b/patches.drivers/scsi-qla2xxx-fix-spelling-mistake-alredy-already.patch
new file mode 100644
index 0000000000..ebe34b3def
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-fix-spelling-mistake-alredy-already.patch
@@ -0,0 +1,28 @@
+From: Colin Ian King <colin.king@canonical.com>
+Date: Mon, 8 Apr 2019 09:20:14 +0100
+Subject: scsi: qla2xxx: fix spelling mistake "alredy" -> "already"
+Patch-mainline: v5.2-rc1
+Git-commit: ef19af9c2852a39878d54f185a1b32b781719542
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+There is a spelling mistake in a ql_log message. Fix it.
+
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -205,7 +205,7 @@ static void qla_nvme_abort_work(struct w
+ if (atomic_read(&sp->ref_count) == 0) {
+ WARN_ON(1);
+ ql_log(ql_log_info, fcport->vha, 0xffff,
+- "%s: command alredy aborted on sp: %p\n",
++ "%s: command already aborted on sp: %p\n",
+ __func__, sp);
+ return;
+ }
diff --git a/patches.drivers/scsi-qla2xxx-move-IO-flush-to-the-front-of-NVME-rpor.patch b/patches.drivers/scsi-qla2xxx-move-IO-flush-to-the-front-of-NVME-rpor.patch
new file mode 100644
index 0000000000..8c9fc6f0f3
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-move-IO-flush-to-the-front-of-NVME-rpor.patch
@@ -0,0 +1,125 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Sun, 16 Jun 2019 08:05:53 -0700
+Subject: scsi: qla2xxx: move IO flush to the front of NVME rport
+ unregistration
+Patch-mainline: v5.3-rc1
+Git-commit: baf23eddbf2a4ba9bf2bdb342686c71a8042e39b
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+On session deletion, current qla code would unregister an NVMe session
+before flushing IOs. This patch would move the unregistration of NVMe
+session after IO flush. This way FC-NVMe layer would not have to wait for
+stuck IOs. In addition, qla2xxx would stop accepting new IOs during session
+deletion.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_def.h | 1 -
+ drivers/scsi/qla2xxx/qla_gbl.h | 2 ++
+ drivers/scsi/qla2xxx/qla_nvme.c | 14 ++------------
+ drivers/scsi/qla2xxx/qla_target.c | 16 ++++++++--------
+ 4 files changed, 12 insertions(+), 21 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -2371,7 +2371,6 @@ typedef struct fc_port {
+ unsigned int id_changed:1;
+ unsigned int scan_needed:1;
+
+- struct work_struct nvme_del_work;
+ struct completion nvme_del_done;
+ uint32_t nvme_prli_service_param;
+ #define NVME_PRLI_SP_CONF BIT_7
+--- a/drivers/scsi/qla2xxx/qla_gbl.h
++++ b/drivers/scsi/qla2xxx/qla_gbl.h
+@@ -908,4 +908,6 @@ void qlt_clr_qp_table(struct scsi_qla_ho
+ void qlt_set_mode(struct scsi_qla_host *);
+ int qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode);
+
++/* nvme.c */
++void qla_nvme_unregister_remote_port(struct fc_port *fcport);
+ #endif /* _QLA_GBL_H */
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -12,8 +12,6 @@
+
+ static struct nvme_fc_port_template qla_nvme_fc_transport;
+
+-static void qla_nvme_unregister_remote_port(struct work_struct *);
+-
+ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
+ {
+ struct qla_nvme_rport *rport;
+@@ -38,7 +36,6 @@ int qla_nvme_register_remote(struct scsi
+ (fcport->nvme_flag & NVME_FLAG_REGISTERED))
+ return 0;
+
+- INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port);
+ fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
+
+ memset(&req, 0, sizeof(struct nvme_fc_port_info));
+@@ -636,16 +633,11 @@ static void qla_nvme_remoteport_delete(s
+ fcport = qla_rport->fcport;
+ fcport->nvme_remote_port = NULL;
+ fcport->nvme_flag &= ~NVME_FLAG_REGISTERED;
+-
+- complete(&fcport->nvme_del_done);
+-
+- INIT_WORK(&fcport->free_work, qlt_free_session_done);
+- schedule_work(&fcport->free_work);
+-
+ fcport->nvme_flag &= ~NVME_FLAG_DELETING;
+ ql_log(ql_log_info, fcport->vha, 0x2110,
+ "remoteport_delete of %p %8phN completed.\n",
+ fcport, fcport->port_name);
++ complete(&fcport->nvme_del_done);
+ }
+
+ static struct nvme_fc_port_template qla_nvme_fc_transport = {
+@@ -668,10 +660,8 @@ static struct nvme_fc_port_template qla_
+ .fcprqst_priv_sz = sizeof(struct nvme_private),
+ };
+
+-static void qla_nvme_unregister_remote_port(struct work_struct *work)
++void qla_nvme_unregister_remote_port(struct fc_port *fcport)
+ {
+- struct fc_port *fcport = container_of(work, struct fc_port,
+- nvme_del_work);
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_NVME_FC))
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -1013,6 +1013,12 @@ void qlt_free_session_done(struct work_s
+ else
+ logout_started = true;
+ }
++ } /* if sess->logout_on_delete */
++
++ if (sess->nvme_flag & NVME_FLAG_REGISTERED &&
++ !(sess->nvme_flag & NVME_FLAG_DELETING)) {
++ sess->nvme_flag |= NVME_FLAG_DELETING;
++ qla_nvme_unregister_remote_port(sess);
+ }
+ }
+
+@@ -1164,14 +1170,8 @@ void qlt_unreg_sess(struct fc_port *sess
+ sess->last_rscn_gen = sess->rscn_gen;
+ sess->last_login_gen = sess->login_gen;
+
+- if (sess->nvme_flag & NVME_FLAG_REGISTERED &&
+- !(sess->nvme_flag & NVME_FLAG_DELETING)) {
+- sess->nvme_flag |= NVME_FLAG_DELETING;
+- schedule_work(&sess->nvme_del_work);
+- } else {
+- INIT_WORK(&sess->free_work, qlt_free_session_done);
+- schedule_work(&sess->free_work);
+- }
++ INIT_WORK(&sess->free_work, qlt_free_session_done);
++ schedule_work(&sess->free_work);
+ }
+ EXPORT_SYMBOL(qlt_unreg_sess);
+
diff --git a/patches.drivers/scsi-qla2xxx-on-session-delete-return-nvme-cmd.patch b/patches.drivers/scsi-qla2xxx-on-session-delete-return-nvme-cmd.patch
new file mode 100644
index 0000000000..acb58d72b5
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-on-session-delete-return-nvme-cmd.patch
@@ -0,0 +1,98 @@
+From: Quinn Tran <qutran@marvell.com>
+Date: Fri, 21 Jun 2019 09:50:23 -0700
+Subject: scsi: qla2xxx: on session delete, return nvme cmd
+Patch-mainline: v5.3-rc1
+Git-commit: 2eb9238affa72a5260b14388cf56598f7413109b
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+ - on session delete or chip reset, reject all NVME commands.
+
+ - on NVME command submission error, free srb resource.
+
+Signed-off-by: Quinn Tran <qutran@marvell.com>
+Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_nvme.c | 28 +++++++++++++++++++---------
+ 1 file changed, 19 insertions(+), 9 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -239,8 +239,16 @@ static int qla_nvme_ls_req(struct nvme_f
+ struct qla_hw_data *ha;
+ srb_t *sp;
+
++
++ if (!fcport || (fcport && fcport->deleted))
++ return rval;
++
+ vha = fcport->vha;
+ ha = vha->hw;
++
++ if (!ha->flags.fw_started)
++ return rval;
++
+ /* Alloc SRB structure */
+ sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
+ if (!sp)
+@@ -272,6 +280,7 @@ static int qla_nvme_ls_req(struct nvme_f
+ "qla2x00_start_sp failed = %d\n", rval);
+ atomic_dec(&sp->ref_count);
+ wake_up(&sp->nvme_ls_waitq);
++ sp->free(sp);
+ return rval;
+ }
+
+@@ -503,11 +512,11 @@ static int qla_nvme_post_cmd(struct nvme
+
+ fcport = qla_rport->fcport;
+
+- vha = fcport->vha;
+-
+- if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
++ if (!qpair || !fcport || (qpair && !qpair->fw_started) ||
++ (fcport && fcport->deleted))
+ return rval;
+
++ vha = fcport->vha;
+ /*
+ * If we know the dev is going away while the transport is still sending
+ * IO's return busy back to stall the IO Q. This happens when the
+@@ -540,6 +549,7 @@ static int qla_nvme_post_cmd(struct nvme
+ "qla2x00_start_nvme_mq failed = %d\n", rval);
+ atomic_dec(&sp->ref_count);
+ wake_up(&sp->nvme_ls_waitq);
++ sp->free(sp);
+ }
+
+ return rval;
+@@ -566,14 +576,13 @@ static void qla_nvme_remoteport_delete(s
+
+ complete(&fcport->nvme_del_done);
+
+- if (!test_bit(UNLOADING, &fcport->vha->dpc_flags)) {
+- INIT_WORK(&fcport->free_work, qlt_free_session_done);
+- schedule_work(&fcport->free_work);
+- }
++ INIT_WORK(&fcport->free_work, qlt_free_session_done);
++ schedule_work(&fcport->free_work);
+
+ fcport->nvme_flag &= ~NVME_FLAG_DELETING;
+ ql_log(ql_log_info, fcport->vha, 0x2110,
+- "remoteport_delete of %p completed.\n", fcport);
++ "remoteport_delete of %p %8phN completed.\n",
++ fcport, fcport->port_name);
+ }
+
+ static struct nvme_fc_port_template qla_nvme_fc_transport = {
+@@ -606,7 +615,8 @@ static void qla_nvme_unregister_remote_p
+ return;
+
+ ql_log(ql_log_warn, NULL, 0x2112,
+- "%s: unregister remoteport on %p\n",__func__, fcport);
++ "%s: unregister remoteport on %p %8phN\n",
++ __func__, fcport, fcport->port_name);
+
+ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
+ init_completion(&fcport->nvme_del_done);
diff --git a/patches.drivers/scsi-qla2xxx-qla2x00_alloc_fw_dump-set-ha-eft.patch b/patches.drivers/scsi-qla2xxx-qla2x00_alloc_fw_dump-set-ha-eft.patch
new file mode 100644
index 0000000000..cdbd72cefc
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-qla2x00_alloc_fw_dump-set-ha-eft.patch
@@ -0,0 +1,38 @@
+From: Martin Wilck <mwilck@suse.com>
+Date: Wed, 14 Aug 2019 13:28:27 +0000
+Subject: scsi: qla2xxx: qla2x00_alloc_fw_dump: set ha->eft
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
+Git-commit: 530106fa95c998ff16fb80a6ad10829396083931
+References: bsc#1134476
+
+In qla2x00_alloc_fw_dump(), an existing EFT buffer (e.g. from previous
+invocation of qla2x00_alloc_offload_mem()) is freed. The buffer is then
+re-allocated, but without setting the eft and eft_dma fields to the new
+values.
+
+Fixes: a28d9e4ef997 ("scsi: qla2xxx: Add support for multiple fwdump templates/segments")
+Cc: Joe Carnuccio <joe.carnuccio@cavium.com>
+Cc: Quinn Tran <qutran@marvell.com>
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+Tested-by: Himanshu Madhani <hmadhani@marvell.com>
+Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -3249,6 +3249,8 @@ try_eft:
+ ql_dbg(ql_dbg_init, vha, 0x00c3,
+ "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
+ eft_size = EFT_SIZE;
++ ha->eft_dma = tc_dma;
++ ha->eft = tc;
+ }
+
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
diff --git a/patches.drivers/scsi-qla2xxx-remove-double-assignment-in-qla2x00_upd.patch b/patches.drivers/scsi-qla2xxx-remove-double-assignment-in-qla2x00_upd.patch
new file mode 100644
index 0000000000..8a3bdb4a02
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-remove-double-assignment-in-qla2x00_upd.patch
@@ -0,0 +1,27 @@
+From: Enzo Matsumiya <ematsumiya@suse.de>
+Date: Tue, 7 May 2019 12:39:05 -0300
+Subject: scsi: qla2xxx: remove double assignment in qla2x00_update_fcport
+Patch-mainline: v5.3-rc1
+Git-commit: a90ef98b21cf40784af7ace77038f8341a7b96c8
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Remove double assignment in qla2x00_update_fcport().
+
+Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_init.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -5408,7 +5408,6 @@ qla2x00_update_fcport(scsi_qla_host_t *v
+ fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
+ fcport->deleted = 0;
+ fcport->logout_on_delete = 1;
+- fcport->login_retry = vha->hw->login_retry_count;
+ fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0;
+
+ switch (vha->hw->current_topology) {
diff --git a/patches.drivers/scsi-qla2xxx-target-Fix-offline-port-handling-and-ho.patch b/patches.drivers/scsi-qla2xxx-target-Fix-offline-port-handling-and-ho.patch
new file mode 100644
index 0000000000..8389aab423
--- /dev/null
+++ b/patches.drivers/scsi-qla2xxx-target-Fix-offline-port-handling-and-ho.patch
@@ -0,0 +1,165 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 17 Apr 2019 14:44:29 -0700
+Subject: scsi: qla2xxx: target: Fix offline port handling and host reset
+ handling
+Patch-mainline: v5.2-rc1
+Git-commit: aefed3e5548f28e5fecafda6604fcbc65484dbaa
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Remove the function qlt_abort_cmd_on_host_reset() because it can do the
+following, all of which can cause a kernel crash:
+
+- DMA unmapping while DMA is in progress.
+- Call target_execute_cmd() while DMA is in progress.
+- Call transport_generic_free_cmd() while the LIO core owns a command.
+
+Instead of trying to abort a command asynchronously, set the 'aborted' flag
+and handle the abort after the hardware has passed control back to the
+tcm_qla2xxx driver.
+
+Cc: Arun Easi <arun.easi@qlogic.com>
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Fixes: c0cb44967b4a ("qla2xxx: Add Host reset handling in target mode.") # v3.18.
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 9 +-------
+ drivers/scsi/qla2xxx/qla_target.c | 41 +++----------------------------------
+ drivers/scsi/qla2xxx/qla_target.h | 11 +++++++--
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 3 +-
+ 4 files changed, 16 insertions(+), 48 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -1852,15 +1852,10 @@ __qla2x00_abort_all_cmds(struct qla_qpai
+ continue;
+ }
+ cmd = (struct qla_tgt_cmd *)sp;
+- qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
++ cmd->aborted = 1;
+ break;
+ case TYPE_TGT_TMCMD:
+- /*
+- * Currently, only ABTS response gets on the
+- * outstanding_cmds[]
+- */
+- ha->tgt.tgt_ops->free_mcmd(
+- (struct qla_tgt_mgmt_cmd *)sp);
++ /* Skip task management functions. */
+ break;
+ default:
+ break;
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -3273,7 +3273,6 @@ int qlt_xmit_response(struct qla_tgt_cmd
+ if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) ||
+ (cmd->sess && cmd->sess->deleted)) {
+ cmd->state = QLA_TGT_STATE_PROCESSED;
+- qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
+ return 0;
+ }
+
+@@ -3302,7 +3301,6 @@ int qlt_xmit_response(struct qla_tgt_cmd
+ * previous life, just abort the processing.
+ */
+ cmd->state = QLA_TGT_STATE_PROCESSED;
+- qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
+ ql_dbg_qp(ql_dbg_async, qpair, 0xe101,
+ "RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n",
+ vha->flags.online, qla2x00_reset_active(vha),
+@@ -3443,8 +3441,10 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *
+ * Either the port is not online or this request was from
+ * previous life, just abort the processing.
+ */
+- cmd->state = QLA_TGT_STATE_NEED_DATA;
+- qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
++ cmd->aborted = 1;
++ cmd->write_data_transferred = 0;
++ cmd->state = QLA_TGT_STATE_DATA_IN;
++ vha->hw->tgt.tgt_ops->handle_data(cmd);
+ ql_dbg_qp(ql_dbg_async, qpair, 0xe102,
+ "RESET-XFR online/active/old-count/new-count = %d/%d/%d/%d.\n",
+ vha->flags.online, qla2x00_reset_active(vha),
+@@ -3966,39 +3966,6 @@ static void *qlt_ctio_to_cmd(struct scsi
+ return cmd;
+ }
+
+-/* hardware_lock should be held by caller. */
+-void
+-qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd)
+-{
+- struct qla_hw_data *ha = vha->hw;
+-
+- if (cmd->sg_mapped)
+- qlt_unmap_sg(vha, cmd);
+-
+- /* TODO: fix debug message type and ids. */
+- if (cmd->state == QLA_TGT_STATE_PROCESSED) {
+- ql_dbg(ql_dbg_io, vha, 0xff00,
+- "HOST-ABORT: state=PROCESSED.\n");
+- } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) {
+- cmd->write_data_transferred = 0;
+- cmd->state = QLA_TGT_STATE_DATA_IN;
+-
+- ql_dbg(ql_dbg_io, vha, 0xff01,
+- "HOST-ABORT: state=DATA_IN.\n");
+-
+- ha->tgt.tgt_ops->handle_data(cmd);
+- return;
+- } else {
+- ql_dbg(ql_dbg_io, vha, 0xff03,
+- "HOST-ABORT: state=BAD(%d).\n",
+- cmd->state);
+- dump_stack();
+- }
+-
+- cmd->trc_flags |= TRC_FLUSH;
+- ha->tgt.tgt_ops->free_cmd(cmd);
+-}
+-
+ /*
+ * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
+ */
+--- a/drivers/scsi/qla2xxx/qla_target.h
++++ b/drivers/scsi/qla2xxx/qla_target.h
+@@ -889,9 +889,16 @@ struct qla_tgt_cmd {
+ unsigned int term_exchg:1;
+ unsigned int cmd_sent_to_fw:1;
+ unsigned int cmd_in_wq:1;
+- unsigned int aborted:1;
+ unsigned int released:1;
+
++ /*
++ * This variable may be set from outside the LIO and I/O completion
++ * callback functions. Do not declare this member variable as a
++ * bitfield to avoid a read-modify-write operation when this variable
++ * is set.
++ */
++ unsigned int aborted;
++
+ struct scatterlist *sg; /* cmd data buffer SG vector */
+ int sg_cnt; /* SG segments count */
+ int bufflen; /* cmd buffer length */
+@@ -1101,7 +1108,5 @@ extern void qlt_do_generation_tick(struc
+
+ void qlt_send_resp_ctio(struct qla_qpair *, struct qla_tgt_cmd *, uint8_t,
+ uint8_t, uint8_t, uint8_t);
+-extern void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *,
+- struct qla_tgt_cmd *);
+
+ #endif /* __QLA_TARGET_H */
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -534,7 +534,8 @@ static void tcm_qla2xxx_handle_data_work
+ if (cmd->aborted) {
+ spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+- tcm_qla2xxx_free_cmd(cmd);
++ transport_generic_request_failure(&cmd->se_cmd,
++ TCM_CHECK_CONDITION_ABORT_CMD);
+ return;
+ }
+ spin_unlock_irqrestore(&cmd->cmd_lock, flags);
diff --git a/patches.drivers/scsi-scsi_transport_fc-nvme-display-FC-NVMe-port-rol.patch b/patches.drivers/scsi-scsi_transport_fc-nvme-display-FC-NVMe-port-rol.patch
new file mode 100644
index 0000000000..23f9be1311
--- /dev/null
+++ b/patches.drivers/scsi-scsi_transport_fc-nvme-display-FC-NVMe-port-rol.patch
@@ -0,0 +1,162 @@
+From: Hannes Reinecke <hare@suse.de>
+Date: Wed, 10 Apr 2019 16:16:19 +0200
+Subject: scsi: scsi_transport_fc: nvme: display FC-NVMe port roles
+Patch-mainline: v5.2-rc1
+Git-commit: a6a6d0589ac4ff3e1eb962f6c53e67d8f6386c18
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Currently the FC-NVMe driver is leverating the SCSI FC transport class to
+access the remote ports. Which means that all FC-NVMe remote ports will be
+visible to the fc transport layer, but due to missing definitions the port
+roles will always be 'unknown'. This patch adds the missing definitions to
+the fc transport class to that the port roles are correctly displayed.
+
+Signed-off-by: Hannes Reinecke <hare@suse.de>
+Reviewed-by: James Smart <james.smart@broadcom.com>
+Reviewed-by: Ewan D. Milne <emilne@redhat.com>
+Reviewed-by: Giridhar Malavali <gmalavali@marvell.com>
+Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/nvme/host/fc.c | 2 +-
+ drivers/scsi/lpfc/lpfc_hbadisc.c | 10 ++++++++--
+ drivers/scsi/qla2xxx/qla_def.h | 5 ++++-
+ drivers/scsi/qla2xxx/qla_init.c | 15 +++++++++++----
+ drivers/scsi/qla2xxx/qla_mbx.c | 8 +++++++-
+ drivers/scsi/scsi_transport_fc.c | 3 +++
+ include/linux/nvme-fc-driver.h | 6 ------
+ include/scsi/scsi_transport_fc.h | 3 +++
+ 8 files changed, 37 insertions(+), 15 deletions(-)
+
+--- a/drivers/nvme/host/fc.c
++++ b/drivers/nvme/host/fc.c
+@@ -26,7 +26,7 @@
+ #include "fabrics.h"
+ #include <linux/nvme-fc-driver.h>
+ #include <linux/nvme-fc.h>
+-
++#include <scsi/scsi_transport_fc.h>
+
+ /* *************************** Data Structures/Defines ****************** */
+
+--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
+@@ -4146,9 +4146,15 @@ lpfc_register_remote_port(struct lpfc_vp
+ rdata->pnode = lpfc_nlp_get(ndlp);
+
+ if (ndlp->nlp_type & NLP_FCP_TARGET)
+- rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
++ rport_ids.roles |= FC_PORT_ROLE_FCP_TARGET;
+ if (ndlp->nlp_type & NLP_FCP_INITIATOR)
+- rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
++ rport_ids.roles |= FC_PORT_ROLE_FCP_INITIATOR;
++ if (ndlp->nlp_type & NLP_NVME_INITIATOR)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_INITIATOR;
++ if (ndlp->nlp_type & NLP_NVME_TARGET)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_TARGET;
++ if (ndlp->nlp_type & NLP_NVME_DISCOVERY)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_DISCOVERY;
+
+ if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN)
+ fc_remote_port_rolechg(rport, rport_ids.roles);
+--- a/drivers/scsi/qla2xxx/qla_def.h
++++ b/drivers/scsi/qla2xxx/qla_def.h
+@@ -2264,7 +2264,10 @@ typedef enum {
+ FCT_BROADCAST,
+ FCT_INITIATOR,
+ FCT_TARGET,
+- FCT_NVME
++ FCT_NVME_INITIATOR = 0x10,
++ FCT_NVME_TARGET = 0x20,
++ FCT_NVME_DISCOVERY = 0x40,
++ FCT_NVME = 0xf0,
+ } fc_port_type_t;
+
+ enum qla_sess_deletion {
+--- a/drivers/scsi/qla2xxx/qla_init.c
++++ b/drivers/scsi/qla2xxx/qla_init.c
+@@ -5275,16 +5275,23 @@ qla2x00_reg_remote_port(scsi_qla_host_t
+
+ rport->supported_classes = fcport->supported_classes;
+
+- rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
++ rport_ids.roles = FC_PORT_ROLE_UNKNOWN;
+ if (fcport->port_type == FCT_INITIATOR)
+- rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
++ rport_ids.roles |= FC_PORT_ROLE_FCP_INITIATOR;
+ if (fcport->port_type == FCT_TARGET)
+- rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
++ rport_ids.roles |= FC_PORT_ROLE_FCP_TARGET;
++ if (fcport->port_type & FCT_NVME_INITIATOR)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_INITIATOR;
++ if (fcport->port_type & FCT_NVME_TARGET)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_TARGET;
++ if (fcport->port_type & FCT_NVME_DISCOVERY)
++ rport_ids.roles |= FC_PORT_ROLE_NVME_DISCOVERY;
+
+ ql_dbg(ql_dbg_disc, vha, 0x20ee,
+ "%s %8phN. rport %p is %s mode\n",
+ __func__, fcport->port_name, rport,
+- (fcport->port_type == FCT_TARGET) ? "tgt" : "ini");
++ (fcport->port_type == FCT_TARGET) ? "tgt" :
++ ((fcport->port_type & FCT_NVME) ? "nvme" :"ini"));
+
+ fc_remote_port_rolechg(rport, rport_ids.roles);
+ }
+--- a/drivers/scsi/qla2xxx/qla_mbx.c
++++ b/drivers/scsi/qla2xxx/qla_mbx.c
+@@ -6387,7 +6387,13 @@ int __qla24xx_parse_gpdb(struct scsi_qla
+ fcport->d_id.b.rsvd_1 = 0;
+
+ if (fcport->fc4f_nvme) {
+- fcport->port_type = FCT_NVME;
++ fcport->port_type = 0;
++ if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0)
++ fcport->port_type |= FCT_NVME_INITIATOR;
++ if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
++ fcport->port_type |= FCT_NVME_TARGET;
++ if ((pd->prli_svc_param_word_3[0] & BIT_3) == 0)
++ fcport->port_type |= FCT_NVME_DISCOVERY;
+ } else {
+ /* If not target must be initiator or unknown type. */
+ if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
+--- a/drivers/scsi/scsi_transport_fc.c
++++ b/drivers/scsi/scsi_transport_fc.c
+@@ -296,6 +296,9 @@ static const struct {
+ { FC_PORT_ROLE_FCP_INITIATOR, "FCP Initiator" },
+ { FC_PORT_ROLE_IP_PORT, "IP Port" },
+ { FC_PORT_ROLE_FCP_DUMMY_INITIATOR, "FCP Dummy Initiator" },
++ { FC_PORT_ROLE_NVME_INITIATOR, "NVMe Initiator" },
++ { FC_PORT_ROLE_NVME_TARGET, "NVMe Target" },
++ { FC_PORT_ROLE_NVME_DISCOVERY, "NVMe Discovery" },
+ };
+ fc_bitfield_name_search(port_roles, fc_port_role_names)
+
+--- a/include/linux/nvme-fc-driver.h
++++ b/include/linux/nvme-fc-driver.h
+@@ -25,12 +25,6 @@
+
+
+
+-/* FC Port role bitmask - can merge with FC Port Roles in fc transport */
+-#define FC_PORT_ROLE_NVME_INITIATOR 0x10
+-#define FC_PORT_ROLE_NVME_TARGET 0x20
+-#define FC_PORT_ROLE_NVME_DISCOVERY 0x40
+-
+-
+ /**
+ * struct nvme_fc_port_info - port-specific ids and FC connection-specific
+ * data element used during NVME Host role
+--- a/include/scsi/scsi_transport_fc.h
++++ b/include/scsi/scsi_transport_fc.h
+@@ -165,6 +165,9 @@ enum fc_tgtid_binding_type {
+ #define FC_PORT_ROLE_FCP_INITIATOR 0x02
+ #define FC_PORT_ROLE_IP_PORT 0x04
+ #define FC_PORT_ROLE_FCP_DUMMY_INITIATOR 0x08
++#define FC_PORT_ROLE_NVME_INITIATOR 0x10
++#define FC_PORT_ROLE_NVME_TARGET 0x20
++#define FC_PORT_ROLE_NVME_DISCOVERY 0x40
+
+ /* The following are for compatibility */
+ #define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN
diff --git a/patches.drivers/scsi-tcm_qla2xxx-Minimize-include-directives.patch b/patches.drivers/scsi-tcm_qla2xxx-Minimize-include-directives.patch
new file mode 100644
index 0000000000..e290e860b4
--- /dev/null
+++ b/patches.drivers/scsi-tcm_qla2xxx-Minimize-include-directives.patch
@@ -0,0 +1,47 @@
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Thu, 4 Apr 2019 12:44:48 -0700
+Subject: scsi: tcm_qla2xxx: Minimize #include directives
+Patch-mainline: v5.2-rc1
+Git-commit: c8538b0b9ed65eb22849217fd397d614a42216e7
+References: bsc#1082635 bsc#1141340 bsc#1143706
+
+Only include those header files that are needed by the code in this source
+file.
+
+[mkp: include build fix from Bart for SPARC]
+
+Cc: Himanshu Madhani <hmadhani@marvell.com>
+Cc: Giridhar Malavali <gmalavali@marvell.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Himanshu Madhani <hmadhani@marvell.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+---
+ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 ------
+ 1 file changed, 6 deletions(-)
+
+--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+@@ -24,22 +24,16 @@
+
+
+ #include <linux/module.h>
+-#include <linux/moduleparam.h>
+ #include <linux/utsname.h>
+ #include <linux/vmalloc.h>
+-#include <linux/init.h>
+ #include <linux/list.h>
+ #include <linux/slab.h>
+-#include <linux/kthread.h>
+ #include <linux/types.h>
+ #include <linux/string.h>
+ #include <linux/configfs.h>
+ #include <linux/ctype.h>
+ #include <asm/unaligned.h>
+-#include <scsi/scsi.h>
+ #include <scsi/scsi_host.h>
+-#include <scsi/scsi_device.h>
+-#include <scsi/scsi_cmnd.h>
+ #include <target/target_core_base.h>
+ #include <target/target_core_fabric.h>
+
diff --git a/patches.drm/drm-amd-display-Remove-redundant-non-zero-and-overfl.patch b/patches.drm/drm-amd-display-Remove-redundant-non-zero-and-overfl.patch
new file mode 100644
index 0000000000..225ce56264
--- /dev/null
+++ b/patches.drm/drm-amd-display-Remove-redundant-non-zero-and-overfl.patch
@@ -0,0 +1,50 @@
+From 56780940389a344a949d53ed7be77012a20ced7a Mon Sep 17 00:00:00 2001
+From: "Leo (Sunpeng) Li" <sunpeng.li@amd.com>
+Date: Wed, 1 Aug 2018 10:20:53 -0400
+Subject: [PATCH] drm/amd/display: Remove redundant non-zero and overflow check
+Git-commit: 56780940389a344a949d53ed7be77012a20ced7a
+Patch-mainline: v4.20-rc1
+References: bsc#1145946
+
+[Why]
+Unsigned int is guaranteed to be >= 0, and read_channel_reply checks for
+overflows. read_channel_reply also returns -1 on error, which is what
+dc_link_aux_transfer is expected to return on error.
+
+[How]
+Remove the if-statement. Return result of read_channel_reply directly.
+
+Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
+Reviewed-by: Mikita Lipski <Mikita.Lipski@amd.com>
+Acked-by: Leo Li <sunpeng.li@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+index 8def0d9fa0ff..506a97e16956 100644
+--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
++++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+@@ -666,13 +666,9 @@ int dc_link_aux_transfer(struct ddc_service *ddc,
+
+ switch (operation_result) {
+ case AUX_CHANNEL_OPERATION_SUCCEEDED:
+- res = returned_bytes;
+-
+- if (res <= size && res >= 0)
+- res = aux_engine->funcs->read_channel_reply(aux_engine, size,
+- buffer, reply,
+- &status);
+-
++ res = aux_engine->funcs->read_channel_reply(aux_engine, size,
++ buffer, reply,
++ &status);
+ break;
+ case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON:
+ res = 0;
+--
+2.16.4
+
diff --git a/patches.drm/drm-amd-display-num-of-sw-i2c-aux-engines-less-than-.patch b/patches.drm/drm-amd-display-num-of-sw-i2c-aux-engines-less-than-.patch
new file mode 100644
index 0000000000..ae3acf77fc
--- /dev/null
+++ b/patches.drm/drm-amd-display-num-of-sw-i2c-aux-engines-less-than-.patch
@@ -0,0 +1,258 @@
+From 0e8e4fbf8d8905071c045f2922de55adbe1a6abe Mon Sep 17 00:00:00 2001
+From: Hersen Wu <hersenxs.wu@amd.com>
+Date: Tue, 21 Aug 2018 09:35:47 -0400
+Subject: [PATCH] drm/amd/display: num of sw i2c/aux engines less than num of connectors
+Git-commit: 0e8e4fbf8d8905071c045f2922de55adbe1a6abe
+Patch-mainline: v4.20-rc1
+References: bsc#1145946
+
+[why]
+AMD Stoney reference board, there are only 2 pipes (not include
+underlay), and 3 connectors. resource creation, only
+2 I2C/AUX engines are created. Within dc_link_aux_transfer, when
+pin_data_en =2, refer to enengines[ddc_pin->pin_data->en] = NULL.
+NULL point is referred later causing system crash.
+
+[how]
+each asic design has fixed number of ddc engines at hw side.
+for each ddc engine, create its i2x/aux engine at sw side.
+
+Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
+Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
+Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 6 +++
+ drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 4 ++
+ drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 5 +++
+ drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 10 ++++--
+ drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | 25 ++++++++++++++++
+ drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 8 +++--
+ drivers/gpu/drm/amd/display/dc/inc/resource.h | 1
+ 7 files changed, 52 insertions(+), 7 deletions(-)
+
+--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+@@ -371,7 +371,8 @@ static const struct resource_caps res_ca
+ .num_timing_generator = 6,
+ .num_audio = 6,
+ .num_stream_encoder = 6,
+- .num_pll = 3
++ .num_pll = 3,
++ .num_ddc = 6,
+ };
+
+ #define CTX ctx
+@@ -963,6 +964,9 @@ static bool construct(
+ "DC: failed to create output pixel processor!\n");
+ goto res_create_fail;
+ }
++ }
++
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dce100_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+@@ -377,6 +377,7 @@ static const struct resource_caps carriz
+ .num_audio = 3,
+ .num_stream_encoder = 3,
+ .num_pll = 2,
++ .num_ddc = 3,
+ };
+
+ static const struct resource_caps stoney_resource_cap = {
+@@ -385,6 +386,7 @@ static const struct resource_caps stoney
+ .num_audio = 3,
+ .num_stream_encoder = 3,
+ .num_pll = 2,
++ .num_ddc = 3,
+ };
+
+ #define CTX ctx
+@@ -1295,7 +1297,9 @@ static bool construct(
+ "DC: failed to create output pixel processor!\n");
+ goto res_create_fail;
+ }
++ }
+
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dce110_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+--- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
+@@ -383,6 +383,7 @@ static const struct resource_caps polari
+ .num_audio = 6,
+ .num_stream_encoder = 6,
+ .num_pll = 8, /* why 8? 6 combo PHY PLL + 2 regular PLLs? */
++ .num_ddc = 6,
+ };
+
+ static const struct resource_caps polaris_11_resource_cap = {
+@@ -390,6 +391,7 @@ static const struct resource_caps polari
+ .num_audio = 5,
+ .num_stream_encoder = 5,
+ .num_pll = 8, /* why 8? 6 combo PHY PLL + 2 regular PLLs? */
++ .num_ddc = 5,
+ };
+
+ #define CTX ctx
+@@ -1245,6 +1247,9 @@ static bool construct(
+ "DC:failed to create output pixel processor!\n");
+ goto res_create_fail;
+ }
++ }
++
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dce112_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+@@ -402,6 +402,7 @@ static const struct resource_caps res_ca
+ .num_audio = 7,
+ .num_stream_encoder = 6,
+ .num_pll = 6,
++ .num_ddc = 6,
+ };
+
+ static const struct dc_debug_options debug_defaults = {
+@@ -1020,6 +1021,12 @@ static bool construct(
+ dm_error(
+ "DC: failed to create output pixel processor!\n");
+ }
++
++ /* check next valid pipe */
++ j++;
++ }
++
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dce120_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+@@ -1027,9 +1034,6 @@ static bool construct(
+ "DC:failed to create aux engine!!\n");
+ goto res_create_fail;
+ }
+-
+- /* check next valid pipe */
+- j++;
+ }
+
+ /* valid pipe num */
+--- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
+@@ -366,6 +366,7 @@ static const struct resource_caps res_ca
+ .num_audio = 6,
+ .num_stream_encoder = 6,
+ .num_pll = 3,
++ .num_ddc = 6,
+ };
+
+ static const struct resource_caps res_cap_81 = {
+@@ -373,6 +374,7 @@ static const struct resource_caps res_ca
+ .num_audio = 7,
+ .num_stream_encoder = 7,
+ .num_pll = 3,
++ .num_ddc = 6,
+ };
+
+ static const struct resource_caps res_cap_83 = {
+@@ -380,6 +382,7 @@ static const struct resource_caps res_ca
+ .num_audio = 6,
+ .num_stream_encoder = 6,
+ .num_pll = 2,
++ .num_ddc = 2,
+ };
+
+ static const struct dce_dmcu_registers dmcu_regs = {
+@@ -935,7 +938,9 @@ static bool dce80_construct(
+ dm_error("DC: failed to create output pixel processor!\n");
+ goto res_create_fail;
+ }
++ }
+
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dce80_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+@@ -1131,6 +1136,16 @@ static bool dce81_construct(
+ }
+ }
+
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
++ pool->base.engines[i] = dce80_aux_engine_create(ctx, i);
++ if (pool->base.engines[i] == NULL) {
++ BREAK_TO_DEBUGGER();
++ dm_error(
++ "DC:failed to create aux engine!!\n");
++ goto res_create_fail;
++ }
++ }
++
+ dc->caps.max_planes = pool->base.pipe_count;
+ dc->caps.disable_dp_clk_share = true;
+
+@@ -1312,6 +1327,16 @@ static bool dce83_construct(
+ goto res_create_fail;
+ }
+ }
++
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
++ pool->base.engines[i] = dce80_aux_engine_create(ctx, i);
++ if (pool->base.engines[i] == NULL) {
++ BREAK_TO_DEBUGGER();
++ dm_error(
++ "DC:failed to create aux engine!!\n");
++ goto res_create_fail;
++ }
++ }
+
+ dc->caps.max_planes = pool->base.pipe_count;
+ dc->caps.disable_dp_clk_share = true;
+--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+@@ -500,6 +500,7 @@ static const struct resource_caps res_ca
+ .num_audio = 4,
+ .num_stream_encoder = 4,
+ .num_pll = 4,
++ .num_ddc = 4,
+ };
+
+ static const struct dc_debug_options debug_defaults_drv = {
+@@ -1292,7 +1293,11 @@ static bool construct(
+ dm_error("DC: failed to create tg!\n");
+ goto fail;
+ }
++ /* check next valid pipe */
++ j++;
++ }
+
++ for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+ pool->base.engines[i] = dcn10_aux_engine_create(ctx, i);
+ if (pool->base.engines[i] == NULL) {
+ BREAK_TO_DEBUGGER();
+@@ -1300,9 +1305,6 @@ static bool construct(
+ "DC:failed to create aux engine!!\n");
+ goto fail;
+ }
+-
+- /* check next valid pipe */
+- j++;
+ }
+
+ /* valid pipe num */
+--- a/drivers/gpu/drm/amd/display/dc/inc/resource.h
++++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h
+@@ -44,6 +44,7 @@ struct resource_caps {
+ int num_stream_encoder;
+ int num_pll;
+ int num_dwb;
++ int num_ddc;
+ };
+
+ struct resource_straps {
diff --git a/patches.drm/drm-amdgpu-added-support-2nd-UVD-instance.patch b/patches.drm/drm-amdgpu-added-support-2nd-UVD-instance.patch
new file mode 100644
index 0000000000..bafc60356e
--- /dev/null
+++ b/patches.drm/drm-amdgpu-added-support-2nd-UVD-instance.patch
@@ -0,0 +1,63 @@
+From d4e838431d56ac132a7f387b34e5c9f227dce428 Mon Sep 17 00:00:00 2001
+From: Evan Quan <evan.quan@amd.com>
+Date: Tue, 14 Aug 2018 14:53:52 -0400
+Subject: [PATCH] drm/amdgpu: added support 2nd UVD instance
+Git-commit: d4e838431d56ac132a7f387b34e5c9f227dce428
+Patch-mainline: v4.20-rc1
+References: bsc#1143331
+
+[ backport note: the code change for psp_v11_0.c is dropped -- tiwai ]
+
+Added psp fw loading support for vega20 2nd UVD instance.
+
+Signed-off-by: Evan Quan <evan.quan@amd.com>
+Acked-by: Huang Rui <ray.huang@amd.com>
+Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Feifei Xu <Feifei.Xu@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 1 +
+ drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 3 ++-
+ drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 7 +++++++
+ 3 files changed, 10 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
+@@ -193,6 +193,7 @@ enum AMDGPU_UCODE_ID {
+ AMDGPU_UCODE_ID_STORAGE,
+ AMDGPU_UCODE_ID_SMC,
+ AMDGPU_UCODE_ID_UVD,
++ AMDGPU_UCODE_ID_UVD1,
+ AMDGPU_UCODE_ID_VCE,
+ AMDGPU_UCODE_ID_VCN,
+ AMDGPU_UCODE_ID_MAXIMUM,
+--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
++++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+@@ -189,7 +189,8 @@ enum psp_gfx_fw_type
+ GFX_FW_TYPE_RLC_RESTORE_LIST_GPM_MEM = 20,
+ GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_MEM = 21,
+ GFX_FW_TYPE_RLC_RESTORE_LIST_CNTL = 22,
+- GFX_FW_TYPE_MAX = 23
++ GFX_FW_TYPE_UVD1 = 23,
++ GFX_FW_TYPE_MAX = 24
+ };
+
+ /* Command to load HW IP FW. */
+--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+@@ -441,6 +441,13 @@ static int uvd_v7_0_sw_init(void *handle
+ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].fw = adev->uvd.fw;
+ adev->firmware.fw_size +=
+ ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
++
++ if (adev->uvd.num_uvd_inst == UVD7_MAX_HW_INSTANCES_VEGA20) {
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD1].ucode_id = AMDGPU_UCODE_ID_UVD1;
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD1].fw = adev->uvd.fw;
++ adev->firmware.fw_size +=
++ ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
++ }
+ DRM_INFO("PSP loading UVD firmware\n");
+ }
+
diff --git a/patches.drm/drm-amdgpu-change-VEGA-booting-with-firmware-loaded-.patch b/patches.drm/drm-amdgpu-change-VEGA-booting-with-firmware-loaded-.patch
new file mode 100644
index 0000000000..b0cac8f480
--- /dev/null
+++ b/patches.drm/drm-amdgpu-change-VEGA-booting-with-firmware-loaded-.patch
@@ -0,0 +1,58 @@
+From bfcea5204287b0a09dac71fa56a5d066d94d9bb1 Mon Sep 17 00:00:00 2001
+From: Feifei Xu <Feifei.Xu@amd.com>
+Date: Tue, 14 Aug 2018 14:53:53 -0400
+Subject: [PATCH] drm/amdgpu:change VEGA booting with firmware loaded by PSP
+Git-commit: bfcea5204287b0a09dac71fa56a5d066d94d9bb1
+Patch-mainline: v4.20-rc1
+References: bsc#1143331
+
+With PSP firmware loading, TMR mc address is supposed to be used.
+
+Signed-off-by: James Zhu <James.Zhu@amd.com>
+Acked-by: Huang Rui <ray.huang@amd.com>
+Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Feifei Xu <Feifei.Xu@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+index 79cb3787a282..a289f6a20b6b 100644
+--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+@@ -671,9 +671,14 @@ static void uvd_v7_0_mc_resume(struct amdgpu_device *adev)
+ continue;
+ if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
+ WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW,
+- lower_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr));
++ i == 0 ?
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].tmr_mc_addr_lo:
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD1].tmr_mc_addr_lo);
+ WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH,
+- upper_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr));
++ i == 0 ?
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].tmr_mc_addr_hi:
++ adev->firmware.ucode[AMDGPU_UCODE_ID_UVD1].tmr_mc_addr_hi);
++ WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET0, 0);
+ offset = 0;
+ } else {
+ WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW,
+@@ -681,10 +686,10 @@ static void uvd_v7_0_mc_resume(struct amdgpu_device *adev)
+ WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH,
+ upper_32_bits(adev->uvd.inst[i].gpu_addr));
+ offset = size;
++ WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET0,
++ AMDGPU_UVD_FIRMWARE_OFFSET >> 3);
+ }
+
+- WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET0,
+- AMDGPU_UVD_FIRMWARE_OFFSET >> 3);
+ WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_SIZE0, size);
+
+ WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW,
+--
+2.16.4
+
diff --git a/patches.suse/mm-vmscan-do-not-special-case-slab-reclaim-when-watermarks-are-boosted.patch b/patches.suse/mm-vmscan-do-not-special-case-slab-reclaim-when-watermarks-are-boosted.patch
new file mode 100644
index 0000000000..aa7ff21f7f
--- /dev/null
+++ b/patches.suse/mm-vmscan-do-not-special-case-slab-reclaim-when-watermarks-are-boosted.patch
@@ -0,0 +1,292 @@
+From 496a61c34e3f964f5530688cd72895eed729bd23 Mon Sep 17 00:00:00 2001
+From: Mel Gorman <mgorman@suse.de>
+Date: Tue, 13 Aug 2019 15:37:57 -0700
+Subject: [PATCH] mm, vmscan: do not special-case slab reclaim when watermarks
+ are boosted
+
+References: git fixes (mm/vmscan)
+Patch-mainline: v5.3
+Git-commit: 28360f398778d7623a5ff8a8e90958c0d925e120
+
+Dave Chinner reported a problem pointing a finger at commit 1c30844d2dfe
+("mm: reclaim small amounts of memory when an external fragmentation
+event occurs").
+
+The report is extensive:
+
+ https://lore.kernel.org/linux-mm/20190807091858.2857-1-david@fromorbit.com/
+
+and it's worth recording the most relevant parts (colorful language and
+typos included).
+
+ When running a simple, steady state 4kB file creation test to
+ simulate extracting tarballs larger than memory full of small
+ files into the filesystem, I noticed that once memory fills up
+ the cache balance goes to hell.
+
+ The workload is creating one dirty cached inode for every dirty
+ page, both of which should require a single IO each to clean and
+ reclaim, and creation of inodes is throttled by the rate at which
+ dirty writeback runs at (via balance dirty pages). Hence the ingest
+ rate of new cached inodes and page cache pages is identical and
+ steady. As a result, memory reclaim should quickly find a steady
+ balance between page cache and inode caches.
+
+ The moment memory fills, the page cache is reclaimed at a much
+ faster rate than the inode cache, and evidence suggests that
+ the inode cache shrinker is not being called when large batches
+ of pages are being reclaimed. In roughly the same time period
+ that it takes to fill memory with 50% pages and 50% slab caches,
+ memory reclaim reduces the page cache down to just dirty pages
+ and slab caches fill the entirety of memory.
+
+ The LRU is largely full of dirty pages, and we're getting spikes
+ of random writeback from memory reclaim so it's all going to shit.
+ Behaviour never recovers, the page cache remains pinned at just
+ dirty pages, and nothing I could tune would make any difference.
+ vfs_cache_pressure makes no difference - I would set it so high
+ it should trim the entire inode caches in a single pass, yet it
+ didn't do anything. It was clear from tracing and live telemetry
+ that the shrinkers were pretty much not running except when
+ there was absolutely no memory free at all, and then they did
+ the minimum necessary to free memory to make progress.
+
+ So I went looking at the code, trying to find places where pages
+ got reclaimed and the shrinkers weren't called. There's only one
+ - kswapd doing boosted reclaim as per commit 1c30844d2dfe ("mm:
+ reclaim small amounts of memory when an external fragmentation
+ event occurs").
+
+The watermark boosting introduced by the commit is triggered in response
+to an allocation "fragmentation event". The boosting was not intended
+to target THP specifically and triggers even if THP is disabled.
+However, with Dave's perfectly reasonable workload, fragmentation events
+can be very common given the ratio of slab to page cache allocations so
+boosting remains active for long periods of time.
+
+As high-order allocations might use compaction and compaction cannot
+move slab pages the decision was made in the commit to special-case
+kswapd when watermarks are boosted -- kswapd avoids reclaiming slab as
+reclaiming slab does not directly help compaction.
+
+As Dave notes, this decision means that slab can be artificially
+protected for long periods of time and messes up the balance with slab
+and page caches.
+
+Removing the special casing can still indirectly help avoid
+fragmentation by avoiding fragmentation-causing events due to slab
+allocation as pages from a slab pageblock will have some slab objects
+freed. Furthermore, with the special casing, reclaim behaviour is
+unpredictable as kswapd sometimes examines slab and sometimes does not
+in a manner that is tricky to tune or analyse.
+
+This patch removes the special casing. The downside is that this is not
+a universal performance win. Some benchmarks that depend on the
+residency of data when rereading metadata may see a regression when slab
+reclaim is restored to its original behaviour. Similarly, some
+benchmarks that only read-once or write-once may perform better when
+page reclaim is too aggressive. The primary upside is that slab
+shrinker is less surprising (arguably more sane but that's a matter of
+opinion), behaves consistently regardless of the fragmentation state of
+the system and properly obeys VM sysctls.
+
+A fsmark benchmark configuration was constructed similar to what Dave
+reported and is codified by the mmtest configuration
+config-io-fsmark-small-file-stream. It was evaluated on a 1-socket
+machine to avoid dealing with NUMA-related issues and the timing of
+reclaim. The storage was an SSD Samsung Evo and a fresh trimmed XFS
+filesystem was used for the test data.
+
+This is not an exact replication of Dave's setup. The configuration
+scales its parameters depending on the memory size of the SUT to behave
+similarly across machines. The parameters mean the first sample
+reported by fs_mark is using 50% of RAM which will barely be throttled
+and look like a big outlier. Dave used fake NUMA to have multiple
+kswapd instances which I didn't replicate. Finally, the number of
+iterations differ from Dave's test as the target disk was not large
+enough. While not identical, it should be representative.
+
+ fsmark
+ 5.3.0-rc3 5.3.0-rc3
+ vanilla shrinker-v1r1
+ Min 1-files/sec 4444.80 ( 0.00%) 4765.60 ( 7.22%)
+ 1st-qrtle 1-files/sec 5005.10 ( 0.00%) 5091.70 ( 1.73%)
+ 2nd-qrtle 1-files/sec 4917.80 ( 0.00%) 4855.60 ( -1.26%)
+ 3rd-qrtle 1-files/sec 4667.40 ( 0.00%) 4831.20 ( 3.51%)
+ Max-1 1-files/sec 11421.50 ( 0.00%) 9999.30 ( -12.45%)
+ Max-5 1-files/sec 11421.50 ( 0.00%) 9999.30 ( -12.45%)
+ Max-10 1-files/sec 11421.50 ( 0.00%) 9999.30 ( -12.45%)
+ Max-90 1-files/sec 4649.60 ( 0.00%) 4780.70 ( 2.82%)
+ Max-95 1-files/sec 4491.00 ( 0.00%) 4768.20 ( 6.17%)
+ Max-99 1-files/sec 4491.00 ( 0.00%) 4768.20 ( 6.17%)
+ Max 1-files/sec 11421.50 ( 0.00%) 9999.30 ( -12.45%)
+ Hmean 1-files/sec 5004.75 ( 0.00%) 5075.96 ( 1.42%)
+ Stddev 1-files/sec 1778.70 ( 0.00%) 1369.66 ( 23.00%)
+ CoeffVar 1-files/sec 33.70 ( 0.00%) 26.05 ( 22.71%)
+ BHmean-99 1-files/sec 5053.72 ( 0.00%) 5101.52 ( 0.95%)
+ BHmean-95 1-files/sec 5053.72 ( 0.00%) 5101.52 ( 0.95%)
+ BHmean-90 1-files/sec 5107.05 ( 0.00%) 5131.41 ( 0.48%)
+ BHmean-75 1-files/sec 5208.45 ( 0.00%) 5206.68 ( -0.03%)
+ BHmean-50 1-files/sec 5405.53 ( 0.00%) 5381.62 ( -0.44%)
+ BHmean-25 1-files/sec 6179.75 ( 0.00%) 6095.14 ( -1.37%)
+
+ 5.3.0-rc3 5.3.0-rc3
+ vanillashrinker-v1r1
+ Duration User 501.82 497.29
+ Duration System 4401.44 4424.08
+ Duration Elapsed 8124.76 8358.05
+
+This is showing a slight skew for the max result representing a large
+outlier for the 1st, 2nd and 3rd quartile are similar indicating that
+the bulk of the results show little difference. Note that an earlier
+version of the fsmark configuration showed a regression but that
+included more samples taken while memory was still filling.
+
+Note that the elapsed time is higher. Part of this is that the
+configuration included time to delete all the test files when the test
+completes -- the test automation handles the possibility of testing
+fsmark with multiple thread counts. Without the patch, many of these
+objects would be memory resident which is part of what the patch is
+addressing.
+
+There are other important observations that justify the patch.
+
+1. With the vanilla kernel, the number of dirty pages in the system is
+ very low for much of the test. With this patch, dirty pages is
+ generally kept at 10% which matches vm.dirty_background_ratio which
+ is normal expected historical behaviour.
+
+2. With the vanilla kernel, the ratio of Slab/Pagecache is close to
+ 0.95 for much of the test i.e. Slab is being left alone and
+ dominating memory consumption. With the patch applied, the ratio
+ varies between 0.35 and 0.45 with the bulk of the measured ratios
+ roughly half way between those values. This is a different balance to
+ what Dave reported but it was at least consistent.
+
+3. Slabs are scanned throughout the entire test with the patch applied.
+ The vanille kernel has periods with no scan activity and then
+ relatively massive spikes.
+
+4. Without the patch, kswapd scan rates are very variable. With the
+ patch, the scan rates remain quite steady.
+
+4. Overall vmstats are closer to normal expectations
+
+ 5.3.0-rc3 5.3.0-rc3
+ vanilla shrinker-v1r1
+ Ops Direct pages scanned 99388.00 328410.00
+ Ops Kswapd pages scanned 45382917.00 33451026.00
+ Ops Kswapd pages reclaimed 30869570.00 25239655.00
+ Ops Direct pages reclaimed 74131.00 5830.00
+ Ops Kswapd efficiency % 68.02 75.45
+ Ops Kswapd velocity 5585.75 4002.25
+ Ops Page reclaim immediate 1179721.00 430927.00
+ Ops Slabs scanned 62367361.00 73581394.00
+ Ops Direct inode steals 2103.00 1002.00
+ Ops Kswapd inode steals 570180.00 5183206.00
+
+ o Vanilla kernel is hitting direct reclaim more frequently,
+ not very much in absolute terms but the fact the patch
+ reduces it is interesting
+ o "Page reclaim immediate" in the vanilla kernel indicates
+ dirty pages are being encountered at the tail of the LRU.
+ This is generally bad and means in this case that the LRU
+ is not long enough for dirty pages to be cleaned by the
+ background flush in time. This is much reduced by the
+ patch.
+ o With the patch, kswapd is reclaiming 10 times more slab
+ pages than with the vanilla kernel. This is indicative
+ of the watermark boosting over-protecting slab
+
+A more complete set of tests were run that were part of the basis for
+introducing boosting and while there are some differences, they are well
+within tolerances.
+
+Bottom line, the special casing kswapd to avoid slab behaviour is
+unpredictable and can lead to abnormal results for normal workloads.
+
+This patch restores the expected behaviour that slab and page cache is
+balanced consistently for a workload with a steady allocation ratio of
+slab/pagecache pages. It also means that if there are workloads that
+favour the preservation of slab over pagecache that it can be tuned via
+vm.vfs_cache_pressure where as the vanilla kernel effectively ignores
+the parameter when boosting is active.
+
+Link: http://lkml.kernel.org/r/20190808182946.GM2739@techsingularity.net
+Fixes: 1c30844d2dfe ("mm: reclaim small amounts of memory when an external fragmentation event occurs")
+Signed-off-by: Mel Gorman <mgorman@suse.de>
+Reviewed-by: Dave Chinner <dchinner@redhat.com>
+Acked-by: Vlastimil Babka <vbabka@suse.cz>
+Cc: Michal Hocko <mhocko@kernel.org>
+Cc: <stable@vger.kernel.org> [5.0+]
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Mel Gorman <mgorman@suse.de>
+---
+ mm/vmscan.c | 11 ++---------
+ 1 file changed, 2 insertions(+), 9 deletions(-)
+
+diff --git a/mm/vmscan.c b/mm/vmscan.c
+index e32e44c5137d..66934bc43654 100644
+--- a/mm/vmscan.c
++++ b/mm/vmscan.c
+@@ -97,9 +97,6 @@ struct scan_control {
+ /* Can pages be swapped as part of reclaim? */
+ unsigned int may_swap:1;
+
+- /* e.g. boosted watermark reclaim leaves slabs alone */
+- unsigned int may_shrinkslab:1;
+-
+ /*
+ * Cgroups are not reclaimed below their configured memory.low,
+ * unless we threaten to OOM. If any cgroups are skipped due to
+@@ -2557,7 +2554,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
+ shrink_node_memcg(pgdat, memcg, sc, &lru_pages);
+ node_lru_pages += lru_pages;
+
+- if (memcg && sc->may_shrinkslab)
++ if (memcg)
+ shrink_slab(sc->gfp_mask, pgdat->node_id,
+ memcg, sc->nr_scanned - scanned,
+ lru_pages);
+@@ -2588,7 +2585,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
+ * Shrink the slab caches in the same proportion that
+ * the eligible LRU pages were scanned.
+ */
+- if (global_reclaim(sc) && sc->may_shrinkslab)
++ if (global_reclaim(sc))
+ shrink_slab(sc->gfp_mask, pgdat->node_id, NULL,
+ sc->nr_scanned - nr_scanned,
+ node_lru_pages);
+@@ -2989,7 +2986,6 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
+ .may_writepage = !laptop_mode,
+ .may_unmap = 1,
+ .may_swap = 1,
+- .may_shrinkslab = 1,
+ };
+
+ /*
+@@ -3026,7 +3022,6 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,
+ .may_unmap = 1,
+ .reclaim_idx = MAX_NR_ZONES - 1,
+ .may_swap = !noswap,
+- .may_shrinkslab = 1,
+ };
+ unsigned long lru_pages;
+
+@@ -3072,7 +3067,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
+ .may_writepage = !laptop_mode,
+ .may_unmap = 1,
+ .may_swap = may_swap,
+- .may_shrinkslab = 1,
+ };
+
+ /*
+@@ -3374,7 +3368,6 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
+ */
+ sc.may_writepage = !laptop_mode && !nr_boost_reclaim;
+ sc.may_swap = !nr_boost_reclaim;
+- sc.may_shrinkslab = !nr_boost_reclaim;
+
+ /*
+ * Do some background aging of the anon list, to give
diff --git a/series.conf b/series.conf
index 633c22d336..c6a13dc4b2 100644
--- a/series.conf
+++ b/series.conf
@@ -42316,9 +42316,13 @@
patches.drm/drm-i915-Attach-the-pci-match-data-to-the-device-upo.patch
patches.drm/drm-i915-Move-final-cleanup-of-drm_i915_private-to-i.patch
patches.drm/0001-drm-rcar-du-Update-Gen3-output-limitations.patch
+ patches.drm/drm-amd-display-Remove-redundant-non-zero-and-overfl.patch
patches.drm/0037-drm-amdgpu-fix-integer-overflow-test-in-amdgpu_bo_li.patch
+ patches.drm/drm-amdgpu-added-support-2nd-UVD-instance.patch
+ patches.drm/drm-amdgpu-change-VEGA-booting-with-firmware-loaded-.patch
patches.drm/drm-amdgpu-add-missing-CHIP_HAINAN-in-amdgpu_ucode_g.patch
patches.drm/0005-drm-amdgpu-Revert-kmap-PDs-PTs-in-amdgpu_vm_update_d.patch
+ patches.drm/drm-amd-display-num-of-sw-i2c-aux-engines-less-than-.patch
patches.drm/0001-drm-amdgpu-Fix-SDMA-TO-after-GPU-reset-v3.patch
patches.drm/0001-drm-hisilicon-hibmc-Do-not-carry-error-code-in-HiBMC.patch
patches.drm/0001-drm-hisilicon-hibmc-Don-t-overwrite-fb-helper-surfac.patch
@@ -46442,6 +46446,7 @@
patches.arch/powerpc-security-Fix-spectre_v2-reporting.patch
patches.fixes/libceph-wait-for-latest-osdmap-in-ceph_monc_blacklist_add.patch
patches.drivers/scsi-qla2xxx-Fix-FC-AL-connection-target-discovery.patch
+ patches.drivers/scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-stale-CPU.patch
patches.drivers/scsi-hisi_sas-add-softreset-in-hisi_sas_i_t_nexus_reset
patches.drivers/ibmvscsi-Protect-ibmvscsi_head-from-concurrent-modif.patch
patches.drivers/ibmvscsi-Fix-empty-event-pool-access-during-host-rem.patch
@@ -47478,6 +47483,8 @@
patches.drivers/scsi-lpfc-Enhance-6072-log-string.patch
patches.drivers/scsi-lpfc-Update-Copyright-in-driver-version.patch
patches.drivers/scsi-lpfc-Update-lpfc-version-to-12.2.0.1.patch
+ patches.drivers/scsi-qla2xxx-Fix-comment-alignment-in-qla_bsg.c.patch
+ patches.drivers/scsi-qla2xxx-Fix-a-small-typo-in-qla_bsg.c.patch
patches.drivers/scsi-be2iscsi-lpfc-fix-typo
patches.drivers/scsi-lpfc-Fix-build-error.patch
patches.drivers/scsi-lpfc-Fixup-eq_clr_intr-references.patch
@@ -47512,15 +47519,41 @@
patches.drivers/scsi-lpfc-Remove-set-but-not-used-variables.patch
patches.drivers/scsi-lpfc-Remove-unused-functions.patch
patches.drivers/scsi-lpfc-Change-smp_processor_id-into-raw_smp_proce.patch
+ patches.drivers/scsi-qla2xxx-Set-the-SCSI-command-result-before-call.patch
+ patches.drivers/scsi-qla2xxx-Set-the-qpair-in-SRB-to-NULL-when-SRB-i.patch
+ patches.drivers/scsi-qla2xxx-Reset-the-FCF_ASYNC_-SENT-ACTIVE-flags.patch
+ patches.drivers/scsi-qla2xxx-Increase-the-max_sgl_segments-to-1024.patch
+ patches.drivers/scsi-qla2xxx-Disable-T10-DIF-feature-with-FC-NVMe-du.patch
patches.fixes/scsi-qla2xxx-fix-incorrect-region-size-setting-in-optrom-sysfs.patch
+ patches.drivers/scsi-qla2xxx-Further-limit-FLASH-region-write-access.patch
+ patches.drivers/scsi-qla2xxx-Fix-fw-dump-corruption.patch
+ patches.drivers/scsi-qla2xxx-Use-mutex-protection-during-qla2x00_sys.patch
+ patches.drivers/scsi-qla2xxx-Cleanup-fcport-memory-to-prevent-leak.patch
patches.drivers/scsi-qla2xxx-Set-remote-port-devloss-timeout-to-0.patch
+ patches.drivers/scsi-qla2xxx-Cleanup-redundant-qla2x00_abort_all_cmd.patch
+ patches.drivers/scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUNs-are.patch
+ patches.drivers/scsi-qla2xxx-Change-abort-wait_loop-from-msleep-to-w.patch
+ patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.16-k.patch
patches.drivers/scsi-qedf-remove-set-but-not-used-variable-fr_len
+ patches.drivers/scsi-qla2xxx-Remove-useless-set-memory-to-zero-use-m.patch
patches.drivers/scsi-lpfc-Fix-a-recently-introduced-compiler-warning.patch
patches.drivers/scsi-fc-add-FPIN-ELS-definition.patch
patches.drivers/scsi-scsi_transport_fc-refactor-event-posting-routin.patch
patches.drivers/scsi-scsi_transport_fc-Add-FPIN-fc-event-codes.patch
patches.drivers/scsi-lpfc-add-support-for-posting-FC-events-on-FPIN-.patch
+ patches.drivers/scsi-qla2xxx-fix-spelling-mistake-alredy-already.patch
+ patches.drivers/scsi-qla2xxx-Change-a-stack-variable-into-a-static-c.patch
+ patches.drivers/scsi-qla2xxx-Remove-a-comment-that-refers-to-the-SCS.patch
+ patches.drivers/scsi-qla2xxx-Use-ARRAY_SIZE-in-the-definition-of-QLA.patch
+ patches.drivers/scsi-qla2xxx-Declare-local-symbols-static.patch
+ patches.drivers/scsi-qla2xxx-Reduce-the-number-of-forward-declaratio.patch
+ patches.drivers/scsi-qla2xxx-Make-qla2x00_process_response_queue-eas.patch
+ patches.drivers/scsi-qla2xxx-Use-get-put_unaligned-where-appropriate.patch
+ patches.drivers/scsi-qla2xxx-Unregister-chrdev-if-module-initializat.patch
+ patches.drivers/scsi-qla2xxx-Unregister-resources-in-the-opposite-or.patch
+ patches.drivers/scsi-tcm_qla2xxx-Minimize-include-directives.patch
patches.drivers/scsi-cxgbi-remove-redundant-_kfree_skb-call-on-skb-and-free-cst-atid
+ patches.drivers/scsi-scsi_transport_fc-nvme-display-FC-NVMe-port-rol.patch
patches.drivers/scsi-hisi_sas-add-host-reset-interface-for-test
patches.drivers/scsi-hisi_sas-remedy-inconsistent-phy-down-state-in-software
patches.drivers/scsi-hisi_sas-fix-for-setting-the-phy-linkrate-when-disconnected
@@ -47536,12 +47569,24 @@
patches.drivers/scsi-libsas-inject-revalidate-event-for-root-port-event
patches.drivers/scsi-libsas-do-discovery-on-empty-phy-to-update-phy-info
patches.drivers/scsi-libsas-print-expander-phy-indexes-in-decimal
+ patches.drivers/scsi-qla2xxx-Use-tabs-to-indent-code.patch
+ patches.drivers/scsi-qla2xxx-Leave-a-blank-line-after-declarations.patch
+ patches.drivers/scsi-qla2xxx-Fix-formatting-of-pointer-types.patch
+ patches.drivers/scsi-qla2xxx-Insert-spaces-where-required.patch
+ patches.drivers/scsi-qla2xxx-Move-the-port_state_str-definition-from.patch
+ patches.drivers/scsi-qla2xxx-Declare-qla24xx_build_scsi_crc_2_iocbs-.patch
+ patches.drivers/scsi-qla2xxx-Move-the-linux-io-64-nonatomic-lo-hi.h-.patch
+ patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.data_work-and-qla_tg.patch
+ patches.drivers/scsi-qla2xxx-Remove-two-superfluous-casts.patch
+ patches.drivers/scsi-qla2xxx-Move-qla2x00_set_fcport_state-from-a-.h.patch
patches.drivers/scsi-qla2xxx-Fix-read-offset-in-qla24xx_load_risc_fl.patch
patches.drivers/scsi-libcxgbi-find-cxgbi-device-by-mac-address
patches.drivers/scsi-libcxgbi-update-route-finding-logic
patches.drivers/scsi-cxgb4i-fix-incorrect-spelling-reveive-receive
patches.fixes/scsi-qedf-remove-memset-memcpy-to-nfunc-and-use-func-instead
patches.drivers/scsi-lpfc-Make-lpfc_sli4_oas_verify-static.patch
+ patches.drivers/scsi-qla2xxx-Fix-device-staying-in-blocked-state.patch
+ patches.drivers/scsi-qla2xxx-Silence-Successful-ELS-IOCB-message.patch
patches.drivers/scsi-qedf-change-msi-x-load-error-message
patches.drivers/scsi-qedf-add-driver-state-to-driver_stats-debugfs-node
patches.drivers/scsi-qedf-print-scsi_cmd-backpointer-in-good-completion-path-if-the-command-is-still-being-used
@@ -47555,7 +47600,38 @@
patches.drivers/scsi-qedf-add-return-value-to-log-message-if-scsi_add_host-fails
patches.drivers/scsi-qedf-update-the-driver-version-to-8-37-25-20
patches.drivers/scsi-qedf-remove-set-but-not-used-variables
+ patches.drivers/scsi-qla2xxx-Update-two-source-code-comments.patch
+ patches.drivers/scsi-qla2xxx-Fix-a-format-specifier.patch
+ patches.drivers/scsi-qla2xxx-Move-qla2x00_set_reserved_loop_ids-defi.patch
+ patches.drivers/scsi-qla2xxx-Declare-qla2x00_find_new_loop_id-static.patch
+ patches.drivers/scsi-qla2xxx-Remove-a-set-but-not-used-variable-6eaa5f94.patch
+ patches.drivers/scsi-qla2xxx-Move-qla2x00_clear_loop_id-from-qla_inl.patch
+ patches.drivers/scsi-qla2xxx-Move-qla2x00_is_reserved_id-from-qla_in.patch
+ patches.drivers/scsi-qla2xxx-Uninline-qla2x00_init_timer.patch
+ patches.drivers/scsi-qla2xxx-Remove-the-fcport-test-from-qla_nvme_ab.patch
+ patches.drivers/scsi-qla2xxx-Avoid-that-Coverity-complains-about-der.patch
+ patches.drivers/scsi-qla2xxx-Log-the-status-code-if-a-firmware-comma.patch
+ patches.drivers/scsi-qla2xxx-Increase-the-size-of-the-mailbox-arrays.patch
+ patches.drivers/scsi-qla2xxx-Make-qla2x00_mem_free-easier-to-verify.patch
+ patches.drivers/scsi-qla2xxx-Avoid-that-qla2x00_mem_free-crashes-if-.patch
+ patches.drivers/scsi-qla2xxx-Fix-a-qla24xx_enable_msix-error-path.patch
+ patches.drivers/scsi-qla2xxx-Fix-use-after-free-issues-in-qla2xxx_qp.patch
+ patches.drivers/scsi-qla2xxx-Simplify-qlt_send_term_imm_notif.patch
+ patches.drivers/scsi-qla2xxx-Fix-error-handling-in-qlt_alloc_qfull_c.patch
patches.fixes/scsi-qla2xxx-fix-abort-handling-in-tcm_qla2xxx_write_pending.patch
+ patches.drivers/scsi-qla2xxx-target-Fix-offline-port-handling-and-ho.patch
+ patches.drivers/scsi-qla2xxx-Complain-if-a-command-is-released-that-.patch
+ patches.drivers/scsi-qla2xxx-Remove-qla_tgt_cmd.released.patch
+ patches.drivers/scsi-qla2xxx-Remove-unnecessary-locking-from-the-tar.patch
+ patches.drivers/scsi-qla2xxx-Make-qla24xx_async_abort_cmd-static.patch
+ patches.drivers/scsi-qla2xxx-Use-an-on-stack-completion-in-qla24xx_c.patch
+ patches.drivers/scsi-qla2xxx-Fix-race-conditions-in-the-code-for-abo.patch
+ patches.drivers/scsi-qla2xxx-Pass-little-endian-values-to-the-firmwa.patch
+ patches.drivers/scsi-qla2xxx-Check-the-size-of-firmware-data-structu.patch
+ patches.drivers/scsi-qla2xxx-Complain-loudly-about-reference-count-u.patch
+ patches.drivers/scsi-qla2xxx-Fix-hardirq-unsafe-locking.patch
+ patches.drivers/scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corrupts-.patch
+ patches.drivers/scsi-qla2xxx-Avoid-that-lockdep-complains-about-unsa.patch
patches.drivers/pinctrl-pistachio-fix-leaked-of_node-references.patch
patches.drivers/ipmi-ssif-compare-block-number-correctly-for-multi-p.patch
patches.drivers/media-cpia2-Fix-use-after-free-in-cpia2_exit.patch
@@ -47921,6 +47997,7 @@
patches.fixes/sbitmap-fix-improper-use-of-smp_mb__before_atomic.patch
patches.fixes/blk-mq-fix-hang-caused-by-freeze-unfreeze-sequence.patch
patches.fixes/nvme-copy-mtfa-field-from-identify-controller.patch
+ patches.drivers/scsi-qla2xxx-Add-cleanup-for-PCI-EEH-recovery.patch
patches.drivers/scsi-qedi-remove-set-but-not-used-variables-cdev-and-udev
patches.fixes/scsi-bnx2fc-fix-incorrect-cast-to-u64-on-shift-operation
patches.fixes/ext4-wait-for-outstanding-dio-during-truncate-in-noj.patch
@@ -48177,6 +48254,7 @@
patches.drivers/net-hns3-Fix-inconsistent-indenting.patch
patches.fixes/tcp-refine-memory-limit-test-in-tcp_fragment.patch
patches.drivers/Bluetooth-Fix-regression-with-minimum-encryption-key.patch
+ patches.drivers/scsi-qla2xxx-Fix-hardlockup-in-abort-command-during-.patch
patches.arch/powerpc-mm-64s-hash-Reallocate-context-ids-on-fork.patch
patches.drivers/ppp-mppe-Add-softdep-to-arc4.patch
patches.suse/net-stmmac-fixed-new-system-time-seconds-value-calcu.patch
@@ -48499,6 +48577,7 @@
patches.drivers/scsi-lpfc-Update-lpfc-version-to-12.2.0.3.patch
patches.fixes/scsi-hpsa-fix-an-uninitialized-read-and-dereference-of-pointer-dev
patches.drivers/scsi-mpt3sas_ctl-fix-double-fetch-bug-in-ctl_ioctl_main
+ patches.drivers/scsi-qla2xxx-remove-double-assignment-in-qla2x00_upd.patch
patches.drivers/scsi-mpt3sas-function-pointers-of-request-descriptor.patch
patches.drivers/scsi-mpt3sas-Add-Atomic-RequestDescriptor-support-on.patch
patches.drivers/scsi-mpt3sas-Add-flag-high_iops_queues.patch
@@ -48525,6 +48604,10 @@
patches.drivers/scsi-mpt3sas-Use-configured-PCIe-link-speed-not-max.patch
patches.drivers/scsi-mpt3sas-Determine-smp-affinity-on-per-HBA-basis.patch
patches.drivers/scsi-mpt3sas-Fix-msix-load-balance-on-and-off-settin.patch
+ patches.drivers/scsi-qla2xxx-Fix-kernel-crash-after-disconnecting-NV.patch
+ patches.drivers/scsi-qla2xxx-on-session-delete-return-nvme-cmd.patch
+ patches.drivers/scsi-qla2xxx-Fix-NVME-cmd-and-LS-cmd-timeout-race-co.patch
+ patches.drivers/scsi-qla2xxx-move-IO-flush-to-the-front-of-NVME-rpor.patch
patches.drivers/scsi-pmcraid-use-sg-helper-to-iterate-over-scatterli.patch
patches.drivers/scsi-lib-sg_pool.c-improve-APIs-for-allocating-sg-po.patch
patches.drivers/scsi-core-avoid-preallocating-big-SGL-for-protection.patch
@@ -48786,6 +48869,7 @@
patches.drivers/ata-libahci-do-not-complain-in-case-of-deferred-prob.patch
patches.arch/s390-dasd-fix-endless-loop-after-read-unit-address-c.patch
patches.drivers/scsi-mpt3sas-Use-63-bit-DMA-addressing-on-SAS35-HBA.patch
+ patches.drivers/scsi-qla2xxx-Fix-possible-fcport-null-pointer-derefe.patch
patches.fixes/0001-xen-swiotlb-fix-condition-for-calling-xen_destroy_co.patch
patches.drm/drm-i915-perf-fix-ICL-perf-register-offsets.patch
patches.drm/drm-i915-perf-ensure-we-keep-a-reference-on-the-driv.patch
@@ -48849,6 +48933,7 @@
patches.drivers/usb-iowarrior-fix-deadlock-on-disconnect.patch
patches.drivers/iio-adc-max9611-Fix-misuse-of-GENMASK-macro.patch
patches.fixes/driver_core-Fix_use-after-free_and_double_free_on_glue.patch
+ patches.suse/mm-vmscan-do-not-special-case-slab-reclaim-when-watermarks-are-boosted.patch
patches.drivers/iommu-dma-handle-sg-length-overflow-better
patches.drivers/ALSA-hda-Apply-workaround-for-another-AMD-chip-1022-.patch
patches.drivers/ALSA-hda-Fix-a-memory-leak-bug.patch
@@ -49177,6 +49262,27 @@
patches.suse/sphinx-1.2-doc-build-fix.patch
+ # bsc#1082635 bsc#1141340 bsc#1143706 bsc#1134476
+ # not yet in mainline, in subsystem maintainer's tree
+ patches.drivers/scsi-qla2xxx-Remove-unnecessary-null-check.patch
+ patches.drivers/scsi-qla2xxx-Replace-vmalloc-memset-with-vzalloc.patch
+ patches.drivers/scsi-qla2xxx-Fix-DMA-unmap-leak.patch
+ patches.drivers/scsi-qla2xxx-Fix-different-size-DMA-Alloc-Unmap.patch
+ patches.drivers/scsi-qla2xxx-Fix-abort-timeout-race-condition.patch
+ patches.drivers/scsi-qla2xxx-Use-Correct-index-for-Q-Pair-array.patch
+ patches.drivers/scsi-qla2xxx-Skip-FW-dump-on-LOOP-initialization-err.patch
+ patches.drivers/scsi-qla2xxx-Reject-EH_-abort-device_reset-target_re.patch
+ patches.drivers/scsi-qla2xxx-Fix-Relogin-to-prevent-modifying-scan_s.patch
+ patches.drivers/scsi-qla2xxx-Fix-premature-timer-expiration.patch
+ patches.drivers/scsi-qla2xxx-Retry-fabric-Scan-on-IOCB-queue-full.patch
+ patches.drivers/scsi-qla2xxx-Correct-error-handling-during-initializ.patch
+ patches.drivers/scsi-qla2xxx-Fix-NVMe-port-discovery-after-a-short-d.patch
+ patches.drivers/scsi-qla2xxx-Use-common-update-firmware-options-rout.patch
+ patches.drivers/scsi-qla2xxx-Fix-hang-in-fcport-delete-path.patch
+ patches.drivers/scsi-qla2xxx-Allow-NVMe-IO-to-resume-with-short-cabl.patch
+ patches.drivers/scsi-qla2xxx-Update-driver-version-to-10.01.00.18-k.patch
+ patches.drivers/scsi-qla2xxx-qla2x00_alloc_fw_dump-set-ha-eft.patch
+
########################################################
# ACPI patches
########################################################