From patchwork Tue May 3 01:13:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12834952 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90973C433F5 for ; Tue, 3 May 2022 01:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbiECBRF (ORCPT ); Mon, 2 May 2022 21:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiECBRB (ORCPT ); Mon, 2 May 2022 21:17:01 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BEB46B07 for ; Mon, 2 May 2022 18:13:29 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d15so13820500plh.2 for ; Mon, 02 May 2022 18:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CalPoUtN9smAF07Uzze+T4CtQMp/sb3wvgmZLzif5pM=; b=fsxja45VUBKFjPx+BM9HaAzJQxHK8/E9yNFX/yyyzjktgBeXynTbEn4nO8fh9urBPe +EFQVwQOwQR429lftxQdrZVle/tLI3NTwkWAfBF/VPUiLE7smqQbXPyQwM1oY1UVUppg H+wjrKlEXiL9TLAQ3IOWX/FImTLIBe9JZr9uM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CalPoUtN9smAF07Uzze+T4CtQMp/sb3wvgmZLzif5pM=; b=UBRIyLM3znx1hy8zta0CxiwZ0ybvZVyzxDJmOwi2pMb2HK3FVgrT+wR6O+CTsNeRZW jA4OAafHDhypmOXnzBBhdWBwMQR1jPthkc2x7xn94AglAcMfPHBWfQIblzDAe/+yLyjj 7hn41lde0KUKgQGyr1biIys0yAtwf2nLHsYJdbGW557z0D4pb6l1rg6fNIFukqgDMx+6 UfbfoTCUIGNJUhU8vB2CExAeR1XFkhYvqVjmss5cVqPWuHEIpzWHl77AVOXw6Z2Wzcdq kwvUl9WbUtUDyoeRhZCm+44tDVqmZbzAtb0NcCKNwYKQccAMNrGaM9YGAK57dV7mhV/I C0Tw== X-Gm-Message-State: AOAM531QEC3u3dXhiCA1tRk7p+xfQXg8MTCVWNtepJ+5e5mBegEV6pGG 0OlDrfeQwZ8thkGoj2rDUI3plg== X-Google-Smtp-Source: ABdhPJxQN7OUJJQT5iE7ZTz/MF3p++Im+jFIZH1fRz24zddA94RNnaiXSOzvlm7yPYwiHvQsfDB33g== X-Received: by 2002:a17:902:e891:b0:15e:9c42:af2f with SMTP id w17-20020a170902e89100b0015e9c42af2fmr9682636plg.71.1651540409212; Mon, 02 May 2022 18:13:29 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k23-20020a170902ba9700b0015e8d4eb1fesm5272169pls.72.2022.05.02.18.13.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2022 18:13:28 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, Somnath Kotur Subject: [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Date: Mon, 2 May 2022 21:13:10 -0400 Message-Id: <1651540392-2260-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1651540392-2260-1-git-send-email-michael.chan@broadcom.com> References: <1651540392-2260-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Somnath Kotur bnxt_open() can fail in this code path, especially on a VF when it fails to reserve default rings: bnxt_open() __bnxt_open_nic() bnxt_clear_int_mode() bnxt_init_dflt_ring_mode() RX rings would be set to 0 when we hit this error path. It is possible for a subsequent bnxt_open() call to potentially succeed with a code path like this: bnxt_open() bnxt_hwrm_if_change() bnxt_fw_init_one() bnxt_fw_init_one_p3() bnxt_set_dflt_rfs() bnxt_rfs_capable() bnxt_hwrm_reserve_rings() On older chips, RFS is capable if we can reserve the number of vnics that is equal to RX rings + 1. But since RX rings is still set to 0 in this code path, we may mistakenly think that RFS is supported for 0 RX rings. Later, when the default RX rings are reserved and we try to enable RFS, it would fail and cause bnxt_open() to fail unnecessarily. We fix this in 2 places. bnxt_rfs_capable() will always return false if RX rings is not yet set. bnxt_init_dflt_ring_mode() will call bnxt_set_dflt_rfs() which will always clear the RFS flags if RFS is not supported. Fixes: 20d7d1c5c9b1 ("bnxt_en: reliably allocate IRQ table on reset to avoid crash") Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 874fad0a5cf8..2818cfef42f8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10983,7 +10983,7 @@ static bool bnxt_rfs_capable(struct bnxt *bp) if (bp->flags & BNXT_FLAG_CHIP_P5) return bnxt_rfs_supported(bp); - if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp)) + if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) return false; vnics = 1 + bp->rx_nr_rings; @@ -13234,10 +13234,9 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp) goto init_dflt_ring_err; bp->tx_nr_rings_per_tc = bp->tx_nr_rings; - if (bnxt_rfs_supported(bp) && bnxt_rfs_capable(bp)) { - bp->flags |= BNXT_FLAG_RFS; - bp->dev->features |= NETIF_F_NTUPLE; - } + + bnxt_set_dflt_rfs(bp); + init_dflt_ring_err: bnxt_ulp_irq_restart(bp, rc); return rc;