From patchwork Tue Jan 14 13:59:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11332353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29E4F14E3 for ; Tue, 14 Jan 2020 14:00:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07C8F2467A for ; Tue, 14 Jan 2020 14:00:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LY0AQeNE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EGE60Tz9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07C8F2467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CAthQoP1bdG5GSEacJY6wKcc1pDBXUJk2MTJ0BAnSjs=; b=LY0AQeNEe/8tnD eqju+us1tC+t2JgCZiEp2YbT7crxUmtrXAXb8I0DIjMzgiuvXVGJP0dpYpUR7jItSsxLM6LaNAFXQ lTq6wK+51QGwJ/iWmHqRdYAuMbdb2CuAazizMq7typOpF3Nr/U5PHVKV+xNttL/B1GXkTXo0DYnO0 CkLTu/aZ3mTY7mZl2xLNQ9viplmUapmR8nnM5bhi5T2jtjmWRN4XGm15tl9vOHhnCm4fqz8LNzpIB 4GG1+4yNMOc5L9jAqmlnhlrTvkS/UmtISilQzUDR0Vpy5tjlMjbq4NwaDtBLQwSYx1dnAhvcGmIkT RygFZYH8QHrsyUF3HyCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjz-0000kW-BY; Tue, 14 Jan 2020 14:00:19 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMja-0007Yk-O2 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:00 +0000 Received: by mail-wm1-x342.google.com with SMTP id t14so13842045wmi.5 for ; Tue, 14 Jan 2020 05:59:52 -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=CpAqaZx6JeHzamdabNXS/MeiqNHInVywNzBkpn7W7C4=; b=EGE60Tz9ZomQozYGZ/klz3rYuQFmxyX/3ipXjYNC2U1eKb5UWY4x3m/pWmsI9myf1r UpibKFW4DOAw/goE/hdwe8S4JkRJvWfA7bQR4zvQm10+mEvPFqQJThEeKdgs7JKeMIQG fiUgFXYCSS+7SlaTMVUD1Vys/I00NPBymU0+qrlXceClhkgNI+4lFy+rM+Ud36ROg/4c 1fHrX+5g9m9d1xROUHKCSLUz1+yeyQnke9P7l0rheXf6k4lTij/EkdAGpqoAm4FdY3/I fNBXEgHqARWslgm5hDKc4ORHALnr9CQIC2Y9RljKGyDgNy/mfxqYXGpw1GwiEAFjRx6A 4BwQ== 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=CpAqaZx6JeHzamdabNXS/MeiqNHInVywNzBkpn7W7C4=; b=kpiVMEQy/7WKqHmLGSNp71bgtR8lCGSpLc8x0FTRMHJ+5TUIOtZbmK5UEUjR8eNd9Y wjqughj3cGijHF8SBNwEivIytue8tWsJrXp3q8Nhie9Cyo3obLlOC/tAp1dY540iONyl hr8FeXN62vU8T/MVikYd6lCeJkVZEron0MlfVm7Aas27LzK5lo0u76vUCIWZvBq6hDJj z7BJ3zx+sPdxDe6MZFabm6GDSB2tU7BE0DVFs8fc1ajmhJ6BNI73PtIN6iTE34SclI0k UETXb7oyU5B89Jw7OeLD+1XKNKpkkZegc3jcsummDD52q4Xsi8553LGLOxbiIH01Vbwi LkTQ== X-Gm-Message-State: APjAAAWLA3wfI99JdYJ7OuunQJoj+IVbg9m+zkq8pQGkzdgt4798zvn3 e7aAQkiTwy6AlZLy4qD2lW8= X-Google-Smtp-Source: APXvYqw+ky2HWP39jMAlwguBjhRJJXXYNObsWOMbBN+eNALLt0hLuU+EgqRGX3WRMq+vYEMZZ16sGQ== X-Received: by 2002:a05:600c:1003:: with SMTP id c3mr27443453wmc.47.1579010391218; Tue, 14 Jan 2020 05:59:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:50 -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 Subject: [PATCH RFC 01/10] crypto: sun8i-ce: move iv data to request context Date: Tue, 14 Jan 2020 14:59:27 +0100 Message-Id: <20200114135936.32422-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_055954_778230_E65B6ABE X-CRM114-Status: GOOD ( 15.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Instead of storing IV data in the channel context, store them in the request context. Storing them in the channel structure was conceptualy wrong since they are per request related. Signed-off-by: Corentin Labbe --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 27 +++++++++---------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 10 ++++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 75e2bef2b363..6108cea0e0bd 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -91,7 +91,6 @@ static int sun8i_ce_cipher(struct skcipher_request *areq) struct scatterlist *sg; unsigned int todo, len, offset, ivsize; dma_addr_t addr_iv = 0, addr_key = 0; - void *backup_iv = NULL; u32 common, sym; int flow, i; int nr_sgs = 0; @@ -154,24 +153,24 @@ static int sun8i_ce_cipher(struct skcipher_request *areq) ivsize = crypto_skcipher_ivsize(tfm); if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) { - chan->ivlen = ivsize; - chan->bounce_iv = kzalloc(ivsize, GFP_KERNEL | GFP_DMA); - if (!chan->bounce_iv) { + rctx->ivlen = ivsize; + rctx->bounce_iv = kzalloc(ivsize, GFP_KERNEL | GFP_DMA); + if (!rctx->bounce_iv) { err = -ENOMEM; goto theend_key; } if (rctx->op_dir & CE_DECRYPTION) { - backup_iv = kzalloc(ivsize, GFP_KERNEL); - if (!backup_iv) { + rctx->backup_iv = kzalloc(ivsize, GFP_KERNEL); + if (!rctx->backup_iv) { err = -ENOMEM; goto theend_key; } offset = areq->cryptlen - ivsize; - scatterwalk_map_and_copy(backup_iv, areq->src, offset, - ivsize, 0); + scatterwalk_map_and_copy(rctx->backup_iv, areq->src, + offset, ivsize, 0); } - memcpy(chan->bounce_iv, areq->iv, ivsize); - addr_iv = dma_map_single(ce->dev, chan->bounce_iv, chan->ivlen, + memcpy(rctx->bounce_iv, areq->iv, ivsize); + addr_iv = dma_map_single(ce->dev, rctx->bounce_iv, rctx->ivlen, DMA_TO_DEVICE); cet->t_iv = cpu_to_le32(addr_iv); if (dma_mapping_error(ce->dev, addr_iv)) { @@ -252,17 +251,17 @@ static int sun8i_ce_cipher(struct skcipher_request *areq) theend_iv: if (areq->iv && ivsize > 0) { if (addr_iv) - dma_unmap_single(ce->dev, addr_iv, chan->ivlen, + dma_unmap_single(ce->dev, addr_iv, rctx->ivlen, DMA_TO_DEVICE); offset = areq->cryptlen - ivsize; if (rctx->op_dir & CE_DECRYPTION) { - memcpy(areq->iv, backup_iv, ivsize); - kzfree(backup_iv); + memcpy(areq->iv, rctx->backup_iv, ivsize); + kzfree(rctx->backup_iv); } else { scatterwalk_map_and_copy(areq->iv, areq->dst, offset, ivsize, 0); } - kfree(chan->bounce_iv); + kfree(rctx->bounce_iv); } theend_key: diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 8f8404c84a4d..49507ef2ec63 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -129,8 +129,6 @@ struct ce_task { /* * struct sun8i_ce_flow - Information used by each flow * @engine: ptr to the crypto_engine for this flow - * @bounce_iv: buffer which contain the IV - * @ivlen: size of bounce_iv * @complete: completion for the current task on this flow * @status: set to 1 by interrupt if task is done * @t_phy: Physical address of task @@ -139,8 +137,6 @@ struct ce_task { */ struct sun8i_ce_flow { struct crypto_engine *engine; - void *bounce_iv; - unsigned int ivlen; struct completion complete; int status; dma_addr_t t_phy; @@ -183,10 +179,16 @@ struct sun8i_ce_dev { * struct sun8i_cipher_req_ctx - context for a skcipher request * @op_dir: direction (encrypt vs decrypt) for this request * @flow: the flow to use for this request + * @backup_iv: buffer which contain the next IV to store + * @bounce_iv: buffer which contain a copy of IV + * @ivlen: size of bounce_iv */ struct sun8i_cipher_req_ctx { u32 op_dir; int flow; + void *backup_iv; + void *bounce_iv; + unsigned int ivlen; }; /* 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: 11332365 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C2D51398 for ; Tue, 14 Jan 2020 14:00:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC2DF2467A for ; Tue, 14 Jan 2020 14:00:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Yupkvjz0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vf0d1GFb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC2DF2467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WMZugspbEhsVtxeElJjJuT/hPbs+vLeh9tQnxMt4dKI=; b=Yupkvjz0evsqIY AxwKa0U5Dcw4tVqgAWH1ZYcR7WlLpf1Bq3pGc99WBeWS80IoZXlcEsdDScJ0sdTVYWZjEkrnYfHrB ycLxszTuNnu5VM9kvlfAj8HGxqSl1FFwO41HKIkU0micAxtldCHhcSMlB2vUrsFyFCp3MavW9i46d /xNFzpTurKzDqM29ktxbTDRfhWRr+O4wjIio/YevGdvd06xzx8eWFyiJylMAViJgY+T1dlaGNOudH JImrZ5PLl1VvjaLSvGALyYQqPKqHq8BbFbnbYEYYLO/6KbknY6MEJNR/9QJi0RjQ3Cza6fxk7zjL5 1pxZ5Zqxjdv0HfiyUg0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMkK-000122-KS; Tue, 14 Jan 2020 14:00:40 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjb-0007Yy-EU for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:03 +0000 Received: by mail-wr1-x444.google.com with SMTP id j42so12229369wrj.12 for ; Tue, 14 Jan 2020 05:59:54 -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=iRrIgLt+ChKtNZrXmZWhgjSfbWlgup2RRT/cwSIFNfb5k9Mv/h4Rlso0OEc7gHz+uK kwqySKzjlAHKI4kDkISGb2TWnS2OIWVGD6ldM/dfGa3SeT2JOo4eaOXvRJX6BZUJLJ5A rTK7jzRvGq3eoBFplFxgw3HP2DwATVMLm5+OY4LTC97JVC7sSOTKNsNT+AkirYUTDk35 9RjZuqLU0PRa8ys/EuC77B8hi9y11i1q6PT0xAHc1UytF1QcM7c7tuPHR+v373z5e9Al B5aIWAl/zLxHCrEuM4E+1vHag00woPByQ6/FzlkSzn/y1L8InaIf5wHt/bihAfu2cArA GyPw== X-Gm-Message-State: APjAAAVEhKMD/LWoh6y8anpX968CMzYkwktsv63aSOCyi/p/UbC9tuw+ GvwjYkLOmzgKIRgIfc2mD/ntkZts 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_055955_480630_54D9E094 X-CRM114-Status: GOOD ( 12.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 11332367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AD8592A for ; Tue, 14 Jan 2020 14:00:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECC442072B for ; Tue, 14 Jan 2020 14:00:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XmaEFWbJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oSFvsfR/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECC442072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pWTYUmOTdHKwxQFgabamwSQmpq2LLRv8YbV2yud94mQ=; b=XmaEFWbJlnO+L9 795iDll6Qa0kGGyaTXDHXDpgAk+c7qpSzGXvtI7Dta1OtmyxM4LKrlc6EJKFhOQakgUlVKKIgWhVA dYnfzRfAE0ggdXNGA8z6zirRV2/wqNWbmlsGvHmo7g/tB3zs/ti5NPooPBG+U3PNbGa3E+ztvBmwr L6EVH9ET3q+xSVdTAqeBXB0gfyopII6aRI54f/zqvYY+drkVUvsRTng/0IF7UEG3h+sAeqdCOd86K 5zx/jI1UnZk64bTHDHkfJlRoES/PFCaidl2V0vnQ9Nr5AskK4Ho0qOyLdoUWmQzg7D/UgiG7gGJDz SU2Wsx1ZM5uORtpZYECQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMkV-0001Ba-7T; Tue, 14 Jan 2020 14:00:51 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjd-0007ZL-A0 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:03 +0000 Received: by mail-wr1-x443.google.com with SMTP id y11so12273639wrt.6 for ; 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=EiUyHREx0lBqsOERGLxx7HNjmLydx0RfbvEDAzF9RcQdXAg1yXsRNGdQ7xATGN199X TZODOS0q/AM5mPx63RsvQZ3ZAaT5SF9AA7ABndaTDWw64ZCLqCkz3tcfW/Eg5M7XJt4t BM2yjFrIWcmRvBWXFDWKlD/LqfugB7C2BSXHBwaxgS/1k4hUqtIpt9psX4+O3I7G4mJd UEzm397TMdIkhDQKYV246aQ53RqIog4po8HKk/2Q42JIuq9T2rRPpIVoFa8uwCBH7nJV O1+e5yAH8YXo+qb/A9ONURAqJyeRmCw3krb3nSkjv1RLuojXBEjOMRKS7BIHBjBldLyJ lI7w== X-Gm-Message-State: APjAAAUaA1GvHj5mCTTtlqoX1f0Ve6azkyhysuwBfPXNV1ZN7bTuGWn0 jUWnUHo8YpfqWNwVo9FoMm8= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_055957_347930_F1DB7856 X-CRM114-Status: GOOD ( 15.15 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11332369 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BF8392A for ; Tue, 14 Jan 2020 14:01:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDBCE2467A for ; Tue, 14 Jan 2020 14:01:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b9LKGV5M"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EUO5m76U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDBCE2467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xWUdDOvfoBIzagrP0BdezQPtZpAMoYCgYCGj+kHNqgE=; b=b9LKGV5MR8QKo9 IJiTcvQCt9A/LcicoDi2RpFze2DJYMuYbKjz9jdhbB8lIl9zTG3ecVm3rvM4jGieJohb9ULB/9MC3 /jBiSrGAn+cSJAoNv92emyeHcY8cybr6eYomafc0+CLFXnrW9JfP/OG/SGycfVkr/8WyBZEsFROCN nCaZXEjAeIVeuDKbKsENbY5aa5u1v5thZMK6BEUsYOrgQ7OeLYngYvqXoJjXgnxAQP9maTTOjaSqY Kog4umBxq66LivD1HmGss20F5F1F/bSSRLqZhVlfyWm0kKnGtTCKUoXc32OAigzouqtoU5kZ0v2ZH To/+zZD0pQdPCK//sQZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMkl-0001T5-V0; Tue, 14 Jan 2020 14:01:07 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjd-0007Zr-Rs for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:03 +0000 Received: by mail-wm1-x344.google.com with SMTP id f129so13858864wmf.2 for ; Tue, 14 Jan 2020 05:59:57 -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=xjPV4Ha5BYE0MCX17Wl6xnLI6QAy5DnWASz8VTCVvYQ=; b=EUO5m76UvmdUwWtNzcIKhgu1b3wsytiLJXK+nCU8Jd+QLUFj3sjQ6tp4GDPLdz01Tk CqD2W85UbyrcCOMSjLf/dFpOusOr7BW9TGliVE1RP6bXsB8Sxe8ahdtC2GAFpvVWPHtu huctNx72GCsTAiGkF1SCKWPEXR1HgUR4pAxwdKl8372GYVvlcoKFEIjoubnexI0StKy6 x656qiDvIBYjjnHT10RUOQDzOjyDF4tIiOjDG3EtntrJNHGhnm/SU9hhc3qJmCNhKtuH mUG4dI9ncJ9bO9nTWh1qxkJkNIl9HucXdHS5WgPs9si0eKsDk+9KCo/JNtoxvjSE9hva LINg== 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=xjPV4Ha5BYE0MCX17Wl6xnLI6QAy5DnWASz8VTCVvYQ=; b=CIMGoACKwtw0+tiV/vGW98XJ7aOnM4G29skkNGHFHcuvShhlJCxPPF9inVqtfQqyqd OKj0mmwXyFCbziewZ5M1v5B1JXJqvztul3j9Uui2YykdGCBAHU6RCPWk2oX6k5NV5B6p IJDqqOxkmMnbVjBSEz1iVOvffsVHoPfCYFLVcm2hBxmFth65cdTpR89ABgsPu+DnZbjG suHanQdNZSL5Lg22mUrk5pQQXU1/yaj61advhSbEzwaiuT+h1S7pjN/isuu0tIMxWqh/ gvGDClxwj63AhCJ/6ApaonUAIfQTJpDX1CuBNtVmHSvf8tx6V9Djh/nxy+Oiy30U7ogc f7oA== X-Gm-Message-State: APjAAAW53o3STke1YdY+/gRMCxw/u44CxpI1nrfj7WrrRDQe56f9ekI/ +NAjfeTxOV5PjnG/m6B4xZs= X-Google-Smtp-Source: APXvYqzVCraPGaXbAoGqhP1ygDTY7R+QHVftrzEYOGKAwqSEbThaIsz0cQp5wFfFNd9DXBamDMmh5Q== X-Received: by 2002:a1c:62c1:: with SMTP id w184mr28138545wmb.150.1579010396021; Tue, 14 Jan 2020 05:59:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:55 -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 Subject: [PATCH RFC 04/10] crypto: sun8i-ce: introduce the slot number Date: Tue, 14 Jan 2020 14:59:30 +0100 Message-Id: <20200114135936.32422-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_055957_896701_6335719C X-CRM114-Status: GOOD ( 14.53 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds the slot position, for choosing which task in the task list should be prepared/unprepared. The slot is for the moment is always 0 until the infrastructure will handle non 0 value. Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 6 ++++-- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 401f39f144ea..9c1f6c9eaaf9 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -96,6 +96,7 @@ 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); @@ -114,7 +115,7 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req chan = &ce->chanlist[flow]; - cet = chan->tl; + cet = &chan->tl[slot]; memset(cet, 0, sizeof(struct ce_task)); cet->t_id = cpu_to_le32(flow); @@ -301,11 +302,12 @@ 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 = 0; 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) { diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index e8bf7bf31061..bd355f4b95f3 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -120,7 +120,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); From patchwork Tue Jan 14 13:59:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11332371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D38692A for ; Tue, 14 Jan 2020 14:01:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45D812072B for ; Tue, 14 Jan 2020 14:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="t+AygkJM"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="efXBmH3q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45D812072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h5PKjTKny+0WUO68Kqku04c3Sc5TLB/hzuer+uyIU30=; b=t+AygkJMWij5sa StX4iphjOY0d0RdxpfEZoQ9JUMo2H44Snu9q9eU3h/zFTVOntIvu1QgjdADzq16PnJwIuyrxpCtyC LPS9rfUz8zkMCfXS/3YcQNIBXiiI/Efhyv5vDQsonfBciOPhKqspdW4gYLI4upmpT6RV3T2W4aaTK urU6cAVUyqgi2GtKqG2tRInErk9flX8M38LqY4lpVHnAU0D0ov2B9jjefhSpITnTnQ5SW2J/N3Ppt GflVb0Z6G1CG8pYbkrm1/++x52rtBY3rhKmnmKi0r973PbChR8qWrgQ/jtS4Cj7CuRvYlPYO5ezOR OxRXNrCyUyATFVclJzvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMl3-0001lr-Ao; Tue, 14 Jan 2020 14:01:25 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMje-0007aj-T7 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:06 +0000 Received: by mail-wm1-x344.google.com with SMTP id p17so13872032wmb.0 for ; Tue, 14 Jan 2020 05:59:58 -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=QK7uW2JyHvV/1Sv2A8qlxlva+nc6onlWMSezJazY5hk=; b=efXBmH3q24U2Ufo+ifFyvvi/Yqw1RTmkeHkZXJeT9nLqdmsYllLF/q2N9FAhZlqGqu RBRE6imvHtTjPuAT6uSI0u8gEa/aPiV6fx5u9Qii+wAEjQj3bN75LYbj3UReGbmzuu/S +EzcxW3bE2JtTlpJKXIIUfixjAHAB/MQ0QBD0T6YKviQ0xcdASq9RQWCkCEqLyk9Yur1 wclEEH0H2U8Vb3gbbzVV57N6NPZcXUO0AMROkDiuduyRPXBEl4w51A/OdtHtlcbeBr/v 80KsdAyRRVrqwaBL/Cr8miC6ZA8T/MZhNVmkKio/bN9Ns/IdyFqzfoBa/JNmlZzDl1fz RpVA== 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=QK7uW2JyHvV/1Sv2A8qlxlva+nc6onlWMSezJazY5hk=; b=SaVALBk8Cd0srPZZlapnDS3eqlAr5t//tB/ovCnIEqas1DxdFSmGLyCW40HwwpNTWN 0IH1iJ4SCrEqTKctD/74IOLuliezY50RKmojL++VtIMRV/rqnhDQqjgXgaJWGdB1hRXQ TsHTfJQ9WhcYknynlDJ4otRQUeQOpPohvZ2GgsmBPZd+cXR8x9vxOyq9WQr/eH1X5jrG g8oL69TpuUOo5mrLUvpJUq+H5ppl4yY8njvs60RMwkaL34KNISZWpIp5YOpMJk0G+5MW klub2MZfWaBzjLB4qLbn7xqyyISSbM0HQIwCnm6EfZPhywWMQ9m6MOvLoaDq/ux0OzZw tDYw== X-Gm-Message-State: APjAAAWy6pAG2kBVOnNvxOIO3p0YqkZo6bbBBccy7PB6hycDD49TsC+g swo8/nzi9oKJlB9AddOV6qQ= X-Google-Smtp-Source: APXvYqwah42w9ldVBz5YQTGbbxH1zgfKmZAqapYTzwVE0gSRGQr7ndjMeZOzQrZT2x49dlCWNGYM4g== X-Received: by 2002:a1c:1d16:: with SMTP id d22mr27986303wmd.158.1579010397577; Tue, 14 Jan 2020 05:59:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 05:59:57 -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 Subject: [PATCH RFC 05/10] crypto: engine: transform cur_req in an array Date: Tue, 14 Jan 2020 14:59:31 +0100 Message-Id: <20200114135936.32422-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_055958_974942_768328F5 X-CRM114-Status: GOOD ( 18.79 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For having the ability of doing a batch of request in one do_one_request(), we should be able to store them in an array. (for unpreparing them later). This patch converts cur_req in an array of request, but for the moment hardcode the maximum to 1. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 32 ++++++++++++++++++-------------- include/crypto/engine.h | 19 +++++++++++++++---- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index eb029ff1e05a..b72873550587 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -30,26 +30,27 @@ static void crypto_finalize_request(struct crypto_engine *engine, struct crypto_engine_ctx *enginectx; spin_lock_irqsave(&engine->queue_lock, flags); - if (engine->cur_req == req) + if (engine->cur_reqs[0].req == req) finalize_cur_req = true; spin_unlock_irqrestore(&engine->queue_lock, flags); if (finalize_cur_req) { - enginectx = crypto_tfm_ctx(req->tfm); - if (engine->cur_req_prepared && + 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, req); + 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); spin_lock_irqsave(&engine->queue_lock, flags); - engine->cur_req = NULL; - engine->cur_req_prepared = false; + engine->cur_reqs[0].prepared = false; + engine->cur_reqs[0].req = NULL; spin_unlock_irqrestore(&engine->queue_lock, flags); + } else { + req->complete(req, err); } - req->complete(req, err); - kthread_queue_work(engine->kworker, &engine->pump_requests); } @@ -74,7 +75,7 @@ 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) + if (engine->cur_reqs[0].req) goto out; /* If another context is idling then defer */ @@ -114,7 +115,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, if (!async_req) goto out; - engine->cur_req = async_req; + engine->cur_reqs[0].req = async_req; if (backlog) backlog->complete(backlog, -EINPROGRESS); @@ -143,14 +144,14 @@ static void crypto_pump_requests(struct crypto_engine *engine, ret); goto req_err; } - engine->cur_req_prepared = true; + engine->cur_reqs[0].prepared = true; } if (!enginectx->op.do_one_request) { dev_err(engine->dev, "failed to do request\n"); ret = -EINVAL; goto req_err; } - ret = enginectx->op.do_one_request(engine, async_req); + ret = enginectx->op.do_one_request(engine, engine->cur_reqs[0].req); if (ret) { dev_err(engine->dev, "Failed to do one request from queue: %d\n", ret); goto req_err; @@ -158,7 +159,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, return; req_err: - crypto_finalize_request(engine, async_req, ret); + crypto_finalize_request(engine, engine->cur_reqs[0].req, ret); return; out: @@ -411,10 +412,13 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool 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), "%s-engine", dev_name(dev)); + engine->rmax = 1; + engine->cur_reqs = devm_kzalloc(dev, sizeof(struct cur_req) * engine->rmax, GFP_KERNEL); + if (!engine->cur_reqs) + return NULL; crypto_init_queue(&engine->queue, CRYPTO_ENGINE_MAX_QLEN); spin_lock_init(&engine->queue_lock); diff --git a/include/crypto/engine.h b/include/crypto/engine.h index e29cd67f93c7..362134e226f4 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -18,13 +18,23 @@ #include #define ENGINE_NAME_LEN 30 + +/* + * struct cur_req - Represent a request to be processed + * @prepared: Does the request was prepared + * @req: The request to be processed + */ +struct cur_req { + bool prepared; + struct crypto_async_request *req; +}; + /* * 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 * @list: link with the global crypto engine list * @queue_lock: spinlock to syncronise access to request queue * @queue: the crypto queue of the engine @@ -38,14 +48,14 @@ * @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 + * @rmax: The number of request which can be processed in one batch + * @cur_reqs: A list for requests to be processed */ struct crypto_engine { char name[ENGINE_NAME_LEN]; bool idling; bool busy; bool running; - bool cur_req_prepared; struct list_head list; spinlock_t queue_lock; @@ -61,7 +71,8 @@ struct crypto_engine { struct kthread_work pump_requests; void *priv_data; - struct crypto_async_request *cur_req; + int rmax; + struct cur_req *cur_reqs; }; /* 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: 11332373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 633711398 for ; Tue, 14 Jan 2020 14:01:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A6E22072B for ; Tue, 14 Jan 2020 14:01:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jC4JMD4c"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LRbl4YL7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A6E22072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HQkpteMOLEHIZDKvOLx217P8UlBA6yHKG7p+8BU9xtQ=; b=jC4JMD4cgI+YXK zDBUZFIIYI65euY/9i4hCC2da5A5IO7AbpmC5u5Pq7Tyrb6Eu6bA2uRQEbjljfiWl74+j720H43hM gKUcYxqKaENhVRWx5mKc1mdKPwuO/RBignnrZVQPS9QEvJTibUwYoRLKbQmvN/+XurKWfGf/m/3wn xxgnSOPH8TCXH39KxG+FuXFMC9Q8enVUoyS2WdDWO2TvagyN1JY2TgXtcP3oEIUe1VpWSpKugkcDJ hqxzTvmBdzoCYsivDkDnBiQh53GTNK3Gkf2P8Z8hQVc6czECHfdLp53wKU7YXPMCB21RnlmNjITIi QDhebb0h7y0oBT+CAEMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMlO-00020Y-2y; Tue, 14 Jan 2020 14:01:46 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMji-0007fP-Q9 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:08 +0000 Received: by mail-wm1-x343.google.com with SMTP id f129so13859078wmf.2 for ; Tue, 14 Jan 2020 06:00:00 -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=LWTxNEIm91aLdbpgkqT1Yx6iGSE+fV17Yi7XSjMOpSVyet+jfVD/dCviHy/E5fgxz9 U9DBdpPmABWdzQQtW2ua+Z13Aek9utpawKZoI5lq5WjDr0TDCLXs3I3/P9k7XTSHsSRe 4gnAnmoQKnvx9PdN+CnulkAqVoFFiGTOH6NvztdyOQLDkn2UunkIvzCgWz2Bki5RsDdf 6UTUq04p+ZBhpEmJatungztXgoMz6UbqmEgXmRlbr3tZBim8ueAk6gcvqggl6kkbjAnq qs6fqZ2t+jTF23GjBBlkElMZwv/p9Zip+b1scF89Rz9hqK4BKvpOoKprby1X9CIlnsnk aeDQ== X-Gm-Message-State: APjAAAUvz+6G6YnOpsXhxj48QN8fEQnFViX0xOFxK/HWAScV2l+TDDuN NY1YKLICTMgQg87bb8nTrrI= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_060002_904734_738BAD0C X-CRM114-Status: GOOD ( 16.14 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 11332375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 125011398 for ; Tue, 14 Jan 2020 14:02:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF34324679 for ; Tue, 14 Jan 2020 14:02:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h8CbwcBA"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IZGzjrkK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF34324679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TG/4ibZVieN6/LVdv1AKfzTijoTTvMxQ8rxAiQkt00g=; b=h8CbwcBAxJLYdp TMnI0W0M1ajvmkO9j0BTZ9zysxe9WBlcfZJGh74VEoTW3q7hvIAK2qV1rAPPEhlhvgGSlIn71pjN8 W50KKS+QYKwc0JZ/wiftR5QdC1Mm2ufA966YhEf+6KLchoYXnWO5207yj2ebPIdFctAPpDoJHtZTx cvjFNL3n/m5ingboNNpjfUsjPzSSkwD9yWnD7uvMRWSVawmgO6BeMJxS53oN09rFvU0p94jrstyga Plzu15FiwO3tnyxNN1/MVTPRXNuppZtrCuwNcee7ycKKr92H2hyX0b/CxwfZ7kt811kV0uh6Uorv9 fMCkx+jKy1dN1QySCx6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMle-0002Em-OL; Tue, 14 Jan 2020 14:02:02 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjk-0007ix-Jb for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:10 +0000 Received: by mail-wm1-x341.google.com with SMTP id a5so13907575wmb.0 for ; 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=uBsBGG5aJV6cfGntsi1E3xENFVtYRGAWsqKp1XXhiyQEemmjzL/H0larKSMdjnxBNG U4b4ctGN/GZVMCgjiRFHhnbc3d1OCCNeK5PObrXStqgh6PRKm7CDUarqQ0knQmgC2alZ 8C8n42wQKeopfPMg6qTz6HWM/NY9LnNifwkgysFBQyYWZfKwoocwcizDGvXuKonnLK7z LSD5U3yCyhJAti5e64M2A7N1dscFelk+lYmo/E3bX765WCKaG7J4i00vNPhmmYxCMh7G yc5JoS17+v2yoH7RawNOa4TZh41pPIsejQTh3KITfb6VwMwl3ygg62yGb2nqrtAklY0t 1sqw== X-Gm-Message-State: APjAAAVhhPPbdL/8ZxZdOom9nDE6BpayvkKZc1h91seyQmix+hqBNSqJ gfboyJ3ks8c4NsX03R0QTjw= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_060004_727983_7955693B X-CRM114-Status: GOOD ( 12.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11332389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01AED14E3 for ; Tue, 14 Jan 2020 14:02:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEC4E2072B for ; Tue, 14 Jan 2020 14:02:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qethd59c"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b9ZF2ddh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEC4E2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FoRQZKVyqQy9OvIxYS1fC023+mRimhOmTqu14yejP00=; b=qethd59cW8Gd1n vdonaHA1LN/b0SHEcpMxNDS7tBmI64JBDjq9/MruWZyF02ysO6gS+UexzBsD2f1QruAMxLkjRe0Ql 9pMtq4qjWpsJPFfz9WzXH3IQBwzWYKIat6ExCR6p99S3wl60BpGsJvr+/EifXD8zTMf08dYNZVHfY h0iDTKvhsoh0y6B9K8Ho1zXovzHbdJwOa5wvOf3ppfGbWaEFx8RlRQgYdkASkGDvu4HDim7yw5UAX S1lsLrkIDGO/kgy16dNBIyHzdyg0jaSta2eR5RkrotHKL6aV1b5JGCUF9P9INwe1cGpSplZWYrlk7 mpq/iKKntht8R0T9EYbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMlu-0002T0-Sw; Tue, 14 Jan 2020 14:02:19 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjk-0007np-64 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:10 +0000 Received: by mail-wm1-x343.google.com with SMTP id q9so13891817wmj.5 for ; Tue, 14 Jan 2020 06:00:03 -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=AaGocOWYYqqxxVSnuFJaes6fIuVCOqjGVL46fuoWceA=; b=b9ZF2ddhd9zGkBUQfYFINe52pfdd1cQRB5F71PoXqYhsv0I8C5zSpPdxZldg1b50IX rRbXf0DOHBwabaizpHXOVgrzXx5h1pybWotTD745Mh2HMmCt3jeVIpDjfrBOLPWRn2hw sdpmhM8LJLIUpPTw60uqNDGVdrNhK5EgVjV/Sva1mfNFlROzQfwcX7Gkj9tTwPCLXPlI RZ5xfscNXx+zApX/Fy0SGHwyPKv7Vwcl/HsdZ1P4zFADNJyFc6Xuwpp6gatMrFaf15bK MlKgfS22UUABgUklrYWfOLgo9eaCJJ7QX/eXvzzcsumnQhuGTe7TfacEeL6CGr/7pTqK E8uw== 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=AaGocOWYYqqxxVSnuFJaes6fIuVCOqjGVL46fuoWceA=; b=RuUw17T+VF4WAxIY964tLlF92sInTYJzhHRe84tFrc+4gpT+W2PxXdpyLD4THXjIPU Bk8PlI4n4L6IRD0k8AsUN20S0Yzo4fYXqDZTN8D5ZXd9jEOa4kUgaLbZEqSRYJyNx0Ib fI7h9GOVKT2qFTHA16ihJ+N67RbL1VUbLnaP2m9TJ4dU8i2csI+E9eCHKOPsA+ONsjDa y1fBiCgXxjkQ55xa97tjYMNvaSyj70YheSy4AhmZ5LsWq6t2w33VzDwkJNiby55le9E9 ofU/bDNTJ1KwckQnOL8rjQx6DEfIdHwVzb/JE5XcdYIzUOCw1EenGbKkrOozu3vzplFp ftZQ== X-Gm-Message-State: APjAAAXgjNE/GnDeflME94k2DZqm9EPWCA+3q9qIxiQRZXKLt9bRxTjB t6p6DoB5uXX0a84hrb81u+ifJlSI X-Google-Smtp-Source: APXvYqx+OxKcWRqq8m9tk4fmOp55+mC1hDkwaWDzxu8S8kxilLu0l5ArdfWrRaXSdKdve/5st6FN/Q== X-Received: by 2002:a05:600c:2383:: with SMTP id m3mr28610665wma.32.1579010402204; Tue, 14 Jan 2020 06:00:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 06:00:01 -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 Subject: [PATCH RFC 08/10] crypto: engine: add slot parameter Date: Tue, 14 Jan 2020 14:59:34 +0100 Message-Id: <20200114135936.32422-9-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_060004_725921_FAC09D10 X-CRM114-Status: GOOD ( 13.64 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org prepare/unprepare functions should be able to know which slot in a batch should be used for preparing a request. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 4 ++-- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 6 ++---- drivers/crypto/omap-aes-gcm.c | 2 +- drivers/crypto/omap-aes.c | 4 ++-- drivers/crypto/omap-des.c | 4 ++-- drivers/crypto/stm32/stm32-cryp.c | 8 ++++---- drivers/crypto/stm32/stm32-hash.c | 4 ++-- include/crypto/engine.h | 4 ++-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index 591dea5ddeec..e23a398ba330 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -40,7 +40,7 @@ static void crypto_finalize_request(struct crypto_engine *engine, 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); + ret = enginectx->op.unprepare_request(engine, engine->cur_reqs[i].req, i); if (ret) dev_err(engine->dev, "failed to unprepare request\n"); } @@ -143,7 +143,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, enginectx = crypto_tfm_ctx(async_req->tfm); if (enginectx->op.prepare_request) { - ret = enginectx->op.prepare_request(engine, async_req); + ret = enginectx->op.prepare_request(engine, async_req, engine->ct); if (ret) { dev_err(engine->dev, "failed to prepare request: %d\n", ret); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index d56c992fbf93..41d18c18d1d1 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -78,7 +78,7 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request *areq) return err; } -static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req) +static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req, int slot) { struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); @@ -96,7 +96,6 @@ 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; if (slot < 0 || slot >= MAXTASK) @@ -296,7 +295,7 @@ int sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq) return 0; } -static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_req) +static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_req, int slot) { struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); @@ -308,7 +307,6 @@ 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 = 0; int flow; flow = rctx->flow; diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index 32dc00dc570b..0fea3dd40378 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -213,7 +213,7 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, return 0; } -static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq) +static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq, int slot) { struct aead_request *req = container_of(areq, struct aead_request, base); diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 824ddf2a66ff..4d9caa7ce8da 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -427,7 +427,7 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd, } static int omap_aes_prepare_req(struct crypto_engine *engine, - void *areq) + void *areq, int slot) { struct skcipher_request *req = container_of(areq, struct skcipher_request, base); struct omap_aes_ctx *ctx = crypto_skcipher_ctx( @@ -632,7 +632,7 @@ static int omap_aes_ctr_decrypt(struct skcipher_request *req) } static int omap_aes_prepare_req(struct crypto_engine *engine, - void *req); + void *req, int slot); static int omap_aes_crypt_req(struct crypto_engine *engine, void *req); diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 8eda43319204..92c5fb1d4b83 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -524,7 +524,7 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, } static int omap_des_prepare_req(struct crypto_engine *engine, - void *areq) + void *areq, int slot) { struct skcipher_request *req = container_of(areq, struct skcipher_request, base); struct omap_des_ctx *ctx = crypto_skcipher_ctx( @@ -711,7 +711,7 @@ static int omap_des_cbc_decrypt(struct skcipher_request *req) } static int omap_des_prepare_req(struct crypto_engine *engine, - void *areq); + void *areq, int slot); static int omap_des_crypt_req(struct crypto_engine *engine, void *areq); diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index d347a1d6e351..7c65b526d20e 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -684,7 +684,7 @@ static int stm32_cryp_cpu_start(struct stm32_cryp *cryp) static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq); static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine, - void *areq); + void *areq, int slot); static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm) { @@ -700,7 +700,7 @@ static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm) static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq); static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine, - void *areq); + void *areq, int slot); static int stm32_cryp_aes_aead_init(struct crypto_aead *tfm) { @@ -1015,7 +1015,7 @@ static int stm32_cryp_prepare_req(struct skcipher_request *req, } static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine, - void *areq) + void *areq, int slot) { struct skcipher_request *req = container_of(areq, struct skcipher_request, @@ -1039,7 +1039,7 @@ static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq) return stm32_cryp_cpu_start(cryp); } -static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine, void *areq) +static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine, void *areq, int slot) { struct aead_request *req = container_of(areq, struct aead_request, base); diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 167b80eec437..4a696c48126c 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -824,7 +824,7 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, } static int stm32_hash_one_request(struct crypto_engine *engine, void *areq); -static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq); +static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq, int slot); static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev, struct ahash_request *req) @@ -832,7 +832,7 @@ static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev, return crypto_transfer_hash_request_to_engine(hdev->engine, req); } -static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq) +static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq, int slot) { struct ahash_request *req = container_of(areq, struct ahash_request, base); diff --git a/include/crypto/engine.h b/include/crypto/engine.h index 021136a47b93..55d3dbc2498c 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -85,9 +85,9 @@ struct crypto_engine { */ struct crypto_engine_op { int (*prepare_request)(struct crypto_engine *engine, - void *areq); + void *areq, int slot); int (*unprepare_request)(struct crypto_engine *engine, - void *areq); + void *areq, int slot); int (*do_one_request)(struct crypto_engine *engine, void *areq); }; From patchwork Tue Jan 14 13:59:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11332393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 898161398 for ; Tue, 14 Jan 2020 14:02:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BEAC2072B for ; Tue, 14 Jan 2020 14:02:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Gh0W8BHh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CMlWfiRv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BEAC2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0NpxaHI44UQXcd+45klXaTZg33+WnvKWXI05BDk6yHQ=; b=Gh0W8BHhWOXS2U AdA/EMxs0H/i07xy85aSUPQVEZXAuUbn6Y5B9tpOKHC6fInxtRRjnmiwyCCgWqfjbF8Tu2WMcog7G KOvf3Konb4UKezitcBizVBbzML0sfQrRExdEDPIQAY7LOoKQXu/l7jWwqymkR4cjT6xNgtSKMD9I4 +ZuMyYrA+PXOq8JzGNVVI8FkP7r5zwrerKQFA9HvaAfRfsDNb6OS0WcRjzx5Fqh2c2ZaetD3F7bqx YJSBnArNzxstLQKLgNRY44pzw2PGpcUktu4X+pIwScvCnNarAAbEE5Ye+98iSuzcOQ4PlMnmU8U/q OST3ojydBYa/ZuVOJkpQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMmC-0002k0-N2; Tue, 14 Jan 2020 14:02:36 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjm-00080h-V8 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:12 +0000 Received: by mail-wr1-x441.google.com with SMTP id t2so12296714wrr.1 for ; Tue, 14 Jan 2020 06:00:05 -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=Lxb7PN4lvjObtQ59KMU2hHjHYfZBsU9IrbvtHskV7n0=; b=CMlWfiRvaRRJU+hOQ4WPokjIT8GHSX3vkbMyfsBc8DCF2hmxmKbLRl3XuVhkhou0oY 8ildadcB1t+iC3etvIdUbg1E1UntznuFyodZFJWT/fKIama5xaeApXEASHJT7JgN2ozv QCnT8RndunnruzJfnh/71PB8HtxvyO7XJKZnUF7uB+UEQl7A2erDumW8cUH7LVKRRVSc clHmeeo+WxvTbERdluTb53uZ8A62/xxsCsI0ksjNmkSLPYzaqbl3ZsQ8rb2gQr+2OhwQ umwgvNEbrkvZ6ozlVfbhYTa8lSeqFFXS2E6ACT6PSnFlW92eK2gHkYubDtNs9tVVSPeA TMUw== 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=Lxb7PN4lvjObtQ59KMU2hHjHYfZBsU9IrbvtHskV7n0=; b=ed2HazuTRdGUcwJBraR8ATv8huPTmMgmQU6di6FCVCkbeant4ke14rqTlfSy3mlJAC BIruc9XzQx9PT2RGTCQPZcbYGjn2HTU9T8s1OT6WNnbrIy1bYcMyHitFnC397LLBL49F hNveIsgPIRceAOKPDmzQczoVLrerLKaFqB4eZwAUJDJoNC7UeC3KDD+hlLLS+EZgc6fI yfnnswE6MrebmKdTHn4u/X1E5lsyC2XW4hc7WrXLVhQCUEbw3bMZuqviWV9uTg8dzLL3 lx2bk3QmgjW5saPbvdfeHIwu+EftMoD8KMjb5YhLmZL0K/hm5UfE5g05arsVAlkIZa6j cEuA== X-Gm-Message-State: APjAAAWW7xDd/bYEbGCcHcxpiynDW+nzpQmnpfC6TE/w+qxC9Z83sflh isqI84uVHKjbP49UDFk1L/Q= X-Google-Smtp-Source: APXvYqxq5XivXy1rjI7OaJJ+olOKx4Pgt9tO+9ND8MTyENMvSQ3szmCgKQXFPKTU/w3I7VW7kOqisA== X-Received: by 2002:a5d:4651:: with SMTP id j17mr26245596wrs.237.1579010403794; Tue, 14 Jan 2020 06:00:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 06:00:03 -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 Subject: [PATCH RFC 09/10] crypto: engine: permit to batch requests Date: Tue, 14 Jan 2020 14:59:35 +0100 Message-Id: <20200114135936.32422-10-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_060007_028901_FC92AF39 X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Now everything is ready, this patch permits to choose the number of request to batch. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 32 +++++++++++++++++++++++++++----- include/crypto/engine.h | 2 ++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index e23a398ba330..e9cd9ec9a732 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -114,6 +114,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, } engine->ct = 0; +retry: /* Get the fist request from the engine queue to handle */ backlog = crypto_get_backlog(&engine->queue); async_req = crypto_dequeue_request(&engine->queue); @@ -151,7 +152,10 @@ static void crypto_pump_requests(struct crypto_engine *engine, } engine->cur_reqs[engine->ct].prepared = true; } - engine->ct++; + if (++engine->ct < engine->rmax && engine->queue.qlen > 0) { + spin_lock_irqsave(&engine->queue_lock, flags); + goto retry; + } if (!enginectx->op.do_one_request) { dev_err(engine->dev, "failed to do request\n"); ret = -EINVAL; @@ -393,15 +397,18 @@ 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 + * @rmax: The number of request that the engine can batch in one + * @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 rmax, int qlen) { struct sched_param param = { .sched_priority = MAX_RT_PRIO / 2 }; struct crypto_engine *engine; @@ -421,12 +428,12 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) engine->priv_data = dev; snprintf(engine->name, sizeof(engine->name), "%s-engine", dev_name(dev)); - engine->rmax = 1; + engine->rmax = rmax; engine->cur_reqs = devm_kzalloc(dev, sizeof(struct cur_req) * engine->rmax, GFP_KERNEL); if (!engine->cur_reqs) return NULL; - 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); @@ -443,6 +450,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, 1, CRYPTO_ENGINE_MAX_QLEN); +} EXPORT_SYMBOL_GPL(crypto_engine_alloc_init); /** diff --git a/include/crypto/engine.h b/include/crypto/engine.h index 55d3dbc2498c..fe0dfea8bf07 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -115,6 +115,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 rmax, int qlen); int crypto_engine_exit(struct crypto_engine *engine); #endif /* _CRYPTO_ENGINE_H */ 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: 11332395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8103A92A for ; Tue, 14 Jan 2020 14:02:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EC1C2072B for ; Tue, 14 Jan 2020 14:02:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kdvCMDpS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YwKwklKF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EC1C2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jeiWGpblCjI8y2Kco6Qo0LguiF83dVdlaB2NTK5eEgo=; b=kdvCMDpSEPfk4E FtvxCCi5HRvJjDC5hJ+FSvznJnHm+S3oEPmRSIa2knslQNJ59gzk71/lVLxNUVToAfIa+rprbCQcd zSIOKG7t6G9YEt6JVtPSLrnAqe//1816LJJxHE4NF3mf+EvVC6xo19MuRc6/8JEJmszebRjvGtsT/ qrJENWuEMKY7e8BBjdAF9g6Wi6a604ig6bf+zz0NfiJqCYZdm1v5qu8j6UiE8PR2DzqE/pWfiJ9We uk0wm9pf9C2ptu7PBg6P0cbY7iNyXdp9OsfKgYDdJa+LO0tsxum9Kb8mBQysVsaoIJAAxUmY5slSz 63O+n5M4KZEcJWtqvMCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMmP-0002wt-8f; Tue, 14 Jan 2020 14:02:49 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irMjn-00088f-IY for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 14:00:14 +0000 Received: by mail-wm1-x344.google.com with SMTP id p17so13872681wmb.0 for ; Tue, 14 Jan 2020 06:00:07 -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=mBgCY7BR+HKdwv+edOCQQJIKCa44uAXmF7lOcCBdDBsmEjfDobU4zlcIcjuYWpNYmt VgIFMkxR6PfbdXrAVM28Uqsy5ONR0OXuPPnyPBadIqaIaeH1WqgXljhbPCNGMw8hxlA8 ldFwdXneW4SWNaawqz/gdOvkX54ZohJzObKK1Vsa0StvU48eKyBgLabZpMjcevOrWSrk IwDMRusNQREYL2wKombj2HAEdB+MU+wlZLZsU4EkQHbf5yUcQovnORVcKiAk4H9a7GVJ j8da4gyfFk1saRKQk6jsUISMhiJH0QJJ9UcNRw2sjn/ijnDcGvuihrzh0Mzych55oXLN bVug== X-Gm-Message-State: APjAAAX1PKUi+0kJRhUR1BJTxut1FGZtw5euahiBwjypQCyIXkQ+t3TC fL6AeYRMZYjY1kGKPreubB4= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_060007_862213_48B31613 X-CRM114-Status: GOOD ( 14.92 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (clabbe.montjoie[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 };