From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62DDE606A33E for ; Wed, 2 Dec 2026 10:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=k0CnFM2K; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KRLBgDnR DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=i/s0ylt807oJ4YAvbUXP87dV3zv+g9cnmQlMSwH4oXE=; b=k0CnFM2KHRymh9c1g9NZs4M9Oy mtjgz/1e7O7nnTkfFW+zjK2qEEK3ktiyp2Das48k3I1x2lRXPXaAUNb9vhBrkkjq0J6owBm59F+sh lT3BKiWi6T/8ZxsJbGlMZHceIcBKZsGtdpSU8gqHik4GuS+E6FM+Go3OCbQZsNxrfEQACXT94cQpy m7RQUGdendk8QWdtUdiCcLDiSEZ7yK7aFkuhps8v+bA/HPSy9mxv3lEe/FmHMxxND2FMCEH7w/ccA id4lu39OyHKZCk0H0+PXvYi5aALj1+hXkP3qkzQS2cRziNsYemoFId/rBB/uKQfpQKR2T5I50B34N YufBiStA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYhFx-0000000B1nn-2Otd; Wed, 02 Dec 2026 10:08:09 +0000 Received: from mail-wr1-f49.google.com ([209.85.221.49]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYhFq-0000000B1UQ-0GaV for linux-amlogic@lists.infradead.org; Wed, 02 Dec 2026 10:08:05 +0000 Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4a358881793so6831403f8f.0 for ; Wed, 02 Dec 2026 02:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796206079; x=1796810879; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=H6JuaHlgOFaTRvm4ik6+FqVcECQ77XVTUFxb5teXNtM=; b=KRLBgDnRgs8bfmpLL7Ayof57Gp7TbD7AZLmHoknR2bHg5S9b73mGZV5OwsOKYWjN++ 68mCDVQ2REmQfMSIIW5Y7VfZcT/8PWBxUMR0jCf4J5lKjTM7rx6xHMFrfsct4t3PRazA FCBUjXBmIQLDT5NzORCQ0hCwGn8EFYTKarRWtbnovq5Np0DX22QadMM5qAfGJaLr8Dtz HuwnIBZELSHE0cQLY9hfjNqhSoxYpKJb29yrb5e9oISvSyfpOnBv+0TnMHxlVYugGJZV /edkSMTUUf3UNf2G6DuzdV6rdr/ZeUBVgQd+0SNw4Asxwy0hK1Nb0Qu409lqxtd6BMEl IhZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796206079; x=1796810879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=H6JuaHlgOFaTRvm4ik6+FqVcECQ77XVTUFxb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f p3kBzQuPGT3siVy8Gy1L0mZ7a3nj69KnD7Dt1IC0ud1mt19JLkp+Jl9AfUxHlXwfBdkOsh4yHmw Q5F8VCtYymCbcfD56wNcY6gcPv5xUk8iise3OmO65HkFp6onOtXg7NFdkFPXkeUeAMzxvnkxXBR heTY+TTYmnR2cTMqS76gHL9ce2LGBoGzR0fnPgKgglRFCA== X-Received: by 2002:a05:6000:470c:b0:4a6:ad0e:6cd4 with SMTP id ffacd0b85a97d-4abb759dd4dmr74368529f8f.48.1796206079277; Wed, 02 Dec 2026 02:07:59 -0800 (PST) Received: from localhost.localdomain ([79.117.198.103]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a67fe75sm87617495f8f.24.2026.12.02.02.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 02:07:57 -0800 (PST) From: Jose Nieto To: Corentin Labbe , Herbert Xu , "David S . Miller" Cc: linux-crypto@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jose Nieto Subject: [PATCH v15 19/35] crypto: amlogic: hasher: add one-shot digest path Date: Wed, 2 Dec 2026 11:06:58 +0100 Message-ID: <20261202100714.115460-20-jnieto.alaber@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261202100714.115460-1-jnieto.alaber@gmail.com> References: <20261202100714.115460-1-jnieto.alaber@gmail.com> X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_020802_463954_4E6B9A59 X-CRM114-Status: GOOD ( 19.73 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Implement the ahash ->digest callback so one-shot SHA requests are sent as a single engine transfer instead of the init/update/final sequence, and skip the spurious trailing block for digest requests. Also unregister the hasher on device removal and lower the "hasher not supported" message to dev_dbg. Signed-off-by: Jose Nieto --- drivers/crypto/amlogic/amlogic-gxl-core.c | 9 ++++--- drivers/crypto/amlogic/amlogic-gxl-hasher.c | 29 +++++++++++++++++++-- drivers/crypto/amlogic/amlogic-gxl.h | 5 +++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 3a6bac10bb04..38b9645386ae 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -237,6 +237,10 @@ static int meson_crypto_probe(struct platform_device *pdev) if (err) goto error_flow; + err = meson_hasher_register(mc); + if (err) + goto error_hasher; + if (IS_ENABLED(CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG)) { struct dentry *dbgfs_dir; @@ -247,10 +251,6 @@ static int meson_crypto_probe(struct platform_device *pdev) #endif } - err = meson_hasher_register(mc); - if (err) - goto error_hasher; - return 0; error_hasher: @@ -269,6 +269,7 @@ static void meson_crypto_remove(struct platform_device *pdev) debugfs_remove_recursive(mc->dbgfs_dir); #endif + meson_hasher_unregister(mc); meson_cipher_unregister(mc); meson_free_chanlist(mc, mc->flow_cnt - 1); diff --git a/drivers/crypto/amlogic/amlogic-gxl-hasher.c b/drivers/crypto/amlogic/amlogic-gxl-hasher.c index c83739ec3456..978cdcd8a4f9 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-hasher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-hasher.c @@ -51,6 +51,25 @@ static int meson_sha_final(struct ahash_request *req) return crypto_transfer_hash_request_to_engine(engine, req); } +static int meson_sha_digest(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx_dma(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct crypto_engine *engine; + + memset(rctx, 0, sizeof(struct meson_hasher_req_ctx)); + + rctx->flow = meson_get_engine_number(tctx->mc); + rctx->begin_req = true; + rctx->final_req = true; + rctx->digest_req = true; + + engine = tctx->mc->chanlist[rctx->flow].engine; + + return crypto_transfer_hash_request_to_engine(engine, req); +} + static int meson_hasher_req_map(struct ahash_request *req) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); @@ -251,7 +270,7 @@ static int meson_hasher_do_one_request(struct crypto_engine *engine, void *areq) struct hasher_ctx ctx = { .tloffset = 0, .src_offset = 0, - .nbytes = rctx->final_req ? 0 : req->nbytes, + .nbytes = (rctx->final_req && !rctx->digest_req) ? 0 : req->nbytes, .src_sg = req->src, .areq = areq, }; @@ -310,6 +329,9 @@ static int meson_hasher_do_one_request(struct crypto_engine *engine, void *areq) if (!ctx.todo && ctx.nbytes) continue; + if (!ctx.todo && rctx->final_req && rctx->partial_size) + continue; + if (!ctx.todo && !rctx->final_req && !ctx.tloffset) continue; @@ -393,6 +415,7 @@ static struct meson_alg_template mc_algs[] = { .init = meson_sha_init, .update = meson_sha_update, .final = meson_sha_final, + .digest = meson_sha_digest, .export = meson_hasher_export, .import = meson_hasher_import, }, @@ -421,6 +444,7 @@ static struct meson_alg_template mc_algs[] = { .init = meson_sha_init, .update = meson_sha_update, .final = meson_sha_final, + .digest = meson_sha_digest, .export = meson_hasher_export, .import = meson_hasher_import, }, @@ -449,6 +473,7 @@ static struct meson_alg_template mc_algs[] = { .init = meson_sha_init, .update = meson_sha_update, .final = meson_sha_final, + .digest = meson_sha_digest, .export = meson_hasher_export, .import = meson_hasher_import, }, @@ -463,7 +488,7 @@ int meson_hasher_register(struct meson_dev *mc) int i; if (!mc->pdata->hasher_supported) { - pr_info("amlogic-gxl-hasher: hasher not supported at current platform"); + dev_dbg(mc->dev, "hasher is not supported on this platform\n"); return 0; } diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index a44290fcf3a0..3f1ce6c05558 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -161,7 +161,9 @@ struct meson_cipher_tfm_ctx { * @partial_size: size of the partial buffer * @partial_addr: physical address of partial buffer * @partial_mapped: indicates is partial buffer currently mapped or not - * @flags: request flags (for example, is this final req or not) + * @begin_req: indicates this is the first request + * @final_req: indicates this is the final request + * @digest_req: indicates a one-shot digest request * @flow: the flow to use for this request */ struct meson_hasher_req_ctx { @@ -173,6 +175,7 @@ struct meson_hasher_req_ctx { bool begin_req; bool final_req; + bool digest_req; int flow; }; -- 2.47.3 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic