Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6056577iob; Tue, 10 May 2022 09:20:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXsQXE0yXRza4UHiyAlF9JTRegZzoOId0fJEe1miRpq6X0e32srMxtzRjQBFYh8bbsoUTn X-Received: by 2002:a63:68c2:0:b0:3c5:ecca:5207 with SMTP id d185-20020a6368c2000000b003c5ecca5207mr17165406pgc.574.1652199620292; Tue, 10 May 2022 09:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652199620; cv=none; d=google.com; s=arc-20160816; b=WGLJDsxVJLULaADm8ZfoPy5zySB3Zvxj3U012xt7QjHWe7eb0CNMv/BzckUzbQVulU oUBpIIu7TPBRF8u5QnVXs6+LkUq3HYjbSR3nNxs/b4kPuarWzp5RJRTsLJ4c3p/1LD3P BLcA7rb1nh7/OQcA7W9VjnNzytdXHUfX58HFV64zg1Fa2qy66TP6O0318ftrf2kLCV+f jpzlkUvM794EIHkZmreMDFec2tYowTHWqmS59V8nh3v7nEPbRW0++al0HmL7fUROyw0H VouMzBC3l9hSDZM6vyV0jk4uZRdfTacWnS8FZy/rmLY6gU/KG/hxQmvpw6zEFO+w6WB/ 3/vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uVrp4YGvXAIiKuOukjvO6FZ0dYQBQdmcLl4yxSoEOcs=; b=RMmqbgoj+GDjDby9jGdewADWJUkWVt1wfNiXDH8595C+RIbp5Cd0slK3mXlAmifcnz FxV7ilNENuKjISsIUv0NChgjx9UWoSeZkufcXZpFdj7Gy8T6AFICUgShWvMGS85FELyp rONve632VhD2zgKbCSOcQssKhML1//c49fdhZBKBm628cqzb/V4lpHn3NULzbgntAjKe vUGpgTcFNnkHNnJBjOEeXam8PT+hpc1OpF09RuSMfVL1S7/+44i9vk3Da8Uw/PcJxSCx 7ndcTd5TG1e7IdJInzdaQ/vpd/DAWZNmyga+kaqTdgRmmlymCR3dWKKP6I99xJjcPr7/ HMkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NB9O4Cyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056a001ac800b0051078cc4fd5si21990990pfv.354.2022.05.10.09.20.04; Tue, 10 May 2022 09:20:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NB9O4Cyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245677AbiEJNsF (ORCPT + 99 others); Tue, 10 May 2022 09:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243894AbiEJNcU (ORCPT ); Tue, 10 May 2022 09:32:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46C95178562; Tue, 10 May 2022 06:23:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D7A0E61768; Tue, 10 May 2022 13:23:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6614C385A6; Tue, 10 May 2022 13:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189000; bh=tm/Y3N1xRtkC0eTpSWQ2qqM2l+6CezNMfRdf2u3uhmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NB9O4CyfeK3PlALCvmuxjZPLP+rJABn/PGfZwIJ/PqoyOBPusDfUAMVgv3djEjS9P NW7FSlG495zv5Ixw7Vv3r3MqFigeYfYXKHzjQ4Znr+BE/UCjivzCVVp7Epn/CviTme lPvXJKw7LTiHfivu5C3joGWquz1AVsysm2oafyhc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Somnath Kotur , Michael Chan , Jakub Kicinski Subject: [PATCH 5.4 30/52] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Date: Tue, 10 May 2022 15:07:59 +0200 Message-Id: <20220510130730.735895357@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130729.852544477@linuxfoundation.org> References: <20220510130729.852544477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Somnath Kotur commit 13ba794397e45e52893cfc21d7a69cb5f341b407 upstream. 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 Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9791,7 +9791,7 @@ static bool bnxt_rfs_capable(struct bnxt 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; @@ -11725,10 +11725,9 @@ static int bnxt_init_dflt_ring_mode(stru 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;