From patchwork Mon Nov 20 23:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13462279 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="K/8VRauR" Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CEFCC7 for ; Mon, 20 Nov 2023 15:44:39 -0800 (PST) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-42033328ad0so29939321cf.0 for ; Mon, 20 Nov 2023 15:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1700523878; x=1701128678; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=atj0wcg9XYQePoheikbPi9EKAIZzEF9jPNFTWltqhrY=; b=K/8VRauRGnvpKAovrzK5PWyQJLz7GorhsdgPnc3kjTvuFojMF7b5mMmFkDmZRnNR2U kwu+dkHfgEv9P6NZkclDdV9gruHwwj1t4o5yffDBT4K+IevJ2uQmiFk18kl0/zgAIqA/ wfmYh5doVR0YR23PzcscXuRgl/ggEEJDBkxOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700523878; x=1701128678; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=atj0wcg9XYQePoheikbPi9EKAIZzEF9jPNFTWltqhrY=; b=ZOph2JqOt8kao0BYBA7eUhECQmebVjBolRVbi6lrrsLT694YHYrYXju6n4Yw4xSBxf GVebX1bwYbPdMMMhuNLPjy1+252Jqwf4QQYM+BKLosYtTyz9N0L78//idwAeNOzdfzR2 1RYsjZZOcpA96RX8J3vDCFZ+aa4iyW7N4ndPwoXqnTCPnsTeQhlci5RVQ2GIhZ2/128W 5bw08+DuARnyN2wTJgcIFvkL0jukjjCvlqt0KZJzBowtgfulj9aXpRFtAvry6Ex8ltwb haaPsiVzK3g96MrB/5SdOqje1go7mBf4HiPBUylxxm/udJj/wTzD3mK5i0ASSiHWbeCH u1rg== X-Gm-Message-State: AOJu0YxnuIyuHJXHhWvGa7zHbI07gSwkMjO5tl5PHN9NfGUZAp9IkM9l iGoHaX35leS3X6Yfu7/JGZT7TA== X-Google-Smtp-Source: AGHT+IHlT+BNCYyJ3G1giaXbfyf3KH+fE7GUOntzEBLAU3l021t0YOBEVDN72auwvP3ySc1Yjynd7A== X-Received: by 2002:a05:622a:50b:b0:418:15ab:85b8 with SMTP id l11-20020a05622a050b00b0041815ab85b8mr10844638qtx.13.1700523878329; Mon, 20 Nov 2023 15:44:38 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id i9-20020ac871c9000000b0041803dfb240sm3053384qtp.45.2023.11.20.15.44.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 15:44:38 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Somnath Kotur Subject: [PATCH net-next 02/13] bnxt_en: Free bp->ctx inside bnxt_free_ctx_mem() Date: Mon, 20 Nov 2023 15:43:54 -0800 Message-Id: <20231120234405.194542-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231120234405.194542-1-michael.chan@broadcom.com> References: <20231120234405.194542-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org We always free bp->ctx right after calling bnxt_free_ctx_mem(), so just free it at the end of that function to make things simpler. Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 14 ++------------ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 2 -- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6b19d5b8d95a..8ff21768e592 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7552,6 +7552,8 @@ void bnxt_free_ctx_mem(struct bnxt *bp) bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem); bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem); ctx->flags &= ~BNXT_CTX_FLAG_INITED; + kfree(ctx); + bp->ctx = NULL; } static int bnxt_alloc_ctx_mem(struct bnxt *bp) @@ -10321,8 +10323,6 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) bnxt_ulp_stop(bp); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; bnxt_dcb_free(bp); rc = bnxt_fw_init_one(bp); if (rc) { @@ -11948,8 +11948,6 @@ static void bnxt_fw_reset_close(struct bnxt *bp) if (pci_is_enabled(bp->pdev)) pci_disable_device(bp->pdev); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; } static bool is_bnxt_fw_ok(struct bnxt *bp) @@ -13368,8 +13366,6 @@ static void bnxt_remove_one(struct pci_dev *pdev) bp->fw_health = NULL; bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; kfree(bp->rss_indir_tbl); bp->rss_indir_tbl = NULL; bnxt_free_port_stats(bp); @@ -13969,8 +13965,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->fw_health = NULL; bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; kfree(bp->rss_indir_tbl); bp->rss_indir_tbl = NULL; @@ -14023,8 +14017,6 @@ static int bnxt_suspend(struct device *device) bnxt_hwrm_func_drv_unrgtr(bp); pci_disable_device(bp->pdev); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; rtnl_unlock(); return rc; } @@ -14121,8 +14113,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, if (pci_is_enabled(pdev)) pci_disable_device(pdev); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; rtnl_unlock(); /* Request a slot slot reset. */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index f302dac56599..10b842539b08 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -469,8 +469,6 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, } bnxt_cancel_reservations(bp, false); bnxt_free_ctx_mem(bp); - kfree(bp->ctx); - bp->ctx = NULL; break; } case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: {