From patchwork Fri Mar 27 16:47:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11462627 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 2FBA314B4 for ; Fri, 27 Mar 2020 16:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 185A720B80 for ; Fri, 27 Mar 2020 16:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727750AbgC0Qry (ORCPT ); Fri, 27 Mar 2020 12:47:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:41800 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727718AbgC0Qry (ORCPT ); Fri, 27 Mar 2020 12:47:54 -0400 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 3CF96AFCF; Fri, 27 Mar 2020 16:47:52 +0000 (UTC) From: mwilck@suse.com To: "Martin K. Petersen" , Arun Easi , Quinn Tran , Himanshu Madhani Cc: Roman Bolshakov , Daniel Wagner , Bart Van Assche , James Bottomley , Hannes Reinecke , linux-scsi@vger.kernel.org, Martin Wilck Subject: [PATCH v3 5/5] scsi: qla2xxx: only send certain mailbox commands to stopped firmware Date: Fri, 27 Mar 2020 17:47:11 +0100 Message-Id: <20200327164711.5358-6-mwilck@suse.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200327164711.5358-1-mwilck@suse.com> References: <20200327164711.5358-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 may hang. Only certain mailbox commands should be sent in this situation. This patch identifies the mailbox commands sent during adapter initialization (before QLA_FW_STARTED() is called) and allows only these to be sent to the firmware in stopped state. Signed-off-by: Martin Wilck --- drivers/scsi/qla2xxx/qla_mbx.c | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 9fd83d1..4a9a583 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -77,6 +77,45 @@ static int is_rom_cmd(uint16_t cmd) return 0; } +/* + * Mailbox commands that must (and can) be sent to the Firmware + * even if it isn't running. IOW, commands that are sent before + * QLA_FW_STARTED() is called. + */ +static uint16_t fw_stopped_cmds[] = { + MBC_EXECUTE_FIRMWARE, + MBC_READ_RAM_WORD, + MBC_MAILBOX_REGISTER_TEST, + MBC_VERIFY_CHECKSUM, + MBC_GET_FIRMWARE_VERSION, + MBC_LOAD_RISC_RAM, + MBC_LOAD_RISC_RAM_EXTENDED, + MBC_WRITE_RAM_WORD_EXTENDED, + MBC_READ_RAM_EXTENDED, + MBC_GET_ADAPTER_LOOP_ID, + MBC_GET_SET_ZIO_THRESHOLD, + MBC_GET_FIRMWARE_OPTION, + MBC_GET_MEM_OFFLOAD_CNTRL_STAT, + MBC_SET_FIRMWARE_OPTION, + MBC_GET_RESOURCE_COUNTS, + MBC_INITIALIZE_FIRMWARE, + MBC_TRACE_CONTROL, + MBC_READ_SFP, + MBC_MID_INITIALIZE_FIRMWARE, + MBC_FLASH_ACCESS_CTRL, +}; + +static bool must_send_if_fw_stopped(uint16_t cmd) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(fw_stopped_cmds); i++) { + if (fw_stopped_cmds[i] == cmd) + return true; + } + return false; +} + /* * qla2x00_mailbox_command * Issue mailbox command and waits for completion. @@ -169,6 +208,13 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) return QLA_FUNCTION_TIMEOUT; } + if (!ha->flags.fw_started && !must_send_if_fw_stopped(mcp->mb[0])) { + ql_log(ql_log_info, vha, 0x1006, + "Cmd 0x%x skipped with timeout since FW is stopped\n", + mcp->mb[0]); + return QLA_FUNCTION_TIMEOUT; + } + atomic_inc(&ha->num_pend_mbx_stage1); /* * Wait for active mailbox commands to finish by waiting at most tov