Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3303893pxk; Mon, 21 Sep 2020 10:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvSdkjwfB/fIIQpIVTmmAyZ3efplDmH22Uhh7cGVjaviJhNsZCU87eoSG0vNzU8+CUf4i3 X-Received: by 2002:a05:6402:1d0f:: with SMTP id dg15mr675939edb.342.1600708064474; Mon, 21 Sep 2020 10:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600708064; cv=none; d=google.com; s=arc-20160816; b=LsPZ2fjIXPdhFMxhy4oU8ObkKPujQc9aCjH/owCaWCtQR8ts7GtxBjTR5UlMaqL9Ss NBtn4YnWLxk5ikwAJWvGai5NqRErJ5M8ULbyNy+TXrS0viFHJ7MO3Mxw2LPhLUdTxCFW diuRDfiCHqr8NNcV+KAmXXpdvkyzP7OTp9Ve14ndE+/UG8S5O7dlzGGV7YOFbv45FlY9 XBma/o2M5JB5QTCRHhA84P7fWgnm8ECTDvdRa0WdcBsNVmh9vpgrTY5AXZFtPxaF7Y1j pn4QZNbChiBsqST4bG3H/2yNT1nnDjVGrnQnJ3bqapq0BOoKMGBGO4vR9SCyLlY+j4+K RW/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AtEtooV2wkssJnp9edtMEewlEqzJhd+pVJ6olqp68PY=; b=jmJgTELW86uN2TZSyudFh7NL0BWANZn6KwL8OcRmqNITYFUrhndOWbey8jMpIKPgBV aleyHqmkAtgfn9Ery2G2Gx9kbY6akITTDDkBJAG7DwAPcX5d725qt1h2R0cLB7xS7dgW Oyoq5K8LIgqL0NuTzlQeZsZ1o0uRNwfUw6ozDQg9zmUwJY5Wx5E+uBAj8hNnmrJFOGXm tv379aR6AyDG43LIhKr/SKQkqf9Amiad3AY4KKBU+kjSNd6guSAqDFHZWc4jRHF3kW9y N9HWBwhrhV5tiJqAdBXJxQbkZgVdIyX+KZerQBWkMV6wyA4B+Aagm4aaAKUgyb7QNkcA f1lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P5tlKJDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si8769043edj.64.2020.09.21.10.07.20; Mon, 21 Sep 2020 10:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P5tlKJDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbgIURGa (ORCPT + 99 others); Mon, 21 Sep 2020 13:06:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728518AbgIUQcl (ORCPT ); Mon, 21 Sep 2020 12:32:41 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1D19D239EB; Mon, 21 Sep 2020 16:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600705960; bh=kAMW49P1gnd6Q7vgEB8RTzXo+02ZKiNLkrobbCM3QN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5tlKJDeR/4bVF5cT7IkBnegW7OGrMkbtW1cVKVrMl2YHaJvBtP24mkEA7qJvWUnC JQ01C7ygVWwAIi64q6k/fzYr8Ffwm1eZEp/HC8hEOgDU2DeGkwPngVrE36B5tKYZL3 hG0/PwTMJOFlcCXle0aVNatxGrclNL8Ce2DXl1e0= 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 4.4 31/46] scsi: lpfc: Fix FLOGI/PLOGI receive race condition in pt2pt discovery Date: Mon, 21 Sep 2020 18:27:47 +0200 Message-Id: <20200921162034.739599477@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162033.346434578@linuxfoundation.org> References: <20200921162033.346434578@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart [ Upstream commit 7b08e89f98cee9907895fabb64cf437bc505ce9a ] The driver is unable to successfully login with remote device. During pt2pt login, the driver completes its FLOGI request with the remote device having WWN precedence. The remote device issues its own (delayed) FLOGI after accepting the driver's and, upon transmitting the FLOGI, immediately recognizes it has already processed the driver's FLOGI thus it transitions to sending a PLOGI before waiting for an ACC to its FLOGI. In the driver, the FLOGI is received and an ACC sent, followed by the PLOGI being received and an ACC sent. The issue is that the PLOGI reception occurs before the response from the adapter from the FLOGI ACC is received. Processing of the PLOGI sets state flags to perform the REG_RPI mailbox command and proceed with the rest of discovery on the port. The same completion routine used by both FLOGI and PLOGI is generic in nature. One of the things it does is clear flags, and those flags happen to drive the rest of discovery. So what happened was the PLOGI processing set the flags, the FLOGI ACC completion cleared them, thus when the PLOGI ACC completes it doesn't see the flags and stops. Fix by modifying the generic completion routine to not clear the rest of discovery flag (NLP_ACC_REGLOGIN) unless the completion is also associated with performing a mailbox command as part of its handling. For things such as FLOGI ACC, there isn't a subsequent action to perform with the adapter, thus there is no mailbox cmd ptr. PLOGI ACC though will perform REG_RPI upon completion, thus there is a mailbox cmd ptr. Link: https://lore.kernel.org/r/20200828175332.130300-3-james.smart@broadcom.com Co-developed-by: Dick Kennedy 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_els.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 315dd25a0c44e..5be938b47f48b 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3841,7 +3841,9 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, out: if (ndlp && NLP_CHK_NODE_ACT(ndlp) && shost) { spin_lock_irq(shost->host_lock); - ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); + if (mbox) + ndlp->nlp_flag &= ~NLP_ACC_REGLOGIN; + ndlp->nlp_flag &= ~NLP_RM_DFLT_RPI; spin_unlock_irq(shost->host_lock); /* If the node is not being used by another discovery thread, -- 2.25.1