Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp658407ybl; Wed, 11 Dec 2019 05:35:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwU2heJD7t5QaS4moe93AKvEL6e+rfn80pIebwwwFj31KA7URuUrf+KbDA2P7SzIIPdQfxF X-Received: by 2002:aca:fd58:: with SMTP id b85mr2882824oii.106.1576071337944; Wed, 11 Dec 2019 05:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576071337; cv=none; d=google.com; s=arc-20160816; b=p6uGLyMNxRsWrslYV4KfyjBZDJksSUQDYe1EN5g+H1t8Z1ncUn2XYG5HrmbolIcfmR 9VLd3++kGAwqXl+2TygLc0a4uqolqTXhqfc+3rcuutMHslWxW+rf0KRmct5SGMHUORdj jH/eowNu0PuqPWyZ7pMxF0TQv3EV9kbcxs1dJigJg0zM7PCkXp7gq+iA7PF0oYMN6F5X ZW2ILgi8pq+O9jflXNzBcbMpYOWibbagQ+tbSTtbCHRfciBOLsxkzcEdTehjW1hkmF0Y DQQJ6owkFYpyOAEIKiPcOdey855Ec17UuspIvvq7YhJ9enQQ6lxOVY+vxzWjcPU1NkCX d9rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=SYmq0WctmPV1swWpGBzEpWP8+g1BgxdZsrRR89lZaGQ=; b=c5VPUP9Mkdvolyj2Aq85LDwWtiHi/A8ryWbhWNi1pwwPLsQbeTcOX45qNejr0aHQDt BIXiRUkIUGkTSMVnJDVfCMfYMuIVl5eBXQA5CcPriY0GcOoSOseutuUjYYnBwUcKHSaH qjhxEmpales8eiaajc+QrPrSXe20HKogbhEw6A5B2g+mi8edv2d2mRFQamrPPduhxHlQ EgWJSvxsj2dy+oaiJieqXuBvH69ME+eYZk1arLP2R8IGihg7tSnN1AzZZzNQ2Ay70Yjl GRCICV9bzjSRLvqDKJBO3MycksXKkPx2/BInrWh+V2L0JNjptu9IJBIEY9Y0wECgbvIR YrpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si1146739oib.192.2019.12.11.05.35.18; Wed, 11 Dec 2019 05:35:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727477AbfLKNdt (ORCPT + 99 others); Wed, 11 Dec 2019 08:33:49 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37251 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729438AbfLKNdr (ORCPT ); Wed, 11 Dec 2019 08:33:47 -0500 Received: from erbse.hi.pengutronix.de ([2001:67c:670:100:9e5c:8eff:fece:cdfe]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1if27d-0001zF-83; Wed, 11 Dec 2019 14:33:45 +0100 Subject: Re: [PATCH 08/12] crypto: caam - support crypto_engine framework for SKCIPHER algorithms To: Iuliana Prodan , Herbert Xu , Horia Geanta , Aymen Sghaier Cc: "David S. Miller" , Tom Lendacky , Gary Hook , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , "kernel@pengutronix.de" References: <1574029845-22796-1-git-send-email-iuliana.prodan@nxp.com> <1574029845-22796-9-git-send-email-iuliana.prodan@nxp.com> From: Bastian Krause Message-ID: <56aa6894-6df9-1ade-6c22-cccb99172d2a@pengutronix.de> Date: Wed, 11 Dec 2019 14:33:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:9e5c:8eff:fece:cdfe X-SA-Exim-Mail-From: bst@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi, On 12/11/19 1:20 PM, Iuliana Prodan wrote: > On 12/10/2019 5:27 PM, Bastian Krause wrote: >> On 11/17/19 11:30 PM, Iuliana Prodan wrote: >>> Integrate crypto_engine into CAAM, to make use of the engine queue. >>> Add support for SKCIPHER algorithms. >>> >>> This is intended to be used for CAAM backlogging support. >>> The requests, with backlog flag (e.g. from dm-crypt) will be listed >>> into crypto-engine queue and processed by CAAM when free. >>> This changes the return codes for caam_jr_enqueue: >>> -EINPROGRESS if OK, -EBUSY if request is backlogged, >>> -ENOSPC if the queue is full, -EIO if it cannot map the caller's >>> descriptor, -EINVAL if crypto_tfm not supported by crypto_engine. >>> >>> Signed-off-by: Iuliana Prodan >>> Signed-off-by: Franck LENORMAND >>> Reviewed-by: Horia Geant? >>> --- >>> drivers/crypto/caam/Kconfig | 1 + >>> drivers/crypto/caam/caamalg.c | 84 +++++++++++++++++++++++++++++++++++-------- >>> drivers/crypto/caam/intern.h | 2 ++ >>> drivers/crypto/caam/jr.c | 51 ++++++++++++++++++++++++-- >>> 4 files changed, 122 insertions(+), 16 deletions(-) >>> >>> diff --git a/drivers/crypto/caam/Kconfig b/drivers/crypto/caam/Kconfig >>> index 87053e4..1930e19 100644 >>> --- a/drivers/crypto/caam/Kconfig >>> +++ b/drivers/crypto/caam/Kconfig >>> @@ -33,6 +33,7 @@ config CRYPTO_DEV_FSL_CAAM_DEBUG >>> > ... >>> >>> +static int skcipher_do_one_req(struct crypto_engine *engine, void *areq) >>> +{ >>> + struct skcipher_request *req = skcipher_request_cast(areq); >>> + struct caam_ctx *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req)); >>> + struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req); >>> + struct caam_jr_request_entry *jrentry; >>> + u32 *desc = rctx->edesc->hw_desc; >>> + int ret; >>> + >>> + jrentry = &rctx->edesc->jrentry; >>> + jrentry->bklog = true; >>> + >>> + ret = caam_jr_enqueue_no_bklog(ctx->jrdev, desc, >>> + rctx->skcipher_op_done, jrentry); >>> + >>> + if (ret != -EINPROGRESS) { >>> + skcipher_unmap(ctx->jrdev, rctx->edesc, req); >>> + kfree(rctx->edesc); >>> + } else { >>> + ret = 0; >>> + } >>> + >>> + return ret; >> >> While testing this on a i.MX6 DualLite I see -ENOSPC being returned here >> after a couple of GiB of data being encrypted (via dm-crypt with LUKS >> extension). This results in these messages from crypto_engine: >> >> caam_jr 2101000.jr0: Failed to do one request from queue: -28 >> >> And later.. >> >> Buffer I/O error on device dm-0, logical block 59392 >> JBD2: Detected IO errors while flushing file data on dm-0-8 >> >> Reproducible with something like this: >> >> echo "testkey" | cryptsetup luksFormat \ >> --cipher=aes-cbc-essiv:sha256 \ >> --key-file=- \ >> --key-size=256 \ >> /dev/mmcblk1p8 >> echo "testkey" | cryptsetup open \ >> --type luks \ >> --key-file=- \ >> /dev/mmcblk1p8 data >> >> mkfs.ext4 /dev/mapper/data >> mount /dev/mapper/data /mnt >> >> set -x >> while [ true ]; do >> dd if=/dev/zero of=/mnt/big_file bs=1M count=1024 >> sync >> done >> >> Any ideas? >> > > Thanks for testing this! Sure :) > I reproduced this issue on imx6dl, _but_ only with the bypass sw queue > patch. It only reproduces on some targets, e.g. on imx7d I don't get the > -ENOSPC error. So, I believe there is a timing issue between > crypto-engine and CAAM driver, both sending requests to CAAM hw. > I'm debugging this and I'll let you know my findings. I can't even use this without the "crypto: caam - bypass crypto-engine sw queue, if empty". The mkfs.ext4 command does not even finish and I see hung task warnings. Am I holding it wrong? Regards, Bastian -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |