From patchwork Wed Feb 3 12:46:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 8202701 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 62636BEEE5 for ; Wed, 3 Feb 2016 13:20:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89D74201BB for ; Wed, 3 Feb 2016 13:20:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95E6A2010E for ; Wed, 3 Feb 2016 13:20:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751029AbcBCNUL (ORCPT ); Wed, 3 Feb 2016 08:20:11 -0500 Received: from mail-by2on0057.outbound.protection.outlook.com ([207.46.100.57]:22592 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751237AbcBCNUJ (ORCPT ); Wed, 3 Feb 2016 08:20:09 -0500 X-Greylist: delayed 1988 seconds by postgrey-1.27 at vger.kernel.org; Wed, 03 Feb 2016 08:20:09 EST Received: from BY2PR03CA001.namprd03.prod.outlook.com (10.255.93.18) by CY1PR0301MB2060.namprd03.prod.outlook.com (10.164.2.142) with Microsoft SMTP Server (TLS) id 15.1.403.16; Wed, 3 Feb 2016 12:47:02 +0000 Received: from BY2FFO11FD016.protection.gbl (10.255.93.4) by BY2PR03CA001.outlook.office365.com (10.255.93.18) with Microsoft SMTP Server (TLS) id 15.1.396.15 via Frontend Transport; Wed, 3 Feb 2016 12:47:01 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD016.mail.protection.outlook.com (10.1.14.148) with Microsoft SMTP Server (TLS) id 15.1.409.7 via Frontend Transport; Wed, 3 Feb 2016 12:47:01 +0000 Received: from fabio-Latitude-E6410.am.freescale.net (fabio-Latitude-E6410.am.freescale.net [10.29.244.212]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u13CktG7032693; Wed, 3 Feb 2016 05:46:59 -0700 From: Fabio Estevam To: CC: , , , , Fabio Estevam Subject: [PATCH v3 2/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Date: Wed, 3 Feb 2016 10:46:51 -0200 Message-ID: <1454503612-21344-2-git-send-email-fabio.estevam@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454503612-21344-1-git-send-email-fabio.estevam@nxp.com> References: <1454503612-21344-1-git-send-email-fabio.estevam@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 130989772216541364; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD016; 1:xnKYpFFiTMntEiS07o15slgLf/KdooijmVcp1bM/DcY7VWvXH3RLTqA4hSxhnxPilKu1dz380sOjKPqKyuuvXoeQWi49T5LJGKsubz/B2WX7legoMrAvE6LgNxZ17tOx3XjyofEUFz2/qw67BbH+oyU1FiUx5KjWa/bRNopciH0fA+zpgRx9V0OsxEZEJ1QSOP1MSsthkt6zjWgszwwP7ir23or0LKbI4qABAk6PDLz2a8vAh9W9Zkd6Jdta1tHiCZYipw0863i44ttwkFFIZdV+aYNb6UqnqyVQ72ICzDRHXHpgylkD9ZLLYI9G+4QqmZEFDfybgbRDBl+wp83aGdt9iaq95giwCvdi3sp8RZVeVtYRrMnWlfg4MsCc41CTPZDnKNpFxeq4TGIYekyOkhhuwS112ejjtnmN3q3CCVcpCEJ1gbhMGdcELmZq1Fei+Kh23r6soe9c+IpgAiHTsqsDklYj0JpCRxftfQqiVVuT/7Gn654HTEnt6zhsIE0s3Zh/ZW2tddWyevTvCYfGYyKhMPNJSkAsZDR5/oXIu1T9zN9KHI0TRJBFnIJDG1mMU9BKyTmEjQf8z2U1gbrtTQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(36756003)(85426001)(2950100001)(33646002)(19580395003)(19580405001)(1220700001)(47776003)(1096002)(11100500001)(586003)(50466002)(50226001)(6806005)(48376002)(104016004)(5008740100001)(77096005)(50986999)(76176999)(5003940100001)(86362001)(92566002)(229853001)(105606002)(2351001)(4326007)(106466001)(189998001)(2906002)(5001960100002)(87936001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB2060; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: fc5042c5-8d36-41de-15ac-08d32c981c91 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2060; 2:OV0o1vBCCjANpC2cdm/u0ulyM2MSEUTCvmLgSBuemL8US4XJdhGkMh271HYZVMXU7aJj9eMoK32iGLtc4J0W2ZqL2g9xm71wvhBNlK0/hBMDg+b/ZFezc3a/NudL2hhHAvxlbkvQftOQ1ldfTtfymKd7Bl2wKtkBqZp+rR8YizAZVMj+A0/uGm7omyGgdNYc; 3:P6cBPHB09Q7SyZy40ac0LiqwPPz2ieXL6z19buvBKa/NxR57jjCZQlLR3TwusytH5MJhsEvEQZUiflFgBSDQYG5VyHWgqx9TEYO1fjGy25LzBCZhlOxoLXUAKHjWU5R5LhwMJhyZ/GYNB4RD8AApjLwAehpNC92gRXmSMK5T71DFtXbo+H96TUmwr+m+paVbKLYQBZ4gPcnHXlZteopkGJ/NL9tkOYo/iK2vSH3geA8=; 25:QB+JVdt6G2590k1lBIMxOrNS81KslYjz5I5rX3ajEqzt9YKn68z6iCJoZgQKBXOcrpE71gok4A2SmWO1H9n80WtyVS6qebChOF6FacJeAll00inAoOW4SAlr36yyzUN63ioiy98+a3X0savn1/5SdkSM4e9B2fgVFE7jLf9xmIYPfVVOf89HmhSiZzgFtehYLgiewuZtdLH+Fdl1egNOFhQXugGGIzTzfr8VtHHVaODi8o8nHQ58uznYf4Yjhh// X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB2060; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13018025)(5005006)(13024025)(13017025)(13015025)(13023025)(3002001)(10201501046); SRVR:CY1PR0301MB2060; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB2060; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2060; 4:hMvDjL1D/rWgV0Fs1CCbVLuDzJvPyQT5dj3xpHJJEMwZRu0tXezkEj23memWtv5FUtGrpRlJ/9mgCAPd63CdOyHfiUwK0HJ0voEL4IMuXEjGAvpr+q97IkIaHr36zpfYizzDIhxUo2YOvpuViaXibwsL0sL2OppCrZuitXi1XNTt2S2NZBHFRdgUgWXyzB6g708ImKZjbHRxL1cNOfr5ndyKU7LhC3L6WV71iMNvPMhLf7ZPUtzDRx4JFuqLOKmJ3idd+93Hdef3ialdmkCTpTYl1isxoKiO3OnnyouHdoXlbTlGZkwwqGY+o1w+/+i6sw7+MdfKNLO6mzuwGNKm9Pz96bozxB85Gfljbux550EpbkPrAv7vZcK6X5bUrLj+eQuz/yYla5L5fvtmRiX9y5okf/Yzsvmgb6P+CULGPe4Zdu4WO4vrVwwNP/ct6jJEiKPKGsBvJLpnAmcWyrTRE16jU6FACPgm4UfS/ceYkMIrSI6c3xiBufM7FzJCWNE9 X-Forefront-PRVS: 08417837C5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB2060; 23:bdUFpoQJZbthNAoyA0UxyMXUq4X/w0EBkWK5jj0?= =?us-ascii?Q?nA8LAFXPXJOohHTBGWgxQSnClze/OgcbubRCmZ3Xd7UbYQ6WDQv8CPKv0FxP?= =?us-ascii?Q?UdQGYG/yFSTvwumLryBwi+jthw60Ko6/lL/1a0Tdn2KtwCWgdGV9Gemi4G+i?= =?us-ascii?Q?GwApkzJk3JWysc5TeWPywDjqvQpqkMtkDdNoBBFxZA9/NoP3VFSs5eI6LGXV?= =?us-ascii?Q?6cn0SkQhsUIJq3OXPS26PYDBOj/S49QaWQwLAVriXhwAA4KQzZIgMzijMh2a?= =?us-ascii?Q?r2koOumBDLoCixa9jeaSHCmYu9aQlMWmTmS/4hokkBUZ3iqyRlLyYlpSVz/E?= =?us-ascii?Q?ZI2MNTH+PMG5gUERiSgBukoNzxMTGqs6Lsyo32QSRecFPR0xx0jBNcMAx64Y?= =?us-ascii?Q?z2w1aFViWHD9tB7AnSyxueaB17XQURyPy1W9Li7KlLDWGIRpgr2BLRscxIs/?= =?us-ascii?Q?DDy424eRX4R0N5g4m0f+Lak538DO4uGgbuIBWlXqsO7TMMThuPKcDJVHnQoo?= =?us-ascii?Q?9OZi6Bm3vs1BQIcH1PpSp9m0067GWy3Mm4FWVvXoveRiptUTNUJDvMRVdw2s?= =?us-ascii?Q?I2IlZ6F2IBupdcHGyM2n545W+K5uFLLankLDmS1ENn4emR03i2fXjiKS9pVH?= =?us-ascii?Q?DQO1FG03T/XnXzp66mq0jDWcfxula2gksV+Qo4dG900H3ohFAEMQfr9sIAiN?= =?us-ascii?Q?kEKVbG/MJ407sTkF3N9mXrV84agcalvt3/lgKdwr8ZVLSaxxla3ZF5rKG6sx?= =?us-ascii?Q?sws6bPCQkd8COqkq2r+eZ5h9v45TvFnVVtNEsYyn54RVvDogiUPagWaB0o1C?= =?us-ascii?Q?gliFPxaIluD8l03D4CzNIxGGNTFMnD35m5MwMGYwcpet8vURn/U9TydrmwdK?= =?us-ascii?Q?pqqx9XgM8h8lX3nBwpWOkutbrlaF+gEajv7Qu8sLfZ7dAiiimM3uKR1Rnsmg?= =?us-ascii?Q?UukBf7Tf0KaUXCsr6exk2zJhrLSsCLqAIOv17uVbMsPANcSKCfw9z9TMr8pb?= =?us-ascii?Q?1SQwbuQhkSu8NBjw8i+2quumSMJ+WJIw31WcVDPcToyzbTLQouebFVuNmhiS?= =?us-ascii?Q?BX2ghm7I=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2060; 5:GMEX+3Nfz+4EyXwnrkt6/4WZYTgF1DqY5ix2JziJJVC1al2dp8Fz5Z1TnqdTScSoc1SDSoS0vm7XkCZEB6cmT11FVAUjGrKFP8D9QbsTbY7aMAb1fXB0P0p8dJycaais+0KT3mN8hBiCOWjPfOeuwtG9fcY65NXnyao+HqeFzdM=; 24:rwLowf1J5DfjhkTiNNinhxeUolvsAasRCTfSxM7DLgX/a4QkkgxXhPag2eUZcsnLv/tL8cFYzcQztrgFNFRWraM2mSz9UVvNwxyJGfDyqB0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2016 12:47:01.4201 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB2060 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 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 --- 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 7e8147d..9db09b6 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -1162,26 +1162,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; }