From patchwork Fri Sep 22 06:17:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9965243 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 A08EF602D8 for ; Fri, 22 Sep 2017 06:18:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85DF629707 for ; Fri, 22 Sep 2017 06:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC212970B; Fri, 22 Sep 2017 06:18:24 +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 D459629707 for ; Fri, 22 Sep 2017 06:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbdIVGSW (ORCPT ); Fri, 22 Sep 2017 02:18:22 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36770 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbdIVGSN (ORCPT ); Fri, 22 Sep 2017 02:18:13 -0400 Received: by mail-pg0-f67.google.com with SMTP id d8so120863pgt.3 for ; Thu, 21 Sep 2017 23:18: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=0yYWKyzIXHxyxC+iLfNJENtGLO/MkDgzTeQ2Jz+zKZ0=; b=idzwnXAIKlDFbr8Hu7fRiNeBN2PJGt4VK3M4FbHIiiFY0e8H3oknJ4+hhFvjellqlb KoHUy2CblHqjAhX09UTZV6NbUo/74VqWtTMpOHnCJpUKRnVguAvyvK3p1HR5uo5sFHcg 6qXansF/k7NoAFAmuWjHPTo5J4E6c64+H4tGVVm/4+fnOrFTzvfF5c2fMcveNZLC2KJN rElM9YgP1k9NSxFhuNKOV5TYG46PQwaqOVZT2pT/aejszdXhDNdKtreK6txTRdTQhcln 798Ju84GreX2Csi7bhPgtUcdlDRKcZGvv70BENcLIZGydB3p/hPUUyVyeXd+LB3sTOmV qy3Q== 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=0yYWKyzIXHxyxC+iLfNJENtGLO/MkDgzTeQ2Jz+zKZ0=; b=NzVLn2jFgQiHJqRdw9NPn4bkXLpnsWVYU3SsaHXC4cCxLBZQRhQDQohlrcvyeZvWkH sQ7/ibvfBwppC+iy4kAFBvKsXjYiDMwmciiVg2yM+BtgS5aqSQtlMo/AlGLlp7JVPu3q dFo/s+rgxJD3XAEpnYewo6TT1AQ+wfjvtd5hZ3hQcfQMWdB4q9fpL52wnAd9THPNnuiz IJSy6JpT93gw0xZN/9WcOJSRw548o+gc33mzjxMldBFXpSv2QIRHiY61Y1VT0KdpoFvZ r6P/kx3Nrxa7fhHqOL16BMreufyIepoLyZS0JwteJ0lYnUiZlRYuRzETMiKmkjGmX58A WAZg== X-Gm-Message-State: AHPjjUiNHJfyWZZq0K53CFjbNkqw/03VQZW7HrYfGdE0cH7kIOQUFy7O WEKkOLx0mo6pKg2dXTrIFZW4qg== X-Google-Smtp-Source: AOwi7QDtUP40qoR5+DbQ6f41IVnNr56qniEbUsg/9N5BUL+S469LRDbbxBx14A3P9o6X/YmDdCWs3g== X-Received: by 10.84.140.133 with SMTP id 5mr7865882plt.266.1506061092783; Thu, 21 Sep 2017 23:18:12 -0700 (PDT) Received: from os42.localdomain (ip68-4-115-207.oc.oc.cox.net. [68.4.115.207]) by smtp.gmail.com with ESMTPSA id e87sm5911355pfl.46.2017.09.21.23.18.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 23:18:12 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: Dick Kennedy , James Smart Subject: [PATCH 18/19] lpfc: Fix oops of nvme host during driver unload. Date: Thu, 21 Sep 2017 23:17:40 -0700 Message-Id: <20170922061741.12347-19-jsmart2021@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170922061741.12347-1-jsmart2021@gmail.com> References: <20170922061741.12347-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 abort 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 --- drivers/scsi/lpfc/lpfc_nvme.c | 14 ++++++++++++++ drivers/scsi/lpfc/lpfc_nvmet.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index e3642c1890ea..e01e67856458 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, @@ -531,6 +534,9 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS, @@ -1252,6 +1258,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, @@ -1479,6 +1490,9 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + /* Announce entry to new IO submit field. */ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, "6002 Abort Request to rport DID x%06x " diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 55badeace591..84cf1b9079f7 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);