Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3411991rwa; Tue, 23 Aug 2022 04:28:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR5627yxQY3nHj3x/QG6rc1oA9r2rwmB6vgG3bfllcLwQAaqZ6UGH6L5hta2q9qv9gTCt9nr X-Received: by 2002:a17:902:8486:b0:171:48cd:1356 with SMTP id c6-20020a170902848600b0017148cd1356mr23131550plo.153.1661254089056; Tue, 23 Aug 2022 04:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254089; cv=none; d=google.com; s=arc-20160816; b=wXba+7VBMVXSS90OXThMrdd3itwZpeG8UvX+6HxbG/oaBX1MzFWBUADapR9RbPjnXq 2tKsjbZ8bJjZ6Tuosr+9fX+AduSAbA3mtxNwTTNTpdV69fO3E0MQfUx5ikMRtBdb1aZ1 dbr1fRhh9ts5hjMEgArTmx02i/4Mn4wPSlbmW/eOvZaSM8eaTB/1rk+h6oULGPIeyP6p oUiBYcSWhkrVxeTu47NXCDRqlu16GtfkWNnotMRVJbBpmShxTB48SRElSoDRXLMh93e3 vtDckSoua+v3g2h48LtTGBImgQfNos2biE/2PFQXAGt3BOUaXXgJyt2oVgB70UJ8BRTq mBTA== 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=yjidBtpUTdBBPD1LL/e7xBxsrXKbxJVS/jRPPuImEo4=; b=g9UMkKIUE2FcWZPtfBCkVkxa1Wfp7sjOY0OSn/zIxyYpqCMC6xzp72vGco+WWQHcD5 I/V39OsXwQ/QgigiBKUYJpKk7o2l35fQBmKrnoB+9qLvYOYwGNJZIaAh8WoMLsJYB6sU ygjcq8qrLGr6FfE1u6+T6wXD4t55oncy5wUSHp5qTYtU6XXLtLiwRNBBxRY7b7IqW6BP Zb6qrYFHrIQcL1h7uS7xYqiQBkjObOWP71Go9RKrl2nn/4i1fz4tsRrRHGQ6PqY/LxkX tTXshU4d+IcCQEOPI7mHw5MuMUuEGDXAIxJ2+tzaUGkGp8YcgVhxbENOtu5oGEENYcRR u+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TrHjzJiO; 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 c16-20020a17090a8d1000b001fb034f4938si9719529pjo.85.2022.08.23.04.27.57; Tue, 23 Aug 2022 04:28:09 -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=TrHjzJiO; 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 S243390AbiHWJwl (ORCPT + 99 others); Tue, 23 Aug 2022 05:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351767AbiHWJux (ORCPT ); Tue, 23 Aug 2022 05:50:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 330606E2D9; Tue, 23 Aug 2022 01:45:24 -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 C21796150F; Tue, 23 Aug 2022 08:45:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB4E5C433D6; Tue, 23 Aug 2022 08:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244323; bh=Gw5twUXOvoHjEK0G5Er3C/B887fyZ4ZMAvf9n6M7dVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TrHjzJiOp3cZtALkR8wFf1/y8sdIK786jbtLvuhAIchgvUla5bxn0AGvWK7KIeged Wx9I08omfe70GXHk78ZOhFkhm+v2x96J27jqVyciR+8Etuaj4tHNd8oeVLdF7LLR0+ /GXIIn/yP6418hQ1T9AU/7hro8pF0xr0hGOdyBmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Subbaraya Sundeep , Sunil Goutham , Jakub Kicinski Subject: [PATCH 5.15 073/244] octeontx2-af: Fix mcam entry resource leak Date: Tue, 23 Aug 2022 10:23:52 +0200 Message-Id: <20220823080101.496529284@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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: Subbaraya Sundeep commit 3f8fe40ab7730cf8eb6f8b8ff412012f7f6f8f48 upstream. The teardown sequence in FLR handler returns if no NIX LF is attached to PF/VF because it indicates that graceful shutdown of resources already happened. But there is a chance of all allocated MCAM entries not being freed by PF/VF. Hence free mcam entries even in case of detached LF. Fixes: c554f9c1574e ("octeontx2-af: Teardown NPA, NIX LF upon receiving FLR") Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Goutham Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 6 ++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 6 ++++++ 2 files changed, 12 insertions(+) --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c @@ -2504,6 +2504,12 @@ static void __rvu_flr_handler(struct rvu rvu_blklf_teardown(rvu, pcifunc, BLKADDR_NPA); rvu_reset_lmt_map_tbl(rvu, pcifunc); rvu_detach_rsrcs(rvu, NULL, pcifunc); + /* In scenarios where PF/VF drivers detach NIXLF without freeing MCAM + * entries, check and free the MCAM entries explicitly to avoid leak. + * Since LF is detached use LF number as -1. + */ + rvu_npc_free_mcam_entries(rvu, pcifunc, -1); + mutex_unlock(&rvu->flr_lock); } --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -1096,6 +1096,9 @@ static void npc_enadis_default_entries(s void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf) { + if (nixlf < 0) + return; + npc_enadis_default_entries(rvu, pcifunc, nixlf, false); /* Delete multicast and promisc MCAM entries */ @@ -1107,6 +1110,9 @@ void rvu_npc_disable_default_entries(str void rvu_npc_enable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf) { + if (nixlf < 0) + return; + /* Enables only broadcast match entry. Promisc/Allmulti are enabled * in set_rx_mode mbox handler. */