Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2055168pxb; Mon, 11 Oct 2021 20:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwstbT1K6apPJRs24RlGcvn61Gg0hoMf0675g74hfq9s07JoAS6k2nqhkwbu9SQ7AN08BbQ X-Received: by 2002:a63:5d5f:: with SMTP id o31mr21185266pgm.312.1634009044034; Mon, 11 Oct 2021 20:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634009044; cv=none; d=google.com; s=arc-20160816; b=QfH5Zdac+tNIYfWUEXHNRI7yp3bemZgRO6EfG0FnA9pZ/n+DQ2rwvmFy0VkOzjo9hh uGu5Gu1+/jyuQDCpvKEx0bju0jZ+cDkgu5PCCPLazcbE955vcCalSKTdew3WSOUDpHZZ /uELP83OyRPih7kfrRZSisON5h4mfMwQ1nbnrMwihncwVjvr8w9FiXREcI0JOXFqGrs3 B3qk0qeEp2heZJtju+oIoUOklHJuzpwYwvlxgeWxNXjqXKFnBajw9Gec6/JP2HCBfIcp 9QXcK6o0ROxWb0xvLa6XhHk+gfq/sksjwhl8bU82GABNVFpezKMhn/EutN4uXAVzfAhd hERg== 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=OPc2dtZYYOMd/ALgzeTbblYmF7HIjl4epZJXYj7dbO4=; b=Qe5+3/cOKE4kmHwauqyYwUlLvLRCCoP4GOitclfV+37sPGkjsXY4XbnCxFwRf2otpS JXmsR+Xc5FS6UekSCa6boqjgyErOdM+fYr+lpp0pMAkNZ2kZ5bsCWrXWubz1GyEmawnD gt9qlnpB/6CEcC/vKBe/ymHBqVFmVEMOCCoxKYpI1SdOnkX85/ajImv7/Q4V4L2zaO9Z sAz89uEibyGk9dvGQbWv/XjUT17gWd5Lk9yIgWyMnLsBgqE/0eCgpVoIqXow6RbJNzlV eTXHkIcRstdAn6/UjrhBJea9r3WKBiHMFIjTWR+13LAr39uv42cXLXnYMvn1pAb3WXNK HNFA== 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 k3si15217912pfu.66.2021.10.11.20.23.35; Mon, 11 Oct 2021 20:24:04 -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 S232248AbhJLDYo (ORCPT + 99 others); Mon, 11 Oct 2021 23:24:44 -0400 Received: from mx22.baidu.com ([220.181.50.185]:37648 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232281AbhJLDYl (ORCPT ); Mon, 11 Oct 2021 23:24:41 -0400 Received: from BC-Mail-Ex14.internal.baidu.com (unknown [172.31.51.54]) by Forcepoint Email with ESMTPS id 3BF78C342203DDB486CD; Tue, 12 Oct 2021 11:22:36 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex14.internal.baidu.com (172.31.51.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Tue, 12 Oct 2021 11:22:36 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (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; Tue, 12 Oct 2021 11:22:35 +0800 From: Cai Huoqing To: CC: Cai Huoqing , Boris Brezillon , Arnaud Ebalard , Srujana Challa , Herbert Xu , "David S. Miller" , , Subject: [PATCH v2] crypto: octeontx2 - Use dma_alloc_noncoherent() instead of kzalloc/dma_map_single() Date: Tue, 12 Oct 2021 11:22:28 +0800 Message-ID: <20211012032229.2307-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-Ex12.internal.baidu.com (172.31.51.52) 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_noncoherent/dma_free_noncoherent() helps to reduce code size, and simplify the code, and the hardware can keep DMA coherent itself. Signed-off-by: Cai Huoqing --- v1->v2: *Change to dma_alloc/free_noncoherent from dma_alloc/free_coherent. *Update changelog. 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..f023a02ee2b5 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_noncoherent(&pdev->dev, len, &rptr_baddr, DMA_BIDIRECTIONAL, 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_noncoherent(&pdev->dev, len, (void *)result, rptr_baddr, DMA_BIDIRECTIONAL); cptpf->is_eng_caps_discovered = true; -free_result: - kfree(result); lf_cleanup: otx2_cptlf_shutdown(&cptpf->lfs); delete_grps: -- 2.25.1