Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1683589ybz; Thu, 16 Apr 2020 13:37:44 -0700 (PDT) X-Google-Smtp-Source: APiQypJ0+FoYfiDplKSG1fGCtx7al9J+ckUnYuRhagu1zHKutSOUB2/V2vc+1HLYE+burn/+p6JZ X-Received: by 2002:a05:6402:22a4:: with SMTP id cx4mr27178edb.133.1587069464155; Thu, 16 Apr 2020 13:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587069464; cv=none; d=google.com; s=arc-20160816; b=x8Tb1Brwcha4VmYpS2Glsre6dhSbSV5eab5xhNGxd9gAvBANgKbyR3GjOF8KhKN0ER f81oGc256eD3loE7rL+DbColaOoviT5Coyfy6Z75h9W/SwWUF1u+m65Na3RnRzxw3nTQ C0OhIWFO97SIkhKfVnY/9A02GHOACtvQ5YE2mO4kXcQYyFOGw4XzrmN2cM+vDr2JMAwG +xJl+XGw7LlSqdrABKgVikLZjRgGk36rrfehpEqPDYTxDZdVAUDPMhrebYBd89Vo5w7Z 7xK/jeivG1HCsVNDNgTbvYCYbs97ms0O0dbVdbFExR0e0tY9XWinC2qEkQrl2hTW9wSQ Fokg== 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=BjlZ1PrZAxov5tS9/ec2i1GQ6PfWx0M3sk6wQ68qDSo=; b=miSZreP/lETSa5OrIRQ94gDeWIgpMJV7Z1I7pGALzRSpkMECWHM6aOiV6NVGOCmF7w 7uPuIsNYKkMCNhcTlaOuvK/6i/Dyj31TANXOehjrk5LHRwD36tcyy1qnsClxZInPq2PB gHt+vR1mGrJMipRBCFhyuzwaMfTfE0ZyDlFhdmjQsy8QCtfhLyq09Xrnn6hH/wic1jHM vZNSyNwYeg5asuuInpqBQSolj+vvcIjyWkK/cPUES1AtbFMjMu00NvOe1ZCw8rZqJSHk ibw0wNeRBwATG8AfR4ZeAJApJUp5sTS9NqzpsR7Ft9+vJ8pzBfgJKysAAGXyp/zloiK7 VVbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f0rWHkqW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc28si16994329edb.531.2020.04.16.13.37.21; Thu, 16 Apr 2020 13:37: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=f0rWHkqW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395328AbgDPPgl (ORCPT + 99 others); Thu, 16 Apr 2020 11:36:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:52354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898005AbgDPNjx (ORCPT ); Thu, 16 Apr 2020 09:39:53 -0400 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 EC4752222C; Thu, 16 Apr 2020 13:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044392; bh=UNh0GgZ5iRahcSR9YwXtGHyMEu2+qInqjaAHe6Rzyf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0rWHkqW6JY9mqbuEUvP8onDk3JfIf1ielWo2DxBHf3Qn99od5b7yBNYSI3yP+t7z vyRnICmAoOc2xgdMyO7UoNWuB7TffpL5nZlKqq5vqmCxkRzufb6G4xzLESr53aWGK1 F8Ux2PAztjhZyYmjVgJwiSI9QCmCVX+yb4WzbKgA= 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" Subject: [PATCH 5.5 198/257] scsi: lpfc: Fix broken Credit Recovery after driver load Date: Thu, 16 Apr 2020 15:24:09 +0200 Message-Id: <20200416131350.895170770@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131325.891903893@linuxfoundation.org> References: <20200416131325.891903893@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 commit 835214f5d5f516a38069bc077c879c7da00d6108 upstream. When driver is set to enable bb credit recovery, the switch displayed the setting as inactive. If the link bounces, it switches to Active. During link up processing, the driver currently does a MBX_READ_SPARAM followed by a MBX_CONFIG_LINK. These mbox commands are queued to be executed, one at a time and the completion is processed by the worker thread. Since the MBX_READ_SPARAM is done BEFORE the MBX_CONFIG_LINK, the BB_SC_N bit is never set the the returned values. BB Credit recovery status only gets set after the driver requests the feature in CONFIG_LINK, which is done after the link up. Thus the ordering of READ_SPARAM needs to follow the CONFIG_LINK. Fix by reordering so that READ_SPARAM is done after CONFIG_LINK. Added a HBA_DEFER_FLOGI flag so that any FLOGI handling waits until after the READ_SPARAM is done so that the proper BB credit value is set in the FLOGI payload. Fixes: 6bfb16208298 ("scsi: lpfc: Fix configuration of BB credit recovery in service parameters") Cc: # v5.4+ Link: https://lore.kernel.org/r/20200128002312.16346-4-jsmart2021@gmail.com Signed-off-by: Dick Kennedy Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc.h | 1 drivers/scsi/lpfc/lpfc_hbadisc.c | 59 +++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 20 deletions(-) --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -749,6 +749,7 @@ struct lpfc_hba { * capability */ #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */ +#define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */ uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/ struct lpfc_dmabuf slim2p; --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1162,13 +1162,16 @@ lpfc_mbx_cmpl_local_config_link(struct l } /* Start discovery by sending a FLOGI. port_state is identically - * LPFC_FLOGI while waiting for FLOGI cmpl + * LPFC_FLOGI while waiting for FLOGI cmpl. Check if sending + * the FLOGI is being deferred till after MBX_READ_SPARAM completes. */ - if (vport->port_state != LPFC_FLOGI) - lpfc_initial_flogi(vport); - else if (vport->fc_flag & FC_PT2PT) - lpfc_disc_start(vport); - + if (vport->port_state != LPFC_FLOGI) { + if (!(phba->hba_flag & HBA_DEFER_FLOGI)) + lpfc_initial_flogi(vport); + } else { + if (vport->fc_flag & FC_PT2PT) + lpfc_disc_start(vport); + } return; out: @@ -3093,6 +3096,14 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hb lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); mempool_free(pmb, phba->mbox_mem_pool); + + /* Check if sending the FLOGI is being deferred to after we get + * up to date CSPs from MBX_READ_SPARAM. + */ + if (phba->hba_flag & HBA_DEFER_FLOGI) { + lpfc_initial_flogi(vport); + phba->hba_flag &= ~HBA_DEFER_FLOGI; + } return; out: @@ -3223,6 +3234,23 @@ lpfc_mbx_process_link_up(struct lpfc_hba } lpfc_linkup(phba); + sparam_mbox = NULL; + + if (!(phba->hba_flag & HBA_FCOE_MODE)) { + cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); + if (!cfglink_mbox) + goto out; + vport->port_state = LPFC_LOCAL_CFG_LINK; + lpfc_config_link(phba, cfglink_mbox); + cfglink_mbox->vport = vport; + cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; + rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT); + if (rc == MBX_NOT_FINISHED) { + mempool_free(cfglink_mbox, phba->mbox_mem_pool); + goto out; + } + } + sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); if (!sparam_mbox) goto out; @@ -3243,20 +3271,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba goto out; } - if (!(phba->hba_flag & HBA_FCOE_MODE)) { - cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!cfglink_mbox) - goto out; - vport->port_state = LPFC_LOCAL_CFG_LINK; - lpfc_config_link(phba, cfglink_mbox); - cfglink_mbox->vport = vport; - cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; - rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) { - mempool_free(cfglink_mbox, phba->mbox_mem_pool); - goto out; - } - } else { + if (phba->hba_flag & HBA_FCOE_MODE) { vport->port_state = LPFC_VPORT_UNKNOWN; /* * Add the driver's default FCF record at FCF index 0 now. This @@ -3313,6 +3328,10 @@ lpfc_mbx_process_link_up(struct lpfc_hba } /* Reset FCF roundrobin bmask for new discovery */ lpfc_sli4_clear_fcf_rr_bmask(phba); + } else { + if (phba->bbcredit_support && phba->cfg_enable_bbcr && + !(phba->link_flag & LS_LOOPBACK_MODE)) + phba->hba_flag |= HBA_DEFER_FLOGI; } return;