From patchwork Fri Sep 22 06:17:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9965211 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 97791602D8 for ; Fri, 22 Sep 2017 06:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87CC329707 for ; Fri, 22 Sep 2017 06:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BCD629711; Fri, 22 Sep 2017 06:18:00 +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 0C7F72970F for ; Fri, 22 Sep 2017 06:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbdIVGR6 (ORCPT ); Fri, 22 Sep 2017 02:17:58 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36694 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbdIVGR5 (ORCPT ); Fri, 22 Sep 2017 02:17:57 -0400 Received: by mail-pg0-f67.google.com with SMTP id d8so120443pgt.3 for ; Thu, 21 Sep 2017 23:17:56 -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=3pgrsOJam5dA0JziFxZtRHo55dvlIPRHUgTjyl22LQA=; b=Ga5eHbjzQUDVEeL4ruQWBJjrsqbS4Lrcg/7NgRGYqIReaJ3m61Kc5K7eohGo75K8w1 tClVGF2Idlhd8j5O5iYyWc8g2v1ufzlVXuDEr7vATwrrUXiwQmZP5mraA3ATSx56x6YZ BcAKsEbBLtyASV4wMMRQZOiLCueU4iQfbIkrFoiUXZQC6c6JrulJBIylg8RUSQYlNaSN IVUmeRal60lQAVISFAITxvZmmnrenSvsocyLpkp3hQZQpwbT4id8aJ0sOLS86zRziK7+ O1sG8FnA9obEnRnxtPP2tTOQjtR4Alnfit3eBrQqhqjbDhiWIL4GqmZkklVrA4K+h11m sBaw== 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=3pgrsOJam5dA0JziFxZtRHo55dvlIPRHUgTjyl22LQA=; b=RJmW0ANTauDFirrg0/Qrc7zeBjGHwDrnxyqS9nzspLC7Cok4pnkc0I4Uju9rwoN9Na olKGbG52mlGJ9anfShFlKyTmUvBAdIP5gWO/UfFVd+BWRaAHdQ8wkCaUvYlzQDRujhcd AaHAW5sP8Uhj/uCu3Chf+uRF6NM6e9T6tnPMvLI0xrhd2gfkUDDSyBajqlHErnmX+wXv gD0C3qeczYtcKdVZCXvNGhcZmwbn8FTPgLgPtr04L9luimuhu3agdyFIjrrax8soj5M+ Dzy6QCrTpnOA1xlp8bnOUHvlQQgH1tJRoILPH5/hUR1rlqVAutNL4InIYUtnRqmlZwIG L4PA== X-Gm-Message-State: AHPjjUh7j5JbJPcOnlyMtsjJ44qTuepVcAyHINRbaw/6hCmX2OdLfuEY DoqH/Pacn2xltQ1wsk3bmGa7VA== X-Google-Smtp-Source: AOwi7QDyL9LTJmuA1rZ4GEYztItpoZk/CZBpQ70T81qh9Klw3ActmD6dsL+jAKapTz5ZNLIBFtOIBA== X-Received: by 10.99.38.7 with SMTP id m7mr8184725pgm.53.1506061076337; Thu, 21 Sep 2017 23:17:56 -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.17.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 23:17:55 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: Dick Kennedy , James Smart Subject: [PATCH 01/19] lpfc: Fix crash in pci hot plug situations Date: Thu, 21 Sep 2017 23:17:23 -0700 Message-Id: <20170922061741.12347-2-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 During pci hot plug scenarios the driver had two issues: a) oops in a list_add call The lookup by tag function will return null if the IOCB is out of range or does not have the on txcmplq flag set. Fix: Check for null return from lookup by tag. b) oops in kernels timer management code The sli4 remove_one handler is not stoping the timers as it starts to remove the port so that it can be swapped. Fix: Stop the timers early in the routine. Note: Fix in SLI-4 only. SLI-3 already stopped the timers properly. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_init.c | 1 + drivers/scsi/lpfc/lpfc_sli.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7e7ae786121b..1773b9ce3149 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -11419,6 +11419,7 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) lpfc_debugfs_terminate(vport); lpfc_sli4_hba_unset(phba); + lpfc_stop_hba_timers(phba); spin_lock_irq(&phba->hbalock); list_del_init(&vport->listentry); spin_unlock_irq(&phba->hbalock); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8b119f87b51d..b8513c1adcef 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -12507,19 +12507,21 @@ lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *phba, /* Look up the ELS command IOCB and create pseudo response IOCB */ cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring, bf_get(lpfc_wcqe_c_request_tag, wcqe)); - /* Put the iocb back on the txcmplq */ - lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq); - spin_unlock_irqrestore(&pring->ring_lock, iflags); - if (unlikely(!cmdiocbq)) { + spin_unlock_irqrestore(&pring->ring_lock, iflags); lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, "0386 ELS complete with no corresponding " - "cmdiocb: iotag (%d)\n", - bf_get(lpfc_wcqe_c_request_tag, wcqe)); + "cmdiocb: 0x%x 0x%x 0x%x 0x%x\n", + wcqe->word0, wcqe->total_data_placed, + wcqe->parameter, wcqe->word3); lpfc_sli_release_iocbq(phba, irspiocbq); return NULL; } + /* Put the iocb back on the txcmplq */ + lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq); + spin_unlock_irqrestore(&pring->ring_lock, iflags); + /* Fake the irspiocbq and copy necessary response information */ lpfc_sli4_iocb_param_transfer(phba, irspiocbq, cmdiocbq, wcqe); @@ -17137,7 +17139,8 @@ lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, if (pcmd && pcmd->virt) dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); kfree(pcmd); - lpfc_sli_release_iocbq(phba, iocbq); + if (iocbq) + lpfc_sli_release_iocbq(phba, iocbq); lpfc_in_buf_free(phba, &dmabuf->dbuf); }