| From 377fc09732057019f0436ea574e99491a680e01f Mon Sep 17 00:00:00 2001 |
| From: "song.han" <song.han@amlogic.com> |
| Date: Wed, 23 Feb 2022 14:20:28 +0800 |
| Subject: [PATCH] boottime: reduce boot time [1/1] |
| |
| PD#SWPL-71744 |
| PD#SWPL-52793 |
| |
| Problem: |
| 1. jitter rng is doing 1024 rounds of tests and causing |
| long initialization time. |
| 2. add sysfs params too slow, kernel bootup block 1 hour in pxp. |
| |
| Solution: |
| 1. change jent_mod_int to delaywork to reduce boot time. |
| 2. use async add sysfs params to reduce boot time. |
| |
| Verify: |
| c2_af400 |
| |
| Signed-off-by: song.han <song.han@amlogic.com> |
| Signed-off-by: yao zhang1 <yao.zhang1@amlogic.com> |
| Change-Id: I90e67854b213dd673077c72bb4830264d17f1f88 |
| --- |
| crypto/jitterentropy-kcapi.c | 27 +++++++++++++++++++++++++++ |
| kernel/params.c | 12 ++++++++++++ |
| 2 files changed, 39 insertions(+) |
| |
| diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c |
| index 7d1463a1562a..6098e8c80628 100644 |
| --- a/crypto/jitterentropy-kcapi.c |
| +++ b/crypto/jitterentropy-kcapi.c |
| @@ -318,6 +318,32 @@ static struct rng_alg jent_alg = { |
| } |
| }; |
| |
| +#if IS_ENABLED(CONFIG_AMLOGIC_BOOT_TIME) |
| +static struct delayed_work jent_work; |
| +static void __jent_mod_init(struct work_struct *work) |
| +{ |
| + int ret = 0; |
| + |
| + ret = jent_entropy_init(); |
| + if (ret) { |
| + pr_info("jitterentropy: Initialization failed with : %d\n", ret); |
| + return; |
| + } |
| + ret = crypto_register_rng(&jent_alg); |
| + if (ret) { |
| + pr_err("registering jent_alg failed: %d\n", ret); |
| + return; |
| + } |
| +} |
| + |
| +static int __init jent_mod_init(void) |
| +{ |
| + INIT_DELAYED_WORK(&jent_work, __jent_mod_init); |
| + schedule_delayed_work(&jent_work, msecs_to_jiffies(1000)); |
| + |
| + return 0; |
| +} |
| +#else |
| static int __init jent_mod_init(void) |
| { |
| SHASH_DESC_ON_STACK(desc, tfm); |
| @@ -348,6 +374,7 @@ static int __init jent_mod_init(void) |
| } |
| return crypto_register_rng(&jent_alg); |
| } |
| +#endif |
| |
| static void __exit jent_mod_exit(void) |
| { |
| diff --git a/kernel/params.c b/kernel/params.c |
| index 2d4a0564697e..deac97a77122 100644 |
| --- a/kernel/params.c |
| +++ b/kernel/params.c |
| @@ -973,6 +973,14 @@ static int __init param_sysfs_init(void) |
| } |
| subsys_initcall(param_sysfs_init); |
| |
| +#if IS_ENABLED(CONFIG_AMLOGIC_BOOT_TIME) |
| +static void __init async_param_sysfs_builtin(void *data, async_cookie_t cookie) |
| +{ |
| + version_sysfs_builtin(); |
| + param_sysfs_builtin(); |
| +} |
| +#endif |
| + |
| /* |
| * param_sysfs_builtin_init - add sysfs version and parameter |
| * attributes for built-in modules |
| @@ -982,8 +990,12 @@ static int __init param_sysfs_builtin_init(void) |
| if (!module_kset) |
| return -ENOMEM; |
| |
| +#if IS_ENABLED(CONFIG_AMLOGIC_BOOT_TIME) |
| + async_schedule(async_param_sysfs_builtin, NULL); |
| +#else |
| version_sysfs_builtin(); |
| param_sysfs_builtin(); |
| +#endif |
| |
| return 0; |
| } |
| -- |
| 2.42.0 |
| |