From patchwork Mon Nov 20 23:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13462278 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="Ibb6NuDz" Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F6FC3 for ; Mon, 20 Nov 2023 15:44:38 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-41feb963f60so41924611cf.1 for ; Mon, 20 Nov 2023 15:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1700523877; x=1701128677; 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=FHM+sryUZM0YAe3w2WUaneVLgkyeK6T8H2Goa73kBR4=; b=Ibb6NuDzyaTwttHmPAYX6r3KSmov1sc3SV1tKutwrUqLdt9+2Z/rLanFKAgpxpoIIf X+pBleygHCpPGdcaduHnCIz+KbRtRWqFcl8r28SXAl8tXXM96nZb2F/lNKeLMPVD3VTR XKzj2eaRPe86RODsVz3oaYNTf+NMC+DCSFlgk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700523877; x=1701128677; 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=FHM+sryUZM0YAe3w2WUaneVLgkyeK6T8H2Goa73kBR4=; b=FDmxhMtTHRxa9GXBnRXs8pxm+9w+WpYTAlKi2woApwVCZZx8wcOpvfPQ2p2GpHFYSE qlz/aLiWQ89jNW4CX6uaV+aeGn+kSwp4803b+gEAFrmFUc940977nmRagsTMoRt4sG1T YdDGHof9TsUDZgqte73y3lYoLk8TL+RTqLKGk93nX08koCfWTl7lOx0uUYazIJCgY5Aw /N64f/eZVUSZD590eFSWHejz9SQR+KossRaoFUlfYsMVKbvMYe3OIk6pr0HAhfsi2IGv XX0I3tXOasGXho8FNvnVCY4fdo2z3ObrwGuugdboSzAEiRkU4cJPkPYcFD4ujcbVEEig LnkQ== X-Gm-Message-State: AOJu0YynxclAvVSRBMml4kGSLW7rvnTZ48Z6FV9BsSQ4Wo9fjs9OL1Kv FRuc8aZrUGbyo/YiH2x27H/IPy1HfTbHzBbBXps= X-Google-Smtp-Source: AGHT+IFHdoEWyyi1oZI1F7yEp0ccJo3oxEjINof+rcIQTNvEiRA0ilKZfULD4sRKLq/cT24m+QmVtw== X-Received: by 2002:a05:622a:15c2:b0:417:af0a:70a0 with SMTP id d2-20020a05622a15c200b00417af0a70a0mr1726341qty.14.1700523877056; Mon, 20 Nov 2023 15:44:37 -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.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 15:44:36 -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, Pavan Chebbi , Somnath Kotur Subject: [PATCH net-next 01/13] bnxt_en: The caller of bnxt_alloc_ctx_mem() should always free bp->ctx Date: Mon, 20 Nov 2023 15:43:53 -0800 Message-Id: <20231120234405.194542-2-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 bnxt_alloc_ctx_mem() calls bnxt_hwrm_func_backing_store_qcaps() to allocate the memory for bp->ctx. Initialize bp->ctx with the allocated memory and let the caller free it during unwind. The unwind logic is already there, we just need to always set bp->ctx to the allocated memory so the caller will always free it. This simplifies the logic and makes it easier to expand on the backing store logic. Reviewed-by: Pavan Chebbi Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e6ac1bd21bb3..6b19d5b8d95a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7233,6 +7233,8 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp) rc = -ENOMEM; goto ctx_err; } + bp->ctx = ctx; + ctx->qp_max_entries = le32_to_cpu(resp->qp_max_entries); ctx->qp_min_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); ctx->qp_max_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); @@ -7276,13 +7278,11 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp) tqm_rings = ctx->tqm_fp_rings_count + BNXT_MAX_TQM_SP_RINGS; ctx_pg = kcalloc(tqm_rings, sizeof(*ctx_pg), GFP_KERNEL); if (!ctx_pg) { - kfree(ctx); rc = -ENOMEM; goto ctx_err; } for (i = 0; i < tqm_rings; i++, ctx_pg++) ctx->tqm_mem[i] = ctx_pg; - bp->ctx = ctx; } else { rc = 0; }