Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3121551pxm; Mon, 28 Feb 2022 12:29:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6I6RYUkMltZDVpAP//NDa7J0S7QWgAyv+Jwat7p1ufhyAw2YsnMicVuyofQBgxORYcFXT X-Received: by 2002:a62:d156:0:b0:4cd:fd21:e406 with SMTP id t22-20020a62d156000000b004cdfd21e406mr23470613pfl.44.1646080144055; Mon, 28 Feb 2022 12:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646080144; cv=none; d=google.com; s=arc-20160816; b=CoDajepFs6rXS0+TZmcHDlBHZ8rB3qS9kgR7xhG1wyQouJJ3hoQM0gc+cDt1kKcHji MUjJJy5AdJw/Ngo8E/mH4slzO09yst/Qf0uczULuCkFs3bcxZVlb23kxJ4ZWwcOlvTzA gf6xGIISHrwGXwrdE1RPCCz59b+7+IceL0MIashxtUe4iGjBRipRgIExDkSE3yefXvp1 fkBQZU7Ovso8ZIswz62upraY81dL5o3NRxI1vIikAv7nvgl39q9rpiRUW/0AelgGgSxu WVXaR2mGOmIW6L2bhzKM0EP3AqXUiKmqB7GDNR/lEVMpLcW3utBGO+3pniDb/NQsKDsi hZDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v1CCwvJnO4832jIoRmVnfn1erTUdDyF/92qblaVtPw0=; b=A3rTHMRSN1vZqwGKtais5l7tgucOazgYOX97ojMTP2HrpOxNoq4SsOPYiwfp8enPfA 2W51BmVBThNGh1iIV2TtNJejiRpxjLzYOJU1Q3NLbbAAJgeuceQxM8SS6ppJVHwjsyuS ypSgBAYQoC50otiTZIMZ54zIvUgXlWZXSesNKCSg7oqy5gup3cH0YK48N7/MGAf0JucH ZKZqEVRXODjCw/P1KN3zT7S2+gsQZwCXavUaAfqHmaC0cAcMVJXQ9m2Bn3dCTD1yvhzJ lHC6txyZRUGMXE559BLF0S5xKm0MoxzV1xu9b1byyAEBnqK2EzZbKiOzCt+JaHF3CSzq A9ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=T6Rn7DKp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t2-20020a639542000000b0037865a76ab7si8135377pgn.668.2022.02.28.12.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:29:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=T6Rn7DKp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16140F94C1; Mon, 28 Feb 2022 11:47:14 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbiB1Trv (ORCPT + 99 others); Mon, 28 Feb 2022 14:47:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiB1Tro (ORCPT ); Mon, 28 Feb 2022 14:47:44 -0500 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D4AEDF32 for ; Mon, 28 Feb 2022 11:45:56 -0800 (PST) Received: by mail-wr1-f50.google.com with SMTP id v21so17092644wrv.5 for ; Mon, 28 Feb 2022 11:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v1CCwvJnO4832jIoRmVnfn1erTUdDyF/92qblaVtPw0=; b=T6Rn7DKpnSnnyV16iFJeQmRkesyHpgcXn2Birf8VDLN9xJJGQpe3sACuKvCcbBSzZp siIvE0Wto1zd4n35xBM9jwhXXuxpshiEgB5NSXAzBIjyPFM7YZxoUzrs/crK6L5GQeOi qp2or336e6FCD9jVoQLmc8cKh7dDQmcYGeJSvQLQh/petM7XhbHZ9vcjasOowF/9lO+d k5bSMHM5nIKEgCLuN2GImvNmVAizz+JSDptuOE9n3ShIu8d7B4cvboMM+3h6/P2EpHPa rowmx1yWviBahOqGRGPklUwvfFZhf4c28OrRmBMOilIh7Mplsg6Y8IualsaBFQhrgK5Q CoQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v1CCwvJnO4832jIoRmVnfn1erTUdDyF/92qblaVtPw0=; b=vQZihaSZd2jkyNbGJKzfbAUMe0Mersm1nrivIyjozl/OpcODgpDhWFj3yI0/4TJ4U2 ZL54fFHgSp0Hfh1RYbga6UScFXlTRwCVQqy+jdz5UPe2G90MWnvPzWUNnM5LVUJYS4mQ ROfiIXCtysuFvaC5yEmIbKODaZnHoXTvAwOqKOjlAu24KhDbX9uvqrzKPsdusoKKWpa5 mJMR0mGiOAMbqOdXR63xOjPMJDdspmMrHLczmscC74ENnEn/T27N+U47I3rokDt7Vccn xsPpFtXxreQ/IdGGEVetqE2oPzZCMvX38Y/el1WFL62xkdkznJGX2sP+BOn7S8Qovc8H oM/A== X-Gm-Message-State: AOAM532qL9gdEGVwj0RIGcawkTs+r0OTvwWd2ffXz47XM5fSUve5bPz3 In1R9Emq6eUQzuRIudlU9eSFCA== X-Received: by 2002:a5d:45cb:0:b0:1ed:f938:7e17 with SMTP id b11-20020a5d45cb000000b001edf9387e17mr16706103wrs.170.1646077248771; Mon, 28 Feb 2022 11:40:48 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id v25-20020a05600c215900b0038117f41728sm274143wml.43.2022.02.28.11.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 11:40:48 -0800 (PST) From: Corentin Labbe To: heiko@sntech.de, herbert@gondor.apana.org.au, krzysztof.kozlowski@canonical.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Corentin Labbe Subject: [PATCH 07/16] crypto: rockchip: add fallback for ahash Date: Mon, 28 Feb 2022 19:40:28 +0000 Message-Id: <20220228194037.1600509-8-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228194037.1600509-1-clabbe@baylibre.com> References: <20220228194037.1600509-1-clabbe@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Adds a fallback for all case hardware cannot handle. Fixes: ce0183cb6464b ("crypto: rockchip - switch to skcipher API") Signed-off-by: Corentin Labbe --- drivers/crypto/rockchip/rk3288_crypto_ahash.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c index 49017d1fb510..417cf4487514 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c +++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c @@ -16,6 +16,40 @@ * so we put the fixed hash out when met zero message. */ +static bool rk_ahash_need_fallback(struct ahash_request *req) +{ + struct scatterlist *sg; + + sg = req->src; + while (sg) { + if (!IS_ALIGNED(sg->offset, sizeof(u32))) { + return true; + } + if (sg->length % 4) { + return true; + } + sg = sg_next(sg); + } + return false; +} + +static int rk_ahash_digest_fb(struct ahash_request *areq) +{ + struct rk_ahash_rctx *rctx = ahash_request_ctx(areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); + struct rk_ahash_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; + rctx->fallback_req.result = areq->result; + + return crypto_ahash_digest(&rctx->fallback_req); +} + static int zero_message_process(struct ahash_request *req) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); @@ -167,6 +201,9 @@ static int rk_ahash_digest(struct ahash_request *req) struct rk_ahash_ctx *tctx = crypto_tfm_ctx(req->base.tfm); struct rk_crypto_info *dev = tctx->dev; + if (rk_ahash_need_fallback(req)) + return rk_ahash_digest_fb(req); + if (!req->nbytes) return zero_message_process(req); else -- 2.34.1