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; From patchwork Tue May 3 01:13:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12834954 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 27F62C433F5 for ; Tue, 3 May 2022 01:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiECBRQ (ORCPT ); Mon, 2 May 2022 21:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbiECBRE (ORCPT ); Mon, 2 May 2022 21:17:04 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6C750473 for ; Mon, 2 May 2022 18:13:31 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id j8so13784561pll.11 for ; Mon, 02 May 2022 18:13:31 -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=iAX+z7Fsw/QyOlQK4J1/wswlMzMJSOKCKmYsxclry74=; b=Ux4ORijnL5rh94TsCGEF//Jfplbg/SqBTNFkPthdGBLlHZ0Xgy16+mm/W7XvFGIZvm e1BpniX+gmntMOpUCD9NXHxt1c4lHqK1KxIqzXv+g9//aPdEZywMxCw+1me0urLkfnze GDjXFgjzqsV5b3Tc4vlgNFpgS75SfGPJO3KTk= 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=iAX+z7Fsw/QyOlQK4J1/wswlMzMJSOKCKmYsxclry74=; b=ndGzjvEyIXke7i6ZSZ6XFQ9yABvzatHifwUpcbcASi1Dv5i8anYgQK8lkWMTr5yG8c ZJ5wB2d92dzy+qMbXWlNPPn/O79IeZ9fZlXVeEhhZ5r+1w9rc3u6morlBl7h3WncGOXq BGfpkIeUDmeNjkC/6YV80jsqANMZ90Y0gy9w6EMwk3QhPjiISY4OAjUAyxHI4MSYIlA1 BmeVN6Ts9EQ1xrNXibBfZMzt0LnV+5UtqS356+M1H0uryykUfyJHd+9hdhxFZiyFL6qH 2gBR+vUcOzzFwr/oX/fshnNAnTgIf23cWbmaLzHWVJHiYkJ91XgVKtLqwQqiYItyENII kBjA== X-Gm-Message-State: AOAM530GH5PLa7bf3Ks7sKqrOVptu+jFFc3OxTcpVfhg4s3XUXnq4OHX 41VTR78sqfdwemnec0X8UaE70g== X-Google-Smtp-Source: ABdhPJxwoymwwnqw3R/ytk4Xr/LOkIcjM35pDDOisj5juemTlNgUrsrj/v1QNTSoY9XXtmDn1w3ydw== X-Received: by 2002:a17:902:9b92:b0:158:9b65:a78 with SMTP id y18-20020a1709029b9200b001589b650a78mr14670205plp.53.1651540410370; Mon, 02 May 2022 18:13:30 -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.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2022 18:13:29 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net 2/3] bnxt_en: Initiallize bp->ptp_lock first before using it Date: Mon, 2 May 2022 21:13:11 -0400 Message-Id: <1651540392-2260-3-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 bnxt_ptp_init() calls bnxt_ptp_init_rtc() which will acquire the ptp_lock spinlock. The spinlock is not initialized until later. Move the bnxt_ptp_init_rtc() call after the spinlock is initialized. Fixes: 24ac1ecd5240 ("bnxt_en: Add driver support to use Real Time Counter for PTP") Reviewed-by: Pavan Chebbi Reviewed-by: Saravanan Vajravel Reviewed-by: Andy Gospodarek Reviewed-by: Somnath Kotur Reviewed-by: Damodharam Ammepalli Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 9c2ad5e67a5d..00f2f80c0073 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -846,13 +846,6 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) if (rc) return rc; - if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) { - bnxt_ptp_timecounter_init(bp, false); - rc = bnxt_ptp_init_rtc(bp, phc_cfg); - if (rc) - goto out; - } - if (ptp->ptp_clock && bnxt_pps_config_ok(bp)) return 0; @@ -861,8 +854,14 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS); spin_lock_init(&ptp->ptp_lock); - if (!(bp->fw_cap & BNXT_FW_CAP_PTP_RTC)) + if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) { + bnxt_ptp_timecounter_init(bp, false); + rc = bnxt_ptp_init_rtc(bp, phc_cfg); + if (rc) + goto out; + } else { bnxt_ptp_timecounter_init(bp, true); + } ptp->ptp_info = bnxt_ptp_caps; if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) { From patchwork Tue May 3 01:13:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12834955 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 5A36FC433EF for ; Tue, 3 May 2022 01:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbiECBRX (ORCPT ); Mon, 2 May 2022 21:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbiECBRF (ORCPT ); Mon, 2 May 2022 21:17:05 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBF4506C7 for ; Mon, 2 May 2022 18:13:32 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id n18so13812285plg.5 for ; Mon, 02 May 2022 18:13:32 -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=JV8HZH/RPwztFz8GsBRUtlTHu110VIJsgQCQJI8UpIw=; b=JiFCRWn3cJ1sB06VBquVzKwcJgxuUxYydgI33z61EK2iojfj1sRxDN/WzkLFGtHeRn wzLfsYA1/6A/gxTcKaxdwCrfBd/nkyy+kUc+wQW27WzB16ASxJ5/M5FEb5+JNpFy4uZM d667zxjrMJ+Y1UfpLPZ5xD02M+WHtn+NeRoNA= 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=JV8HZH/RPwztFz8GsBRUtlTHu110VIJsgQCQJI8UpIw=; b=DopX5da53YkkddrzrNmqJadctifwtbOLuSciXBeZKKLBHoqc9PtUpiQm4mGwvhWOx5 KMpXsHOCwLuxjL6Mk3zJCaagtYRWONL69uIJrECAo6qlGiqnTGkoHHY2lywTIQZwlKdV AnggR30K7ySaVwUNACqI3+5EMev1irHZtezD0mbDcU3iuAOHwmtvjo9ziBn6hldjSewu HGjMnimRucPBBd8vKMGNZLrNe1GvoODE05+IhRedhbG2PkwyE1RVH7ULwioDmIJ2630f J2CffBumTFDRgzk0o+bujN6Mk4P5Z5OUGEMyc5lMgVFKNYQAln8LiYXn9K31J5d/UZL5 ACJQ== X-Gm-Message-State: AOAM531qji5pt2RZGaKgXJwIY9VNzYsRC4ZvU3q38rOS6x68qdOTVsWd haQ7bnV/W04PtVyIs6JPGWbFTw== X-Google-Smtp-Source: ABdhPJyCh0KNFy/iizL+WV+y0HyJ6FCZyGMJ4aVWrx/GX5KNSc3upch7rXvBwJbdVYJ70GUYOa84uQ== X-Received: by 2002:a17:903:2306:b0:15e:b7be:dafd with SMTP id d6-20020a170903230600b0015eb7bedafdmr456797plh.29.1651540411519; Mon, 02 May 2022 18:13:31 -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.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2022 18:13:31 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net 3/3] bnxt_en: Fix unnecessary dropping of RX packets Date: Mon, 2 May 2022 21:13:12 -0400 Message-Id: <1651540392-2260-4-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 In bnxt_poll_p5(), we first check cpr->has_more_work. If it is true, we are in NAPI polling mode and we will call __bnxt_poll_cqs() to continue polling. It is possible to exhanust the budget again when __bnxt_poll_cqs() returns. We then enter the main while loop to check for new entries in the NQ. If we had previously exhausted the NAPI budget, we may call __bnxt_poll_work() to process an RX entry with zero budget. This will cause packets to be dropped unnecessarily, thinking that we are in the netpoll path. Fix it by breaking out of the while loop if we need to process an RX NQ entry with no budget left. We will then exit NAPI and stay in polling mode. Fixes: 389a877a3b20 ("bnxt_en: Process the NQ under NAPI continuous polling.") Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 2818cfef42f8..1d69fe0737a1 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2707,6 +2707,10 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget) u32 idx = le32_to_cpu(nqcmp->cq_handle_low); struct bnxt_cp_ring_info *cpr2; + /* No more budget for RX work */ + if (budget && work_done >= budget && idx == BNXT_RX_HDL) + break; + cpr2 = cpr->cp_ring_arr[idx]; work_done += __bnxt_poll_work(bp, cpr2, budget - work_done);