Re: [PATCH v9 2/5] crypto: loongson - add Loongson RNG driver support
From: Herbert Xu
Date: Mon May 19 2025 - 01:57:33 EST
On Tue, May 06, 2025 at 11:19:44AM +0800, Qunqin Zhao wrote:
>
> +static int loongson_rng_init(struct crypto_tfm *tfm)
> +{
> + struct loongson_rng_ctx *ctx = crypto_tfm_ctx(tfm);
> + struct loongson_rng *rng;
> + int ret = -EBUSY;
> +
> + mutex_lock(&rng_devices.lock);
> + list_for_each_entry(rng, &rng_devices.list, list) {
> + if (!rng->is_used) {
> + rng->is_used = true;
> + ctx->rng = rng;
> + ret = 0;
> + break;
> + }
> + }
> + mutex_unlock(&rng_devices.lock);
> +
> + return ret;
> +}
This isn't right. The number of TFMs in the system is unlimited.
You should not pair each tfm with an individual hardwre device.
If you want to do load-balancing you could certainly pick a device
per tfm, but each device must be able to support an unlimited number
of tfms.
Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt