From patchwork Tue Jan 14 13:59:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A095DC33CB1 for ; Tue, 14 Jan 2020 14:00:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75FF12467A for ; Tue, 14 Jan 2020 14:00:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vf0d1GFb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729145AbgANOAd (ORCPT ); Tue, 14 Jan 2020 09:00:33 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37401 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728909AbgANN7y (ORCPT ); Tue, 14 Jan 2020 08:59:54 -0500 Received: by mail-wr1-f65.google.com with SMTP id w15so12304724wru.4; Tue, 14 Jan 2020 05:59:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vXhhnXKXoxYSpa1+LXBS7VNs2uspXwnX5jIhIQmwFrM=; b=vf0d1GFbo08+NG6G7zxZJeTZMiLIJ81itsHNzneSbCkxlMw9PSK/5EefhFcFVz9UQt opn2DFmB99e8fxSV8zDeioxOunCEPA1JwLFUV1JZ7tohx4yS9VeIx8szZELtTSaUVi8e MpWVfqUzXzlqC8OzVcKJK0ejjOuekOA7kfio69OKQHzwuuBCoSSJilnH5swyZxmwDZJF tN3p1UTmeFTOKAHtBkIz5KeyE9Q4FZuzTOg9R23HG9C9cgjdnkGH0O/sF2p6DB0IkmgJ U5ZD/0/mbzXaXbqd6FkEoMNCPZqXCdUeNLQe5nz7k+II0heYxnrX1j0mMKgnkq6aGLYT cx4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vXhhnXKXoxYSpa1+LXBS7VNs2uspXwnX5jIhIQmwFrM=; b=Oy7B2bqjPKt3JraVLq+uRzyqxAQ+oq1+bZQRKVEb9acahUDnzYz6RYg0EahBGWJC54 XF70JortqoD97HwErlkrFyPa1MsByZvV/YiscIxclzu1wUBV7vgCOib0EmUlpB/lB+YC Rwlmjuad+RxWwJYv4RNQzWU1EVQqAaWDxN0YH1wrsQ3HdSERoOvFdW4wdNeF6pW+P4eQ geC62V7fs6qg4iJw0tgBG1n5YIwk16WrmKLmWFpJZ/V50sBTiUorDtUTLUoFvnVZvPqB 9WDwceEDDJiJB8CK6tVKKkKlfZDPARo0lYeJda4GinAEy1/rCKN62s8rzU7wcOFvyrsi ixsw== X-Gm-Message-State: APjAAAUCBWmJx19grPHAOvID7IXwC5JqNXR8kEznfFcMxAhcAB/nnNVo 3wnixloHzpZJLBDEDxIDD0c= X-Google-Smtp-Source: APXvYqzIL5QDAbPSLYL8aOpzAthE16eu5faMIOdeePz7IfOOcLviaBT2dTkTsFRl6NklQxS0c9Fjhw== X-Received: by 2002:a5d:6703:: with SMTP id o3mr26238015wru.235.1579010392992; Tue, 14 Jan 2020 05:59:52 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id 4sm17854448wmg.22.2020.01.14.05.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:52 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, davem@davemloft.net, herbert@gondor.apana.org.au, mcoquelin.stm32@gmail.com, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com, horia.geanta@nxp.com, aymen.sghaier@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH RFC 02/10] crypto: sun8i-ce: increase task list size Date: Tue, 14 Jan 2020 14:59:28 +0100 Message-Id: <20200114135936.32422-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114135936.32422-1-clabbe.montjoie@gmail.com> References: <20200114135936.32422-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The CE can handle more than 1 task at once, so this patch increase the size of the task list up to 8. For the moment I did not see more gain beyong this value. Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 4 ++-- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index f72346a44e69..e8bf7bf31061 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -321,7 +321,7 @@ static void sun8i_ce_free_chanlist(struct sun8i_ce_dev *ce, int i) while (i >= 0) { crypto_engine_exit(ce->chanlist[i].engine); if (ce->chanlist[i].tl) - dma_free_coherent(ce->dev, sizeof(struct ce_task), + dma_free_coherent(ce->dev, sizeof(struct ce_task) * MAXTASK, ce->chanlist[i].tl, ce->chanlist[i].t_phy); i--; @@ -356,7 +356,7 @@ static int sun8i_ce_allocate_chanlist(struct sun8i_ce_dev *ce) goto error_engine; } ce->chanlist[i].tl = dma_alloc_coherent(ce->dev, - sizeof(struct ce_task), + sizeof(struct ce_task) * MAXTASK, &ce->chanlist[i].t_phy, GFP_KERNEL); if (!ce->chanlist[i].tl) { diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 49507ef2ec63..049b3175d755 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -73,6 +73,7 @@ #define CE_MAX_CLOCKS 3 #define MAXFLOW 4 +#define MAXTASK 8 /* * struct ce_clock - Describe clocks used by sun8i-ce From patchwork Tue Jan 14 13:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7D61C33CB1 for ; Tue, 14 Jan 2020 14:00:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92FE32467A for ; Tue, 14 Jan 2020 14:00:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oSFvsfR/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728951AbgANN76 (ORCPT ); Tue, 14 Jan 2020 08:59:58 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40020 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbgANN75 (ORCPT ); Tue, 14 Jan 2020 08:59:57 -0500 Received: by mail-wr1-f67.google.com with SMTP id c14so12269688wrn.7; Tue, 14 Jan 2020 05:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t9FT5fa3SeoozrvYAEFmKmMXN/EPpMMGGoi0s6SDiyU=; b=oSFvsfR/LJOKaCs8d7wwS3haZMNmt9yVMFgpfRLn2shhRClhS1eumasQBeBg6P1WIf EWgofZKZ2JeBcfnsbgwg2NzMLRh51ivNtRUwOJW5KHOmEb5a1zY3ZLh7jB1lN/iQkEVH 8orzTRi/8f+jnRtzLhxEZ4LNftMcmaYCD/dS5lilG/OXNQTF/Y4HA/6SLS28Hm2wEkWj 6fCqEzadKadEgcFW04TPWTSsKtux74+cwwT871kCJy/rbMhsI9r25HBcMql4Kpuxwr7v 7r8ADb/enBtLFwrKWsyo7av1/mrgvaLqZgWDFUYTv21H25VfZyQYqmy8ykMObOCJtWpC Gysg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t9FT5fa3SeoozrvYAEFmKmMXN/EPpMMGGoi0s6SDiyU=; b=Rcq0WHjquQ1hf+tcidjdXegnBGivq005jo0yGqWVGIH69cogNhM9PUnzIJfqIr4dON ueaWvth8kaGY8qnF69dAe2bOTu8iUwAODP7+UfXgFZY6jxAfsCYCMR/SL7fCfm/zAF9m 9ycmkzI2VU3J/TRQK/NcZI6OhdxJ85cXhLtEPtm0s1E7Bgt6EQTeYVU1j4pmzWKQXvWu XPM8svbMLk/CFYBavZL9WnKWItx0G/670JuQzrUZ9EFJ1G2mlI1copeonfsZRa8cXVr1 EeumgjKI0PZ+ay7Zs5aoY3uIWPmDMGTqWZokSk0dqRPxP+SECpS5tyv+B8shqZhGBFut 5hMQ== X-Gm-Message-State: APjAAAUDDSPMoUZwe/VKNBdfvIII8B6RYb2cdSs9FMCva+b0vK6n1isv 1DRQ5PO5DDaj2FMLynbu7yY= X-Google-Smtp-Source: APXvYqxeoPOewBzfM1WWeAN9PbUvz883FCNn39JDjsvf/kr7lRyYmTOjgl6pRX5IxaOrrboo+lb4yw== X-Received: by 2002:a5d:494f:: with SMTP id r15mr26124939wrs.143.1579010394666; Tue, 14 Jan 2020 05:59:54 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id 4sm17854448wmg.22.2020.01.14.05.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:54 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, davem@davemloft.net, herbert@gondor.apana.org.au, mcoquelin.stm32@gmail.com, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com, horia.geanta@nxp.com, aymen.sghaier@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH RFC 03/10] crypto: sun8i-ce: split into prepare/run/unprepare Date: Tue, 14 Jan 2020 14:59:29 +0100 Message-Id: <20200114135936.32422-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114135936.32422-1-clabbe.montjoie@gmail.com> References: <20200114135936.32422-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch split the do_one_request into three. Prepare will handle all DMA mapping and initialisation of the task structure. Unprepare will clean all DMA mapping. And the do_one_request will be limited to just excuting the task. Signed-off-by: Corentin Labbe --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 70 ++++++++++++++++--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 4 ++ 2 files changed, 66 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 6108cea0e0bd..401f39f144ea 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -78,8 +78,9 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request *areq) return err; } -static int sun8i_ce_cipher(struct skcipher_request *areq) +static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req) { + struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); struct sun8i_ce_dev *ce = op->ce; @@ -237,7 +238,9 @@ static int sun8i_ce_cipher(struct skcipher_request *areq) } chan->timeout = areq->cryptlen; - err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(areq->base.tfm)); + rctx->nr_sgs = nr_sgs; + rctx->nr_sgd = nr_sgd; + return 0; theend_sgs: if (areq->src == areq->dst) { @@ -271,13 +274,64 @@ static int sun8i_ce_cipher(struct skcipher_request *areq) return err; } -static int sun8i_ce_handle_cipher_request(struct crypto_engine *engine, void *areq) +int sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq) { - int err; struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(breq); + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_ce_dev *ce = op->ce; + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(breq); + int flow, err; - err = sun8i_ce_cipher(breq); + flow = rctx->flow; + err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(breq->base.tfm)); crypto_finalize_skcipher_request(engine, breq, err); + return 0; +} + +static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_req) +{ + struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_ce_dev *ce = op->ce; + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + struct sun8i_ce_flow *chan; + struct ce_task *cet; + unsigned int ivsize, offset; + int nr_sgs = rctx->nr_sgs; + int nr_sgd = rctx->nr_sgd; + int flow; + + flow = rctx->flow; + chan = &ce->chanlist[flow]; + cet = chan->tl; + ivsize = crypto_skcipher_ivsize(tfm); + + if (areq->src == areq->dst) { + dma_unmap_sg(ce->dev, areq->src, nr_sgs, 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); + } + + if (areq->iv && ivsize > 0) { + if (cet->t_iv) + dma_unmap_single(ce->dev, cet->t_iv, rctx->ivlen, + DMA_TO_DEVICE); + offset = areq->cryptlen - ivsize; + if (rctx->op_dir & CE_DECRYPTION) { + memcpy(areq->iv, rctx->backup_iv, ivsize); + kzfree(rctx->backup_iv); + } else { + scatterwalk_map_and_copy(areq->iv, areq->dst, offset, + ivsize, 0); + } + kfree(rctx->bounce_iv); + } + + dma_unmap_single(ce->dev, cet->t_key, op->keylen, DMA_TO_DEVICE); return 0; } @@ -347,9 +401,9 @@ int sun8i_ce_cipher_init(struct crypto_tfm *tfm) crypto_tfm_alg_driver_name(&sktfm->base), crypto_tfm_alg_driver_name(crypto_skcipher_tfm(&op->fallback_tfm->base))); - op->enginectx.op.do_one_request = sun8i_ce_handle_cipher_request; - op->enginectx.op.prepare_request = NULL; - op->enginectx.op.unprepare_request = NULL; + op->enginectx.op.do_one_request = sun8i_ce_cipher_run; + op->enginectx.op.prepare_request = sun8i_ce_cipher_prepare; + op->enginectx.op.unprepare_request = sun8i_ce_cipher_unprepare; err = pm_runtime_get_sync(op->ce->dev); if (err < 0) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 049b3175d755..2d3325a13bf1 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -183,6 +183,8 @@ struct sun8i_ce_dev { * @backup_iv: buffer which contain the next IV to store * @bounce_iv: buffer which contain a copy of IV * @ivlen: size of bounce_iv + * @nr_sgs: The number of source SG (as given by dma_map_sg()) + * @nr_sgd: The number of destination SG (as given by dma_map_sg()) */ struct sun8i_cipher_req_ctx { u32 op_dir; @@ -190,6 +192,8 @@ struct sun8i_cipher_req_ctx { void *backup_iv; void *bounce_iv; unsigned int ivlen; + int nr_sgs; + int nr_sgd; }; /* From patchwork Tue Jan 14 13:59:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E265C33CB1 for ; Tue, 14 Jan 2020 14:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 535162468C for ; Tue, 14 Jan 2020 14:00:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LRbl4YL7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728984AbgANOAB (ORCPT ); Tue, 14 Jan 2020 09:00:01 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50650 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbgANOAA (ORCPT ); Tue, 14 Jan 2020 09:00:00 -0500 Received: by mail-wm1-f65.google.com with SMTP id a5so13907447wmb.0; Tue, 14 Jan 2020 05:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vwz74GVw3RqN4zv8KJzc6WOhikJUNutjS1yfSHb85f4=; b=LRbl4YL7xfmzQ1ubfonhUq+riBVo7Eyg2CecNwz5sXvOhYgCzzU5f4KizEPmiziF4m D5jqMuwxJGXYuIgRLNfSlIMO+OvP0h0nyl6yQNA07t23ws19poi5JoP44FXZMMfT1blT T3g1hisBu9zecBZnslMBQqKKbPPRXL+YE/DWuBrcGUUkV79ew8rqEstIc7XJNGwgFxr4 3iIX6iHzJCNHtV57Fr2N1q7nvQvfgoyA65gMyrBolpyP0gZSZgu2GCp/UZhTJaZcRuV4 BIIJ1IGwfAmSGYq+Sz31qndyOjB9icWSWIwv2nO1LrhDw0SIB1FsPcGfwJW5AK9eqv2g ZHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vwz74GVw3RqN4zv8KJzc6WOhikJUNutjS1yfSHb85f4=; b=FZmYRyq4dSOP4Pew2XLld+wIGyj8cupiT39jiPeni65BU4zB+dKOiVwbTO22ozJNoW X/ni2S3K2mLfD9UxqVGpnVrsNQgak3lOMbUvJ3w+XT0OY3w1Kvdqq6wyILt1dCEHbXd2 rkELsKTJr20XDFzQclJPXeyr6NxviRjlQAALX5JHYRAcJBMg3O3Se7YAqQ99AQjS9CJl 6NiCWueeN86MOyKomvBetadYtzPrHTl6PcrbAecevJE0FKebXi1QmLVhFhCNWaDOyf2l TWnRj2Qyb1sFeWtMDxCUwg04IfOY9SD5H1J54sCHcIlkJlO3uLdIfYrOFsN9bbc5z7NK rOtA== X-Gm-Message-State: APjAAAWZDXusv0+DTTiJ/nQjnNRyldca6FUSbqVCQ3IEIUvUfr8dz9ml 4gtBgk8GfOdS6v5T7RVOI24= X-Google-Smtp-Source: APXvYqy5IpziUXqSl8mzGqH49R4MKas13Mk/3/YX/GN9HtlxDzqVTADoOUc6wXiGyyxKvj7oJv29NA== X-Received: by 2002:a1c:9c87:: with SMTP id f129mr26421503wme.26.1579010399002; Tue, 14 Jan 2020 05:59:59 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id 4sm17854448wmg.22.2020.01.14.05.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:58 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, davem@davemloft.net, herbert@gondor.apana.org.au, mcoquelin.stm32@gmail.com, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com, horia.geanta@nxp.com, aymen.sghaier@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH RFC 06/10] crypto: engine: introduce ct Date: Tue, 14 Jan 2020 14:59:32 +0100 Message-Id: <20200114135936.32422-7-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114135936.32422-1-clabbe.montjoie@gmail.com> References: <20200114135936.32422-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org We will store the number of request in a batch in engine->ct. This patch adds all loop to unprepare all requests of a batch. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 30 ++++++++++++++++++------------ include/crypto/engine.h | 2 ++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index b72873550587..591dea5ddeec 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -28,6 +28,7 @@ static void crypto_finalize_request(struct crypto_engine *engine, bool finalize_cur_req = false; int ret; struct crypto_engine_ctx *enginectx; + int i = 0; spin_lock_irqsave(&engine->queue_lock, flags); if (engine->cur_reqs[0].req == req) @@ -35,17 +36,20 @@ static void crypto_finalize_request(struct crypto_engine *engine, spin_unlock_irqrestore(&engine->queue_lock, flags); if (finalize_cur_req) { - enginectx = crypto_tfm_ctx(engine->cur_reqs[0].req->tfm); - if (engine->cur_reqs[0].prepared && - enginectx->op.unprepare_request) { - ret = enginectx->op.unprepare_request(engine, engine->cur_reqs[0].req); - if (ret) - dev_err(engine->dev, "failed to unprepare request\n"); - } - engine->cur_reqs[0].req->complete(engine->cur_reqs[0].req, err); + do { + enginectx = crypto_tfm_ctx(engine->cur_reqs[i].req->tfm); + if (engine->cur_reqs[i].prepared && + enginectx->op.unprepare_request) { + ret = enginectx->op.unprepare_request(engine, engine->cur_reqs[i].req); + if (ret) + dev_err(engine->dev, "failed to unprepare request\n"); + } + engine->cur_reqs[i].prepared = false; + engine->cur_reqs[i].req->complete(engine->cur_reqs[i].req, err); + } while (++i < engine->ct); spin_lock_irqsave(&engine->queue_lock, flags); - engine->cur_reqs[0].prepared = false; - engine->cur_reqs[0].req = NULL; + while (engine->ct-- > 0) + engine->cur_reqs[engine->ct].req = NULL; spin_unlock_irqrestore(&engine->queue_lock, flags); } else { req->complete(req, err); @@ -109,13 +113,14 @@ static void crypto_pump_requests(struct crypto_engine *engine, goto out; } + engine->ct = 0; /* Get the fist request from the engine queue to handle */ backlog = crypto_get_backlog(&engine->queue); async_req = crypto_dequeue_request(&engine->queue); if (!async_req) goto out; - engine->cur_reqs[0].req = async_req; + engine->cur_reqs[engine->ct].req = async_req; if (backlog) backlog->complete(backlog, -EINPROGRESS); @@ -144,8 +149,9 @@ static void crypto_pump_requests(struct crypto_engine *engine, ret); goto req_err; } - engine->cur_reqs[0].prepared = true; + engine->cur_reqs[engine->ct].prepared = true; } + engine->ct++; if (!enginectx->op.do_one_request) { dev_err(engine->dev, "failed to do request\n"); ret = -EINVAL; diff --git a/include/crypto/engine.h b/include/crypto/engine.h index 362134e226f4..021136a47b93 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -50,6 +50,7 @@ struct cur_req { * @priv_data: the engine private data * @rmax: The number of request which can be processed in one batch * @cur_reqs: A list for requests to be processed + * @ct: How many requests will be handled in one batch */ struct crypto_engine { char name[ENGINE_NAME_LEN]; @@ -73,6 +74,7 @@ struct crypto_engine { void *priv_data; int rmax; struct cur_req *cur_reqs; + int ct; }; /* From patchwork Tue Jan 14 13:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A5EFC33CB2 for ; Tue, 14 Jan 2020 14:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E09BD24685 for ; Tue, 14 Jan 2020 14:00:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IZGzjrkK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbgANOAD (ORCPT ); Tue, 14 Jan 2020 09:00:03 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39330 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgANOAC (ORCPT ); Tue, 14 Jan 2020 09:00:02 -0500 Received: by mail-wm1-f67.google.com with SMTP id 20so13832894wmj.4; Tue, 14 Jan 2020 06:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+qS8cmFG129sXx7XLwvT27GqZEqHpjOOs5rdHnFSHiU=; b=IZGzjrkKewPPH+1qPChWS+BhLPaglsstZcFbIFMqVrWlnEyYo4D//EwlO073t5dWRt wsEUkhhhPmT8ar86gm41TZiFZdKhJ2hH3xwEbn3ADew+ZParRG4n8k5o10jGL1LVRUU2 BrBFsb3E1LCR5wy9kjfteNYmsmUS3a6zFMW85ywB2QE/McqEpFsR6LhS7Q4jCZc/iMUv PlIJAqPajK75h7F0rRdhNWoe63r2OhG9YYn/0wMxi/hX/wkIBchGVH/aHmOKmpMenkfJ zmjXb4+u1GtLTbLFq3gs2YUvR/hG+0pZd1Z57g5j0ZHtScUCIuDBo32GjFTElntjiR5m nDvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+qS8cmFG129sXx7XLwvT27GqZEqHpjOOs5rdHnFSHiU=; b=q11OWSEesovI4m+PrmHb30wvYAYC7nz1KzpRnOcRUZF9W1C9JDl+iXyHmW0WHxIwGu FXz0+2x4dJS6vAXqQ5aKfwaxO48MTKFw5fUceINWEHp0zX9/dZlopz/AorZLIPzAsGVY 108kCqdTt7S9jlFfDXkbikTpxHyDV4vCCi3avci8wEzWFyHVLrWR4UWNpMNlA9UWUcB8 N2kJmXTDqxNeiOQB41sAPtI6yeniLrjCZ4loK0N5IFtBRF1jV+De9Gc/vGAJOz4U1RJY eqnm6/DBmwwlwN645flm4wJKgspUtwyY4IPtRFgVGWZZQkjQ07AEg8XLWPDwBSBFOh8p NBtw== X-Gm-Message-State: APjAAAVFM5pMxiuHUGsiE8nOu/TQe7i+oMDmXnAqOCpPbr8+UK6dTw7j 25pQMgIwqsM6fgJJWpfOq4E= X-Google-Smtp-Source: APXvYqww13Rw2lNgkQnVrqZqhVvYRprXFy6sm0G6g1K6ZSDEAxdwdk/Iiwdc3bXXKo2jLD2F6nJdKg== X-Received: by 2002:a1c:a702:: with SMTP id q2mr27788126wme.6.1579010400417; Tue, 14 Jan 2020 06:00:00 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id 4sm17854448wmg.22.2020.01.14.05.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:59 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, davem@davemloft.net, herbert@gondor.apana.org.au, mcoquelin.stm32@gmail.com, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com, horia.geanta@nxp.com, aymen.sghaier@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH RFC 07/10] crypto: sun8i-ce: handle slot > 0 Date: Tue, 14 Jan 2020 14:59:33 +0100 Message-Id: <20200114135936.32422-8-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114135936.32422-1-clabbe.montjoie@gmail.com> References: <20200114135936.32422-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Handle the fact a slot could be different than 0. This imply: - linking two task via next - set interrupt flag just before running the batch in the last task. Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 8 +++++++- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 9c1f6c9eaaf9..d56c992fbf93 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -99,6 +99,9 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req int slot = 0; int err = 0; + if (slot < 0 || slot >= MAXTASK) + return -EINVAL; + algt = container_of(alg, struct sun8i_ce_alg_template, alg.skcipher); dev_dbg(ce->dev, "%s %s %u %x IV(%p %u) key=%u\n", __func__, @@ -120,8 +123,11 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req cet->t_id = cpu_to_le32(flow); common = ce->variant->alg_cipher[algt->ce_algo_id]; - common |= rctx->op_dir | CE_COMM_INT; + common |= rctx->op_dir; cet->t_common_ctl = cpu_to_le32(common); + if (slot > 0) + chan->tl[slot - 1].next = cpu_to_le32(chan->t_phy + 176 * slot); + /* CTS and recent CE (H6) need length in bytes, in word otherwise */ if (ce->variant->has_t_dlen_in_bytes) cet->t_dlen = cpu_to_le32(areq->cryptlen); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index bd355f4b95f3..39bf684c0ff5 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -106,6 +106,8 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG ce->chanlist[flow].stat_req++; #endif + /* mark last one */ + ce->chanlist[flow].tl[ce->chanlist[flow].engine->ct - 1].t_common_ctl |= cpu_to_le32(CE_COMM_INT); mutex_lock(&ce->mlock); From patchwork Tue Jan 14 13:59:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A92BC33CB3 for ; Tue, 14 Jan 2020 14:00:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40DEB24679 for ; Tue, 14 Jan 2020 14:00:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YwKwklKF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbgANOAM (ORCPT ); Tue, 14 Jan 2020 09:00:12 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54628 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729040AbgANOAH (ORCPT ); Tue, 14 Jan 2020 09:00:07 -0500 Received: by mail-wm1-f65.google.com with SMTP id b19so13872899wmj.4; Tue, 14 Jan 2020 06:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mmCo0cmcYxTYUl0HTh9b5uPHQjBF+Ornrl4fpC6nIuw=; b=YwKwklKFwVrhQTbq9+emPqf95apR1314k05ofi1R4X4ecmLMYVeTbhUyQp8rc6JOOE 1OtSdz22N7qTe1XPnouOPYwL70jWyR9WzmlK2ZXg2p4vGpwHbn4BMRc+jo0MBgwO6T0l kwj1Qo0YWV0mSI6WuIA9JmgmgulgXFJC/X0mzv2VstuVM/XkmTbkjnaL13iIDmY92It8 5oNt9CMr3GzgOVZqxWqargG03QKjOuUSUMJbmcmPXGbcmT0gddtiaVxm7R4gWVDD353H OJ5ZNctjqERrdhzXqK1zFZdA3CDKpvZ79XSCt2HQ6upbF63gIHwk+/f4B7j0TroYbesC L5Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mmCo0cmcYxTYUl0HTh9b5uPHQjBF+Ornrl4fpC6nIuw=; b=rcIHleI73aIPMfFTkCUOdiB4s/Di6/J114pp92+lkbFvqF7JcYF2ekbKFO7xnLsp2l uywubl83JiupnTTu/BnxsB7UgGHEU//5PfYw1QMWiQTbEBauMABOI6HYz2VGb603VbKh 1EugfIiCNkzXwvxv6GQXSSLQCwU0PkOMslPkUPzl5LqDDJJzLXZed0ATVdqyNOAQcT0a pPwFNv27r/KUPXWLpY3xG54AhdoM3g364wYQIAbFrShC+LQ9Gph0N+E4emAa78p3oEyk NjD7LUZgEQJLGUebYh1rXIVtadh72+CE77MSzcuQMkB70j9iQ+RsqDufs/nTMlZZ0yTt TNMQ== X-Gm-Message-State: APjAAAV5xiXdxrUJsuCQg8SN5CD1Un/n4EUs+dp661ZOcabNI9lJoUqY GrINbq9f0mK6BIV8DHWuRNg= X-Google-Smtp-Source: APXvYqxIi99Bpxvcwct69pL122PlCYsc6pFqFmQLsPv1kKKkDRC+0KM4vq6kSF3tJBiUx5oECNcNKw== X-Received: by 2002:a7b:c389:: with SMTP id s9mr27249334wmj.7.1579010405396; Tue, 14 Jan 2020 06:00:05 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id 4sm17854448wmg.22.2020.01.14.06.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 06:00:04 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, davem@davemloft.net, herbert@gondor.apana.org.au, mcoquelin.stm32@gmail.com, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com, horia.geanta@nxp.com, aymen.sghaier@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH RFC 10/10] crypto: sun8i-ce: use the new batch mechanism Date: Tue, 14 Jan 2020 14:59:36 +0100 Message-Id: <20200114135936.32422-11-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114135936.32422-1-clabbe.montjoie@gmail.com> References: <20200114135936.32422-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Now all infrastructure to batch request are in place, it is time to use it. Introduce some debug for it also. Signed-off-by: Corentin Labbe --- .../crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 14 ++++++++------ drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 9 ++++++--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 41d18c18d1d1..fe5374788304 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -103,20 +103,22 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req algt = container_of(alg, struct sun8i_ce_alg_template, alg.skcipher); - dev_dbg(ce->dev, "%s %s %u %x IV(%p %u) key=%u\n", __func__, + dev_dbg(ce->dev, "%s %s %u %x IV(%p %u) key=%u slot=%d\n", __func__, crypto_tfm_alg_name(areq->base.tfm), areq->cryptlen, rctx->op_dir, areq->iv, crypto_skcipher_ivsize(tfm), - op->keylen); - -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - algt->stat_req++; -#endif + op->keylen, slot); flow = rctx->flow; chan = &ce->chanlist[flow]; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + algt->stat_req++; + if (chan->engine->ct + 1 > chan->tmax) + chan->tmax = chan->engine->ct + 1; +#endif + cet = &chan->tl[slot]; memset(cet, 0, sizeof(struct ce_task)); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index 39bf684c0ff5..7cd98c227357 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -104,7 +104,7 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) int err = 0; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - ce->chanlist[flow].stat_req++; + ce->chanlist[flow].stat_req += ce->chanlist[flow].engine->ct; #endif /* mark last one */ ce->chanlist[flow].tl[ce->chanlist[flow].engine->ct - 1].t_common_ctl |= cpu_to_le32(CE_COMM_INT); @@ -287,7 +287,10 @@ static int sun8i_ce_dbgfs_read(struct seq_file *seq, void *v) int i; for (i = 0; i < MAXFLOW; i++) - seq_printf(seq, "Channel %d: nreq %lu\n", i, ce->chanlist[i].stat_req); + seq_printf(seq, "Channel %d: nreq %lu tmax %d eqlen=%d/%d\n", i, + ce->chanlist[i].stat_req, ce->chanlist[i].tmax, + ce->chanlist[i].engine->queue.qlen, + ce->chanlist[i].engine->queue.max_qlen); for (i = 0; i < ARRAY_SIZE(ce_algs); i++) { if (!ce_algs[i].ce) @@ -345,7 +348,7 @@ static int sun8i_ce_allocate_chanlist(struct sun8i_ce_dev *ce) for (i = 0; i < MAXFLOW; i++) { init_completion(&ce->chanlist[i].complete); - ce->chanlist[i].engine = crypto_engine_alloc_init(ce->dev, true); + ce->chanlist[i].engine = crypto_engine_alloc_init2(ce->dev, true, MAXTASK, MAXTASK * 2); if (!ce->chanlist[i].engine) { dev_err(ce->dev, "Cannot allocate engine\n"); i--; diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 2d3325a13bf1..22bb15fea476 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -135,6 +135,7 @@ struct ce_task { * @t_phy: Physical address of task * @tl: pointer to the current ce_task for this flow * @stat_req: number of request done by this flow + * @tmax: The maximum number of tasks done in one batch */ struct sun8i_ce_flow { struct crypto_engine *engine; @@ -145,6 +146,7 @@ struct sun8i_ce_flow { struct ce_task *tl; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG unsigned long stat_req; + int tmax; #endif };