From 7979501b80a9c641cee54efa3afb76d6dec47ae0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Aug 2022 12:17:03 +0200 Subject: [PATCH] 5.4-stable patches added patches: scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch --- ...x-discovery-issues-in-fc-al-topology.patch | 107 ++++++++ ...ox-timeout-after-pci-error-injection.patch | 61 +++++ ...turn-off-multi-queue-for-8g-adapters.patch | 61 +++++ ...t-scan-and-thus-missing-target-ports.patch | 232 ++++++++++++++++++ queue-5.4/series | 4 + 5 files changed, 465 insertions(+) create mode 100644 queue-5.4/scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch create mode 100644 queue-5.4/scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch create mode 100644 queue-5.4/scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch create mode 100644 queue-5.4/scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch diff --git a/queue-5.4/scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch b/queue-5.4/scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch new file mode 100644 index 00000000000..00b14dae3ce --- /dev/null +++ b/queue-5.4/scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch @@ -0,0 +1,107 @@ +From 47ccb113cead905bdc236571bf8ac6fed90321b3 Mon Sep 17 00:00:00 2001 +From: Arun Easi +Date: Tue, 12 Jul 2022 22:20:42 -0700 +Subject: scsi: qla2xxx: Fix discovery issues in FC-AL topology + +From: Arun Easi + +commit 47ccb113cead905bdc236571bf8ac6fed90321b3 upstream. + +A direct attach tape device, when gets swapped with another, was not +discovered. Fix this by looking at loop map and reinitialize link if there +are devices present. + +Link: https://lore.kernel.org/linux-scsi/baef87c3-5dad-3b47-44c1-6914bfc90108@cybernetics.com/ +Link: https://lore.kernel.org/r/20220713052045.10683-8-njavali@marvell.com +Cc: stable@vger.kernel.org +Reported-by: Tony Battersby +Tested-by: Tony Battersby +Reviewed-by: Himanshu Madhani +Signed-off-by: Arun Easi +Signed-off-by: Nilesh Javali +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/qla2xxx/qla_gbl.h | 3 ++- + drivers/scsi/qla2xxx/qla_init.c | 29 +++++++++++++++++++++++++++++ + drivers/scsi/qla2xxx/qla_mbx.c | 5 ++++- + 3 files changed, 35 insertions(+), 2 deletions(-) + +--- a/drivers/scsi/qla2xxx/qla_gbl.h ++++ b/drivers/scsi/qla2xxx/qla_gbl.h +@@ -397,7 +397,8 @@ extern int + qla2x00_get_resource_cnts(scsi_qla_host_t *); + + extern int +-qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map); ++qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map, ++ u8 *num_entries); + + extern int + qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *, +--- a/drivers/scsi/qla2xxx/qla_init.c ++++ b/drivers/scsi/qla2xxx/qla_init.c +@@ -5068,6 +5068,22 @@ qla2x00_configure_loop(scsi_qla_host_t * + return (rval); + } + ++static void ++qla_reinitialize_link(scsi_qla_host_t *vha) ++{ ++ int rval; ++ ++ atomic_set(&vha->loop_state, LOOP_DOWN); ++ atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); ++ rval = qla2x00_full_login_lip(vha); ++ if (rval == QLA_SUCCESS) { ++ ql_dbg(ql_dbg_disc, vha, 0xd050, "Link reinitialized\n"); ++ } else { ++ ql_dbg(ql_dbg_disc, vha, 0xd051, ++ "Link reinitialization failed (%d)\n", rval); ++ } ++} ++ + /* + * qla2x00_configure_local_loop + * Updates Fibre Channel Device Database with local loop devices. +@@ -5132,6 +5148,19 @@ skip_login: + spin_unlock_irqrestore(&vha->work_lock, flags); + + if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { ++ u8 loop_map_entries = 0; ++ int rc; ++ ++ rc = qla2x00_get_fcal_position_map(vha, NULL, ++ &loop_map_entries); ++ if (rc == QLA_SUCCESS && loop_map_entries > 1) { ++ /* ++ * There are devices that are still not logged ++ * in. Reinitialize to give them a chance. ++ */ ++ qla_reinitialize_link(vha); ++ return QLA_FUNCTION_FAILED; ++ } + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); + } +--- a/drivers/scsi/qla2xxx/qla_mbx.c ++++ b/drivers/scsi/qla2xxx/qla_mbx.c +@@ -2928,7 +2928,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_ + * Kernel context. + */ + int +-qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) ++qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map, ++ u8 *num_entries) + { + int rval; + mbx_cmd_t mc; +@@ -2968,6 +2969,8 @@ qla2x00_get_fcal_position_map(scsi_qla_h + + if (pos_map) + memcpy(pos_map, pmap, FCAL_MAP_SIZE); ++ if (num_entries) ++ *num_entries = pmap[0]; + } + dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); + diff --git a/queue-5.4/scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch b/queue-5.4/scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch new file mode 100644 index 00000000000..da77401f7b8 --- /dev/null +++ b/queue-5.4/scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch @@ -0,0 +1,61 @@ +From f260694e6463b63ae550aad25ddefe94cb1904da Mon Sep 17 00:00:00 2001 +From: Quinn Tran +Date: Wed, 15 Jun 2022 22:35:07 -0700 +Subject: scsi: qla2xxx: Fix erroneous mailbox timeout after PCI error injection + +From: Quinn Tran + +commit f260694e6463b63ae550aad25ddefe94cb1904da upstream. + +Clear wait for mailbox interrupt flag to prevent stale mailbox: + +Feb 22 05:22:56 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-500a:4: LOOP UP detected (16 Gbps). +Feb 22 05:22:59 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-d04c:4: MBX Command timeout for cmd 69, ... + +To fix the issue, driver needs to clear the MBX_INTR_WAIT flag on purging +the mailbox. When the stale mailbox completion does arrive, it will be +dropped. + +Link: https://lore.kernel.org/r/20220616053508.27186-11-njavali@marvell.com +Fixes: b6faaaf796d7 ("scsi: qla2xxx: Serialize mailbox request") +Cc: Naresh Bannoth +Cc: Kyle Mahlkuch +Cc: stable@vger.kernel.org +Reported-by: Naresh Bannoth +Tested-by: Naresh Bannoth +Signed-off-by: Quinn Tran +Signed-off-by: Nilesh Javali +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/qla2xxx/qla_mbx.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/drivers/scsi/qla2xxx/qla_mbx.c ++++ b/drivers/scsi/qla2xxx/qla_mbx.c +@@ -271,6 +271,12 @@ qla2x00_mailbox_command(scsi_qla_host_t + atomic_inc(&ha->num_pend_mbx_stage3); + if (!wait_for_completion_timeout(&ha->mbx_intr_comp, + mcp->tov * HZ)) { ++ ql_dbg(ql_dbg_mbx, vha, 0x117a, ++ "cmd=%x Timeout.\n", command); ++ spin_lock_irqsave(&ha->hardware_lock, flags); ++ clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); ++ spin_unlock_irqrestore(&ha->hardware_lock, flags); ++ + if (chip_reset != ha->chip_reset) { + spin_lock_irqsave(&ha->hardware_lock, flags); + ha->flags.mbox_busy = 0; +@@ -281,12 +287,6 @@ qla2x00_mailbox_command(scsi_qla_host_t + rval = QLA_ABORTED; + goto premature_exit; + } +- ql_dbg(ql_dbg_mbx, vha, 0x117a, +- "cmd=%x Timeout.\n", command); +- spin_lock_irqsave(&ha->hardware_lock, flags); +- clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); +- spin_unlock_irqrestore(&ha->hardware_lock, flags); +- + } else if (ha->flags.purge_mbox || + chip_reset != ha->chip_reset) { + spin_lock_irqsave(&ha->hardware_lock, flags); diff --git a/queue-5.4/scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch b/queue-5.4/scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch new file mode 100644 index 00000000000..895c751ed88 --- /dev/null +++ b/queue-5.4/scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch @@ -0,0 +1,61 @@ +From 5304673bdb1635e27555bd636fd5d6956f1cd552 Mon Sep 17 00:00:00 2001 +From: Quinn Tran +Date: Wed, 15 Jun 2022 22:35:01 -0700 +Subject: scsi: qla2xxx: Turn off multi-queue for 8G adapters + +From: Quinn Tran + +commit 5304673bdb1635e27555bd636fd5d6956f1cd552 upstream. + +For 8G adapters, multi-queue was enabled accidentally. Make sure +multi-queue is not enabled. + +Link: https://lore.kernel.org/r/20220616053508.27186-5-njavali@marvell.com +Cc: stable@vger.kernel.org +Signed-off-by: Quinn Tran +Signed-off-by: Nilesh Javali +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/qla2xxx/qla_def.h | 4 ++-- + drivers/scsi/qla2xxx/qla_isr.c | 16 ++++++---------- + 2 files changed, 8 insertions(+), 12 deletions(-) + +--- a/drivers/scsi/qla2xxx/qla_def.h ++++ b/drivers/scsi/qla2xxx/qla_def.h +@@ -3899,8 +3899,8 @@ struct qla_hw_data { + #define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001) + #define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS) + #define IS_CT6_SUPPORTED(ha) ((ha)->device_type & DT_CT6_SUPPORTED) +-#define IS_MQUE_CAPABLE(ha) ((ha)->mqenable || IS_QLA83XX(ha) || \ +- IS_QLA27XX(ha) || IS_QLA28XX(ha)) ++#define IS_MQUE_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ ++ IS_QLA28XX(ha)) + #define IS_BIDI_CAPABLE(ha) \ + (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) + /* Bit 21 of fw_attributes decides the MCTP capabilities */ +--- a/drivers/scsi/qla2xxx/qla_isr.c ++++ b/drivers/scsi/qla2xxx/qla_isr.c +@@ -3568,16 +3568,12 @@ msix_register_fail: + } + + /* Enable MSI-X vector for response queue update for queue 0 */ +- if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { +- if (ha->msixbase && ha->mqiobase && +- (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 || +- ql2xmqsupport)) +- ha->mqenable = 1; +- } else +- if (ha->mqiobase && +- (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 || +- ql2xmqsupport)) +- ha->mqenable = 1; ++ if (IS_MQUE_CAPABLE(ha) && ++ (ha->msixbase && ha->mqiobase && ha->max_qpairs)) ++ ha->mqenable = 1; ++ else ++ ha->mqenable = 0; ++ + ql_dbg(ql_dbg_multiq, vha, 0xc005, + "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", + ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); diff --git a/queue-5.4/scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch b/queue-5.4/scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch new file mode 100644 index 00000000000..0bfd481c91a --- /dev/null +++ b/queue-5.4/scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch @@ -0,0 +1,232 @@ +From 4da8c5f76825269f28d6a89fa752934a4bcb6dfa Mon Sep 17 00:00:00 2001 +From: Steffen Maier +Date: Fri, 29 Jul 2022 18:25:29 +0200 +Subject: scsi: zfcp: Fix missing auto port scan and thus missing target ports + +From: Steffen Maier + +commit 4da8c5f76825269f28d6a89fa752934a4bcb6dfa upstream. + +Case (1): + The only waiter on wka_port->completion_wq is zfcp_fc_wka_port_get() + trying to open a WKA port. As such it should only be woken up by WKA port + *open* responses, not by WKA port close responses. + +Case (2): + A close WKA port response coming in just after having sent a new open WKA + port request and before blocking for the open response with wait_event() + in zfcp_fc_wka_port_get() erroneously renders the wait_event a NOP + because the close handler overwrites wka_port->status. Hence the + wait_event condition is erroneously true and it does not enter blocking + state. + +With non-negligible probability, the following time space sequence happens +depending on timing without this fix: + +user process ERP thread zfcp work queue tasklet system work queue +============ ========== =============== ======= ================= +$ echo 1 > online +zfcp_ccw_set_online +zfcp_ccw_activate +zfcp_erp_adapter_reopen +msleep scan backoff zfcp_erp_strategy +| ... +| zfcp_erp_action_cleanup +| ... +| queue delayed scan_work +| queue ns_up_work +| ns_up_work: +| zfcp_fc_wka_port_get +| open wka request +| open response +| GSPN FC-GS +| RSPN FC-GS [NPIV-only] +| zfcp_fc_wka_port_put +| (--wka->refcount==0) +| sched delayed wka->work +| +~~~Case (1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +zfcp_erp_wait +flush scan_work +| wka->work: +| wka->status=CLOSING +| close wka request +| scan_work: +| zfcp_fc_wka_port_get +| (wka->status==CLOSING) +| wka->status=OPENING +| open wka request +| wait_event +| | close response +| | wka->status=OFFLINE +| | wake_up /*WRONG*/ +~~~Case (2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +| wka->work: +| wka->status=CLOSING +| close wka request +zfcp_erp_wait +flush scan_work +| scan_work: +| zfcp_fc_wka_port_get +| (wka->status==CLOSING) +| wka->status=OPENING +| open wka request +| close response +| wka->status=OFFLINE +| wake_up /*WRONG&NOP*/ +| wait_event /*NOP*/ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +| (wka->status!=ONLINE) +| return -EIO +| return early + open response + wka->status=ONLINE + wake_up /*NOP*/ + +So we erroneously end up with no automatic port scan. This is a big problem +when it happens during boot. The timing is influenced by v3.19 commit +18f87a67e6d6 ("zfcp: auto port scan resiliency"). + +Fix it by fully mutually excluding zfcp_fc_wka_port_get() and +zfcp_fc_wka_port_offline(). For that to work, we make the latter block +until we got the response for a close WKA port. In order not to penalize +the system workqueue, we move wka_port->work to our own adapter workqueue. +Note that before v2.6.30 commit 828bc1212a68 ("[SCSI] zfcp: Set WKA-port to +offline on adapter deactivation"), zfcp did block in +zfcp_fc_wka_port_offline() as well, but with a different condition. + +While at it, make non-functional cleanups to improve code reading in +zfcp_fc_wka_port_get(). If we cannot send the WKA port open request, don't +rely on the subsequent wait_event condition to immediately let this case +pass without blocking. Also don't want to rely on the additional condition +handling the refcount to be skipped just to finally return with -EIO. + +Link: https://lore.kernel.org/r/20220729162529.1620730-1-maier@linux.ibm.com +Fixes: 5ab944f97e09 ("[SCSI] zfcp: attach and release SAN nameserver port on demand") +Cc: #v2.6.28+ +Reviewed-by: Benjamin Block +Signed-off-by: Steffen Maier +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/s390/scsi/zfcp_fc.c | 29 ++++++++++++++++++++--------- + drivers/s390/scsi/zfcp_fc.h | 6 ++++-- + drivers/s390/scsi/zfcp_fsf.c | 4 ++-- + 3 files changed, 26 insertions(+), 13 deletions(-) + +--- a/drivers/s390/scsi/zfcp_fc.c ++++ b/drivers/s390/scsi/zfcp_fc.c +@@ -145,27 +145,33 @@ void zfcp_fc_enqueue_event(struct zfcp_a + + static int zfcp_fc_wka_port_get(struct zfcp_fc_wka_port *wka_port) + { ++ int ret = -EIO; ++ + if (mutex_lock_interruptible(&wka_port->mutex)) + return -ERESTARTSYS; + + if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE || + wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) { + wka_port->status = ZFCP_FC_WKA_PORT_OPENING; +- if (zfcp_fsf_open_wka_port(wka_port)) ++ if (zfcp_fsf_open_wka_port(wka_port)) { ++ /* could not even send request, nothing to wait for */ + wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; ++ goto out; ++ } + } + +- mutex_unlock(&wka_port->mutex); +- +- wait_event(wka_port->completion_wq, ++ wait_event(wka_port->opened, + wka_port->status == ZFCP_FC_WKA_PORT_ONLINE || + wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); + + if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) { + atomic_inc(&wka_port->refcount); +- return 0; ++ ret = 0; ++ goto out; + } +- return -EIO; ++out: ++ mutex_unlock(&wka_port->mutex); ++ return ret; + } + + static void zfcp_fc_wka_port_offline(struct work_struct *work) +@@ -181,9 +187,12 @@ static void zfcp_fc_wka_port_offline(str + + wka_port->status = ZFCP_FC_WKA_PORT_CLOSING; + if (zfcp_fsf_close_wka_port(wka_port)) { ++ /* could not even send request, nothing to wait for */ + wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; +- wake_up(&wka_port->completion_wq); ++ goto out; + } ++ wait_event(wka_port->closed, ++ wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); + out: + mutex_unlock(&wka_port->mutex); + } +@@ -193,13 +202,15 @@ static void zfcp_fc_wka_port_put(struct + if (atomic_dec_return(&wka_port->refcount) != 0) + return; + /* wait 10 milliseconds, other reqs might pop in */ +- schedule_delayed_work(&wka_port->work, HZ / 100); ++ queue_delayed_work(wka_port->adapter->work_queue, &wka_port->work, ++ msecs_to_jiffies(10)); + } + + static void zfcp_fc_wka_port_init(struct zfcp_fc_wka_port *wka_port, u32 d_id, + struct zfcp_adapter *adapter) + { +- init_waitqueue_head(&wka_port->completion_wq); ++ init_waitqueue_head(&wka_port->opened); ++ init_waitqueue_head(&wka_port->closed); + + wka_port->adapter = adapter; + wka_port->d_id = d_id; +--- a/drivers/s390/scsi/zfcp_fc.h ++++ b/drivers/s390/scsi/zfcp_fc.h +@@ -185,7 +185,8 @@ enum zfcp_fc_wka_status { + /** + * struct zfcp_fc_wka_port - representation of well-known-address (WKA) FC port + * @adapter: Pointer to adapter structure this WKA port belongs to +- * @completion_wq: Wait for completion of open/close command ++ * @opened: Wait for completion of open command ++ * @closed: Wait for completion of close command + * @status: Current status of WKA port + * @refcount: Reference count to keep port open as long as it is in use + * @d_id: FC destination id or well-known-address +@@ -195,7 +196,8 @@ enum zfcp_fc_wka_status { + */ + struct zfcp_fc_wka_port { + struct zfcp_adapter *adapter; +- wait_queue_head_t completion_wq; ++ wait_queue_head_t opened; ++ wait_queue_head_t closed; + enum zfcp_fc_wka_status status; + atomic_t refcount; + u32 d_id; +--- a/drivers/s390/scsi/zfcp_fsf.c ++++ b/drivers/s390/scsi/zfcp_fsf.c +@@ -1625,7 +1625,7 @@ static void zfcp_fsf_open_wka_port_handl + wka_port->status = ZFCP_FC_WKA_PORT_ONLINE; + } + out: +- wake_up(&wka_port->completion_wq); ++ wake_up(&wka_port->opened); + } + + /** +@@ -1684,7 +1684,7 @@ static void zfcp_fsf_close_wka_port_hand + } + + wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; +- wake_up(&wka_port->completion_wq); ++ wake_up(&wka_port->closed); + } + + /** diff --git a/queue-5.4/series b/queue-5.4/series index 0a0fa7b9cab..5533bcf0981 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -251,3 +251,7 @@ tools-thermal-fix-possible-path-truncations.patch video-fbdev-vt8623fb-check-the-size-of-screen-before.patch video-fbdev-arkfb-check-the-size-of-screen-before-me.patch video-fbdev-s3fb-check-the-size-of-screen-before-mem.patch +scsi-zfcp-fix-missing-auto-port-scan-and-thus-missing-target-ports.patch +scsi-qla2xxx-fix-discovery-issues-in-fc-al-topology.patch +scsi-qla2xxx-turn-off-multi-queue-for-8g-adapters.patch +scsi-qla2xxx-fix-erroneous-mailbox-timeout-after-pci-error-injection.patch -- 2.47.3