Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3300080pxk; Mon, 21 Sep 2020 10:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQdSrG0157HUYWGbZt2Rrv91t8YglVG7kfwuBuUCHcJHD6Pan5s6kfDp4HKqoSaIMO8zpn X-Received: by 2002:a17:906:4e82:: with SMTP id v2mr454964eju.218.1600707782279; Mon, 21 Sep 2020 10:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707782; cv=none; d=google.com; s=arc-20160816; b=hFgnH/AcMSU6IariakS0hfAXde0q6V5n/OcEOzRMTt+ILKTuAF0XfUjaTqpGiAr/cy 1UmPK8inYf+1zpjq7VUo1RDkPSAfbMBu6J83JUnnr3/uLIGWR+9/cqLhFexZIP6FELHk ltAA7+4FHbFg7hXtRtfGlq9/Ag5erBmhUMJsja2LkJh0qUzx2qJO0ncxAkZw8gvpWRUn pQe9I0b4A2cNqtTiUsrbAVz213Skj2EdyCm9XfIeJFT0AAOMhtzLTDDvxVzOPvh+Cv7S B7P/438p9wfdpk9tjIQIEa04aZjlZGAL/J/s4GlZ0ATjmbVzdaL2gneQRe0LPRyOeQkZ 61Xw== 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=pm/yNw1x/yq1Bp27aHaHIOf0Dqgo67/iNmtsj/twhdo=; b=x0WvhXy+oT2C/njsJuVL8XQOsdpclyHUmrTchNs0PQ5yQNlAh6rxHlv0Khe3vdwoLZ uJpBeEH0hwwkBxeJc90XgnlNguyrU1PWkZRKb9CYJUJwGJy8e+zgKnFolAjfA0IGQ3fo bWYBuPwjBdVO31607b83n+OjaBXQ4bw3uShnfHA9AttL2G8qPdZunuHsxz/0CE3HktQj 7XhqG84KDbAmP7rPmWQYZylAQBuXpIOVnZGqG2uWOB6oeN6ZDHCthnyDcxRlr6xC04H2 Pezo9k4HG96rdaHRAEct7jUAs3BIkFRp9kmvwQBmedrfWpvDlHnQxP6dSHhlKe5N5o4r iyDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=msaaB46P; 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 g19si8762071eds.240.2020.09.21.10.02.37; Mon, 21 Sep 2020 10:03:02 -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=msaaB46P; 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 S1730307AbgIURBh (ORCPT + 99 others); Mon, 21 Sep 2020 13:01:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:41048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728615AbgIUQjR (ORCPT ); Mon, 21 Sep 2020 12:39:17 -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 A799623998; Mon, 21 Sep 2020 16:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706355; bh=PLDnCob4qOnx8MoDAzF8jK/Lj2hpnJ6NEWBajDcMRJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=msaaB46PlBEtPnb8x9Lfyxbf9tUy9FE3gwbbBzVnJnELOnHohqMtBoQIxDChR+P0c 4kByXC3xBWgBcXD0KCWMs5n7Po7Or+LhXkg7u4Hvx9qPUhGq5GiJXjKrwptaJyD0lT fceWQrVp98opGClbnsKwJJc3gFKZtXwDpFB2w0QY= 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.14 67/94] scsi: lpfc: Fix FLOGI/PLOGI receive race condition in pt2pt discovery Date: Mon, 21 Sep 2020 18:27:54 +0200 Message-Id: <20200921162038.598297409@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@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 db1111f7e85ae..566e8d07cb058 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -4104,7 +4104,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