From patchwork Tue Feb 6 02:40:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ratheesh Kannoth X-Patchwork-Id: 197146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1282308dyb; Mon, 5 Feb 2024 18:41:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHh41EelTjit7WJeggWoa9bSjOhkeeOUY2CjdbCRkdb3KWFXCm/wTKjMK5aY6EmQ2moVU2r X-Received: by 2002:a17:90a:ce94:b0:296:3779:813c with SMTP id g20-20020a17090ace9400b002963779813cmr1116123pju.4.1707187271092; Mon, 05 Feb 2024 18:41:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707187271; cv=pass; d=google.com; s=arc-20160816; b=qz7HXhqxe3VOrw4RPSEzNPAxy9DMTl48jv0XnXJ5IIXrGVKt/58gZbE2t9NKvujPSL Zq88BjtZvliARk6STSrhnNvEsjU2rCI3k9xU7/HXEDBzMnbXJ2ldqK8qQcCF9WwEWTPp n07MXXCUyk7VcCEU0LfnGejrdOIlKZS/FTkR2ap+JI4D9nO3Bp7VlzYhsmwwUiUQvpm/ rE3RaTXdaij8TDNo0QGQI1xJnnYpDkYRZbNcasVyqbQV+PeWMnOtaBxhQhKtah5LbJbP eJetq0m/Ov7In8Ebwi7zyqpvVKuccSI/CsoQKbybSmqDYA1ZWIq0m1H8/kt79GnJtslV GHAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Xnfjto22NaZBakIjy0kZNG1xU7eVaZSmtkgjvrHY/Ec=; fh=pVo4zbILjThnplKvTxLUN7km9VlzB5OVcv8ePmDXgZI=; b=SqDjTkOcOlPQMdVP9B6Wyb8fb+KYKtDSSx2mrjnX+HYiilkRZ3M8jP2oHYLr7cm7ys 31QpmTIZITHJdHMhOh41Y/Pm2vh0B+lTtYwgBgn8GdccmMmXUdpqpgKTNqdpgh4xvSmp /ZK2d/d+zFkchcP2zJLAW70kedOaYX7xkz85NNG4RKEgKeUXzkB80Gb6JLDXYUogywOn XqQqAEjK4umcDRy2HqDbwC+4IH1dsb+xNWL3ps1WglcX4QHX/h8P8TGJDB/YLboz4nBO HHhMQ8BAd3waz4mhfJa/5C0CzvbIaxqL/JEX5sRij188eIfGayl8SFyC5Hgx2FrH0Rdh q0iQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=gECEq9Bn; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-54210-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54210-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com X-Forwarded-Encrypted: i=1; AJvYcCWdr2nAGBWM8oejD145ZUOvdlDUk3GaxRR2h5ODKcmFfBkjktmWlQzHHdRd66qd+RQ/m4q+PXcDhqJWUiZuU9FsOokYcA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q9-20020a17090aa00900b002964f6f750fsi292895pjp.153.2024.02.05.18.41.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 18:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54210-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=gECEq9Bn; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-54210-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54210-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DB03DB224BE for ; Tue, 6 Feb 2024 02:41:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7127F6EB6A; Tue, 6 Feb 2024 02:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="gECEq9Bn" Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBC6A6E2A8; Tue, 6 Feb 2024 02:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707187230; cv=none; b=n9XSe3WqGhx5gK2GyZEbZNCc9iw3419PC1U7iuPpKmtFVR3gJ7eKL+5guXayM18pZwASOWh/fg4F7ckvt7jvN2TlrNrYKzg84v3clFvvE5oz2IFWikyu0nquFMQ+HmCd0D3Ik1p0CxK4PHQOPTn2JDHg519ZphSzy6pXtwoSh04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707187230; c=relaxed/simple; bh=554/SMyrxITigOVehx3nyTUdAXmq86rzKbc8ZsI5Dpg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=CnNA6R6p3+gV2i3cjSawuLiNGt7o66wTOcg1mRbrHeq/3L/PewEhBcgjz/czGQQoGmw174eTQLkTyqGGX3iyKkZ9D0M5zt8uaHtK+O5a2sRIFj9OYRMrLOtFkFL1BsCKCM3vms3NVzX5cm4Xq9QDFH75IKWXpy/tIEs+FJZin9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=gECEq9Bn; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 415Mxdb4024639; Mon, 5 Feb 2024 18:40:08 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=pfpt0220; bh=Xnfjto22 NaZBakIjy0kZNG1xU7eVaZSmtkgjvrHY/Ec=; b=gECEq9Bnk4Ft5wSEdn26AigP ZGcZdgT9zqLxBE+FW4icUPeddAf52CY13BBl5gT4QDipDyG6twmfMaVg46hv8og1 wDsy9DxhKX9FnnLm4ceaxe4pzYDulrNsDpFhN4wJ9L2ZUQAgvokACw0Wrhj4jf38 PWmchr7bQpildET00Ph20jS3a1gPTN4/MNExB1jvsZpJPu36DX8mfTGFN53a5BkK DNITet7TOT5M/ditRggehBDMC+GakpV76VQevmHEUEMNmXluc2+tohWh3PV5aIUL VlpYcDrP5PyneU1qF336XsebLwXKwMRZkvZKJdSz9RqvBmjQzg3JJd5XbKRHIg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3w38y4gmqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 18:40:08 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 5 Feb 2024 18:40:06 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 5 Feb 2024 18:40:06 -0800 Received: from marvell-OptiPlex-7090.marvell.com (unknown [10.28.36.165]) by maili.marvell.com (Postfix) with ESMTP id BDF2D3F70B3; Mon, 5 Feb 2024 18:40:02 -0800 (PST) From: Ratheesh Kannoth To: , CC: , , , , , , , , , , , Ratheesh Kannoth Subject: [PATCH net v4] octeontx2-af: Initialize maps. Date: Tue, 6 Feb 2024 08:10:00 +0530 Message-ID: <20240206024000.1070260-1-rkannoth@marvell.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: HKkFmmPIHyiAJKcqDH49cUZHRlm6p-ny X-Proofpoint-GUID: HKkFmmPIHyiAJKcqDH49cUZHRlm6p-ny X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_18,2024-01-31_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790115599810042709 X-GMAIL-MSGID: 1790115599810042709 kmalloc_array() without __GFP_ZERO flag does not initialize memory to zero. This causes issues. Use kcalloc() for maps and bitmap_zalloc() for bitmaps. Fixes: dd7842878633 ("octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs") Signed-off-by: Ratheesh Kannoth Reviewed-by: Brett Creeley Reviewed-by: Simon Horman --- ChangeLogs: v3 -> v4: Used kcalloc() for normal maps v2 -> v3: Used GFP_ZERO for normal map arrays v1 -> v2: Used bitmap_zalloc() API. v0 -> v1: Removed devm_kcalloc()._ --- --- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c index 167145bdcb75..8cfd74ad991c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -1850,8 +1850,8 @@ void npc_mcam_rsrcs_deinit(struct rvu *rvu) { struct npc_mcam *mcam = &rvu->hw->mcam; - kfree(mcam->bmap); - kfree(mcam->bmap_reverse); + bitmap_free(mcam->bmap); + bitmap_free(mcam->bmap_reverse); kfree(mcam->entry2pfvf_map); kfree(mcam->cntr2pfvf_map); kfree(mcam->entry2cntr_map); @@ -1904,21 +1904,20 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) mcam->pf_offset = mcam->nixlf_offset + nixlf_count; /* Allocate bitmaps for managing MCAM entries */ - mcam->bmap = kmalloc_array(BITS_TO_LONGS(mcam->bmap_entries), - sizeof(long), GFP_KERNEL); + mcam->bmap = bitmap_zalloc(mcam->bmap_entries, GFP_KERNEL); if (!mcam->bmap) return -ENOMEM; - mcam->bmap_reverse = kmalloc_array(BITS_TO_LONGS(mcam->bmap_entries), - sizeof(long), GFP_KERNEL); + mcam->bmap_reverse = bitmap_zalloc(mcam->bmap_entries, GFP_KERNEL); if (!mcam->bmap_reverse) goto free_bmap; mcam->bmap_fcnt = mcam->bmap_entries; /* Alloc memory for saving entry to RVU PFFUNC allocation mapping */ - mcam->entry2pfvf_map = kmalloc_array(mcam->bmap_entries, - sizeof(u16), GFP_KERNEL); + mcam->entry2pfvf_map = kcalloc(mcam->bmap_entries, sizeof(u16), + GFP_KERNEL); + if (!mcam->entry2pfvf_map) goto free_bmap_reverse; @@ -1941,21 +1940,21 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) if (err) goto free_entry_map; - mcam->cntr2pfvf_map = kmalloc_array(mcam->counters.max, - sizeof(u16), GFP_KERNEL); + mcam->cntr2pfvf_map = kcalloc(mcam->counters.max, sizeof(u16), + GFP_KERNEL); if (!mcam->cntr2pfvf_map) goto free_cntr_bmap; /* Alloc memory for MCAM entry to counter mapping and for tracking * counter's reference count. */ - mcam->entry2cntr_map = kmalloc_array(mcam->bmap_entries, - sizeof(u16), GFP_KERNEL); + mcam->entry2cntr_map = kcalloc(mcam->bmap_entries, sizeof(u16), + GFP_KERNEL); if (!mcam->entry2cntr_map) goto free_cntr_map; - mcam->cntr_refcnt = kmalloc_array(mcam->counters.max, - sizeof(u16), GFP_KERNEL); + mcam->cntr_refcnt = kcalloc(mcam->counters.max, sizeof(u16), + GFP_KERNEL); if (!mcam->cntr_refcnt) goto free_entry_cntr_map; @@ -1988,9 +1987,9 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) free_entry_map: kfree(mcam->entry2pfvf_map); free_bmap_reverse: - kfree(mcam->bmap_reverse); + bitmap_free(mcam->bmap_reverse); free_bmap: - kfree(mcam->bmap); + bitmap_free(mcam->bmap); return -ENOMEM; }