Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10180508ybi; Wed, 24 Jul 2019 17:47:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW+OXnjyktJ5P7m/PRPqBdA7+rnYIRujuyVjC9HTdyNHhSEm4m+S8MDwJqLnIqYFPQk4ek X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr5674177plp.126.1564015678080; Wed, 24 Jul 2019 17:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564015678; cv=none; d=google.com; s=arc-20160816; b=HS9Im7EOWBrTZAw6sJ38EYWrmjWCtoG0FpTMk32IXvucrmZmeXMLP+zIFdr5dFphMK q3kGWRw1M2i6XkzEUP/CpZBG2JyPZqFnqTRxqN8nSWjr6IW20nQ6dMpUzlwcwizPRbIs i9Ic7OYlbFf/67Y/WdtRZFCBykfmTqHdsSvblvjrEmFPUTHEj8i8x8QArFU2Y6E7tVN/ 5ntNI95oAql9S3xuHM/+n3YL6MuZYIzboJFlOWZ+cZo5caoVfh5ZCjNY34kncMT19lJ3 8CMxngeJIIblXb3M4ezh/HFQnQdptYHTicG3o68FZynYLoHpGmAXB4uDAbxaDA8xszzz vPwg== 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=tq31B6WjldpFowgfmgzCJlch4QmvFuRvy4JKmx6jfk0=; b=D7WCQSudnlktdPUqakp4Bfc2Vse0Z1swke+5cYseK0rVfv8tyfyhHp1FwXFBh3F37g tIJ2N+y5FhaDHfn7Fz4JzvXzE1LiFiENSemx7dB6HnxwmKj0BrbYg5/jElgP+wvrhnNe JZhdGCwGnXSYoOOatvwJem7vendSF0uz1CfTdL3HXhYx5n8R8AUmATssc1uK+NCUm2I3 H2432ndzk/pyreo91buU5tNfXpk7l4H2473VRVD3FI/SG58V5lrlLtYHlbdFLInmcxHc ko0L4qQYI5SSoo73C69UjrPoJGrYiuBAtHSrdapoPowyBi2EuCpNq00e8DlhhDW91Kg4 JR+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pEIKapar; 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 f16si7571810pgj.257.2019.07.24.17.47.03; Wed, 24 Jul 2019 17:47:58 -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=pEIKapar; 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 S2389170AbfGXTfP (ORCPT + 99 others); Wed, 24 Jul 2019 15:35:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:59156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389154AbfGXTfN (ORCPT ); Wed, 24 Jul 2019 15:35:13 -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 E9CE62238C; Wed, 24 Jul 2019 19:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996912; bh=AP55X1PqztwacX+FE9hkkP/VFQux9rxqmPCX8qc+YsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pEIKaparyjUitXuevUX+PuIVzoivUROjpX7TgEoLv6UcGGIcC02GXVwUaDjb0kh0D W9w17V4InVfvE/77Wlyd10RhJ0qSmhum+QVJSgCqTN7XeybGCfR05xJOI//I5DfIoB rZP+EnTtdwBlR0h6wl7N1yPbbsNCNpHQLMSRfrzc= 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.2 207/413] bnxt_en: Fix statistics context reservation logic for RDMA driver. Date: Wed, 24 Jul 2019 21:18:18 +0200 Message-Id: <20190724191749.324005847@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 b9bc829aa9da..9090c79387c1 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5508,7 +5508,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) @@ -7477,11 +7486,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