From patchwork Wed Jan 22 10:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198184 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 D0092C2D0DB for ; Wed, 22 Jan 2020 10:46:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A586E2465B for ; Wed, 22 Jan 2020 10:46:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gY97jhBx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729592AbgAVKpm (ORCPT ); Wed, 22 Jan 2020 05:45:42 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36348 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729578AbgAVKpm (ORCPT ); Wed, 22 Jan 2020 05:45:42 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so6746551wru.3; Wed, 22 Jan 2020 02:45:41 -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=lo8LLHFbuM7TeGYDeTlQoBN8WOd2hUEZekUpabEc1mM=; b=gY97jhBxzfGaSoSJe/9DJBRMWHpcwm2pHDbhJbZ5+5w49H5BCpCkqHYZwE1vo8tDnt bpNKVku2NGfETc/ThU4Sf5qw6sbYIP7ndKZm7JEw3KE3mY14jO1zcipE/+V6fIkB+Zc3 t0z4/Th/wP+oUvshpss+455rUZGXGelGdf/W++RDJoqlmIwGmLjYRgE3V48yyng4q5z8 NwZYiLZ/LFp91vIAWzQvCLPji0AZjRVfXKWoUdQgOsCy41402wg0mwK3AHWpNyWfzgt3 8xPncSZ5Zzc337KUWJC/dwoeVjEWa548Zs872YwKEh9NIB7yjGbA83TfhohB5xzkK7M4 F6Gw== 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=lo8LLHFbuM7TeGYDeTlQoBN8WOd2hUEZekUpabEc1mM=; b=MRJpBvHrJh43J6X0H0yDoy1nTblSqvi7o4fQrPbfPkN5w0HCFCLCpg7nc+ggsEfD6Q RUrWV6qeOZPCNKfZeXbcQyPVhaSw6m7BxcLHbosZ0STaMw0dHSd8A0vdMTBUkU+tJAKL Y4qnXicRUStavgivWHiQktF0YWOtOTYKyn1LzczCSbFmS16t+CMGCADUcSEN/CQPGgjn C2ckzfBfUrbnvxAeqilkhSlEdRYjOgfr3OPkKDocP9LRhfXhdktZI/m2+Y9qFyatZQBS hIpkVy5+1BOFQdPCnc6kh0JnHbBR0asZuQPO+Gv4TMCacxVT9U7WGhwZpu0lqw4eUdZQ EbJA== X-Gm-Message-State: APjAAAWKMKwYo9IIUBFot2x39Iug5RxM5JNDVZYiN/C31s/tt/qwdO88 /Kzf6U00elF0IdELiD9U5qQ= X-Google-Smtp-Source: APXvYqylHdDo0Ce4Pl3PZywawsbwSz1/WCPI8gnceqoCrzqzmRYGpJyEyygKdIwwAlHY5ZOO24nm3A== X-Received: by 2002:a5d:49c7:: with SMTP id t7mr10174792wrs.369.1579689940777; Wed, 22 Jan 2020 02:45:40 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:40 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 1/9] crypto: engine: workqueue can only be processed one by one Date: Wed, 22 Jan 2020 11:45:20 +0100 Message-Id: <20200122104528.30084-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-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 Some bykeshedding are unnecessary since a workqueue can only be executed one by one. This behaviour is documented in: - kernel/kthread.c: comment of kthread_worker_fn() - Documentation/core-api/workqueue.rst: the functions associated with the work items one after the other Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 13 ------------- include/crypto/engine.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index eb029ff1e05a..feb0d82dd454 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -73,16 +73,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, spin_lock_irqsave(&engine->queue_lock, flags); - /* Make sure we are not already running a request */ - if (engine->cur_req) - goto out; - - /* If another context is idling then defer */ - if (engine->idling) { - kthread_queue_work(engine->kworker, &engine->pump_requests); - goto out; - } - /* Check if the engine queue is idle */ if (!crypto_queue_len(&engine->queue) || !engine->running) { if (!engine->busy) @@ -96,7 +86,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, } engine->busy = false; - engine->idling = true; spin_unlock_irqrestore(&engine->queue_lock, flags); if (engine->unprepare_crypt_hardware && @@ -104,7 +93,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, dev_err(engine->dev, "failed to unprepare crypt hardware\n"); spin_lock_irqsave(&engine->queue_lock, flags); - engine->idling = false; goto out; } @@ -410,7 +398,6 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) engine->rt = rt; engine->running = false; engine->busy = false; - engine->idling = false; engine->cur_req_prepared = false; engine->priv_data = dev; snprintf(engine->name, sizeof(engine->name), diff --git a/include/crypto/engine.h b/include/crypto/engine.h index e29cd67f93c7..7e7cbd9ca3b5 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -21,7 +21,6 @@ /* * struct crypto_engine - crypto hardware engine * @name: the engine name - * @idling: the engine is entering idle state * @busy: request pump is busy * @running: the engine is on working * @cur_req_prepared: current request is prepared @@ -42,7 +41,6 @@ */ struct crypto_engine { char name[ENGINE_NAME_LEN]; - bool idling; bool busy; bool running; bool cur_req_prepared; From patchwork Wed Jan 22 10:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198186 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 D7D5EC2D0DB for ; Wed, 22 Jan 2020 10:46:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADA8F2468C for ; Wed, 22 Jan 2020 10:46:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="atOCu/d8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729191AbgAVKqS (ORCPT ); Wed, 22 Jan 2020 05:46:18 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54947 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729624AbgAVKpp (ORCPT ); Wed, 22 Jan 2020 05:45:45 -0500 Received: by mail-wm1-f67.google.com with SMTP id b19so6279438wmj.4; Wed, 22 Jan 2020 02:45:44 -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=XyFi4QUbF6No7tCrbJhCVZ5TjcE02iPJvNCt7IcZqnw=; b=atOCu/d8xHcTs6Q9DCR4yOoCncsmGvFRwn3VBq48XEuBvYixBWtSdK1x3JaE3OU9OC ODxVylq8Tytjegvo1QsONKr8O8Ky3aMD+tJg0xp4PCXlYb+KbzMgFeN6dhsHfp1BGMI/ 4KEEm8ebnJg+6uaVjvk0lQLz3vgTZOc456xdXU8EFacdblCYBkAQVFPUgp24ytbh5qoC vGvFem36xG4b5EgtG3QDmFGRl527x+c3sU0mbL5FukG1lZ4tFDZrvzvsPCaqj14Z+fUe Xgz9D6mrp1jW5sywBLwKC5lO+RWFgtOKK2j2T3VaF4fadactNW6r2jTZT6qd15pEjdmL vMQQ== 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=XyFi4QUbF6No7tCrbJhCVZ5TjcE02iPJvNCt7IcZqnw=; b=iWprySoo+im6AuWHxiFCupWd+/88tWwh6BrH169B/AJNgopOPZU+B8OwpZc1+cFaOF stoeoHu2Wk5FGBuYDd0iABZbDZ6cj7go2eNinsvucguPq4IbEaKiV3YVs1nTmygGszkG kZrfiwRgijMbL1leQ0NiWGtUlSbWR/9HMlnFR9YDCid/4VyAFiELqHi4R+gV5V3rbWFX xf03H5YevxxKlMNKX5BvmL9cT9D1I9q3JHJcWhxYR4YKQdehMkOPWRU5tM6aYi4Gbowo 08K0cQGynq44NWvsHBgrP+NBePKEOGDTkeZGzDuEbqIaL6hrvznqnO5LntXRKCDVH+hT gaug== X-Gm-Message-State: APjAAAW/xZn2cWhnb932deWRzsp4npDqaum17UvQxVFIgQpI5WJ+DYuE BhrCRAvCAWDsx2Zxu1twOeQ= X-Google-Smtp-Source: APXvYqx85aFHoyjVcQwtyMo+TulGXbL1bKMZfZZMz5sFYzpX97V4AsH6AcMjPZhniYZfPSeIRLYP6Q== X-Received: by 2002:a7b:ce8b:: with SMTP id q11mr2385910wmj.100.1579689943589; Wed, 22 Jan 2020 02:45:43 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:42 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 3/9] crypto: engine: get rid of cur_req Date: Wed, 22 Jan 2020 11:45:22 +0100 Message-Id: <20200122104528.30084-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-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 cur_req was used as a sign of usage of the crypto_engine, now this behaviour has gone, its usage remains for detecting if we finalize the cur_req. But testing if we finalize the cur_req prevent to do more request at a time and is unnecessary. It is unnecessary since crypto_finalize_request() is only used for cryptoengine and so the request finalized will be always the current request. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 25 ++++++------------------- include/crypto/engine.h | 2 -- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index dfcb00e92e09..c21867106aa4 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -24,27 +24,15 @@ static void crypto_finalize_request(struct crypto_engine *engine, struct crypto_async_request *req, int err) { - unsigned long flags; - bool finalize_cur_req = false; int ret; struct crypto_engine_ctx *enginectx; - spin_lock_irqsave(&engine->queue_lock, flags); - if (engine->cur_req == req) - finalize_cur_req = true; - spin_unlock_irqrestore(&engine->queue_lock, flags); - - if (finalize_cur_req) { - enginectx = crypto_tfm_ctx(req->tfm); - if (enginectx->op.prepare_request && - enginectx->op.unprepare_request) { - ret = enginectx->op.unprepare_request(engine, req); - if (ret) - dev_err(engine->dev, "failed to unprepare request\n"); - } - spin_lock_irqsave(&engine->queue_lock, flags); - engine->cur_req = NULL; - spin_unlock_irqrestore(&engine->queue_lock, flags); + enginectx = crypto_tfm_ctx(req->tfm); + if (enginectx->op.prepare_request && + enginectx->op.unprepare_request) { + ret = enginectx->op.unprepare_request(engine, req); + if (ret) + dev_err(engine->dev, "failed to unprepare request\n"); } req->complete(req, err); @@ -101,7 +89,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, if (!async_req) goto out; - engine->cur_req = async_req; if (backlog) backlog->complete(backlog, -EINPROGRESS); diff --git a/include/crypto/engine.h b/include/crypto/engine.h index 4d8a2602c9ed..d77080227beb 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -36,7 +36,6 @@ * @kworker: kthread worker struct for request pump * @pump_requests: work struct for scheduling work to the request pump * @priv_data: the engine private data - * @cur_req: the current request which is on processing */ struct crypto_engine { char name[ENGINE_NAME_LEN]; @@ -57,7 +56,6 @@ struct crypto_engine { struct kthread_work pump_requests; void *priv_data; - struct crypto_async_request *cur_req; }; /* From patchwork Wed Jan 22 10:45:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198188 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 0FAD6C2D0DB for ; Wed, 22 Jan 2020 10:45:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D65E92468A for ; Wed, 22 Jan 2020 10:45:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nr8u3nfY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729664AbgAVKpr (ORCPT ); Wed, 22 Jan 2020 05:45:47 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41831 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729631AbgAVKpr (ORCPT ); Wed, 22 Jan 2020 05:45:47 -0500 Received: by mail-wr1-f66.google.com with SMTP id c9so6699278wrw.8; Wed, 22 Jan 2020 02:45:45 -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=q1c4fMXgRAivI+KIqtp9qKOWY67co/0FrPc2eCYg+90=; b=nr8u3nfYAjPtAAqgYOSmcY7z3j0CmJEacsKmUlaLEU/61bZC071n/wBvVRSqFb857K OgGXGQwDY7DHJImYHGuunm8MMkY7V12amlQB+UxyqzJhkdHTPRioVLHlsU+ufOp0FgRq X6IqpXOf8Fh99IyQsb9U4VwE9TvnHR8txVF9H1KysmQDUCbRxxS1qo/cilQX0gbQw8Vi uBHg1Mk0DGjNKVbVf2FoRcViiKw8KJwChypgsHGnSyvoXbVP8lr7vb+1PVmmsuQLEK4O nJmsWCWeclCL4W2BcmjD2ZhOFAC08n82NXIJYrmNfXoeHq63zbubJ4r7p4AWnk3WyuJI Kt5g== 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=q1c4fMXgRAivI+KIqtp9qKOWY67co/0FrPc2eCYg+90=; b=EJNUQUVcbHMdor3px88m/OP57/K72YbU2Yl8Cu+2HRlJMK4hphKII4peza2hGnjXVy gLbJ3jlgOULnl0sTPupN+wqUiTPvvYc+mKUAAy8VTW35gEVGpDWr3VcVQi1wfEha/9TE YFu5c8zaJKKQykv3gJnf7nWsVPzdgPiqC6/xl1VJoBahdf0ipRhXC1SNFXcCWY+BfsEX zdLMvS3TeIPoXiBDKrD0iY5We+ip1IvUtYaXEiiWg92DgcCg8ZtvUuxvyKW37dOqfnOC oipTTg1WeN3pPvTQky4hrAXBPtXL43QEArtXpx9gTJwU+3E4gjux9EPmW6Qi94iYFBOY mIpA== X-Gm-Message-State: APjAAAV3dAHOdGrNpZgjUeGrDqJncPdtz0EeG4LsDdnjbzZAzTuut1vC Xc2oLMulnsCV7lGKi4aMlQU= X-Google-Smtp-Source: APXvYqwoJEy1uZGesFKgykNXIpCxdh5m24bdAOqtD59KSsP02/GuJsRs39ZlhORaR+RW4F2HEHRhzA== X-Received: by 2002:a5d:4a8c:: with SMTP id o12mr10108920wrq.43.1579689944967; Wed, 22 Jan 2020 02:45:44 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:44 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 4/9] crypto: engine: permit to choose queue length Date: Wed, 22 Jan 2020 11:45:23 +0100 Message-Id: <20200122104528.30084-5-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-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 adds a new function which permit to choose the crypto engine queue length. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 23 ++++++++++++++++++++--- include/crypto/engine.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index c21867106aa4..5bcb1e740fd9 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -365,15 +365,17 @@ int crypto_engine_stop(struct crypto_engine *engine) EXPORT_SYMBOL_GPL(crypto_engine_stop); /** - * crypto_engine_alloc_init - allocate crypto hardware engine structure and + * crypto_engine_alloc_init2 - allocate crypto hardware engine structure and * initialize it. * @dev: the device attached with one hardware engine * @rt: whether this queue is set to run as a realtime task + * @qlen: The size of the crypto queue * * This must be called from context that can sleep. * Return: the crypto engine structure on success, else NULL. */ -struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) +struct crypto_engine *crypto_engine_alloc_init2(struct device *dev, bool rt, + int qlen) { struct sched_param param = { .sched_priority = MAX_RT_PRIO / 2 }; struct crypto_engine *engine; @@ -393,7 +395,7 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) snprintf(engine->name, sizeof(engine->name), "%s-engine", dev_name(dev)); - crypto_init_queue(&engine->queue, CRYPTO_ENGINE_MAX_QLEN); + crypto_init_queue(&engine->queue, qlen); spin_lock_init(&engine->queue_lock); engine->kworker = kthread_create_worker(0, "%s", engine->name); @@ -410,6 +412,21 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) return engine; } +EXPORT_SYMBOL_GPL(crypto_engine_alloc_init2); + +/** + * crypto_engine_alloc_init - allocate crypto hardware engine structure and + * initialize it. + * @dev: the device attached with one hardware engine + * @rt: whether this queue is set to run as a realtime task + * + * This must be called from context that can sleep. + * Return: the crypto engine structure on success, else NULL. + */ +struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) +{ + return crypto_engine_alloc_init2(dev, rt, CRYPTO_ENGINE_MAX_QLEN); +} EXPORT_SYMBOL_GPL(crypto_engine_alloc_init); /** diff --git a/include/crypto/engine.h b/include/crypto/engine.h index d77080227beb..03d9f9ec1cea 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -96,6 +96,8 @@ void crypto_finalize_skcipher_request(struct crypto_engine *engine, int crypto_engine_start(struct crypto_engine *engine); int crypto_engine_stop(struct crypto_engine *engine); struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt); +struct crypto_engine *crypto_engine_alloc_init2(struct device *dev, bool rt, + int qlen); int crypto_engine_exit(struct crypto_engine *engine); #endif /* _CRYPTO_ENGINE_H */ From patchwork Wed Jan 22 10:45:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 198187 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 5F4AFC2D0DB for ; Wed, 22 Jan 2020 10:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35BBA2465B for ; Wed, 22 Jan 2020 10:46:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EykB0ac2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729261AbgAVKqJ (ORCPT ); Wed, 22 Jan 2020 05:46:09 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40701 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729701AbgAVKpv (ORCPT ); Wed, 22 Jan 2020 05:45:51 -0500 Received: by mail-wm1-f66.google.com with SMTP id t14so6629170wmi.5; Wed, 22 Jan 2020 02:45:50 -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=EykB0ac2kjYrYahu/jZIfG6FfpaSNjvW7yVd/WDy3Fs3kS6TW94qvZDp2Z9zG6y7kk P182nzjKGL3aJwP3fYx1VS8CqcqsglP0XtShXtt5mB83h7kB/UbCZwsbp6itjDxeZffB YQgI0AiY2tL/6LwGZDDHn51fT+IL2IyLOtJQbC8iWc60bEqkTi5iz8TYmdwyp2skjvuS J6QJlKUQwoIRUe59EjCf264gffqZjLFpzOEQ2lNaYtjUU9bkehFD0RuPP4ufl7wraoTK 6cIcb4utrANC0cdjxDGPLZ1PkCSHMLDxt7jewacut+G9zXpgQ50ouZwP7IZT5fnbJL5k AUjw== 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=HEF+FN0Poq1tGTAAeqoMyFmrEC7dEr1QFhyDF9pwU3ATFNG/C2Hosuhz2tpry5D7IS ZqznwZxCn6S47AmX3qm+jSpB7+E6EMvpIvLmfynWgWl8nVXV78nR5kjSlV0euozw/Bc/ Ey9wJwsypED8h+w7gOWjPhmTO8C0JK0dHXpuf/yNUDsKtGxS+HVS7TWDf/g9fHNoUJrr Oz1ENaT+UThdBC7WGPQKizMQZujE9QjcI8/PGb6us21NlvHMMEPVH83pqCmnRyJ2cQo0 35RkFXgXqHmKeq8Ph7xRrL9hukV+Y2Nz31JrSTgKxauMAAf+M4jOwRt1d5gQpdE2zrxk 1xSA== X-Gm-Message-State: APjAAAWjEGCX4rrZeEZSKiVvhQdMFAm5lGM3vfaIwyVRVzgd6eE0YLxw unHq0k3dNX5QdNYSiv3obos= X-Google-Smtp-Source: APXvYqxzgTFSZ6oqp6dWOuexRw6nwIAhgLOfYgEFyNAyKcSwm1Rtry4hWg/6bgd0XM2rcSVRYbPuVw== X-Received: by 2002:a1c:5945:: with SMTP id n66mr2249307wmb.98.1579689949561; Wed, 22 Jan 2020 02:45:49 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:48 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 7/9] crypto: sun8i-ce: increase task list size Date: Wed, 22 Jan 2020 11:45:26 +0100 Message-Id: <20200122104528.30084-8-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-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 Wed Jan 22 10:45: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: 198185 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 53DEFC2D0DB for ; Wed, 22 Jan 2020 10:46:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DBD224688 for ; Wed, 22 Jan 2020 10:46:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pHjQAKV6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729878AbgAVKqZ (ORCPT ); Wed, 22 Jan 2020 05:46:25 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34979 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729624AbgAVKqY (ORCPT ); Wed, 22 Jan 2020 05:46:24 -0500 Received: by mail-wr1-f67.google.com with SMTP id g17so6743192wro.2; Wed, 22 Jan 2020 02:46:22 -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=HlVN3+Fqo4CnAsTqD0OmkrdM8WtTRqDQDULyBnPtHug=; b=pHjQAKV6qoTnYiEUG8pxraj4nOM5bni+aQ67wNb2KUb2//W/kbVd+97/KkvsiDvFhU KXfqLc/ykSk0I6tQToqBW5aydEU2S7a5z/ZaqJl4Roqxe9AiFIkwvl5713T/SMxDCs89 zHicB6uVbaRr0/qRVxYiZ4eAl2VabxBEfnuFZow7BlAD5/g8MbRObrb0MYdOm6903zc+ kwYTXGhCbJy/61a+nCJUYJtjXvJFwSNmXt/FpRo7Lb4t7ZpidDNG17axWiCba3nFw3md /P/HBlOYKl5oYmNfqf3u019vsC7R9mbUrN3uRG0Upg7XDFPuVAFOPizJTj5ljKukwAFP 6xkg== 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=HlVN3+Fqo4CnAsTqD0OmkrdM8WtTRqDQDULyBnPtHug=; b=tP5hQcVCsC85SMQQwmkwDu8qYDfzlJg6trgUPg9KBBEQSpAbJVfQXapYKR5vVYj7nn B19oWiQ16Gz9cEX5Std7R071oYMC7KCT7GRhib0tiQU2e66tEKRBudNYNBKW2gsucoGo xZvtsut8H0sMPMoiVwhC2FufMSpmMvoLBh/QprnzALTCfOUgJvA3VDiKWuKiwu14uDkD vwu+M8k9/by1KESoysARV+d/KZBofd1FQcO3TkfPodAGgPfr8V49xSujgyvldgJ6Mcex /9Ni7I3v6/MeoOR2Ol+j7B3U8zhpwnNs9V7nYnpGdPBIp+VLhcmdrm0KRuTE83VfclXq wRbw== X-Gm-Message-State: APjAAAUGkSZr1N0hFDu6iQfBX3ArqlVi0v4MizNrXn1zFKcjoxy1jCcs +UpLoKfkMUBT98lgTJpMQ2Y= X-Google-Smtp-Source: APXvYqxtNeNC1yK6GUuYbu+60bk+pxY4Zl+3F/5+yXvy3VXeniYyMGDE6MOXVSGfQdIi4qEjFVGD7w== X-Received: by 2002:a5d:534d:: with SMTP id t13mr10929059wrv.77.1579689981975; Wed, 22 Jan 2020 02:46:21 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:46:21 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 9/9] crypto: sun8i-ce: permit to batch requests Date: Wed, 22 Jan 2020 11:45:28 +0100 Message-Id: <20200122104528.30084-10-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-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 permit to batch request. This imply: - linking two task via next - set interrupt flag just before running the batch in the last task. - storing all requests for finalizing them later Signed-off-by: Corentin Labbe --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 60 +++++++++++++++---- .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 15 +++-- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 6 ++ 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index fc0a2299c701..832fb4a51da9 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -96,31 +96,38 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req int flow, i; int nr_sgs = 0; int nr_sgd = 0; + int slot = 0; int err = 0; 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]; + slot = chan->ct; + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + algt->stat_req++; + if (chan->ct + 1 > chan->tmax) + chan->tmax = chan->ct + 1; +#endif - cet = chan->tl; + cet = &chan->tl[slot]; memset(cet, 0, sizeof(struct ce_task)); 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); @@ -240,6 +247,9 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req chan->timeout = areq->cryptlen; rctx->nr_sgs = nr_sgs; rctx->nr_sgd = nr_sgd; + rctx->slot = slot; + chan->lreq[chan->ct] = &areq->base; + chan->ct++; return 0; theend_sgs: @@ -281,14 +291,41 @@ int sun8i_ce_cipher_run(struct crypto_engine *engine, void *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(breq); + struct sun8i_ce_flow *chan; int flow, err; + int i; flow = rctx->flow; + chan = &ce->chanlist[flow]; err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(breq->base.tfm)); - crypto_finalize_skcipher_request(engine, breq, err); + for (i = 0; i < chan->ct; i++) { + if (!chan->lreq[i]) { + dev_err(ce->dev, "Missing request at slot %d\n", i); + continue; + } + breq = container_of(chan->lreq[i], struct skcipher_request, base); + crypto_finalize_skcipher_request(engine, breq, err); + chan->lreq[i] = NULL; + } + chan->ct = 0; return 0; } +static int sun8i_ce_qmore(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; + int flow; + + flow = rctx->flow; + chan = &ce->chanlist[flow]; + return MAXTASK - chan->ct; +} + 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); @@ -301,11 +338,13 @@ static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_r unsigned int ivsize, offset; int nr_sgs = rctx->nr_sgs; int nr_sgd = rctx->nr_sgd; + int slot = rctx->slot; int flow; flow = rctx->flow; chan = &ce->chanlist[flow]; - cet = chan->tl; + + cet = &chan->tl[slot]; ivsize = crypto_skcipher_ivsize(tfm); if (areq->src == areq->dst) { @@ -404,6 +443,7 @@ int sun8i_ce_cipher_init(struct crypto_tfm *tfm) 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; + op->enginectx.op.can_queue_more = sun8i_ce_qmore; err = pm_runtime_get_sync(op->ce->dev); if (err < 0) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index e8bf7bf31061..348d3927344b 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -104,8 +104,10 @@ 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].ct; #endif + /* mark last one */ + ce->chanlist[flow].tl[ce->chanlist[flow].ct - 1].t_common_ctl |= cpu_to_le32(CE_COMM_INT); mutex_lock(&ce->mlock); @@ -120,7 +122,7 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) /* Be sure all data is written before enabling the task */ wmb(); - v = 1 | (ce->chanlist[flow].tl->t_common_ctl & 0x7F) << 8; + v = 1 | (ce->chanlist[flow].tl[0].t_common_ctl & 0x7F) << 8; writel(v, ce->base + CE_TLR); mutex_unlock(&ce->mlock); @@ -128,7 +130,7 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) msecs_to_jiffies(ce->chanlist[flow].timeout)); if (ce->chanlist[flow].status == 0) { - dev_err(ce->dev, "DMA timeout for %s\n", name); + dev_err(ce->dev, "DMA timeout for %s on flow %d (batch=%d)\n", name, flow, ce->chanlist[flow].ct); err = -EFAULT; } /* No need to lock for this read, the channel is locked so @@ -285,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) @@ -343,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 * 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..59e9985fc6c8 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; @@ -143,8 +144,11 @@ struct sun8i_ce_flow { dma_addr_t t_phy; int timeout; struct ce_task *tl; + struct crypto_async_request *lreq[MAXTASK]; + int ct; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG unsigned long stat_req; + int tmax; #endif }; @@ -185,6 +189,7 @@ struct sun8i_ce_dev { * @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()) + * @slot: The slot in the tasklist used for this requests */ struct sun8i_cipher_req_ctx { u32 op_dir; @@ -194,6 +199,7 @@ struct sun8i_cipher_req_ctx { unsigned int ivlen; int nr_sgs; int nr_sgd; + int slot; }; /*