From patchwork Fri Jan 26 19:22:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 10186911 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 38363601D5 for ; Fri, 26 Jan 2018 19:23:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A5D428C2A for ; Fri, 26 Jan 2018 19:23:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F2E329DC6; Fri, 26 Jan 2018 19:23:13 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 AADFA28C2A for ; Fri, 26 Jan 2018 19:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752875AbeAZTXK (ORCPT ); Fri, 26 Jan 2018 14:23:10 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:35112 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbeAZTXJ (ORCPT ); Fri, 26 Jan 2018 14:23:09 -0500 Received: by mail-qt0-f194.google.com with SMTP id g14so4004974qti.2 for ; Fri, 26 Jan 2018 11:23:08 -0800 (PST) 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=RtWuq7SLFoXab2AcNQWnjUGiA/9bGTGtsy3w0rumv5E=; b=g16mYlcm+bnQwHoNsnVs5+u0JdTzelg7Thoa3v3etrwIDzpFPt08Xlz9EYdA8ZDQ8g OmKDCd5kKNAtJBMi0/6X38cHaTrTZL5vBT0J69XbKActijehCjtz9S8SsojruQTbAN4C wWLwg9pYacZmxm9a+5scuQqbqOxZ/9ngQJ3xKsvPjwjEnk4Cbz+Nmb+JdGRc3XbI6czR EcyAeSGMzi+Exf0hEkLxCbZtNEyNqLRoQ/UOoqCtzBKy8ePrirOsGtd83DC4EJCaoytR sAKqv9Q+Oje3pHYuS3V4AxBFpmSEzrjSrPL2zqLvTnc2GBHaoT2grSNB4HG1SS3luXfR HMSw== 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=RtWuq7SLFoXab2AcNQWnjUGiA/9bGTGtsy3w0rumv5E=; b=UIte1sS3ngtzYKQzsmw5RNt0T6WR6dyEkfoXvTCQXar3Ij/mECCUr4b+jPGeo0tZe/ jAHmIvjZvYv3H6n6dqKaasrC1JM7Z8NQyxIoU4GaylBor74nJJj7RcpIgg9LMaR3fySR Hw9jJ1K1GZ8lkN0I1uMsJalR1aPGAGHobXRd/jzBbhmwfx4cH5c9tPfJjoBWKK4jBezs jvUbygImyhKABQ2KgvapmCNIAhKLnOPvD3B8VDo0U38RmxqCOruv8RIh+cWwmH7z3DWI 9MtgHT5jZmIggiJoDoWFjB0FZj75v8lIM62NM0OcFKnFIhMLpEjlN8pUAkmzp9q0qaN9 QWDg== X-Gm-Message-State: AKwxytehETfIHDE/V5w7C3guwq9oWchWEUKWfpVjqWEYuveUFm7/Fbjk S/nBXBnKHxqvNLYJ6q29MUIyeQ== X-Google-Smtp-Source: AH8x224sctJx4HKbX7og/STnSo5WmFodIx28cEiV4Ea4jfsBKNxonef7xNQFUg9C81KgtFLispO1QQ== X-Received: by 10.237.59.33 with SMTP id p30mr87536qte.84.1516994588384; Fri, 26 Jan 2018 11:23:08 -0800 (PST) Received: from pallmd1.broadcom.com ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id f129sm3811300qke.82.2018.01.26.11.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 11:23:08 -0800 (PST) From: James Smart To: linux-scsi@vger.kernel.org Cc: James Smart , Dick Kennedy , James Smart Subject: [PATCH v2 13/19] lpfc: Fix SCSI io host reset causing kernel crash Date: Fri, 26 Jan 2018 11:22:33 -0800 Message-Id: <20180126192239.10727-14-jsmart2021@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180126192239.10727-1-jsmart2021@gmail.com> References: <20180126192239.10727-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 During SCSI error handling escalation to host reset, the SCSI io routines were moved off the txcmplq, but the individual io's ON_CMPLQ flag wasn't cleared. Thus, a background thread saw the io and attempted to access it as if on the txcmplq. Clear the flag upon removal. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_init.c | 4 ++++ drivers/scsi/lpfc/lpfc_sli.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 851d4e889042..7fc2db968379 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -958,6 +958,7 @@ lpfc_hba_clean_txcmplq(struct lpfc_hba *phba) struct lpfc_sli_ring *pring; LIST_HEAD(completions); int i; + struct lpfc_iocbq *piocb, *next_iocb; if (phba->sli_rev != LPFC_SLI_REV4) { for (i = 0; i < psli->num_rings; i++) { @@ -983,6 +984,9 @@ lpfc_hba_clean_txcmplq(struct lpfc_hba *phba) if (!pring) continue; spin_lock_irq(&pring->ring_lock); + list_for_each_entry_safe(piocb, next_iocb, + &pring->txcmplq, list) + piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; list_splice_init(&pring->txcmplq, &completions); pring->txcmplq_cnt = 0; spin_unlock_irq(&pring->ring_lock); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8b2919a553d6..d597e15a1974 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -3778,6 +3778,7 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) struct lpfc_sli *psli = &phba->sli; struct lpfc_sli_ring *pring; uint32_t i; + struct lpfc_iocbq *piocb, *next_iocb; spin_lock_irq(&phba->hbalock); /* Indicate the I/O queues are flushed */ @@ -3792,6 +3793,9 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) spin_lock_irq(&pring->ring_lock); /* Retrieve everything on txq */ list_splice_init(&pring->txq, &txq); + list_for_each_entry_safe(piocb, next_iocb, + &pring->txcmplq, list) + piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; /* Retrieve everything on the txcmplq */ list_splice_init(&pring->txcmplq, &txcmplq); pring->txq_cnt = 0; @@ -3813,6 +3817,9 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) spin_lock_irq(&phba->hbalock); /* Retrieve everything on txq */ list_splice_init(&pring->txq, &txq); + list_for_each_entry_safe(piocb, next_iocb, + &pring->txcmplq, list) + piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; /* Retrieve everything on the txcmplq */ list_splice_init(&pring->txcmplq, &txcmplq); pring->txq_cnt = 0; @@ -3844,6 +3851,7 @@ lpfc_sli_flush_nvme_rings(struct lpfc_hba *phba) LIST_HEAD(txcmplq); struct lpfc_sli_ring *pring; uint32_t i; + struct lpfc_iocbq *piocb, *next_iocb; if (phba->sli_rev < LPFC_SLI_REV4) return; @@ -3860,8 +3868,11 @@ lpfc_sli_flush_nvme_rings(struct lpfc_hba *phba) for (i = 0; i < phba->cfg_nvme_io_channel; i++) { pring = phba->sli4_hba.nvme_wq[i]->pring; - /* Retrieve everything on the txcmplq */ spin_lock_irq(&pring->ring_lock); + list_for_each_entry_safe(piocb, next_iocb, + &pring->txcmplq, list) + piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; + /* Retrieve everything on the txcmplq */ list_splice_init(&pring->txcmplq, &txcmplq); pring->txcmplq_cnt = 0; spin_unlock_irq(&pring->ring_lock);