Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17893368ybl; Thu, 2 Jan 2020 14:14:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzgKLO9nLIWTZS1IEym/LiybzbOsK2TMqu+FYut3Gu/wD5Krf81b7TRi5qVntQqCGqSkik7 X-Received: by 2002:a05:6830:22ee:: with SMTP id t14mr91806209otc.236.1578003274454; Thu, 02 Jan 2020 14:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003274; cv=none; d=google.com; s=arc-20160816; b=K8r3TWKnhDSVRyPnITRa71rCBsj8xK2Wn8nh1P0GxKUC6R8rqMYPUV8TI2tCF465Mj EaewIy43IYVNJ5og3HL3ATfkpwZKl0NM3VEbfEIoF9UXd4mi6kOLg7hOov5h3RFEhgdN fVQHkPdSgYEKH3s+rW50jkXAgwNWKuqGVIeU5RCL92Uum4sAjHjbyWCpVKuUdgAjiLG/ ba95QpNU/9ZDW2imOZ4bLTo6jOKdpiV502rF1VkY/8CVom31kRwzB4C6zmADSyqGXRux eaOHcUGHScKSLjPIjbsk+edy7SGfeN4CdiAzw4H6vgYZoHPkGyEZb4EgL7nVcmoZ9mwY Fk5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b6SoaiJ14zH0ig8tG/Qc1M0I5RVsAJCqAasgB7WKfWg=; b=0lMm8K9gOK3Y4YL96B4ErzBWWGhtsfXFwLXA/MRyV9KIgzkL3tjh3memiWn8V99Lso FB1wkAwe5F4umKtgccwkQPHO8Wlye9Qf+2xvjkYktWEG/7E9K8dlQgMmPKjUzjqT9Hcu Q1zcacN2yIcyqBW7fpIBnqh31TvXc9FDrYLtFUTWE1TsO2e421SaoIfkTjJDKfEzpLx6 VuTGp6zuij51UCAr7LmSgWylNIv4PcIuFyJaY1NEV9Mw3FImJwQpDhcaXnBFVTHCAQi9 VnCerE46ZUmsBQUNUXmBu89zhf52hiPt/rNa7kUBZDvlYo/mWImVX3OadONzkpRAMoG/ l7Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NhvXkF6/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si20400835otk.162.2020.01.02.14.14.22; Thu, 02 Jan 2020 14:14:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NhvXkF6/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbgABWMS (ORCPT + 99 others); Thu, 2 Jan 2020 17:12:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:51138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727420AbgABWML (ORCPT ); Thu, 2 Jan 2020 17:12:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DBE121835; Thu, 2 Jan 2020 22:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003131; bh=UaSWdl5NAmEagx4muM7QupwMugM/lWzMusOjB/JUZQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NhvXkF6/V9ODR927GySem0KDc7jEYdnIPzyCPFMtiWPTefHLUulOBc/NMWAN29zYB sKHJ8vy3hsSp/JCF/bHiMsROYCOrPyNtMttW/gg0god4jMk2sEvLYHQe6Jrx2nkNsF lGBE3rCvuS7rEe2AOvF7JfBrjCBabnzYNZIMn5/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dick Kennedy , James Smart , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 006/191] scsi: lpfc: Fix locking on mailbox command completion Date: Thu, 2 Jan 2020 23:04:48 +0100 Message-Id: <20200102215830.496052424@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart [ Upstream commit 07b8582430370097238b589f4e24da7613ca6dd3 ] Symptoms were seen of the driver not having valid data for mailbox commands. After debugging, the following sequence was found: The driver maintains a port-wide pointer of the mailbox command that is currently in execution. Once finished, the port-wide pointer is cleared (done in lpfc_sli4_mq_release()). The next mailbox command issued will set the next pointer and so on. The mailbox response data is only copied if there is a valid port-wide pointer. In the failing case, it was seen that a new mailbox command was being attempted in parallel with the completion. The parallel path was seeing the mailbox no long in use (flag check under lock) and thus set the port pointer. The completion path had cleared the active flag under lock, but had not touched the port pointer. The port pointer is cleared after the lock is released. In this case, the completion path cleared the just-set value by the parallel path. Fix by making the calls that clear mbox state/port pointer while under lock. Also slightly cleaned up the error path. Link: https://lore.kernel.org/r/20190922035906.10977-8-jsmart2021@gmail.com Signed-off-by: Dick Kennedy Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_sli.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 5ed4219675eb..e847244dfde3 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -13161,13 +13161,19 @@ send_current_mbox: phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; /* Setting active mailbox pointer need to be in sync to flag clear */ phba->sli.mbox_active = NULL; + if (bf_get(lpfc_trailer_consumed, mcqe)) + lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); spin_unlock_irqrestore(&phba->hbalock, iflags); /* Wake up worker thread to post the next pending mailbox command */ lpfc_worker_wake_up(phba); + return workposted; + out_no_mqe_complete: + spin_lock_irqsave(&phba->hbalock, iflags); if (bf_get(lpfc_trailer_consumed, mcqe)) lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); - return workposted; + spin_unlock_irqrestore(&phba->hbalock, iflags); + return false; } /** -- 2.20.1