Re: [PATCH v13 2/4] crypto: spacc - Add SPAcc ahash support

From: Herbert Xu

Date: Thu Jun 11 2026 - 01:52:01 EST


On Thu, Jun 04, 2026 at 10:22:08PM +0530, Pavitrakumar Managutte wrote:
>
> +static int spacc_hash_do_one_request(struct crypto_engine *engine, void *areq)
> +{
> + struct ahash_request *req = ahash_request_cast(areq);
> + struct crypto_ahash *reqtfm = crypto_ahash_reqtfm(req);
> + struct spacc_crypto_ctx *tctx = crypto_ahash_ctx(reqtfm);
> + struct spacc_crypto_reqctx *ctx = ahash_request_ctx(req);
> + struct spacc_priv *priv = dev_get_drvdata(tctx->dev);
> + const struct spacc_alg *salg = spacc_tfm_ahash(&reqtfm->base);
> + int rc = 0;
> +
> + ctx->single_shot = 1;
> + ctx->total_nents = sg_nents(req->src);
> +
> + tctx->tmp_sgl = kmalloc_array(2, sizeof(*tctx->tmp_sgl), GFP_KERNEL);
> +
> + if (!tctx->tmp_sgl)
> + goto fallback;
> +
> + sg_init_table(tctx->tmp_sgl, 2);
> + tctx->tmp_sgl[0].length = 0;
> +
> + if (tctx->handle < 0 || !tctx->ctx_valid) {
> + priv = dev_get_drvdata(salg->dev);
> + tctx->dev = get_device(salg->dev);
> +
> + rc = spacc_is_mode_keysize_supported(&priv->spacc,
> + salg->mode->id, tctx->keylen, 1);

This check could've been done before going through the crypto
engine. If we're just going to use the fallback, there is no
point going all the way through the engine just to drop out right
at the end.

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt