From patchwork Sat Sep 30 00:34:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9978885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 06EA56037F for ; Sat, 30 Sep 2017 00:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED9A1298D1 for ; Sat, 30 Sep 2017 00:35:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2B0F298D5; Sat, 30 Sep 2017 00:35:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83358298D1 for ; Sat, 30 Sep 2017 00:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658AbdI3AfS (ORCPT ); Fri, 29 Sep 2017 20:35:18 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:47192 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbdI3AfO (ORCPT ); Fri, 29 Sep 2017 20:35:14 -0400 Received: by mail-qt0-f195.google.com with SMTP id b1so1606925qtc.4 for ; Fri, 29 Sep 2017 17:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RTHU9qHLoFT6YLUMQfce2scAR0l7T45yLqmFH2eaQzQ=; b=hVZGf8ll2x5gIB65A/gGkVufUUTkJsDwQpX8tqS48D8lHWlkjbNA1Ngvc8u1hJG7rm 7uyPA17jdCauXR0GI2DdvZfWYkdAk+aL2wGYrGEACt0FUiRO3rblR4OOfL3OtPw3Kr4r vtSoCX+NuTGWoX+xG4igtkwQQ3gl2BUzuQOuugNzJQSUZcS1FJnrCzqt/RBQE7yE8Xma VxjZq+skTdxLkfyHvaJCtsGdCCR5hxS5zi14rKEb4T1qN2+LNTBX+CLV1oRLLLtoFWPn c5tGZ3vPkUcrDxePG8jiLfw6N9aPSm91IldcSF6NgUUS4OtSlVIs/e6NGb9A9CmaBxwo +Q2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RTHU9qHLoFT6YLUMQfce2scAR0l7T45yLqmFH2eaQzQ=; b=fmlDoLRBx4aZX9LVgklRw3KwTmkg6INit8N8orjzkatqn4Ldmp59HyVXXv1k02SUMQ bLQF8wwFWPyagiA7/T/zHJukGkecruPihYgf6ICCQDHmYRdC2EJX4IKP1c31DAxpQkn9 5pk+oVOZf0tXgd8s1PtPSxug8RPisLB/6LBmlGnPWD1xpdRCzdFs7HOv6t1SfrPpoUa5 P/YwMdrrmy2HfV7JPcUITFHU1bRiZe2oqpRPsqk8GVtTNP6uk5FeZfAU56W52/yq3wHU f1kFb6wMr/DJbtCf/kUXPRgrtGp/urznY7AUXGJZPkFU+V3PocBEpdQ97u0kHOnB6+0Z LdFQ== X-Gm-Message-State: AMCzsaVsjxNo7MYQ8PpWBasURU+QhYsuYNI8iVbx9VbfwRjCeA3rRwd+ i9th88s3Dl82YqQlwxEVIkHzpQ== X-Google-Smtp-Source: AOwi7QCJ7MDlihw4ykACQVpFxd6IagyB9eNcz784x2vwHZJmPkyn5Z9S1Fq5Ckb4v+PIqgkLzbiGSA== X-Received: by 10.200.43.79 with SMTP id 15mr9000024qtv.126.1506731713299; Fri, 29 Sep 2017 17:35:13 -0700 (PDT) Received: from pallmd1.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id u32sm3596918qte.25.2017.09.29.17.35.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 17:35:12 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: Dick Kennedy , James Smart Subject: [PATCH v2 19/21] lpfc: Fix oops of nvme host during driver unload. Date: Fri, 29 Sep 2017 17:34:45 -0700 Message-Id: <20170930003447.10747-20-jsmart2021@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170930003447.10747-1-jsmart2021@gmail.com> References: <20170930003447.10747-1-jsmart2021@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dick Kennedy When running NVME io as a NVME host, if the driver is unloaded there would be oops in lpfc_sli4_issue_wqe. When unloading, controllers are torn down and the transport initiates set_property commands to reset the controller and issues aborts to terminate existing io. The drivers nvme abort and fcp io submit routines needed to recognize the driver is unloading and fail the new requests. It didn't, resulting in the oops. Revise the ls and fcp io submit routines to detect the unloading state and properly handle their cleanup. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Reviewed-by: Johannes Thumshirn --- v2: reduce scope to only submit routines. aborts necessary for cleanup. this was a bug found after submit. drivers/scsi/lpfc/lpfc_nvme.c | 8 ++++++++ drivers/scsi/lpfc/lpfc_nvmet.c | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index e3642c1890ea..040af28073bb 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -416,6 +416,9 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, lport = (struct lpfc_nvme_lport *)pnvme_lport->private; vport = lport->vport; + if (vport->load_flag & FC_UNLOADING) + return -ENODEV; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR, @@ -1252,6 +1255,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) { + ret = -ENODEV; + goto out_fail; + } + /* Validate pointers. */ if (!pnvme_lport || !pnvme_rport || !freqpriv) { lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 1746c888beac..d02a54d7ffc0 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -632,6 +632,9 @@ lpfc_nvmet_xmt_ls_rsp(struct nvmet_fc_target_port *tgtport, struct ulp_bde64 bpl; int rc; + if (phba->pport->load_flag & FC_UNLOADING) + return -ENODEV; + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, "6023 NVMET LS rsp oxid x%x\n", ctxp->oxid); @@ -713,6 +716,11 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, struct lpfc_iocbq *nvmewqeq; int rc; + if (phba->pport->load_flag & FC_UNLOADING) { + rc = -ENODEV; + goto aerr; + } + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS if (ctxp->ts_cmd_nvme) { if (rsp->op == NVMET_FCOP_RSP) @@ -812,6 +820,9 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc_target_port *tgtport, struct lpfc_hba *phba = ctxp->phba; unsigned long flags; + if (phba->pport->load_flag & FC_UNLOADING) + return; + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, "6103 NVMET Abort op: oxri x%x flg x%x ste %d\n", ctxp->oxid, ctxp->flag, ctxp->state);