Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5326309ybv; Tue, 11 Feb 2020 13:34:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxSc60Ca7NMMMN6EidvJhyItSXGnkRBWaV8zn/WOkC/m7HZXzhg6aPoGj+G7L9Xs6fyLlfF X-Received: by 2002:a9d:6b03:: with SMTP id g3mr6796038otp.200.1581456847901; Tue, 11 Feb 2020 13:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581456847; cv=none; d=google.com; s=arc-20160816; b=ZcIBhUGQ8moJT6fyV9JmtByBkQoP5vaoluJcChH2i50nRf/lG4cMWJKXzEVKv3t+I4 R1htLzAgGt/Q+QYaKVF9HtaVJhrDJWBnFJoaPgKfnfFVeImkJqzVZOGlrUD3ALDke2UM IkjFfdtX806acrhh/htLLXzxjtyXEppUSxiswfnq1i9uE5n9gOYcC8ANwqvRgQVuDCeo KllSrEN/2EOVSKate4RH17nzFlmhF1JMm/3VGRHilum9148otru38jxu9ucpvD3HTWAj ENQwn0CqMvhDW0CIYiYhL8sdrgryS/4C55u/KPLwHvjPLZ55Z63DUF/HZQ5LfyARXE2j oACg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=kq+Go6z93ZJ6NNEwVUd/l/1Q8uA944vUuo+g36OOpXE=; b=f/kR6h/tkHyO1Kp3/3ijDxkrYoMSGGpl/DkrJFS56x9fwoz2TRI0xLOBANf1o3ypHS aBSI5QEZ9AVIrgrFHeENArICwZG1paxqmYr3x0yfk611l1Ef0qypVS48VDSMPkp3V9NO 7B6vIcezVm37w6yoQrVwYKuBN4wd+kNqiHRVU8wPuQcG4oCnlxGbkEvaGb9iSzS/iVeY vXNVS2zlzLgKyp6+f3hfXG2uJVI5xUePl0kNGnw4IdwCmcC8f4YPJspAqZDxR10JxaA0 25EA9STDYhDv78OnslTCfuMYK+RxQkOHZ3CqNSZvrj9Uj0BygbhOQdb9FenfwFFxki+H AsQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 17si2785299otu.58.2020.02.11.13.33.56; Tue, 11 Feb 2020 13:34:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731303AbgBKSUr (ORCPT + 99 others); Tue, 11 Feb 2020 13:20:47 -0500 Received: from albert.telenet-ops.be ([195.130.137.90]:60430 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730251AbgBKSTd (ORCPT ); Tue, 11 Feb 2020 13:19:33 -0500 Received: from ramsan ([84.195.182.253]) by albert.telenet-ops.be with bizsmtp id 1WKV2200K5USYZQ06WKVNN; Tue, 11 Feb 2020 19:19:30 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j1a89-0002o8-Mc; Tue, 11 Feb 2020 19:19:29 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j1a89-0003yb-LQ; Tue, 11 Feb 2020 19:19:29 +0100 From: Geert Uytterhoeven To: Gilad Ben-Yossef , Herbert Xu , "David S . Miller" Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-crypto@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed Date: Tue, 11 Feb 2020 19:19:05 +0100 Message-Id: <20200211181928.15178-12-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211181928.15178-1-geert+renesas@glider.be> References: <20200211181928.15178-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the larval digest addresses are not always used in cc_get_plain_hmac_key() and cc_hash_digest(), they are always calculated. Defer their calculations to the points where needed. Signed-off-by: Geert Uytterhoeven --- v2: - New. drivers/crypto/ccree/cc_aead.c | 4 +++- drivers/crypto/ccree/cc_hash.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c index db89144ce6c5e974..d1e7e82b9a40f8ff 100644 --- a/drivers/crypto/ccree/cc_aead.c +++ b/drivers/crypto/ccree/cc_aead.c @@ -417,7 +417,7 @@ static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey, dma_addr_t key_dma_addr = 0; struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm); struct device *dev = drvdata_to_dev(ctx->drvdata); - u32 larval_addr = cc_larval_digest_addr(ctx->drvdata, ctx->auth_mode); + u32 larval_addr; struct cc_crypto_req cc_req = {}; unsigned int blocksize; unsigned int digestsize; @@ -459,6 +459,8 @@ static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey, /* Load hash initial state */ hw_desc_init(&desc[idx]); set_cipher_mode(&desc[idx], hashmode); + larval_addr = cc_larval_digest_addr(ctx->drvdata, + ctx->auth_mode); set_din_sram(&desc[idx], larval_addr, digestsize); set_flow_mode(&desc[idx], S_DIN_to_HASH); set_setup_mode(&desc[idx], SETUP_LOAD_STATE0); diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c index defeb35a16a626ff..cebbe2f08f606bf3 100644 --- a/drivers/crypto/ccree/cc_hash.c +++ b/drivers/crypto/ccree/cc_hash.c @@ -429,8 +429,7 @@ static int cc_hash_digest(struct ahash_request *req) bool is_hmac = ctx->is_hmac; struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; - cc_sram_addr_t larval_digest_addr = - cc_larval_digest_addr(ctx->drvdata, ctx->hash_mode); + cc_sram_addr_t larval_digest_addr; int idx = 0; int rc = 0; gfp_t flags = cc_gfp_flags(&req->base); @@ -472,6 +471,8 @@ static int cc_hash_digest(struct ahash_request *req) set_din_type(&desc[idx], DMA_DLLI, state->digest_buff_dma_addr, ctx->inter_digestsize, NS_BIT); } else { + larval_digest_addr = cc_larval_digest_addr(ctx->drvdata, + ctx->hash_mode); set_din_sram(&desc[idx], larval_digest_addr, ctx->inter_digestsize); } -- 2.17.1