From patchwork Sun Jul 10 12:12:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 589229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72500CCA479 for ; Sun, 10 Jul 2022 12:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229528AbiGJMM7 (ORCPT ); Sun, 10 Jul 2022 08:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiGJMM6 (ORCPT ); Sun, 10 Jul 2022 08:12:58 -0400 Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E69713D48 for ; Sun, 10 Jul 2022 05:12:57 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id AVnvoW3X8V0xUAVnwoV0dy; Sun, 10 Jul 2022 14:12:55 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 10 Jul 2022 14:12:55 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Boris Brezillon , Arnaud Ebalard , Srujana Challa , Herbert Xu , "David S. Miller" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-crypto@vger.kernel.org Subject: [PATCH 1/3] crypto: marvell/octeontx: Simplify bitmap declaration Date: Sun, 10 Jul 2022 14:12:50 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 'OTX_CPT_ENGS_BITMASK_LEN' is only used to allocate a bitmap. This macro only works because OTX_CPT_MAX_ENGINES is 64. BITS_TO_LONGS() should be used to compute the correct size. In order to simplify the code, remove OTX_CPT_ENGS_BITMASK_LEN and use DECLARE_BITMAP to declare the 'bits' bitmap. Signed-off-by: Christophe JAILLET --- drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h index 8620ac87a447..e7e9d1a9a0db 100644 --- a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h +++ b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.h @@ -39,8 +39,6 @@ /* Maximum number of supported engines/cores on OcteonTX 83XX platform */ #define OTX_CPT_MAX_ENGINES 64 -#define OTX_CPT_ENGS_BITMASK_LEN (OTX_CPT_MAX_ENGINES/(BITS_PER_BYTE * \ - sizeof(unsigned long))) /* Microcode types */ enum otx_cpt_ucode_type { @@ -54,7 +52,7 @@ enum otx_cpt_ucode_type { }; struct otx_cpt_bitmap { - unsigned long bits[OTX_CPT_ENGS_BITMASK_LEN]; + DECLARE_BITMAP(bits, OTX_CPT_MAX_ENGINES); int size; }; From patchwork Sun Jul 10 12:19:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 589227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B65AC43334 for ; Sun, 10 Jul 2022 12:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiGJMTd (ORCPT ); Sun, 10 Jul 2022 08:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbiGJMTb (ORCPT ); Sun, 10 Jul 2022 08:19:31 -0400 Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C927EE3A for ; Sun, 10 Jul 2022 05:19:28 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id AVuGokWd9dl7zAVuGohTTG; Sun, 10 Jul 2022 14:19:27 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 10 Jul 2022 14:19:27 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Boris Brezillon , Arnaud Ebalard , Srujana Challa , Herbert Xu , "David S. Miller" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-crypto@vger.kernel.org Subject: [PATCH 2/3] crypto: octeontx2: Use the bitmap API to allocate bitmaps Date: Sun, 10 Jul 2022 14:19:23 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c index f10050fead16..a28a310090e9 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c @@ -1351,7 +1351,7 @@ void otx2_cpt_cleanup_eng_grps(struct pci_dev *pdev, for (i = 0; i < OTX2_CPT_MAX_ENGINE_GROUPS; i++) { grp = &eng_grps->grp[i]; for (j = 0; j < OTX2_CPT_MAX_ETYPES_PER_GRP; j++) { - kfree(grp->engs[j].bmap); + bitmap_free(grp->engs[j].bmap); grp->engs[j].bmap = NULL; } } @@ -1387,9 +1387,8 @@ int otx2_cpt_init_eng_grps(struct pci_dev *pdev, grp->idx = i; for (j = 0; j < OTX2_CPT_MAX_ETYPES_PER_GRP; j++) { - grp->engs[j].bmap = - kcalloc(BITS_TO_LONGS(eng_grps->engs_num), - sizeof(long), GFP_KERNEL); + grp->engs[j].bmap = bitmap_zalloc(eng_grps->engs_num, + GFP_KERNEL); if (!grp->engs[j].bmap) { ret = -ENOMEM; goto cleanup_eng_grps; From patchwork Sun Jul 10 12:13:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 589228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E43CC43334 for ; Sun, 10 Jul 2022 12:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbiGJMNU (ORCPT ); Sun, 10 Jul 2022 08:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbiGJMNS (ORCPT ); Sun, 10 Jul 2022 08:13:18 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E32F13D76 for ; Sun, 10 Jul 2022 05:13:17 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id AVoHoPKXWP8ApAVoHoYufd; Sun, 10 Jul 2022 14:13:15 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 10 Jul 2022 14:13:15 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Boris Brezillon , Arnaud Ebalard , Srujana Challa , Herbert Xu , "David S. Miller" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-crypto@vger.kernel.org Subject: [PATCH 3/3] crypto: marvell/octeontx: Avoid some useless memory initialization Date: Sun, 10 Jul 2022 14:13:11 +0200 Message-Id: <4bf1a510b8c21297ac3261c2b291b1833dc7ac5c.1657455082.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In cpt_detach_and_disable_cores(), 'bmap' is initialized just a few lines below, so there is no need to initialize it when it is declared. In eng_grp_update_masks(), 'tmp_bmap' is zero'ed at each iteration in the first 'for' loop. Signed-off-by: Christophe JAILLET --- drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c index 407e1a3ae841..45d1c9902cf5 100644 --- a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c @@ -204,7 +204,7 @@ static int cpt_detach_and_disable_cores(struct otx_cpt_eng_grp_info *eng_grp, void *obj) { struct otx_cpt_device *cpt = (struct otx_cpt_device *) obj; - struct otx_cpt_bitmap bmap = { {0} }; + struct otx_cpt_bitmap bmap; int timeout = 10; int i, busy; u64 reg; @@ -1056,7 +1056,7 @@ static int eng_grp_update_masks(struct device *dev, struct otx_cpt_eng_grp_info *eng_grp) { struct otx_cpt_engs_rsvd *engs, *mirrored_engs; - struct otx_cpt_bitmap tmp_bmap = { {0} }; + struct otx_cpt_bitmap tmp_bmap; int i, j, cnt, max_cnt; int bit;