Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3847683rwl; Mon, 10 Apr 2023 01:55:44 -0700 (PDT) X-Google-Smtp-Source: AKy350YVtJDt+5hf2clbmyfrbllZ7JYokezxg7cX/7Cxe2SWMJV2nlYUBDrdOzq8bQsFECSq5pxy X-Received: by 2002:a05:6a20:6908:b0:df:e8b2:ffb4 with SMTP id q8-20020a056a20690800b000dfe8b2ffb4mr13315054pzj.3.1681116944711; Mon, 10 Apr 2023 01:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681116944; cv=none; d=google.com; s=arc-20160816; b=xAOvAFM5j/y8mrJk9aJE2fDlFvbsnLp3WoNmFSevTKnGzep5ACm0v10VWDUckDccbG Rub94J5yUxeA1UHfolpJFYhSGEfcTt59A7zJ+UC1KWP48VzG1KNMyXJPNgOpPkrkS8E6 AZZHkNv06DZgz+5+EeCXmEfY2yEajMXHz84G9urAMhd2kZvQ5qk3B9b75S7ZARt2OJsm Zg16tFHmb33/Wch/8xOd1Vz/Pq9oQ+qZShnpVpo/2JQmz0ZMr0wTK177vGqTIqq1nWSm Id5p5int0PlyixZK2KvVB/3106PWsiRYoqrRIBbnJuNGjkOwW4Cl0EZvLrbVrPate2MY Kb8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=8l+ijniDgh4h6doYWPEebrLKFI8elQRTr3ZEg1XoPGQ=; b=oEF3vNJ/Yjkd8jjX/vrxgluIvcLLIJmAYbUJDXPkmsI6EeX7vDtCD+fVs/jHZGYXnm +c+GXidR12QgsAFAgR2V6/VcOrx/GjnsgqeT34Bryo9Ua+pICzSmlFxBmTb4vcr84qa0 E+SVtU1xC2TYV32hUq0F2x29PdR4Q/y12zF+QxMfgiLGu6Jd34587ZeEvaJJaKfyTmYx okoMuhl/PDElQGVSq01IFpD/7NYQaV2WBLcVMCE+Q9VBGlxS5bHqYwmi4kcDRqi47u7u vBCPMWliedLxRjq4noFJ51xmH7GFegq1Zr0yZrY02ujgc5sbb10BSGow2AlUV+CLBY5D LUTA== 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 a190-20020a6390c7000000b00502f48d80b6si3941277pge.645.2023.04.10.01.55.27; Mon, 10 Apr 2023 01:55:44 -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 S229700AbjDJIs6 (ORCPT + 99 others); Mon, 10 Apr 2023 04:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjDJIsl (ORCPT ); Mon, 10 Apr 2023 04:48:41 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB82559F3; Mon, 10 Apr 2023 01:47:31 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id BFC6924E0D6; Mon, 10 Apr 2023 16:43:40 +0800 (CST) Received: from EXMBX168.cuchost.com (172.16.6.78) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 10 Apr 2023 16:43:41 +0800 Received: from [192.168.155.128] (202.188.176.82) by EXMBX168.cuchost.com (172.16.6.78) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 10 Apr 2023 16:43:37 +0800 Message-ID: <6df549e9-d0f6-23ca-882f-527c4e40b553@starfivetech.com> Date: Mon, 10 Apr 2023 16:43:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v4 4/4] crypto: starfive - Add hash and HMAC support Content-Language: en-US To: Herbert Xu CC: "David S . Miller" , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Emil Renner Berthing , Conor Dooley , , , , References: <20230410073752.39506-1-jiajie.ho@starfivetech.com> <20230410073752.39506-5-jiajie.ho@starfivetech.com> From: Jia Jie Ho In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [202.188.176.82] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX168.cuchost.com (172.16.6.78) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-2.9 required=5.0 tests=NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 10/4/2023 3:50 pm, Herbert Xu wrote: > 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. > Hi Herbert, The hardware requires user to set a 'final' bit after data transfer completed. This completion is to wait for the interrupt signal from device that the final digest has been populated to the read registers. I'll do the finalize_request call directly in the next version. >> +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. > I'll change this in the next version too. Thanks for taking time reviewing this patch. Best regards, Jia Jie