Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3799993rwl; Mon, 10 Apr 2023 00:57:59 -0700 (PDT) X-Google-Smtp-Source: AKy350aMhyeJV6EZ49r6KEmW1hwbZUG7kcvyxL6l41Ux1XjU4QD578dRNRxJpNYOSxULnnlys0nj X-Received: by 2002:a05:6a00:3487:b0:5e2:3086:f977 with SMTP id cp7-20020a056a00348700b005e23086f977mr9598981pfb.2.1681113479585; Mon, 10 Apr 2023 00:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681113479; cv=none; d=google.com; s=arc-20160816; b=KiELF1q7nDHbTTu4PfJCS1DiAhU9TXLXs4CAiBiZi7HlHO+bPP6uya0rTeym3uemp/ I09GpTF/BZ9s1Z5WsNpQG00xB7ZPdu4gBH8Um0ubxO3dN2rAA97Cc/ikgRV08nyWKYF2 oyx4Rc0XYq5eyq7/yU096OqpCCOAjQSvWGEeVvsFrgD/QPT5ladElYuwyI/cK6Z3nSPa tNfjlyI9fyHK9t7cvcggpI0q618UWFFdQJI8ggPECbsaKr17hXcKS78NMnOz1366Bt2q P1Jexo6sm809VaFXdfHZe/wKf9s43e8gki8dXTzhexwQmiHs8kyd5hnIPWosOlKhx4oq f2Gw== 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=xAcxcXEvwWTxGW07npNZm3VmwhbfqWYNnq2oUlWpSPc=; b=W/LVrDpLO34IcuCIj8oBgkHMRXhzduHIODwdl38j2KmPXji5RXwL505vX4GhRKnqOp lYWyisDQWIThPVOFICleghHswn8B7ASCUJO0HLlpOnd25tn38t3U8Spf1lzGGsCAzNWd 32gwsUBIXq62huxPIKYp1L9RecKuQG0BkiQNv+Uger38hGeI4JdIhtnuYaWgY9I8DMr9 +mUcvkXvs2fluYCsmhWbb3dPRIC6SK0Xziv7eB3eW2O55NRzudLixXUNJq4eBS1PHx7C pI9Ph6wTQK8biDqkOijuJtfCsB3WejlPPTcMyPLHjUzLZoyex9KdEqdeMnH3Lt3iyXZm DWpw== 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 37-20020a630f65000000b0050c0549c4dbsi10281711pgp.702.2023.04.10.00.57.46; Mon, 10 Apr 2023 00:57:59 -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 S229706AbjDJHv2 (ORCPT + 99 others); Mon, 10 Apr 2023 03:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjDJHv2 (ORCPT ); Mon, 10 Apr 2023 03:51:28 -0400 Received: from 167-179-156-38.a7b39c.syd.nbn.aussiebb.net (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4A63C0A; Mon, 10 Apr 2023 00:51:25 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1plmIR-00EEnN-4P; Mon, 10 Apr 2023 15:50:40 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Mon, 10 Apr 2023 15:50:39 +0800 Date: Mon, 10 Apr 2023 15:50:39 +0800 From: Herbert Xu To: Jia Jie Ho Cc: "David S . Miller" , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Emil Renner Berthing , Conor Dooley , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v4 4/4] crypto: starfive - Add hash and HMAC support Message-ID: References: <20230410073752.39506-1-jiajie.ho@starfivetech.com> <20230410073752.39506-5-jiajie.ho@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230410073752.39506-5-jiajie.ho@starfivetech.com> X-Spam-Status: No, score=4.3 required=5.0 tests=HELO_DYNAMIC_IPADDR2, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,TVD_RCVD_IP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: **** 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 Mon, Apr 10, 2023 at 03:37:52PM +0800, Jia Jie Ho wrote: > > +static void starfive_hash_start(void *param) > +{ > + struct starfive_cryp_ctx *ctx = param; > + struct starfive_cryp_request_ctx *rctx = ctx->rctx; > + struct starfive_cryp_dev *cryp = ctx->cryp; > + union starfive_alg_cr alg_cr; > + union starfive_hash_csr csr; > + > + dma_unmap_sg(cryp->dev, rctx->in_sg, rctx->in_sg_len, DMA_TO_DEVICE); > + > + alg_cr.v = 0; > + alg_cr.clear = 1; > + > + writel(alg_cr.v, cryp->base + STARFIVE_ALG_CR_OFFSET); > + > + csr.v = readl(cryp->base + STARFIVE_HASH_SHACSR); > + csr.firstb = 0; > + csr.final = 1; > + > + reinit_completion(&cryp->hash_done); > + writel(~STARFIVE_IE_MASK_HASH_DONE, cryp->base + STARFIVE_IE_MASK_OFFSET); > + writel(csr.v, cryp->base + STARFIVE_HASH_SHACSR); > +} Why are you still using a completion? The callback function should invoke the crypto_engine finalize_request call directly. > +static int starfive_hash_xmit(struct starfive_cryp_ctx *ctx) > +{ > + struct starfive_cryp_request_ctx *rctx = ctx->rctx; > + struct starfive_cryp_dev *cryp = ctx->cryp; > + int ret; > + > + rctx->csr.hash.v = 0; > + rctx->csr.hash.reset = 1; > + writel(rctx->csr.hash.v, cryp->base + STARFIVE_HASH_SHACSR); > + > + if (starfive_hash_wait_busy(ctx)) > + return dev_err_probe(cryp->dev, -ETIMEDOUT, "Error resetting engine.\n"); > + > + rctx->csr.hash.v = 0; > + rctx->csr.hash.mode = ctx->hash_mode & STARFIVE_HASH_MODE_MASK; > + rctx->csr.hash.ie = 1; > + > + if (ctx->hash_mode & STARFIVE_HASH_HMAC_FLAGS) { > + ret = starfive_hash_hmac_key(ctx); > + if (ret) > + return ret; > + } else { > + rctx->csr.hash.start = 1; > + rctx->csr.hash.firstb = 1; > + writel(rctx->csr.hash.v, cryp->base + STARFIVE_HASH_SHACSR); > + } > + > + ret = starfive_hash_xmit_dma(ctx); > + if (ret) > + return ret; > + > + if (!wait_for_completion_timeout(&cryp->hash_done, msecs_to_jiffies(10000))) > + return dev_err_probe(cryp->dev, -ETIMEDOUT, "Timeout waiting for hash done\n"); There is no point in waiting for completion. Just return 0 and you're done. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt