[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <96118a23-3e6c-c9d1-2135-bd7a22091f35@loongson.cn>
Date: Mon, 19 May 2025 16:13:14 +0800
From: Qunqin Zhao <zhaoqunqin@...ngson.cn>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: lee@...nel.org, davem@...emloft.net, peterhuewe@....de,
jarkko@...nel.org, linux-kernel@...r.kernel.org, loongarch@...ts.linux.dev,
linux-crypto@...r.kernel.org, jgg@...pe.ca, linux-integrity@...r.kernel.org,
pmenzel@...gen.mpg.de, Yinggang Gu <guyinggang@...ngson.cn>,
Huacai Chen <chenhuacai@...ngson.cn>
Subject: Re: [PATCH v9 2/5] crypto: loongson - add Loongson RNG driver support
在 2025/5/19 下午1:57, Herbert Xu 写道:
> 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.
Then the HISI TRNG driver isn't a right demo?
>
> 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.
This can also avoid concurrent access to a device, otherwise i need to
add mutex_lock/unlock in generate and seed callback.
Thanks,
Qunqin.
>
> Cheers,
Powered by blists - more mailing lists