Re: [PATCH v3 1/3] crypto: introduce acomp_is_sleepable to expose if comp drivers might sleep

From: Herbert Xu
Date: Sun Feb 18 2024 - 23:25:14 EST


On Sat, Feb 17, 2024 at 05:51:00PM +1300, Barry Song wrote:
.
> diff --git a/crypto/acompress.c b/crypto/acompress.c
> index 1c682810a484..fa15df394a4c 100644
> --- a/crypto/acompress.c
> +++ b/crypto/acompress.c
> @@ -152,6 +152,14 @@ struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type,
> }
> EXPORT_SYMBOL_GPL(crypto_alloc_acomp_node);
>
> +bool acomp_is_sleepable(struct crypto_acomp *acomp)
> +{
> + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp);
> +
> + return tfm->__crt_alg->cra_type == &crypto_acomp_type;
> +}
> +EXPORT_SYMBOL_GPL(acomp_is_sleepable);

Just because something is of acomp_type it doesn't mean that it's
async. You should be testing the algorithm flags.

So introduce a helper crypto_acomp_get_flags (see the similar
helper crypto_skcipher_get_flags) and test it against CRYPTO_ALG_ASYNC.

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