Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp272305pxb; Mon, 8 Feb 2021 23:06:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyM3CJLr//g2M3vWBLjTUrj0g0vf/tOuMMi8cQTJm5g8XtKbPNv+83st1xrOVCudVitnT6M X-Received: by 2002:a05:6402:190a:: with SMTP id e10mr21332359edz.110.1612854388739; Mon, 08 Feb 2021 23:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612854388; cv=none; d=google.com; s=arc-20160816; b=zlKmQv2bFoSlzuuJW/sPzFW/cQtTeFequntuVoblLb0BY+gMFNyfE1vggYIKFfYYWH KuoPayJrs8xhoAL66sRQVeVoW7L9GwJWiOxshM7nz3UZyYDHdKFeU7SY70uRDu865wkH KBOcAax/8qMw7KONT30p7OHf4pK8M+qEJ9laE4c1l7hDFTM/hghR7+diZHhaS8PvCO8h 7yq09h5EBb0PQTMyVk1PaqE6LcrW+1vIPDdQhahUcY31A4Y4bAUsM9w9LO5jFGAL5IvV 06zJntDbn1awYAZ1bwQ2fLJPIGc6V1KFT97w3hcAGUmZB92p3nL60cF2qUQZH1h1sVXj E0Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Eush5gzlyLczV7MKamUi55LT36ggeQZk6eaTN5Lqp+s=; b=ynQ0GiaeiwC+DtEpsvUPSpetvRlBvKJ5jnGdozAlYQgnkDQoboZh/j0AUwVr4yaqY1 HY9/92GFnK5cWmDM0hALHex1ZBTP4MDP1xg6tx5HsOFC46SPSYyyb/B51d0P75OYoXrN ljy/yoLD2OzJ50Sx/V1/j1e8JOqiUIxn5BNZVhCOICHfBRUT356EX0VHY4qCkgT99Kl0 4waUX16KWEKYzqzdKsGga++xm3oWjtPceSVJUaNUWcqwJyAwiUJNed7+T1vU8aZs+CZ1 GyIrkxIEuPaBaBrO2Q0Ywnu51i2gdNZHgTj09yUs65OSPvuPpbwsm8u2c0nLA6qppde6 fMNA== 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 k23si2329162ejq.693.2021.02.08.23.06.03; Mon, 08 Feb 2021 23:06:28 -0800 (PST) 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 S229464AbhBIHEe (ORCPT + 99 others); Tue, 9 Feb 2021 02:04:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11717 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhBIHEd (ORCPT ); Tue, 9 Feb 2021 02:04:33 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DZYjT32zPzlHyd; Tue, 9 Feb 2021 15:02:05 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 9 Feb 2021 15:03:31 +0800 From: chenxiang To: , , , , CC: , , , Xiang Chen Subject: [PATCH 4/4] crypto: allwinner - Fix the parameter of dma_unmap_sg() Date: Tue, 9 Feb 2021 14:59:25 +0800 Message-ID: <1612853965-67777-5-git-send-email-chenxiang66@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1612853965-67777-1-git-send-email-chenxiang66@hisilicon.com> References: <1612853965-67777-1-git-send-email-chenxiang66@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Xiang Chen For function dma_unmap_sg(), the parameter should be number of elements in the scatterlist prior to the mapping, not after the mapping. So fix this usage. Signed-off-by: Xiang Chen --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 9 ++++++--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 3 ++- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 9 ++++++--- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 33707a2..54ae8d1 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -240,11 +240,14 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req theend_sgs: if (areq->src == areq->dst) { - dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL); + dma_unmap_sg(ce->dev, areq->src, sg_nents(areq->src), + DMA_BIDIRECTIONAL); } else { if (nr_sgs > 0) - dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_TO_DEVICE); - dma_unmap_sg(ce->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE); + dma_unmap_sg(ce->dev, areq->src, sg_nents(areq->src), + DMA_TO_DEVICE); + dma_unmap_sg(ce->dev, areq->dst, sg_nents(areq->dst), + DMA_FROM_DEVICE); } theend_iv: diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 2f09a37..8819471 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -405,7 +405,8 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(areq->base.tfm)); dma_unmap_single(ce->dev, addr_pad, j * 4, DMA_TO_DEVICE); - dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_TO_DEVICE); + dma_unmap_sg(ce->dev, areq->src, sg_nents(areq->src), + DMA_TO_DEVICE); dma_unmap_single(ce->dev, addr_res, digestsize, DMA_FROM_DEVICE); diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c index ed2a69f..f945750 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c @@ -232,10 +232,13 @@ static int sun8i_ss_cipher(struct skcipher_request *areq) theend_sgs: if (areq->src == areq->dst) { - dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL); + dma_unmap_sg(ss->dev, areq->src, sg_nents(areq->src), + DMA_BIDIRECTIONAL); } else { - dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_TO_DEVICE); - dma_unmap_sg(ss->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE); + dma_unmap_sg(ss->dev, areq->src, sg_nents(areq->src), + DMA_TO_DEVICE); + dma_unmap_sg(ss->dev, areq->dst, sg_nents(areq->dst), + DMA_FROM_DEVICE); } theend_iv: diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c index 11cbcbc..55c06c3a 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c @@ -432,7 +432,8 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) err = sun8i_ss_run_hash_task(ss, rctx, crypto_tfm_alg_name(areq->base.tfm)); dma_unmap_single(ss->dev, addr_pad, j * 4, DMA_TO_DEVICE); - dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_TO_DEVICE); + dma_unmap_sg(ss->dev, areq->src, sg_nents(areq->src), + DMA_TO_DEVICE); dma_unmap_single(ss->dev, addr_res, digestsize, DMA_FROM_DEVICE); kfree(pad); -- 2.8.1