Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4683347ybl; Wed, 22 Jan 2020 02:47:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwcHhnNQqO+8naaDwytKo7IYAfAHQayhsqMz41zdnJEVPrhwO/wQ4Vi4kGQznSn0xabBw/E X-Received: by 2002:a05:6830:2099:: with SMTP id y25mr6488113otq.87.1579690036337; Wed, 22 Jan 2020 02:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579690036; cv=none; d=google.com; s=arc-20160816; b=q9eugEjGlTrYPH8Zv5QBYr3boC4JbR2DPeh0jfGPhPxlsyDoFPuzCQxqHoJM7dssuf hCda47gTasKvPe7iUW4vvqaSTNf+eKNTwk1ASNEwvcpl6CQAiGOoX5lkT8krZbBhItu6 x6Un/w1dk3lY9g9qJagdoo23WrEtIOZWXm1OoLwzcqB/ypp4VzbLfkjck1RfaiEqIOu/ Ohi+lBG6XM9nleZYCEqO1Ml2hC7dqs53c+DM18IyjFo4zYeQi4qqlYl/vX1+GMSC4/h9 i9iVGPrKkmcvgihXMZU+lIxZwAi8nI+41kerxwPcZxp3k4Qt3HFORh1sblx/KG6sSfl1 VU2g== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DFk6HyWuJiVLCGeJdqAeRNr747mUSUy7WV52UkfDFzg=; b=0sjqkV7L8ln0rvtSTRP06rYme0d8Y7Z06tSp/BRhn3n2CQtlOiCT6yBq9ksykwCaH6 TLPdZAMUro+bcanwN++NSNllcdQDzF5lwa+d/3Rn7AGQ0gEUOebqTpyqEsuSRNzjH9N4 U6F+Zh5vBfPnHVYi5AaaiGGvuUSnAV+Cmbci/UOCkpXffgGnNwZeh4Jaum+sVuUQFnZ1 ns59GRIbJBPoYyEclZCvwqr98F1ocbgld+merLG2bEkIp1XusmloJAuJGiKn5tXiQeun vpTE0NuKjr7dSO8IqOuzKuUOLKZosAVc4kuOei01vYVZbBiinyj58MsLl9HZJWByckDk 4Tnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nh4V8kN1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t82si21476129oif.45.2020.01.22.02.47.05; Wed, 22 Jan 2020 02:47:16 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nh4V8kN1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729855AbgAVKqX (ORCPT + 99 others); Wed, 22 Jan 2020 05:46:23 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34883 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbgAVKpn (ORCPT ); Wed, 22 Jan 2020 05:45:43 -0500 Received: by mail-wr1-f68.google.com with SMTP id g17so6740823wro.2; Wed, 22 Jan 2020 02:45:42 -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=DFk6HyWuJiVLCGeJdqAeRNr747mUSUy7WV52UkfDFzg=; b=nh4V8kN1DQ0V+SZNyGIFD0vsfENzTl54nbI5wPlIaAHa99ct2k7P5oTEzomt8FFx0h sTf6JhdhBFGWOb3u8FHFZTRcPYLq20x6neKn5/J81l56XH5OVnxwWHjG8R6gMhTrvtrb 6WaSVFEc7Ecm+ArWphMtPpplt47QAHfU156O9Lzo4GmcoFKbBGU5CtdMXgzCmYljPsU9 GxQXzTeMqHBtHDCD7tHT5NAeLU1ehq9eVOFZnwBF4n8mZJYSGTW4H8xjooVws0/5coIN UHd5a9MFg2IMtB68T8iFHhbjGZzKWECSnhPY4hUB47d9KBkI1/fpfk34zguUbjpGAqun IZjQ== 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=DFk6HyWuJiVLCGeJdqAeRNr747mUSUy7WV52UkfDFzg=; b=r2Tq+Nv7PyhhRjBpL6uIk2Z3fnNz4gNibK46pGyYpZHgLH5JpfgMZHalwcU7ZEpQOW 1I9wq2Ux4ZpQz3xBh7pf3EYaYAZvGXVNiBEaBwxMdvCgjZDb+0JQS6rw0Z6rDta3Fpya WMElVihhvFGbWPoivNVOzW2fVazvCWAknSBOsL7rFWOf/H31V1SQjcE79mBVUPy20CCT 7SJdIdr1E76xjNxdngt/0lAIGWpbD3+u7NeBmrbArRAtOBbL7spGW81QoRQ7gzv/nI8p shi4+UCoA9Bi7b3Eu71lHqxrp8um1osGdOfIlnBDXMR+IJ5zzhfwPxKZX4b5XmmHq3gR bAJQ== X-Gm-Message-State: APjAAAVzX1XF/gdGVTPLAcAUIz35B2Ew8dpb9/jaoivr6f6/Jdc22oRK bbHtciZHagPf0guuKEjNo3X5Hx75 X-Received: by 2002:adf:f8c4:: with SMTP id f4mr9951911wrq.243.1579689942098; Wed, 22 Jan 2020 02:45:42 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:41 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 2/9] crypto: engine: get rid of cur_req_prepared Date: Wed, 22 Jan 2020 11:45:21 +0100 Message-Id: <20200122104528.30084-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Since we want cryptoengine to support handling more than one request, we need to remove cur_req_prepared. It is used only to choose if we need to unprepare() in crypto_finalize_request(). This choice is needed only in case of error, so let's handle error without crypto_finalize_request. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 17 ++++++++++------- include/crypto/engine.h | 2 -- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index feb0d82dd454..dfcb00e92e09 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -36,7 +36,7 @@ static void crypto_finalize_request(struct crypto_engine *engine, if (finalize_cur_req) { enginectx = crypto_tfm_ctx(req->tfm); - if (engine->cur_req_prepared && + if (enginectx->op.prepare_request && enginectx->op.unprepare_request) { ret = enginectx->op.unprepare_request(engine, req); if (ret) @@ -44,7 +44,6 @@ static void crypto_finalize_request(struct crypto_engine *engine, } spin_lock_irqsave(&engine->queue_lock, flags); engine->cur_req = NULL; - engine->cur_req_prepared = false; spin_unlock_irqrestore(&engine->queue_lock, flags); } @@ -118,7 +117,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, ret = engine->prepare_crypt_hardware(engine); if (ret) { dev_err(engine->dev, "failed to prepare crypt hardware\n"); - goto req_err; + goto req_err2; } } @@ -129,9 +128,8 @@ static void crypto_pump_requests(struct crypto_engine *engine, if (ret) { dev_err(engine->dev, "failed to prepare request: %d\n", ret); - goto req_err; + goto req_err2; } - engine->cur_req_prepared = true; } if (!enginectx->op.do_one_request) { dev_err(engine->dev, "failed to do request\n"); @@ -146,7 +144,13 @@ static void crypto_pump_requests(struct crypto_engine *engine, return; req_err: - crypto_finalize_request(engine, async_req, ret); + if (enginectx->op.unprepare_request) { + ret = enginectx->op.unprepare_request(engine, async_req); + if (ret) + dev_err(engine->dev, "failed to unprepare request\n"); + } +req_err2: + async_req->complete(async_req, ret); return; out: @@ -398,7 +402,6 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) engine->rt = rt; engine->running = false; engine->busy = false; - engine->cur_req_prepared = false; engine->priv_data = dev; snprintf(engine->name, sizeof(engine->name), "%s-engine", dev_name(dev)); diff --git a/include/crypto/engine.h b/include/crypto/engine.h index 7e7cbd9ca3b5..4d8a2602c9ed 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -23,7 +23,6 @@ * @name: the engine name * @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 @@ -43,7 +42,6 @@ struct crypto_engine { char name[ENGINE_NAME_LEN]; bool busy; bool running; - bool cur_req_prepared; struct list_head list; spinlock_t queue_lock; -- 2.24.1