From patchwork Tue Apr 1 19:23:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63DF0C36010 for ; Tue, 1 Apr 2025 19:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=nierB4LEgce+4kZQOSa3FNbylwS0gDWPVPBM7TYut2U=; b=rZbPvkD8kVssCGR+B7wU2cmqHj 7LqbfhBxbyjDg0I8rj1U7stNtyBgz7jqz+ngqHQ41ydGhxKfrZCgKaFrurRDN1xXVNllejA1AEitN qM9L/8/NX/jXhc2mAcuHGI/TSnNzNBqtQTFFqRmtiQQC46+Sw5kqJeuzARjyh9UX43iM5sQbtqoEf sYQ6CG1fBVwZyHrwwpdppcMfSXHUJfVtmGzKs9YhsDRgNQzccx94DDQb+Rgclbu8PsPunfFF6OTED kpqCx2xoNAkWArA/iW0J1Y86FDUkewimFt0JEJqd69LIwA0PY2xMBa+c7oBz+Ht9FcgvUn171PkGe oS6aNxlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhF8-00000004DP6-3b8t; Tue, 01 Apr 2025 19:25:50 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDK-00000004D4R-3xR0 for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:00 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-39c1efc457bso1193300f8f.2 for ; Tue, 01 Apr 2025 12:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535437; x=1744140237; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nierB4LEgce+4kZQOSa3FNbylwS0gDWPVPBM7TYut2U=; b=GjmwNXJMUSKOGEiyUv5zdwbD24jLuemEhBdglp3XfECwOiFVLiSr4Bvtd3pzVLSd2P 5sxSgQ8L+NY7sY9+2qUlKJrKP55SDGwsuHLEGD+dxC7aJgnDnsJZRH34ouUU0Jj+0YPi QPGLyxkEYcxoDtVNzlm8PT/67a5AKj6RPG1ECoriF0MLMCQYwojKmyjf1lC/hpS1185Z zvJgimpdASBUhwdNecmshAsZsn601ANgKE/g8hF0duRjLgfPV2JIS8OyvO5K/I2z1VtP cYShe+2ckMaOs/2Ue83smrTWLJp5R4FO6tqfQK/3d6ARY/MfoTRad2neuomzV7ptpE+1 u2ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535437; x=1744140237; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nierB4LEgce+4kZQOSa3FNbylwS0gDWPVPBM7TYut2U=; b=a+M0JKLhDnhVVSXuL2PgThl0S1uDxIVO+DLj/Qaafjjir/I/GNq18S1wjTWABB+UZ8 K8qAcmsWFYnSaDbw9xRjhf35RSwk1lpW2Wx5SzzONyvv3zBOTThOfOiAoGvjkbr9uny9 xT/uw3wxsqRnIDRkgcc8A/5hDT1s3bINc5HDGuLEte1ImrfW+5LoRJ58XqOUf9F9O5Sq +8KDAqABkBbj3h/Sa94zn2Bo6EzmYCw5w5fYZ1oMRfe9hN+SIuY2nemY256FuFTxj+Ab 1sK6IBubk0e6Ih6UJZZSgcXJEKB48fKsYv6xOsNteE9hGhCwW2h1k+k4TGXdbC3/GBN6 ejSQ== X-Forwarded-Encrypted: i=1; AJvYcCWp3nqa0qPuaYRxVjZcIsv0W67SohxNkSQffbsGgArG5JVrCNst40T4mLL2vXFtw2thPTGMcGZKiY6fuusERBk1@lists.infradead.org X-Gm-Message-State: AOJu0YzMasxNrJwtNTIDqpWDMwxaVRm5P3Xm3mUxalRPFDbC0SRreEwZ 5/7gmn+0OBM+JUutKusEgs2ZidELfPHqu+d6PVt01SYamuK/tL/G X-Gm-Gg: ASbGnctkbIkojfanKUUG+G2wIdmaQyc6oEpWFH1r/RO02+nuslOT9QgZsrWBR5jAQHq fgdEPaoIjj77usSlM9DOVWGxHSRQocmrgKAvAE1v7b6WJtfoP5q2xxVY8RoC3OmGKDrUhOG/nji Ho9DisQXiOk2VM1EhRHyOpcHUPlwUFZTYbKeimrF6afaBR4gRjYg4M1l2bddyKQfktEmkqHDTN6 6kPGszQ1LhVaISXtWvxiYu/A1I5zVjArnP0PhCB8ZVJKFU173aLZ5s5HTOMmJUJirZbLfYCnFth j5DYn8vd1WPNKCAsbL7/kpIA8zWS3ePIfOgbGEm2O6zFQJe2vKAr4HDjv8Z/MEA4BcBiPWdW X-Google-Smtp-Source: AGHT+IGHyzi31e3692ONFiGCVRk0AOakCuPS3Q8lpPUYekXyBseRhASvcdujfWAcxWGfSdab5h7ydg== X-Received: by 2002:a5d:64c7:0:b0:391:4bfd:6d5 with SMTP id ffacd0b85a97d-39c1211d5c8mr11428784f8f.52.1743535436607; Tue, 01 Apr 2025 12:23:56 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:23:56 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 1/6] crypto: sun8i-ce-hash - fix error handling in sun8i_ce_hash_run() Date: Tue, 1 Apr 2025 22:23:16 +0300 Message-ID: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122358_982325_7ECF30F7 X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rework error handling in sun8i_ce_hash_run() to unmap the dma buffers in case of failure. Currently, the dma unmap functions are not called if the function errors out at various points. Fixes: 56f6d5aee88d1 ("crypto: sun8i-ce - support hash algorithms") Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 6072dd9f390b..3f9d79ea01aa 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -343,9 +343,8 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) u32 common; u64 byte_count; __le32 *bf; - void *buf = NULL; + void *buf, *result; int j, i, todo; - void *result = NULL; u64 bs; int digestsize; dma_addr_t addr_res, addr_pad; @@ -365,14 +364,14 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) buf = kcalloc(2, bs, GFP_KERNEL | GFP_DMA); if (!buf) { err = -ENOMEM; - goto theend; + goto err_out; } bf = (__le32 *)buf; result = kzalloc(digestsize, GFP_KERNEL | GFP_DMA); if (!result) { err = -ENOMEM; - goto theend; + goto err_free_buf; } flow = rctx->flow; @@ -398,7 +397,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) if (nr_sgs <= 0 || nr_sgs > MAX_SG) { dev_err(ce->dev, "Invalid sg number %d\n", nr_sgs); err = -EINVAL; - goto theend; + goto err_free_result; } len = areq->nbytes; @@ -411,7 +410,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) if (len > 0) { dev_err(ce->dev, "remaining len %d\n", len); err = -EINVAL; - goto theend; + goto err_unmap_src; } addr_res = dma_map_single(ce->dev, result, digestsize, DMA_FROM_DEVICE); cet->t_dst[0].addr = desc_addr_val_le32(ce, addr_res); @@ -419,7 +418,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) if (dma_mapping_error(ce->dev, addr_res)) { dev_err(ce->dev, "DMA map dest\n"); err = -EINVAL; - goto theend; + goto err_unmap_src; } byte_count = areq->nbytes; @@ -441,7 +440,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) } if (!j) { err = -EINVAL; - goto theend; + goto err_unmap_result; } addr_pad = dma_map_single(ce->dev, buf, j * 4, DMA_TO_DEVICE); @@ -450,7 +449,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) if (dma_mapping_error(ce->dev, addr_pad)) { dev_err(ce->dev, "DMA error on padding SG\n"); err = -EINVAL; - goto theend; + goto err_unmap_result; } if (ce->variant->hash_t_dlen_in_bits) @@ -463,16 +462,25 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) err = sun8i_ce_run_task(ce, flow, crypto_ahash_alg_name(tfm)); dma_unmap_single(ce->dev, addr_pad, j * 4, DMA_TO_DEVICE); - dma_unmap_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); + +err_unmap_result: dma_unmap_single(ce->dev, addr_res, digestsize, DMA_FROM_DEVICE); + if (!err) + memcpy(areq->result, result, algt->alg.hash.base.halg.digestsize); +err_unmap_src: + dma_unmap_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); - memcpy(areq->result, result, algt->alg.hash.base.halg.digestsize); -theend: - kfree(buf); +err_free_result: kfree(result); + +err_free_buf: + kfree(buf); + +err_out: local_bh_disable(); crypto_finalize_hash_request(engine, breq, err); local_bh_enable(); + return 0; } From patchwork Tue Apr 1 19:23:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48AF4C36010 for ; Tue, 1 Apr 2025 19:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bH5VLtP+seSAMs8ZXZEEtVjeNgw0O+SRzuS1o+Cett4=; b=PM21qUB744xub1WROA521/pb0p rAKBhi/xgI1PGlXVj8OeJ8GqYVAnX/xMOY+a0d4VRHlIeS6kBvHJPNaRQtQjw0ZoSAyVxaDJl3Rvg zdKCg27PHJrVMC/bzk5UPka2mhLduCO2YV3UMiRN3KaGJRTcHIpSdYiWmy/gGag7hqTs80uMB0buR ndXC4AVKe72MidtQr5ulX/Wph95m2zVi3vyfs7lV632q4dKyU2iEJYTeJ4jGvoSb5g+jB2W3qG6xv iMUCFpw1Xhq7IVtoesV5jlxvVv/GrRG+sc5LBFoSYJ0cZyyb4s7sxb0I2FWfFMnWsglwG3GvQqFqx v4g+R+tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhGu-00000004Daq-29v2; Tue, 01 Apr 2025 19:27:40 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDL-00000004D4T-2FmL for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:00 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-39c1efc457bso1193318f8f.2 for ; Tue, 01 Apr 2025 12:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535438; x=1744140238; 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; bh=bH5VLtP+seSAMs8ZXZEEtVjeNgw0O+SRzuS1o+Cett4=; b=dMJyUafzA8Y5aVivfRtvYQjotfRcqiix0gyM5KvQdbG28dzIm1Xrd60KJbVhiW7Aot 047kuaXsujuzLxuwxdE7DalSBOPQi1lHqJc7rhPYx+rBOQOn+/GmBNik5tjq/TGM8X5t SA4/cslyBIMlTG8ClhC0mFqP4pELoDVujsinua6oLEBpmOT1GMZ3f+EbRWkJi1jp7uiz mjBOqSQM2Ld8NWd/5/+KknLxpdBAG66JvHHoAHBYenGhc693oZ3OHK3izXN4gcjEH7TA 3RUWJvPAwhD6Vvgt6bQy7a4EU8/GyE5RuUrQpwNJgnNLpeKnsffteZrAUEy+mL+5nov8 NRrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535438; x=1744140238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bH5VLtP+seSAMs8ZXZEEtVjeNgw0O+SRzuS1o+Cett4=; b=dGAaR9ktztI6y90HasNCKKcJ/rPDSWctJJWIatI8plCE6qzV1b2vGwND2PG3mX1c87 Pm/P0hEewlbHL2rps635qOkkb6eKpqwY586uc01+7v8wQnv8Sh0MEFvpEp2eDQCStYAO IOmVbcZY00D05WlViMXRwUJn9JmRCTYj191vUl9640QZiWqanwuGe86nYyRBE6BaejVr 9DYDsQV+SoS9nT2Dd2HzznfVu2Bf7SrEXtiyddaK976xKeOaYilGm+JvYX00jUmmIz/C zzZ9fn74gju2bs9mF0F14J/E/MKjo0MItCDySasv/GzPiqRu+wMceT66RezT/6yGnBdB S29A== X-Forwarded-Encrypted: i=1; AJvYcCXRLcdwLCvLG0qjEFyF9dvi38loMx8HNkq0jlEBwLQW9WIFogKTruaJPBOaBZhUhwm3zRrhkiGMLjlSwbVInvsq@lists.infradead.org X-Gm-Message-State: AOJu0YzXph6pfzAksAdr6ltza5pTxVqCRxRIGSRAwKFn4/bN2zTgBzy2 C+eBtT75oWQ6UqBowi/di8j6KirBIYSvZ7xOIN32F3bBHqoKDyq7 X-Gm-Gg: ASbGncu+RfWBFI5MXGlvEonKR5Oxh9UN82xUikCpOU2zTuoxZpw0C76VbQa72dU/1Wc EsgQL3JwNIPABO4zbSRD6I7nQ96LHqG8nf70/HSWAa/fpHrcegJ9tk9W6x+B6kZpJ635LsNroY9 skP/HfI7A42Lg3lCNuq7nN+jRzRfkhP7ffIPMqlAAV2bV92okqJLcKFmZWmmnAtW6BXITz3OeK9 14/0gBZcGn7KnP+1w9TFDyTnb9eAxulSidvIw4jmJN1glT3UEK6O/R048vPRPDGMjJyHlfYzV3k boQo5T4fs4MGWL9bZSqikxvtbmwEMG1YsD6RuoVeE7oLwV4/Poy/yUei1krtUJTfkrt8/LLbLWx 6haA1Zns= X-Google-Smtp-Source: AGHT+IEeNatuio+GXvnz6jtis2Ifu8CXZWb0U2xpbF/9zUj/YkR/FHukm5fxlTJZb1XZQEdPrISlBQ== X-Received: by 2002:a05:6000:40cf:b0:391:2e6a:30fe with SMTP id ffacd0b85a97d-39c121188b9mr9767506f8f.39.1743535437739; Tue, 01 Apr 2025 12:23:57 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:23:57 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 2/6] crypto: sun8i-ce-hash - remove duplicated fallback checks Date: Tue, 1 Apr 2025 22:23:17 +0300 Message-ID: <20250401192321.3370188-2-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> References: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122359_575195_AEA168AC X-CRM114-Status: GOOD ( 11.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove duplicated fallback checks in sun8i_ce_hash_digest(). The same checks are already done previously in sun8i_ce_hash_need_fallback(). Signed-off-by: Ovidiu Panait --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 3f9d79ea01aa..2c2d285de154 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -244,21 +244,11 @@ int sun8i_ce_hash_digest(struct ahash_request *areq) struct sun8i_ce_alg_template *algt; struct sun8i_ce_dev *ce; struct crypto_engine *engine; - struct scatterlist *sg; - int nr_sgs, e, i; + int e; if (sun8i_ce_hash_need_fallback(areq)) return sun8i_ce_hash_digest_fb(areq); - nr_sgs = sg_nents_for_len(areq->src, areq->nbytes); - if (nr_sgs > MAX_SG - 1) - return sun8i_ce_hash_digest_fb(areq); - - for_each_sg(areq->src, sg, nr_sgs, i) { - if (sg->length % 4 || !IS_ALIGNED(sg->offset, sizeof(u32))) - return sun8i_ce_hash_digest_fb(areq); - } - algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base); ce = algt->ce; From patchwork Tue Apr 1 19:23:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F056C36010 for ; Tue, 1 Apr 2025 19:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZzBkugdw4gdptdF8hF2WvHzloU2qygLTygvgXH5F5js=; b=esbq5p+uRTNclj/4eYK7E+w2s4 85mj5ZZzBCwCutIBrYfmFW3wc8oOclG1NOtCj1nPiGHaB/Mu0Hyes34C9ck6Ox18XzTbenAedPTy3 b+o2gm95ksre2Hmkln6T/uUu06tpsmO1tdnExnnKs3sEMe7zJbKbTH8xqmK95/Axakc4/1yVh6tyt 1r2/Hnoi3CKjf1vwkt9prpisYCecHRmAoEhz8F+hV6lyZK/y7kALZKCImk0MOM0QGt+rXk2RtIOha U8vb2BMraBiAfLbHZ6iCJmQvL08wtBCWjezzI4x3yhnmRdOh/CfqDDceTIwKuozpsn0CYHQkF/MW4 9vAVEr0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhIf-00000004Dp5-0y7U; Tue, 01 Apr 2025 19:29:29 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDM-00000004D4l-1Alc for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:01 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3913b539aabso3487541f8f.2 for ; Tue, 01 Apr 2025 12:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535439; x=1744140239; 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; bh=ZzBkugdw4gdptdF8hF2WvHzloU2qygLTygvgXH5F5js=; b=ZRKnKO0/ZEocPTZ/UX5JVTyDou9oafc1VoI2DGSNn2po57CsOT8vDe5rZJ/U1QatUz +efcPIj13dQeLBpo4Y4y32qIh5yQvOAbIScfmiBVlPcIXrFQxIPmrtnzShPYVYu25atR y0kQL4jjMPMimJfPOXXD34BHdgbFBQPypx9nLrUBQBMY6iZeQV7wdi73QFCHmItcArYG 8/R1Y4efSpnmJAi6kQ4T2EeQF7Hl516+BphJYnt8jITHr0B0fk9iCP7q7RRlBrIfAnm8 EpjTbOej9a+DoiObWFxYL7jQH87SiFTv2oI+ydelDrMzqVFS6Sr6b2YE6pK9q9vwglhr S3Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535439; x=1744140239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZzBkugdw4gdptdF8hF2WvHzloU2qygLTygvgXH5F5js=; b=ca2zuXwBDzgsDLT5Dj2qBQmif7dRPVX6Fi9wuT40xY/cj6P+3SvNdKAayJxiWmi/rm 6mNB2WYvp9x1c1BJPDfTUnb+LNwMMmyvvMA/h6yszqULhpHlHtggncFptLmKTpGuV+MM VHsj1roFxqsHu/JYGiEB2sCdtW5SHiH5aTY19PqqlZoCJJzG2Xwfq1lpg/65libLfraB 9fsYGuaH78EmU8yDWXsjWk/4TKi7LqG9Ozwh7gxPI9MOHw0R59Lucvec2dj5UG0Dn2vu kZYg9JzuShjQQ+F+qtLn/Q/vYHM5yUbXcOYHLXDwOK4T/bt4ojRSfHwSQDMPJW7UhAA9 fwFQ== X-Forwarded-Encrypted: i=1; AJvYcCVrTQUStY39Qq6+Xmd448JTSTKQSGK2q7lwPNmC532ufBMHXV9x+htAZdmTgKFVrOLKH04oA+owUS2Rsrt+UtLU@lists.infradead.org X-Gm-Message-State: AOJu0YybUH5NLQv/JJFyoRJWv+Fg2C7Xww/Zxf/ivo9uN4SehkhP/UhI LgmRIR15VZZmaPW3i/l0vvsfF1q7VCWbznpwnZmjUrFwM9Mg3vbh X-Gm-Gg: ASbGncuyj2fWfr0g6liuFeAPIxbUuWE9oivPi3ANLfiYfeIKUiYHL74u2dhVOXXc0A5 5ESaGPgruTwK2CdJS/qw/aZlgoJkUiJBDnInIQK7TsWBNAxa3zgQSrptXhq2J1bp7+AcU09x64a sKcBcbtTin6OCeTwG+4rRP7Uv5jILO6fA4PzqN55Yxnnt/+fQubmALPt8GSPuHMC0IPwkLT4XaG PMUCWwz0KlWVXQx8SByVB2zssZoabb8bH1vRerJt3ynwVZAy4GLKR51Xbwbx1lWoUSReBbNR1yZ dzpAwpWf5fBfg8pNuciM5MS+9BfoV97Oe7asaDqL1wP9XtLnqChr6FuMLGrIAMjR+zoQUigs X-Google-Smtp-Source: AGHT+IHdVEsoyIGdrpYCryCmSoxbMMM8oYYvuj+OQEED1lz5k318eW2R/hcBuIk9AkMR8eZjNXUkHQ== X-Received: by 2002:a05:6000:381:b0:39c:1f0a:ee0 with SMTP id ffacd0b85a97d-39c1f0a0f69mr5763858f8f.2.1743535438907; Tue, 01 Apr 2025 12:23:58 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:23:58 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 3/6] crypto: sun8i-ce-hash - factor out debugfs fallback statistics Date: Tue, 1 Apr 2025 22:23:18 +0300 Message-ID: <20250401192321.3370188-3-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> References: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122400_329528_D4863D1E X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to reduce code duplication, factor out to a separate function the codepath that increments debugfs fallback stats. Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 53 +++++++------------ 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 2c2d285de154..b0959d8218cb 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -23,6 +23,20 @@ #include #include "sun8i-ce.h" +static void sun8i_ce_hash_stat_fb_inc(struct crypto_ahash *tfm) +{ + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { + struct sun8i_ce_alg_template *algt __maybe_unused; + struct ahash_alg *alg = crypto_ahash_alg(tfm); + + algt = container_of(alg, struct sun8i_ce_alg_template, + alg.hash.base); +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + algt->stat_fb++; +#endif + } +} + int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm) { struct sun8i_ce_hash_tfm_ctx *op = crypto_ahash_ctx(tfm); @@ -113,22 +127,13 @@ int sun8i_ce_hash_final(struct ahash_request *areq) struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); + sun8i_ce_hash_stat_fb_inc(tfm); + ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; rctx->fallback_req.result = areq->result; - if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { - struct sun8i_ce_alg_template *algt __maybe_unused; - struct ahash_alg *alg = crypto_ahash_alg(tfm); - - algt = container_of(alg, struct sun8i_ce_alg_template, - alg.hash.base); -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - algt->stat_fb++; -#endif - } - return crypto_ahash_final(&rctx->fallback_req); } @@ -153,6 +158,8 @@ int sun8i_ce_hash_finup(struct ahash_request *areq) struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); + sun8i_ce_hash_stat_fb_inc(tfm); + ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; @@ -161,17 +168,6 @@ int sun8i_ce_hash_finup(struct ahash_request *areq) rctx->fallback_req.src = areq->src; rctx->fallback_req.result = areq->result; - if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { - struct sun8i_ce_alg_template *algt __maybe_unused; - struct ahash_alg *alg = crypto_ahash_alg(tfm); - - algt = container_of(alg, struct sun8i_ce_alg_template, - alg.hash.base); -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - algt->stat_fb++; -#endif - } - return crypto_ahash_finup(&rctx->fallback_req); } @@ -181,6 +177,8 @@ static int sun8i_ce_hash_digest_fb(struct ahash_request *areq) struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); + sun8i_ce_hash_stat_fb_inc(tfm); + ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; @@ -189,17 +187,6 @@ static int sun8i_ce_hash_digest_fb(struct ahash_request *areq) rctx->fallback_req.src = areq->src; rctx->fallback_req.result = areq->result; - if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { - struct sun8i_ce_alg_template *algt __maybe_unused; - struct ahash_alg *alg = crypto_ahash_alg(tfm); - - algt = container_of(alg, struct sun8i_ce_alg_template, - alg.hash.base); -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - algt->stat_fb++; -#endif - } - return crypto_ahash_digest(&rctx->fallback_req); } From patchwork Tue Apr 1 19:23:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7EA8C36017 for ; Tue, 1 Apr 2025 19:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I/+iZ7oXBPhE3cNOeJn0BX2fJsfTTe1JAGSbvb0XfLY=; b=s1z0anw2cfklVcbd40hUkrWUFL dQJWJ7uBjpUYu2ltoVAabl//vMRB/kzUpg1pE5Rc8yglUqv/RwoaGuKMQj1Pu7HcfmMBxuRTF5cK+ 9rS6pAdeRfLuH6CJeTfiLvL5lNTsHoA3WYpF+Y9aFtzhsN60GHodSO8VEYQatPYIoVT5fT6XTmYP9 8HZCy5ESnkOhjEux5VWwHpr0fD8VdOb9nDkO+83h9TC8OHjKLPxO7yCUFi+xSrOzbPr8/cMFI1jUf XOpwxTs11i3MLcyWw9yu3gjtGBv1uB/lz+OMFBK+h7mBM0/LvF17rKTf+ssZKnCRDUgk/MCEUvrvo Da1uwobQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhKR-00000004E31-0USE; Tue, 01 Apr 2025 19:31:19 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDN-00000004D5K-3Ed1 for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:02 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-39141ffa9fcso5689342f8f.0 for ; Tue, 01 Apr 2025 12:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535440; x=1744140240; 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; bh=I/+iZ7oXBPhE3cNOeJn0BX2fJsfTTe1JAGSbvb0XfLY=; b=l4OW6zk8Z+RO+6IbX6WsJ20pIPoRMiZetlEuc5BATBdJcXVLt5tA/HkSveRYOTlOZv NENQFoeUFgVzu2PPFLOM9DGaB9eXmtasr1Y7RKxWpUGyXZGYGJCW9p2vsUQVgHXR929g tkJk8KnTrXdM38JdEAPh5YB2wVWZQUzxbX1APfay4+HMlWOJHgZmyqhSi96/XWytPqSR /Mn8MkV3TZgkYk5s0sZGDWEBLaRr7t9rcNtLBIDGaQoGCIxvUxZxWWezRojh6kuLeoff ANrKm8SU1+nKf2unsB08b4npdP0WtZyI2dXGZgB16QeigJkbBFfxzJ82H5utxhqu45tX GoiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535440; x=1744140240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I/+iZ7oXBPhE3cNOeJn0BX2fJsfTTe1JAGSbvb0XfLY=; b=qyOVWbUjAlIgOnmy4XmQo4hRVutPwrUrph9sga7mPEm1/BCy1mc4YrykZcRy6kHWYN FTz7pBOyidvSLtD7ISZR6MCpvGgbQphTz1s8XLavkI+WDx9Lcvz3KCnn4cw9n11pnAwK pf0OWXXQu4N4o1FOw+u+XujN3HpP8TRsLu0X6V/p+w8/Oy7RxLJvUENTraQtOnFDAbEz ijgjabVGzfj/qhPeVWOGMaJi8XE2xLBZYquWed7STyEbDTJc5ZOXpVPoadFbl2qsza5R bRqQCd1rGqLL5J0cWeuD4L+pm+HS7TtUXGqtWnC/oQd20ZV9VwwbTc9u4GabjkJWY58+ zPxg== X-Forwarded-Encrypted: i=1; AJvYcCWxLcRG2dL6ZfIzqRxk1MrTo6w0R7WcNCVR1Sc2WpSe1sG1W0cS1ZIE6Vx8d1DXT7uPlI/CirK0zrFirDXR7lN1@lists.infradead.org X-Gm-Message-State: AOJu0YwxihlI1VC1eK/e9j9HWH1lKsx2SUrRJ2TApVu1SB2u2X15siQT zDHwILx+NABxjfUS8XTkdQfs4KZmqggEMTGxsy3x/Uj4AH7K5D4/ X-Gm-Gg: ASbGncsFz8U3jS/CtDzEcRX0VRCkike3mInNTR62PPJ/AkV2UwdCT7v8XjZrwieyY61 I3kOS+fucivMLKVt5SRtehx4Hj+crK+JVGTQLzzdYJHSZl35UqpE3dSW+GKLTZK/WHTnPNGgrSw vG+Eo8Ia9KmFEoxgKvxvCqSFjfZLxfKeUvmpVbxfWu+PYIbFGcO7C/wAeL0DXE6ayF/KRrZvORH R10ox5inLL4UauBrj1hh4K1ZS4sVHYp1tdWlhb2MLhX2MyUxVj3/YV9f4CqtPK2SiMpQYRWe3aH DUkzpzhTk9MEMy3fTqfEyBSTrw5z0ivHwFzK5W/SE3ij7QGS727aMH2AuVNnGwyuwKN4TUcf X-Google-Smtp-Source: AGHT+IEroLhlH55Nn0a2Cu0BMYw27BSdC4OLp0dlkWXs82H+dhWwczs/WCChC+qm41GDorZgNFvJwA== X-Received: by 2002:a05:6000:40ce:b0:399:6ad6:34 with SMTP id ffacd0b85a97d-39c12118e33mr11160301f8f.35.1743535440077; Tue, 01 Apr 2025 12:24:00 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:23:59 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 4/6] crypto: sun8i-ce-hash - drop CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG ifdefs Date: Tue, 1 Apr 2025 22:23:19 +0300 Message-ID: <20250401192321.3370188-4-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> References: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122401_808937_17244733 X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 'struct sun8i_ce_alg_template' is always defined, even with CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG disabled, so the ifdef guards are not needed. Make sure the statistics have IS_ENABLED() checks instead. Signed-off-by: Ovidiu Panait --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index b0959d8218cb..530c5181d73c 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -31,9 +31,7 @@ static void sun8i_ce_hash_stat_fb_inc(struct crypto_ahash *tfm) algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base); -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG algt->stat_fb++; -#endif } } @@ -354,9 +352,9 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) flow = rctx->flow; chan = &ce->chanlist[flow]; -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - algt->stat_req++; -#endif + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + algt->stat_req++; + dev_dbg(ce->dev, "%s %s len=%d\n", __func__, crypto_tfm_alg_name(areq->base.tfm), areq->nbytes); cet = chan->tl; From patchwork Tue Apr 1 19:23:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3FDFC3601A for ; Tue, 1 Apr 2025 19:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i8z+fSx5TSn2FrXLNFfU/1u/JP6JDm+uKA06s523rtI=; b=ytqQwDL81Izn8DZiBAXQzxoNF8 7dbL8vSZAWnGZhgg03Sy5j2wI+WuxAr1G6GKBKVYQeMvwrXnrhqbTwSAIVZhEIbr1LI1CBP0Cwpfz 47VqIaba6PAuVnlR5VWlo5sLuCkrr2yK7S45ZI/fu/cxI1QJBBOzsJnLsY4i47EiCQ04l7DoGkc1R MYkvJHCxu9L6Eg8o2kdpkOXGj5oAwpL3Lk1uNaib0EYo0etVqM31L8ePS8hsOCT6f96G7AB5rKHC6 Jhd03IF23PSHM1omZ2S61A32Zy+r+bO8jX9llXpiC5d9+I46Ty1UJuPGOCjjj5dbx/oeLmcXqAhyr u8KzBVLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhMD-00000004EK7-3ZOs; Tue, 01 Apr 2025 19:33:09 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDP-00000004D66-0tlZ for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:04 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43d2d952eb1so41716835e9.1 for ; Tue, 01 Apr 2025 12:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535441; x=1744140241; 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; bh=i8z+fSx5TSn2FrXLNFfU/1u/JP6JDm+uKA06s523rtI=; b=F+AzR05c5Juy87wbUFLdR1CgK95GgTUuUhc0Iu+usTaQLZsIqsHFBvW6GbhgBttxOL elK4Q8JM+LWPnz/y2Is2Rb4QgFhKyRCEi4E4s6DKh6p/RF0sNYcE2vIsXWw6+YHJ32d1 /I7yi45/Qq6X4R8AHMC4hNXG7U9ffb/YnjZLPG6YmG+Nudq8LAN8FVf94euuMJQoQm7O wDTbot18Uuo98hKgP2cX2199G3n8ybSfO/8S+VZapWs46J6WmYbdq96pFKq1Qs7pfsEV KUGAIG9ku6RX4g2+GFn38HAZzk9eIpuElYOIp0ztn0sY9CqTMf5ha50NDxFsvKZTWOie v7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535441; x=1744140241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i8z+fSx5TSn2FrXLNFfU/1u/JP6JDm+uKA06s523rtI=; b=rIDIJRMN6R0weim2lxgkqb4y5VYKKogrbTkFgnN6V1A+fHK3C2gQw7lpUOUk/KHst3 qigyaAUunGu13JNFfXA3ic7EMrJeKeP2K5DrBstFXsD6jqYIzuvME8nrAACtlFTG0l8j huIiM7ATpI8EtSRvnLZzDSTd4NNRmKei6/6+mvXbV+hNYjoKh99ytIK/OhVUf0Dt8jAK jivzdbwmpibTMJkOyEF0euWdP1hOImIesKOE8wplHwEa4EM+JkLQSd6nfKFxG1Dm6lPh 2OrJkY0UymiYvzs1ghX6AvO5pAuO5E++GI6YxBlqatxVXwJ90sSSob+XxX33QuBD1Meh 2BAg== X-Forwarded-Encrypted: i=1; AJvYcCVARtNa6RQ9JxaEBCwpSYSmEG7SK1e0jMoe0zf4PTsfxBqIuadDCHon2bOM/3QWpgo83R8cCUCZzqhzYN9T8eBe@lists.infradead.org X-Gm-Message-State: AOJu0YwhTYg+UJd+3Tu77c96QEFXy9mVQSsNy5XpSoUTNOrpf1PYmG1W 594QqqfEv7wANQGLf7j5Zb7AbX4dql0yv9J85yJw3HhJLzCiRpvw X-Gm-Gg: ASbGncucJQQ4EKIZZZfTkhU4ZATbZRK2jITNonbetpJfqJN3eP8Ba0j/znMTB0mhqYM VUNdrBt+rey00IZTJ+UzY13G1W7b/F9ZgXd8gtMX/u3Ii+1PJVoaAQXgQBOgpxRGjfw4ypAYBjI vmuXoQk8jolKovcf0zeBPi8FBOO+71dyf1e/dwyryUfiscC5n8JVkN/wnu2huVz+7F+95DP0w5d BfYjDc+8g8J/8YEl2341HnGTYaM/8gSiRXPgBfjuLrCtrmI1BS1Ck86c5yuYJLH2rPLo9N8b2BW Y+3a4AWPLr+h1B4gYSJiNXHdq6Mc2d4lydFRb7BKjipZZce4pGkHBpU1SfKcJVYU++rnAiGK X-Google-Smtp-Source: AGHT+IHEh+OGGdBfpbw9Ezhf9HsQaZImvcYBc/BECi3M6V/8EKmHii6CQkGoC7DxQblK6JTqZon8Ig== X-Received: by 2002:a05:6000:418a:b0:391:22e2:cd21 with SMTP id ffacd0b85a97d-39c12117df4mr9452334f8f.36.1743535441394; Tue, 01 Apr 2025 12:24:01 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:24:00 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 5/6] crypto: sun8i-ce-hash - add IS_ENABLED() checks to debugfs stats Date: Tue, 1 Apr 2025 22:23:20 +0300 Message-ID: <20250401192321.3370188-5-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> References: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122403_250964_211C7A35 X-CRM114-Status: GOOD ( 14.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG) checks before the fallback counter updates to make sure the code is not included when debugfs statistics support is not enabled. Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 530c5181d73c..f2481e1585ba 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -60,8 +60,10 @@ int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm) sizeof(struct sun8i_ce_hash_reqctx) + crypto_ahash_reqsize(op->fallback_tfm)); - memcpy(algt->fbname, crypto_ahash_driver_name(op->fallback_tfm), - CRYPTO_MAX_ALG_NAME); + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + memcpy(algt->fbname, + crypto_ahash_driver_name(op->fallback_tfm), + CRYPTO_MAX_ALG_NAME); err = pm_runtime_get_sync(op->ce->dev); if (err < 0) @@ -198,22 +200,30 @@ static bool sun8i_ce_hash_need_fallback(struct ahash_request *areq) algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base); if (areq->nbytes == 0) { - algt->stat_fb_len0++; + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + algt->stat_fb_len0++; + return true; } /* we need to reserve one SG for padding one */ if (sg_nents_for_len(areq->src, areq->nbytes) > MAX_SG - 1) { - algt->stat_fb_maxsg++; + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + algt->stat_fb_maxsg++; + return true; } sg = areq->src; while (sg) { if (sg->length % 4) { - algt->stat_fb_srclen++; + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + algt->stat_fb_srclen++; + return true; } if (!IS_ALIGNED(sg->offset, sizeof(u32))) { - algt->stat_fb_srcali++; + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) + algt->stat_fb_srcali++; + return true; } sg = sg_next(sg); From patchwork Tue Apr 1 19:23:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 14035267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44878C3601A for ; Tue, 1 Apr 2025 19:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FPD+7okMltc/dAuqJI3eHLzfTcaBka9M3a4LKpm2uhg=; b=S5J4LKNJcappME0LxaUNwpBEp5 bN1yGzSzDdmCGSfJJkfLndLsoamcdGxFqyl5NJsZK0YaY926AilKx0oyZbN9MRpyzGyW3R5K8b0hH ArNRXZm7Pq2aWt5beTlX+J1J0ZSNBbFOJVk3osYU0I2S71DuHFlI/9ZHQ9IZk63RJ5+C/aBN+aY9U LxHTaO5tcNBdAULX2Y3dpnJZDC/q+L7skezc4WWZ0dbkqMNmUOAYqDsAcCagL2Q1PTfvh3JPFX0+H oDuzErhLsYwUjw9Dl7uQzaVwIFP1IWSqDoGi6zWcEX1K3qrEUAGhboIziaIwVZspt2i1gRz8pXOhj grDgw9PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhNy-00000004EUG-2BWX; Tue, 01 Apr 2025 19:34:58 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzhDQ-00000004D6T-1w3q for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 19:24:05 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-39c2688619bso556761f8f.1 for ; Tue, 01 Apr 2025 12:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743535443; x=1744140243; 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; bh=FPD+7okMltc/dAuqJI3eHLzfTcaBka9M3a4LKpm2uhg=; b=NHxui/Hjz8nFYYQ0H8+HKzNdEkc1hqM1+L2GNDLCqcBqJImOoNAAfjGBjOmmfGGSka jJcWle1AWp7SOwJc0uC5fCKwfrpLEtAQEl3FZyiDazx3yOUAyIrZbkm79OIowVBiRvv+ hfpJjtqQ608p9n+YqrPh6C+mH95rKkIKuYYWywwjV22dmBK5a+llCHvJgy+o5lT29+/l 1w5/GXnuZpsg9XHM9PnPbVw8cWsIfJObNpzsLvXPrejRe6W+VfB7tQYBP9OHsF1upWvz 31gC2+VfCcUccWHEB2iGWm1vikoIwB8muxzbWPAMDol7fBfPBPNJieRNOjhSx0+mylbi iZ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535443; x=1744140243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FPD+7okMltc/dAuqJI3eHLzfTcaBka9M3a4LKpm2uhg=; b=naR/NGVb0zK0b3vnHGM3h1GdE0JVqrjwoxBWBCD1NDEJ8bLEelJR8DfIfBxzsCjATb 2ILTx444QO5mgFIx1dyswyJqB130tCNTBupaxp1/NpPJiqkCq4Hs+MafEWjTFAM3kzt9 6TqNI3oHw3kTLKyBNUd+YXkSqso2ZmcYuE+hePRD4F9LP7QwACiEwnuDTjxwoftbdTYi 12fId/YEwMTCR4svk4A4CnZjIFtXvkMbNmBHTbt2HqC/9lDKi/l6WJmPpXHwk9CRS2JI FCXnXUYQtC0+5x/HTbtcL9gCvNDR/vJ5xfTf52NeRURsKEJw8Ui3LadCFVsn8RgD5a2h R3Eg== X-Forwarded-Encrypted: i=1; AJvYcCVdCk6kmX2E/HRGiYWTyN7sPCmGyH8jHeTD2B+uwnzckZJkTe1ZmGoSDGtlw6+aH/q6MvkYQO63oCzceWh/lUyo@lists.infradead.org X-Gm-Message-State: AOJu0Ywu6KCAaE6OaB8a40W8aiJw/PJ3ApEmR2TeXxt/Mh+qHsdYpV/H cJaTjBu9xcNQo2C7cohLF6xm3lDKBNVp2IIm7O6p64zGszcCvZ/1 X-Gm-Gg: ASbGnct9x75NWElrdgmp1qkybCsjLUYsNSsBBqPmGOYSF2odArJp/T8nM4iDB4+/wdE NFhuhR7MwySMDvX8z7HR1UKi7AMKLGQJGwRiALMnGBxXRwL1R5I1H9Qke1UydsONPUAN3JB25Oz 7P2YPbWZCtgCfVonP7ldE6e4Bb7Bf0qkyedLWX63cT8LpQcq60ih3btzcEA8gCh1LUI/bH1XrKL 78Mq57nlPRc7T7ewE9VZ+TFpf32PDjsV/o0v3tibdq0sAu2TOEVs5qnG8SVJt6dgEOujoLqkIC3 U4kISVRAP6Twm8PkfB24EZljE1CBPcAshaSTaAspV7xTwVqDTiDOEApI/Ca8QDbsAvBdm2eT X-Google-Smtp-Source: AGHT+IEaiKwLn7JsnD/3lJiU7PGrasf+3+s7Prm3UNAJkOHPWOkOwYJ5/33v9GOGEA2VI8+dpTqX0g== X-Received: by 2002:a05:6000:1a8b:b0:39a:c9c1:5453 with SMTP id ffacd0b85a97d-39c2367439dmr3498181f8f.49.1743535442768; Tue, 01 Apr 2025 12:24:02 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c50a:8800:cf9e:ee0b:4a01:37f6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b66aa32sm15353438f8f.50.2025.04.01.12.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:24:02 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH 6/6] crypto: sun8i-ce-hash - use API helpers to setup fallback request Date: Tue, 1 Apr 2025 22:23:21 +0300 Message-ID: <20250401192321.3370188-6-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> References: <20250401192321.3370188-1-ovidiu.panait.oss@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_122404_499179_D5DDE41A X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than setting up the fallback request by hand, use ahash_request_set_callback() and ahash_request_set_crypt() API helpers to properly setup the new request. Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index f2481e1585ba..ba13fb75c05d 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -92,7 +92,9 @@ int sun8i_ce_hash_init(struct ahash_request *areq) memset(rctx, 0, sizeof(struct sun8i_ce_hash_reqctx)); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); return crypto_ahash_init(&rctx->fallback_req); } @@ -104,7 +106,9 @@ int sun8i_ce_hash_export(struct ahash_request *areq, void *out) struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); return crypto_ahash_export(&rctx->fallback_req, out); } @@ -116,7 +120,9 @@ int sun8i_ce_hash_import(struct ahash_request *areq, const void *in) struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); return crypto_ahash_import(&rctx->fallback_req, in); } @@ -130,9 +136,10 @@ int sun8i_ce_hash_final(struct ahash_request *areq) sun8i_ce_hash_stat_fb_inc(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP; - rctx->fallback_req.result = areq->result; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); + ahash_request_set_crypt(&rctx->fallback_req, NULL, areq->result, 0); return crypto_ahash_final(&rctx->fallback_req); } @@ -144,10 +151,10 @@ int sun8i_ce_hash_update(struct ahash_request *areq) struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP; - rctx->fallback_req.nbytes = areq->nbytes; - rctx->fallback_req.src = areq->src; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); + ahash_request_set_crypt(&rctx->fallback_req, areq->src, NULL, areq->nbytes); return crypto_ahash_update(&rctx->fallback_req); } @@ -161,12 +168,11 @@ int sun8i_ce_hash_finup(struct ahash_request *areq) sun8i_ce_hash_stat_fb_inc(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP; - - rctx->fallback_req.nbytes = areq->nbytes; - rctx->fallback_req.src = areq->src; - rctx->fallback_req.result = areq->result; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); + ahash_request_set_crypt(&rctx->fallback_req, areq->src, areq->result, + areq->nbytes); return crypto_ahash_finup(&rctx->fallback_req); } @@ -180,12 +186,11 @@ static int sun8i_ce_hash_digest_fb(struct ahash_request *areq) sun8i_ce_hash_stat_fb_inc(tfm); ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm); - rctx->fallback_req.base.flags = areq->base.flags & - CRYPTO_TFM_REQ_MAY_SLEEP; - - rctx->fallback_req.nbytes = areq->nbytes; - rctx->fallback_req.src = areq->src; - rctx->fallback_req.result = areq->result; + ahash_request_set_callback(&rctx->fallback_req, + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP, + areq->base.complete, areq->base.data); + ahash_request_set_crypt(&rctx->fallback_req, areq->src, areq->result, + areq->nbytes); return crypto_ahash_digest(&rctx->fallback_req); }