From patchwork Wed Jan 13 17:52:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 8027561 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B44FBEEE5 for ; Wed, 13 Jan 2016 17:52:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBED120515 for ; Wed, 13 Jan 2016 17:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C288D20513 for ; Wed, 13 Jan 2016 17:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932463AbcAMRwZ (ORCPT ); Wed, 13 Jan 2016 12:52:25 -0500 Received: from mail-yk0-f194.google.com ([209.85.160.194]:33201 "EHLO mail-yk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932130AbcAMRwZ (ORCPT ); Wed, 13 Jan 2016 12:52:25 -0500 Received: by mail-yk0-f194.google.com with SMTP id y10so29254972ykf.0 for ; Wed, 13 Jan 2016 09:52:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=H8MZtxPe6KXs8zeVoPCK/T7QpWkWYrmk4+Q5pL1lo1M=; b=XZPz3IN8JG9a9UHW+yQP8wm+umA4k/IA0f0VL3dWuEv5J8RiZSEV3oERy4tAza4zyx hVyNHksqRfUah7ZxQYB3xMdAnKfJT/z/5PZwMoATtiWXkopme8Ne0/XMfSziMcqmUD5W v+AG8rq0UbFemqBaXTJuKxd/OwBy2F7CAAgKRGIrmqEE3Nyr/SlVxDPb2i0x5uzMANcD MthBAbFmMNKU4Sp4RMS9qCRsaWmOTfXE9aHoBoz59cjL1EYTib5M68Vf6dPejB2G2BCj jPkg0Sc2JEGTaU6P6/E5OA3IaH8vzK+iScE9+3a3ZdmUs4tXiLRGqi52WzUdmQcjnzFr z4Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=H8MZtxPe6KXs8zeVoPCK/T7QpWkWYrmk4+Q5pL1lo1M=; b=ixSVm4psvFf0wqefxHwUigBk404ohXLWeCe/PjKpQoJl6T7nhk4m2Fupxfs5N0fg8z WDhhwe/LjEO3DDn+XlBA1h9IbFe2JC0rlIyffTaxuHMKCRFvu4bzsDURYI9e4Tz4Z0RV 17bgZpXkirvkXeckwUKdE6gmV07ldgLWILdxkecceCsCc6kEcJHJFspfCndFuJgYPyKp lxmJVfHn0EiRuJZ6cbyl0eJjL3nArneEg6tnCiCka5S8peJDzztxeKFpHIsjCQV2OrM2 yoXvbY0pEjpQpcSHSuPECARMP+pc0QkIiJ0VTwVA6bEIZh9n8LFrwx0cNh0XWP8jFayc 41tg== X-Gm-Message-State: ALoCoQm8Tq5Mq40OnnprrY5swHeIoJ+trzkSNIPmttodSD7Z9vu5UTnKBuuSIXyYFPBl60U4gcFuBi2IlPHZk2+464AYbSM7bw== X-Received: by 10.13.236.129 with SMTP id v123mr72554086ywe.308.1452707544736; Wed, 13 Jan 2016 09:52:24 -0800 (PST) Received: from localhost.localdomain ([187.64.228.119]) by smtp.gmail.com with ESMTPSA id r8sm1495550ywb.20.2016.01.13.09.52.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jan 2016 09:52:24 -0800 (PST) From: Fabio Estevam To: herbert@gondor.apana.org.au Cc: marex@denx.de, s.trumtrar@pengutronix.de, thomas.lendacky@amd.com, linux@arm.linux.org.uk, linux-crypto@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Date: Wed, 13 Jan 2016 15:52:02 -0200 Message-Id: <1452707524-7695-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam Based on commit 434b421241f2d0 ("crypto: caam - avoid needlessly saving and restoring caam_hash_ctx") from Russell King. When exporting and importing the hash state, we will only export and import into hashes which share the same struct crypto_ahash pointer. (See hash_accept->af_alg_accept->hash_accept_parent.) This means that saving the sahara_ctx structure on export, and restoring it on import is a waste of resources. So, remove this code. Signed-off-by: Fabio Estevam --- Changes since v1: - Newly introduced in this series drivers/crypto/sahara.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index f68c24a..53c7a9a 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -1155,26 +1155,18 @@ static int sahara_sha_digest(struct ahash_request *req) static int sahara_sha_export(struct ahash_request *req, void *out) { - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); - struct sahara_ctx *ctx = crypto_ahash_ctx(ahash); struct sahara_sha_reqctx *rctx = ahash_request_ctx(req); - memcpy(out, ctx, sizeof(struct sahara_ctx)); - memcpy(out + sizeof(struct sahara_sha_reqctx), rctx, - sizeof(struct sahara_sha_reqctx)); + memcpy(out, rctx, sizeof(struct sahara_sha_reqctx)); return 0; } static int sahara_sha_import(struct ahash_request *req, const void *in) { - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); - struct sahara_ctx *ctx = crypto_ahash_ctx(ahash); struct sahara_sha_reqctx *rctx = ahash_request_ctx(req); - memcpy(ctx, in, sizeof(struct sahara_ctx)); - memcpy(rctx, in + sizeof(struct sahara_sha_reqctx), - sizeof(struct sahara_sha_reqctx)); + memcpy(rctx, in, sizeof(struct sahara_sha_reqctx)); return 0; }