Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp699658pxb; Sun, 10 Oct 2021 09:01:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD1Bk1VpE56x4FZPw6Pwls/c31b7cbmzbTcRo3PI9yucfL/CG67Xa6UfBFVeim697oufY0 X-Received: by 2002:a17:907:767a:: with SMTP id kk26mr19190458ejc.134.1633881687080; Sun, 10 Oct 2021 09:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633881687; cv=none; d=google.com; s=arc-20160816; b=WWyVZ9jY1tIZn/gmvTU29Pe9N7bSvE4gZY8h8oczUjXsAVnVQ2g4ZpanEE5OF0VBcZ clbmNT11nO7TuQksZaGp/fYR3vn99HSUeP/If+W+N3NIg3sRtn5XiIvx9OtzpT+aixVy UKeJJ58Y6rlxihfmHQpks4FcTHOgaEZ/yhPkAgxZq6D38NGTf7dN/UWGzupde20u9F5+ A6PwEBmce12uIFIKfigxj30G2xSVaQzPMfXGajspt6H83ei9YUWp5RmRIOP98lQMQUx5 66XmEPCBoQzLoA0nSSZZbePFnKMvzgM6zFx/b/8NNR0DkKa2O1Fbkg6bB7y2lorf5JV/ iQyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=PI/K7PsfxxYbY/XgO/fjju7daV3XAPCizSGY0UAXD6Y=; b=ErgcrJcseFtM7Kq674NI+9pPFg4XBeUDPPiKQ4dC5j3h2hZ84pSaXqNmsrJm8kA/xp iQ6A8Rm5gmQcsEx2viQGrvmo83uHZ27Hn+GUWqKcyo9mASpfjznt1k6oicZh9szkkAp3 8Yo+GaYdSKR4WlzvUVaXCvViUMTxy/b3PGj10fjdL7LN6qBb8w92XVgZPxTHmMBbFCzb 1pEUswl5Uspd6G6Pv/qnQ6wJruoC1ibbnKnXy2dMk9lQPGcrgtfxF2VGioSaN6xN/4sz p6+KplXMD9ZdBV7O9lSDDLsjxseuiv3EYXwjywnTibSQf5ac+sSC5/wfYJg207WbCR7Z /v/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk4si7167160ejb.8.2021.10.10.09.00.47; Sun, 10 Oct 2021 09:01:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbhJJQCo (ORCPT + 99 others); Sun, 10 Oct 2021 12:02:44 -0400 Received: from mx22.baidu.com ([220.181.50.185]:52118 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231842AbhJJQCn (ORCPT ); Sun, 10 Oct 2021 12:02:43 -0400 Received: from BC-Mail-Ex23.internal.baidu.com (unknown [172.31.51.17]) by Forcepoint Email with ESMTPS id ED7DB433CF7D7CA2F05B; Mon, 11 Oct 2021 00:00:37 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex23.internal.baidu.com (172.31.51.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Mon, 11 Oct 2021 00:00:37 +0800 Received: from localhost.localdomain (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 11 Oct 2021 00:00:37 +0800 From: Cai Huoqing To: CC: Boris Brezillon , Arnaud Ebalard , Srujana Challa , Herbert Xu , "David S. Miller" , , Subject: [PATCH] crypto: octeontx2 - Use dma_alloc_coherent() instead of kzalloc/dma_map_single() Date: Mon, 11 Oct 2021 00:00:04 +0800 Message-ID: <20211010160010.435-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex13.internal.baidu.com (172.31.51.53) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replacing kzalloc/kfree/dma_map_single/dma_unmap_single() with dma_alloc_coherent/dma_free_coherent() helps to reduce code size, and simplify the code, and coherent DMA will not clear the cache every time. Signed-off-by: Cai Huoqing --- drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c index dff34b3ec09e..60d62ce049a6 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c @@ -1449,18 +1449,11 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf) compl_rlen = ALIGN(sizeof(union otx2_cpt_res_s), OTX2_CPT_DMA_MINALIGN); len = compl_rlen + LOADFVC_RLEN; - result = kzalloc(len, GFP_KERNEL); + result = dma_alloc_coherent(&pdev->dev, len, &rptr_baddr, GFP_KERNEL); if (!result) { ret = -ENOMEM; goto lf_cleanup; } - rptr_baddr = dma_map_single(&pdev->dev, (void *)result, len, - DMA_BIDIRECTIONAL); - if (dma_mapping_error(&pdev->dev, rptr_baddr)) { - dev_err(&pdev->dev, "DMA mapping failed\n"); - ret = -EFAULT; - goto free_result; - } rptr = (u8 *)result + compl_rlen; /* Fill in the command */ @@ -1489,11 +1482,9 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf) cptpf->eng_caps[etype].u = be64_to_cpup(rptr); } - dma_unmap_single(&pdev->dev, rptr_baddr, len, DMA_BIDIRECTIONAL); + dma_free_coherent(&pdev->dev, len, (void *)result, rptr_baddr); cptpf->is_eng_caps_discovered = true; -free_result: - kfree(result); lf_cleanup: otx2_cptlf_shutdown(&cptpf->lfs); delete_grps: -- 2.25.1