From patchwork Wed Feb 5 21:44:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11367247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A94A186E for ; Wed, 5 Feb 2020 21:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76F7C2082E for ; Wed, 5 Feb 2020 21:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbgBEVnZ (ORCPT ); Wed, 5 Feb 2020 16:43:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:52404 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbgBEVnY (ORCPT ); Wed, 5 Feb 2020 16:43:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DB6DAACAE; Wed, 5 Feb 2020 21:43:22 +0000 (UTC) From: mwilck@suse.com To: "Martin K. Petersen" , Himanshu Madhani , Quinn Tran , Roman Bolshakov , Hannes Reinecke Cc: Bart Van Assche , Martin Wilck , Daniel Wagner , James Bottomley , linux-scsi@vger.kernel.org Subject: [PATCH v2 1/3] scsi: qla2xxx: avoid sending mailbox commands if firmware is stopped Date: Wed, 5 Feb 2020 22:44:20 +0100 Message-Id: <20200205214422.3657-2-mwilck@suse.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200205214422.3657-1-mwilck@suse.com> References: <20200205214422.3657-1-mwilck@suse.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Martin Wilck Since commit 45235022da99 ("scsi: qla2xxx: Fix driver unload by shutting down chip"), it is possible that FC commands are scheduled after the adapter firmware has been shut down. IO sent to the firmware in this situation hangs indefinitely. Avoid this for the LOGO code path that is typically taken when adapters are shut down. Fixes: 45235022da99 ("scsi: qla2xxx: Fix driver unload by shutting down chip") Signed-off-by: Martin Wilck Reviewed-by: Roman Bolshakov Reviewed-by: Daniel Wagner --- drivers/scsi/qla2xxx/qla_mbx.c | 3 +++ drivers/scsi/qla2xxx/qla_os.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 9e09964..53129f2 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -2644,6 +2644,9 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, "Entered %s.\n", __func__); + if (!ha->flags.fw_started) + return QLA_FUNCTION_FAILED; + lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); if (lg == NULL) { ql_log(ql_log_warn, vha, 0x106e, diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b520a98..2dafb46 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4878,6 +4878,9 @@ qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e) unsigned long flags; bool q = false; + if (!vha->hw->flags.fw_started) + return QLA_FUNCTION_FAILED; + spin_lock_irqsave(&vha->work_lock, flags); list_add_tail(&e->list, &vha->work_list); From patchwork Wed Feb 5 21:44:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11367243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA75692A for ; Wed, 5 Feb 2020 21:43:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B98D32082E for ; Wed, 5 Feb 2020 21:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbgBEVnY (ORCPT ); Wed, 5 Feb 2020 16:43:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:52424 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727170AbgBEVnY (ORCPT ); Wed, 5 Feb 2020 16:43:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 37A2EACD0; Wed, 5 Feb 2020 21:43:23 +0000 (UTC) From: mwilck@suse.com To: "Martin K. Petersen" , Himanshu Madhani , Quinn Tran , Roman Bolshakov , Hannes Reinecke Cc: Bart Van Assche , Martin Wilck , Daniel Wagner , James Bottomley , linux-scsi@vger.kernel.org Subject: [PATCH v2 2/3] scsi: qla2xxx: don't shut down firmware before closing sessions Date: Wed, 5 Feb 2020 22:44:21 +0100 Message-Id: <20200205214422.3657-3-mwilck@suse.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200205214422.3657-1-mwilck@suse.com> References: <20200205214422.3657-1-mwilck@suse.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Martin Wilck Since 45235022da99, the firmware is shut down early in the controller shutdown process. This causes commands sent to the firmware (such as LOGO) to hang forever. Eventually one or more timeouts will be triggered. Move the stopping of the firmware until after sessions have terminated. Fixes: 45235022da99 ("scsi: qla2xxx: Fix driver unload by shutting down chip") Signed-off-by: Martin Wilck Reviewed-by: Daniel Wagner Reviewed-by: Roman Bolshakov --- drivers/scsi/qla2xxx/qla_os.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 2dafb46..e81080d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3720,6 +3720,16 @@ qla2x00_remove_one(struct pci_dev *pdev) } qla2x00_wait_for_hba_ready(base_vha); + qla2x00_wait_for_sess_deletion(base_vha); + + /* + * if UNLOAD flag is already set, then continue unload, + * where it was set first. + */ + if (test_bit(UNLOADING, &base_vha->dpc_flags)) + return; + + set_bit(UNLOADING, &base_vha->dpc_flags); if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { if (ha->flags.fw_started) @@ -3736,17 +3746,6 @@ qla2x00_remove_one(struct pci_dev *pdev) qla2x00_try_to_stop_firmware(base_vha); } - qla2x00_wait_for_sess_deletion(base_vha); - - /* - * if UNLOAD flag is already set, then continue unload, - * where it was set first. - */ - if (test_bit(UNLOADING, &base_vha->dpc_flags)) - return; - - set_bit(UNLOADING, &base_vha->dpc_flags); - qla_nvme_delete(base_vha); dma_free_coherent(&ha->pdev->dev, From patchwork Wed Feb 5 21:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11367249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 252B9924 for ; Wed, 5 Feb 2020 21:43:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D9F82072B for ; Wed, 5 Feb 2020 21:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbgBEVnZ (ORCPT ); Wed, 5 Feb 2020 16:43:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:52460 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727178AbgBEVnZ (ORCPT ); Wed, 5 Feb 2020 16:43:25 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 87A3AAD12; Wed, 5 Feb 2020 21:43:23 +0000 (UTC) From: mwilck@suse.com To: "Martin K. Petersen" , Himanshu Madhani , Quinn Tran , Roman Bolshakov , Hannes Reinecke Cc: Bart Van Assche , Martin Wilck , Daniel Wagner , James Bottomley , linux-scsi@vger.kernel.org Subject: [PATCH v2 3/3] scsi: qla2xxx: set UNLOADING before waiting for session deletion Date: Wed, 5 Feb 2020 22:44:22 +0100 Message-Id: <20200205214422.3657-4-mwilck@suse.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200205214422.3657-1-mwilck@suse.com> References: <20200205214422.3657-1-mwilck@suse.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Martin Wilck The purpose of the UNLOADING flag is to avoid port login procedures to continue when a controller is in the process of shutting down. It makes sense to set this flag before starting session teardown. The only operations that must be able to continue are LOGO, PRLO, and the like. Furthermore, use atomic test_and_set_bit() to avoid the shutdown being run multiple times in parallel. In qla2x00_disable_board_on_pci_error(), the test for UNLOADING is postponed until after the check for an already disabled PCI board. Signed-off-by: Martin Wilck Reviewed-by: Daniel Wagner Reviewed-by: Roman Bolshakov --- drivers/scsi/qla2xxx/qla_os.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index e81080d..8329f95 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3720,16 +3720,15 @@ qla2x00_remove_one(struct pci_dev *pdev) } qla2x00_wait_for_hba_ready(base_vha); - qla2x00_wait_for_sess_deletion(base_vha); - /* - * if UNLOAD flag is already set, then continue unload, + * if UNLOADING flag is already set, then continue unload, * where it was set first. */ - if (test_bit(UNLOADING, &base_vha->dpc_flags)) + if (test_and_set_bit(UNLOADING, &base_vha->dpc_flags)) return; - set_bit(UNLOADING, &base_vha->dpc_flags); + qla2x00_wait_for_sess_deletion(base_vha); + if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { if (ha->flags.fw_started) @@ -6046,13 +6045,6 @@ qla2x00_disable_board_on_pci_error(struct work_struct *work) struct pci_dev *pdev = ha->pdev; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); - /* - * if UNLOAD flag is already set, then continue unload, - * where it was set first. - */ - if (test_bit(UNLOADING, &base_vha->dpc_flags)) - return; - ql_log(ql_log_warn, base_vha, 0x015b, "Disabling adapter.\n"); @@ -6063,9 +6055,14 @@ qla2x00_disable_board_on_pci_error(struct work_struct *work) return; } - qla2x00_wait_for_sess_deletion(base_vha); + /* + * if UNLOADING flag is already set, then continue unload, + * where it was set first. + */ + if (test_and_set_bit(UNLOADING, &base_vha->dpc_flags)) + return; - set_bit(UNLOADING, &base_vha->dpc_flags); + qla2x00_wait_for_sess_deletion(base_vha); qla2x00_delete_all_vps(ha, base_vha);