From: Herbert Xu <herbert@gondor.apana.org.au>
To: Chenghai Huang <huangchenghai2@huawei.com>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
linux-crypto@vger.kernel.org, fanghao11@huawei.com,
liulongfang@huawei.com, qianweili@huawei.com,
linwenkai6@hisilicon.com, wangzhou1@hisilicon.com
Subject: Re: [PATCH 1/2] crypto: hisilicon/trng - use DEFINE_MUTEX() and LIST_HEAD()
Date: Fri, 19 Dec 2025 11:04:46 +0800 [thread overview]
Message-ID: <aUTAznUr2OrikTH9@gondor.apana.org.au> (raw)
In-Reply-To: <20251120135812.1814923-2-huangchenghai2@huawei.com>
On Thu, Nov 20, 2025 at 09:58:11PM +0800, Chenghai Huang wrote:
>
> @@ -308,12 +302,10 @@ static void hisi_trng_remove(struct platform_device *pdev)
> struct hisi_trng *trng = platform_get_drvdata(pdev);
>
> /* Wait until the task is finished */
> - while (hisi_trng_del_from_list(trng))
> - ;
> -
> - if (trng->ver != HISI_TRNG_VER_V1 &&
> - atomic_dec_return(&trng_active_devs) == 0)
> - crypto_unregister_rng(&hisi_trng_alg);
> + while (hisi_trng_crypto_unregister(trng)) {
> + dev_info(&pdev->dev, "trng is in using!\n");
> + msleep(WAIT_PERIOD);
> + }
Please use the new CRYPTO_ALG_DUP_FIRST flag to let the Crypto API
deal with reference count tracking. With that, you should be able
to unregister the RNG even if there are still tfms using it.
The RNG will be freed after all tfms using it are freed.
Of course you should create a way to mark the trng as dead so
that the hisi_trng_generate returns an error instead of trying
to read from the non-existant RNG.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2025-12-19 3:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 13:58 [PATCH 0/2] crypto: hisilicon/trng - support multiple tfms sharing the device Chenghai Huang
2025-11-20 13:58 ` [PATCH 1/2] crypto: hisilicon/trng - use DEFINE_MUTEX() and LIST_HEAD() Chenghai Huang
2025-12-19 3:04 ` Herbert Xu [this message]
2025-12-22 6:10 ` huangchenghai
2025-12-24 2:49 ` Herbert Xu
2025-11-20 13:58 ` [PATCH 2/2] crypto: hisilicon/trng - support tfms sharing the device Chenghai Huang
2025-12-19 3:06 ` Herbert Xu
2025-12-22 3:36 ` huangchenghai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aUTAznUr2OrikTH9@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=fanghao11@huawei.com \
--cc=huangchenghai2@huawei.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linwenkai6@hisilicon.com \
--cc=liulongfang@huawei.com \
--cc=qianweili@huawei.com \
--cc=wangzhou1@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®