Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10409662ybi; Wed, 24 Jul 2019 22:42:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqytXAX/Cy1dKP6u6Nlwy8bX4cLtmP5zyyvUaAsKzmjPD4OaQ/azpk/iMwEaIlnzuQ057H3t X-Received: by 2002:a17:902:8207:: with SMTP id x7mr89496470pln.63.1564033352440; Wed, 24 Jul 2019 22:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033352; cv=none; d=google.com; s=arc-20160816; b=dAkIK7F9fU5x1F0CwiQCcrQ9Hzp6cTaIWHewYr91q6/Dys4zHCBaS98H7YtDyhuGEh yoIvRYJY0F7qNd2jryOG8lS/lP0uINr1dbgvsbQcFdNR+R9dCVy+r90LoYCc6RR1W6BR w2FiWIOrYL86OqcOBdEdd6mDDz2NH2c82KbYg4RSvVMHkE1jfqqMjZvtGwX5p472hXEo tavutscEH2Ur9AhoktR1Xg9pRe2n8GUEnZb9elkzW60cM9oHhMm25VPohdRC6x0kNoWF T5zuicVuB1FngkRQFBAv8pjFVk/Qd8TiaAs/U04/iZ3N0dmZzzcx+OhBend1kDxrF+sa +n8w== 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=HeDn5BObnqTtzaAB/hKu030gA1BRgIvp4tGdO7FV9FI=; b=D3SvlNqdKjK5bV9RtXQI7dRQj3Goolrvrx+iSaKuG1E5z8Jo/hZUVhPgpTCAWOtBu4 FYHGCgAR9BE7uS9h2gA0M01mAEFi8/ORUs0wAo1f+eghTVdueZ84phlg4mfrmeKGmYN9 OFYGjoFo0Dg9M9a9lMcqrxw9Vlp3h4M7HFKMDsCMCuOZtITMWBV8P/z8o3HFuF6iPuhv ElrOJP3Ph6q2dgDvS8iLGI4gRck71US0A5iJD804rjGBM8CWORF9p+VnVdczV37BQg5+ fZeICkHFv/cabQIxFITbFtt5i3uIii/HMmlyt8yf4FE47o+28eCgGTGShmcw7gPBhwS2 8o0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T0rMiuBt; 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 j1si39491730pgk.187.2019.07.24.22.42.18; Wed, 24 Jul 2019 22:42:32 -0700 (PDT) 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=T0rMiuBt; 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 S2392829AbfGXUQN (ORCPT + 99 others); Wed, 24 Jul 2019 16:16:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391711AbfGXTvx (ORCPT ); Wed, 24 Jul 2019 15:51: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 EF96222ADC; Wed, 24 Jul 2019 19:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997912; bh=EMo90s9/Lf/53Jng08uBdWrjmrAc+fc74PM8durqgvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0rMiuBtUQ9HKObRyxjNBldpO1jeQQ4Kg2YZ9YJAf/X5KFZllYvQEuxhAUXzT3wBv Ta0+yfBjYidN1fZS/M3ri1pjqdtVmgWcHMCUY+8RidoVR7vtaHdRM7WaRV3FHiBY+G XDeHWRbHqYsihDwgd138QeuYNzs71nRlyp4oyPJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.1 186/371] bnxt_en: Fix statistics context reservation logic for RDMA driver. Date: Wed, 24 Jul 2019 21:18:58 +0200 Message-Id: <20190724191739.054987764@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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 [ Upstream commit d77b1ad8e87dc5a6cd0d9158b097a4817946ca3b ] The current logic assumes that the RDMA driver uses one statistics context adjacent to the ones used by the network driver. This assumption is not true and the statistics context used by the RDMA driver is tied to its MSIX base vector. This wrong assumption can cause RDMA driver failure after changing ethtool rings on the network side. Fix the statistics reservation logic accordingly. Fixes: 780baad44f0f ("bnxt_en: Reserve 1 stat_ctx for RDMA driver.") Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index bf1fd513fa02..09557bf49bb0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5481,7 +5481,16 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp) static int bnxt_get_func_stat_ctxs(struct bnxt *bp) { - return bp->cp_nr_rings + bnxt_get_ulp_stat_ctxs(bp); + int ulp_stat = bnxt_get_ulp_stat_ctxs(bp); + int cp = bp->cp_nr_rings; + + if (!ulp_stat) + return cp; + + if (bnxt_nq_rings_in_use(bp) > cp + bnxt_get_ulp_msix_num(bp)) + return bnxt_get_ulp_msix_base(bp) + ulp_stat; + + return cp + ulp_stat; } static bool bnxt_need_reserve_rings(struct bnxt *bp) @@ -7373,11 +7382,7 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp) unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp) { - unsigned int stat; - - stat = bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_ulp_stat_ctxs(bp); - stat -= bp->cp_nr_rings; - return stat; + return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); } int bnxt_get_avail_msix(struct bnxt *bp, int num) -- 2.20.1