Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp409189rwe; Thu, 25 Aug 2022 02:37:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7yyu8yG5UdnsNtQi7IaPAuKo3gURlaWvoqYtnmeaQejeZ8UZPXhkhSy1qnRqp8iH1nrnWA X-Received: by 2002:a17:902:c945:b0:16e:d24d:1b27 with SMTP id i5-20020a170902c94500b0016ed24d1b27mr3107942pla.51.1661420243862; Thu, 25 Aug 2022 02:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661420243; cv=none; d=google.com; s=arc-20160816; b=AqOXogYSHMWFzBD9JMbiIsgogNsxfnfmUhf/hF2Xc6jHGu8giPgAn17XIfFAaPbZQg TwGDKF7UJ+5IEQtCvExBJb91j37mbtuWONDtv2PgL3esgqlE/wwkL+UZekTruAnYQaiL 2mA2wGJfBvTTwXBKn+OsKntTnT/O0jxHJoztGKHGuDItFurs+QPgrTQ3FoWs9oZgUTqI gD46FrjlKqhfDXk0DFUokulE783OAHcleXVx1UpqoTnJ6seo555roHMVdbZRoa2GUhjQ YbyExEA3mF7rjLRTayMcFhDS2UbxOWED2ji1KkKLB8P1yJwnD4RgR63KWB51j+muP9z6 k9Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2kxYWiioWW9IbfxYpXSQT5XHayKfgzkjGSQx2KYP+Lw=; b=Aef6WqbXJPa/4Mny7j6nnL+63kVztiRQmqehuTd6kHYwVf52eh5N6OhL3+KzVJ/ZaZ /cMufiV7PDw66eT2xWU9o7kBROIbQnp3WyU6CNxAeD/7cJp5PFu9xTo9WrA4iipGLCqV Bm1ly81s4PwKjfJ+9QqemTAYe+1ide5+8PHbrmmJnOkc0c9NggZErGNk4IZLwBCSA16u MoOk0IIMGLZJPl068IELcdND6xaA3nN+bQmH5caS/TM9KdZcCriaB6xX4eN4VLTjYLHQ NLfRO3/mTad/RwCWneOVxAjcP54xQ7ilt5SD28oALwoKK7yNJbBNBC2QJDKdBBJKtv0O CfEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz19-20020a170902ef9300b0016ccf06c2aesi885216plb.512.2022.08.25.02.37.02; Thu, 25 Aug 2022 02:37:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240296AbiHYJaj (ORCPT + 99 others); Thu, 25 Aug 2022 05:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240130AbiHYJaV (ORCPT ); Thu, 25 Aug 2022 05:30:21 -0400 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3B845EDF3; Thu, 25 Aug 2022 02:30:18 -0700 (PDT) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1oR9Bh-00Eyep-6u; Thu, 25 Aug 2022 19:30:10 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 25 Aug 2022 17:30:09 +0800 Date: Thu, 25 Aug 2022 17:30:09 +0800 From: Herbert Xu To: Linus Walleij Cc: linux-crypto@vger.kernel.org, "David S . Miller" , phone-devel@vger.kernel.org, Stefan Hansson Subject: Re: [PATCH v3 10/16] crypto: ux500/hash: Implement .export and .import Message-ID: References: <20220816140049.102306-1-linus.walleij@linaro.org> <20220816140049.102306-11-linus.walleij@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220816140049.102306-11-linus.walleij@linaro.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Aug 16, 2022 at 04:00:43PM +0200, Linus Walleij wrote: > > -static int ahash_noimport(struct ahash_request *req, const void *in) > +static int ahash_import(struct ahash_request *req, const void *in) > { > - return -ENOSYS; > + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); > + struct hash_ctx *ctx = crypto_ahash_ctx(tfm); > + struct hash_device_data *device_data = ctx->device; > + struct hash_req_ctx *req_ctx = ahash_request_ctx(req); > + const struct hash_state *hstate = in; > + int hash_mode = HASH_OPER_MODE_HASH; > + u32 cr; > + s32 count; > + > + /* Restore software state */ > + req_ctx->length = hstate->length; > + req_ctx->index = hstate->index; > + req_ctx->dma_mode = hstate->dma_mode; > + req_ctx->hw_initialized = hstate->hw_initialized; > + memcpy(req_ctx->buffer, hstate->buffer, HASH_BLOCK_SIZE); > + > + /* > + * Restore hardware state > + * INIT bit. Set this bit to 0b1 to reset the HASH processor core and > + * prepare the initialize the HASH accelerator to compute the message > + * digest of a new message. > + */ > + HASH_INITIALIZE; > + > + cr = hstate->temp_cr; > + writel_relaxed(cr & HASH_CR_RESUME_MASK, &device_data->base->cr); > + > + if (readl(&device_data->base->cr) & HASH_CR_MODE_MASK) > + hash_mode = HASH_OPER_MODE_HMAC; > + else > + hash_mode = HASH_OPER_MODE_HASH; > + > + for (count = 0; count < HASH_CSR_COUNT; count++) { > + if ((count >= 36) && (hash_mode == HASH_OPER_MODE_HASH)) > + break; > + writel_relaxed(hstate->csr[count], > + &device_data->base->csrx[count]); > + } > + > + writel_relaxed(hstate->csfull, &device_data->base->csfull); > + writel_relaxed(hstate->csdatain, &device_data->base->csdatain); > + writel_relaxed(hstate->str_reg, &device_data->base->str); > + writel_relaxed(cr, &device_data->base->cr); > + > + return 0; > } At any time we may have multiple requests outstanding for a given tfm/device, so I'm a bit worried with the direct writes to hardware in the import function. Normally import just transfers data from the caller into the request object as a "soft" state, while the actual update/final functions will then move them into the hardware state as needed. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt