crypto: sun8i-ss - avoid hash and rng references
PATCH 1/1 crypto: sun8i-ss - avoid hash and rng references
From: Arnd Bergmann <[email protected]>
While the sun4i-ss and sun8i-ce drivers started selecting CRYPTO_RNG, the sun8i-ss variant does not, and causes a link failure:
aarch64-linux-ld: drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.o: in function `sun8i_ss_unregister_algs':
sun8i-ss-core.c:(.text.sun8i_ss_unregister_algs+0x94): undefined reference to `crypto_unregister_rng'
aarch64-linux-ld: drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.o: in function `sun8i_ss_probe':
sun8i-ss-core.c:(.text.sun8i_ss_probe+0x40c): undefined reference to `crypto_register_rng'
Looking more closely, I see that all of the allwinner crypto drivers have the same logic where the rng and hash parts of the driver are optional, but then the generic code is still selected, which is a bit inconsistent, aside from the missing CRYPTO_RNG select on sun8i-ss.
Change the approach so only the bits that are actually used are built, using ifdef checks around the optional portions that match the optional references to the sub-drivers.
Ideally the drivers would get reworked in a way that keeps all the bits related to the skcipher/ahash/rng codecs in the respective sub-drivers, rather than having a common driver that knows about all of these.
---
The simpler approach would be to add even more 'select' statements
--- drivers/crypto/allwinner/Kconfig | 2 -- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 8 ++++++++ drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 12 ++++++++++++ drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 12 ++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-)
drivers/crypto/allwinner/Kconfig +0 -2
@@ -14,7 +14,6 @@ config CRYPTO_DEV_SUN4I_SS select CRYPTO_SHA1 select CRYPTO_AES select CRYPTO_LIB_DES - select CRYPTO_RNG select CRYPTO_SKCIPHER help Some Allwinner SoC have a crypto accelerator named
@@ -50,7 +49,6 @@ config CRYPTO_DEV_SUN8I_CE select CRYPTO_CBC select CRYPTO_AES select CRYPTO_DES - select CRYPTO_RNG depends on CRYPTO_DEV_ALLWINNER depends on PM help
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +8 -0
@@ -247,12 +247,14 @@ static int sun4i_ss_debugfs_show(struct seq_file *seq, void *v) ss_algs[i].stat_req, ss_algs[i].stat_opti, ss_algs[i].stat_fb, ss_algs[i].stat_bytes);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , ss_algs[i].alg.rng.base.cra_driver_name, ss_algs[i].alg.rng.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_bytes);break ; +#endif case CRYPTO_ALG_TYPE_AHASH : seq_printf(seq, "%s %s reqs=%lu\n", ss_algs[i].alg.hash.halg.base.cra_driver_name,
@@ -471,6 +473,7 @@ static int sun4i_ss_probe(struct platform_device *pdev) goto error_alg; }break ; +#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG case CRYPTO_ALG_TYPE_RNG : err =crypto_register_rng (&ss_algs[i].alg.rng);if (err) {
@@ -478,6 +481,7 @@ static int sun4i_ss_probe(struct platform_device *pdev) ss_algs[i].alg.rng.base.cra_name); }break ; +#endif } }
@@ -497,9 +501,11 @@ static int sun4i_ss_probe(struct platform_device *pdev)case CRYPTO_ALG_TYPE_AHASH :crypto_unregister_ahash (&ss_algs[i].alg.hash);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :crypto_unregister_rng (&ss_algs[i].alg.rng);break ; +#endif } } error_pm:
@@ -520,9 +526,11 @@ static void sun4i_ss_remove(struct platform_device *pdev)case CRYPTO_ALG_TYPE_AHASH :crypto_unregister_ahash (&ss_algs[i].alg.hash);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :crypto_unregister_rng (&ss_algs[i].alg.rng);break ; +#endif } }
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +12 -0
@@ -676,6 +676,7 @@ static int sun8i_ce_debugfs_show(struct seq_file *seq, void *v)seq_printf (seq,"\tFallback due to SG numbers: %lu\n" , ce_algs[i].stat_fb_maxsg);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_HASH case CRYPTO_ALG_TYPE_AHASH : seq_printf(seq, "%s %s reqs=%lu fallback=%lu\n", ce_algs[i].alg.hash.base.halg.base.cra_driver_name,
@@ -692,12 +693,15 @@ static int sun8i_ce_debugfs_show(struct seq_file *seq, void *v)seq_printf (seq,"\tFallback due to SG numbers: %lu\n" , ce_algs[i].stat_fb_maxsg);break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG case CRYPTO_ALG_TYPE_RNG :seq_printf (seq,"%s %s reqs=%lu bytes=%lu\n" , ce_algs[i].alg.rng.base.cra_driver_name, ce_algs[i].alg.rng.base.cra_name, ce_algs[i].stat_req, ce_algs[i].stat_bytes);break ; +#endif } } #if defined(CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG) && \
@@ -905,6 +909,7 @@ static int sun8i_ce_register_algs(struct sun8i_ce_dev *ce)return err; }break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_HASH case CRYPTO_ALG_TYPE_AHASH : id = ce_algs[i].ce_algo_id; ce_method = ce->variant->alg_hash[id];
@@ -925,6 +930,8 @@ static int sun8i_ce_register_algs(struct sun8i_ce_dev *ce)return err; }break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG case CRYPTO_ALG_TYPE_RNG :if (ce->variant->prng ==CE_ID_NOTSUPP ) { dev_info(ce->dev,
@@ -942,6 +949,7 @@ static int sun8i_ce_register_algs(struct sun8i_ce_dev *ce) ce_algs[i].ce = NULL; }break ; +#endif default : ce_algs[i].ce =NULL ;dev_err (ce->dev,"ERROR: tried to register an unknown algo\n" );
@@ -963,16 +971,20 @@ static void sun8i_ce_unregister_algs(struct sun8i_ce_dev *ce) ce_algs[i].alg.skcipher.base.base.cra_name);crypto_engine_unregister_skcipher (&ce_algs[i].alg.skcipher);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_HASH case CRYPTO_ALG_TYPE_AHASH :dev_info (ce->dev,"Unregister %d %s\n" , i, ce_algs[i].alg.hash.base.halg.base.cra_name);crypto_engine_unregister_ahash (&ce_algs[i].alg.hash);break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG case CRYPTO_ALG_TYPE_RNG :dev_info (ce->dev,"Unregister %d %s\n" , i, ce_algs[i].alg.rng.base.cra_name);crypto_unregister_rng (&ce_algs[i].alg.rng);break ; +#endif } } }
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +12 -0
@@ -501,12 +501,15 @@ static int sun8i_ss_debugfs_show(struct seq_file *seq, void *v)seq_printf (seq,"\tFallback due to SG numbers: %lu\n" , ss_algs[i].stat_fb_sgnum);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , ss_algs[i].alg.rng.base.cra_driver_name, ss_algs[i].alg.rng.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_bytes);break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_HASH case CRYPTO_ALG_TYPE_AHASH : seq_printf(seq, "%s %s reqs=%lu fallback=%lu\n", ss_algs[i].alg.hash.base.halg.base.cra_driver_name,
@@ -523,6 +526,7 @@ static int sun8i_ss_debugfs_show(struct seq_file *seq, void *v)seq_printf (seq,"\tFallback due to SG numbers: %lu\n" , ss_algs[i].stat_fb_sgnum);break ; +#endif } }return 0 ;
@@ -707,6 +711,7 @@ static int sun8i_ss_register_algs(struct sun8i_ss_dev *ss)return err; }break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG case CRYPTO_ALG_TYPE_RNG : err =crypto_register_rng (&ss_algs[i].alg.rng);if (err) {
@@ -715,6 +720,8 @@ static int sun8i_ss_register_algs(struct sun8i_ss_dev *ss) ss_algs[i].ss = NULL; }break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_HASH case CRYPTO_ALG_TYPE_AHASH : id = ss_algs[i].ss_algo_id; ss_method = ss->variant->alg_hash[id];
@@ -735,6 +742,7 @@ static int sun8i_ss_register_algs(struct sun8i_ss_dev *ss) return err; }break ; +#endif default : ss_algs[i].ss =NULL ;dev_err (ss->dev,"ERROR: tried to register an unknown algo\n" );
@@ -756,16 +764,20 @@ static void sun8i_ss_unregister_algs(struct sun8i_ss_dev *ss) ss_algs[i].alg.skcipher.base.base.cra_name);crypto_engine_unregister_skcipher (&ss_algs[i].alg.skcipher);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :dev_info (ss->dev,"Unregister %d %s\n" , i, ss_algs[i].alg.rng.base.cra_name);crypto_unregister_rng (&ss_algs[i].alg.rng);break ; +#endif +#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_HASH case CRYPTO_ALG_TYPE_AHASH :dev_info (ss->dev,"Unregister %d %s\n" , i, ss_algs[i].alg.hash.base.halg.base.cra_name);crypto_engine_unregister_ahash (&ss_algs[i].alg.hash);break ; +#endif } } }
Signature · 1 line
2.39.5
Herbert Xu
maintainerQuoted 6 lines · Arnd Bergmann
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +0
-0
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c static int sun4i_ss_debugfs_show(struct seq_file *seq, void *v) · line 256
Quoted 10 lines
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +1
-0@@ -247,12 +247,14 @@ static int sun4i_ss_debugfs_show(struct seq_file *seq, void *v) ss_algs[i].stat_req, ss_algs[i].stat_opti, ss_algs[i].stat_fb, ss_algs[i].stat_bytes);break ; +#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG case CRYPTO_ALG_TYPE_RNG :seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , ss_algs[i].alg.rng.base.cra_driver_name, ss_algs[i].alg.rng.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_bytes);break ;
Does this work?
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG)) seq_printf(seq, "%s %s reqs=%lu tsize=%lu\n", ss_algs[i].alg.rng.base.cra_driver_name, ss_algs[i].alg.rng.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_bytes); break;
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 9 lines · Herbert Xu
On Thu, Apr 23, 2026 at 08:55:42AM +0200, Arnd Bergmann wrote:
Does this work?if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG)) seq_printf(seq, "%s %s reqs=%lu tsize=%lu\n", ss_algs[i].alg.rng.base.cra_driver_name, ss_algs[i].alg.rng.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_bytes); break;
Yes, I can rework the patch that way. I had considered this originally but decided this would end up less readable in this case because of the extra indentation level. The drivers already has a lot of #ifdef checks, so adding more of those felt more in line with the style used here.
Arnd
Herbert Xu
maintainerQuoted 6 lines · Arnd Bergmann
Yes, I can rework the patch that way. I had considered this originally but decided this would end up less readable in this case because of the extra indentation level. The drivers already has a lot of #ifdef checks, so adding more of those felt more in line with the style used here.
If we're adding new code I prefer doing it inline instead of as an ifdef so that we maximise compiler coverage.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 10 lines · Herbert Xu
Quoted 6 lines · Arnd Bergmann
Yes, I can rework the patch that way. I had considered this originally but decided this would end up less readable in this case because of the extra indentation level. The drivers already has a lot of #ifdef checks, so adding more of those felt more in line with the style used here.
If we're adding new code I prefer doing it inline instead of as an ifdef so that we maximise compiler coverage.
Sure, but I'm not adding new code here, I only reported a regression from Eric's (otherwise very nice) cleanup and tried to come up with a better workaround than adding another 'select'.
I've tried to rework one driver to use IS_ENABLED() checks now instead of the #ifdef, and also replace the for()/switch() loop with three separate loops for simplicity. See below for what I ended up with compared with my first patch.
I'm still not entirely happy with that version either, especially since this is getting beyond a purely mechanical cleanup. If you think this is better, I can do it for all three drivers, otherwise I'd just send the oneline change to work around the third driver link failure the same way that Eric did for the other two, and let the sunxi maintainters worry about cleaning it up.
Arnd
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +88 -85
@@ -31,7 +31,7 @@ static const struct ss_variant ss_a33_variant = { .sha1_in_be = true, }; -static struct sun4i_ss_alg_template ss_algs[] = { +static struct sun4i_ss_alg_template ss_ahash_algs[] = { { .type =CRYPTO_ALG_TYPE_AHASH , .mode =SS_OP_MD5 , .alg.hash = {
@@ -84,6 +84,9 @@ static struct sun4i_ss_alg_template ss_algs[] = { } } }, +}; + +static struct sun4i_ss_alg_template ss_skcipher_algs[] = { { .type =CRYPTO_ALG_TYPE_SKCIPHER , .alg.crypto = { .setkey = sun4i_ss_aes_setkey,
@@ -213,7 +216,9 @@ static struct sun4i_ss_alg_template ss_algs[] = { } } }, -#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG +}; + +static struct sun4i_ss_alg_template ss_rng_algs[] = { { .type =CRYPTO_ALG_TYPE_RNG , .alg.rng = {
@@ -229,40 +234,46 @@ static struct sun4i_ss_alg_template ss_algs[] = { .seedsize = SS_SEED_LEN / BITS_PER_BYTE, } }, -#endif };static int sun4i_ss_debugfs_show (struct seq_file *seq,void *v) {unsigned int i; -for (i =0 ; i <ARRAY_SIZE (ss_algs); i++) { -if (!ss_algs[i].ss) +for (i =0 ; i <ARRAY_SIZE (ss_skcipher_algs); i++) { +if (!ss_skcipher_algs[i].ss)continue ; -switch (ss_algs[i].type) { -case CRYPTO_ALG_TYPE_SKCIPHER : -seq_printf (seq,"%s %s reqs=%lu opti=%lu fallback=%lu tsize=%lu\n" , - ss_algs[i].alg.crypto.base.cra_driver_name, - ss_algs[i].alg.crypto.base.cra_name, - ss_algs[i].stat_req, ss_algs[i].stat_opti, ss_algs[i].stat_fb, - ss_algs[i].stat_bytes); -break ; -#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG -case CRYPTO_ALG_TYPE_RNG : -seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , - ss_algs[i].alg.rng.base.cra_driver_name, - ss_algs[i].alg.rng.base.cra_name, - ss_algs[i].stat_req, ss_algs[i].stat_bytes); -break ; -#endif -case CRYPTO_ALG_TYPE_AHASH : -seq_printf (seq,"%s %s reqs=%lu\n" , - ss_algs[i].alg.hash.halg.base.cra_driver_name, - ss_algs[i].alg.hash.halg.base.cra_name, - ss_algs[i].stat_req); -break ; - } +seq_printf (seq,"%s %s reqs=%lu opti=%lu fallback=%lu tsize=%lu\n" , + ss_skcipher_algs[i].alg.crypto.base.cra_driver_name, + ss_skcipher_algs[i].alg.crypto.base.cra_name, + ss_skcipher_algs[i].stat_req, + ss_skcipher_algs[i].stat_opti, + ss_skcipher_algs[i].stat_fb, + ss_skcipher_algs[i].stat_bytes); } + +for (i =0 ; i <ARRAY_SIZE (ss_ahash_algs); i++) { +if (!ss_ahash_algs[i].ss) +continue ; + +seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , + ss_ahash_algs[i].alg.rng.base.cra_driver_name, + ss_ahash_algs[i].alg.rng.base.cra_name, + ss_ahash_algs[i].stat_req, + ss_ahash_algs[i].stat_bytes); + } + +for (i =0 ; i <ARRAY_SIZE (ss_rng_algs); i++) { +if (!IS_ENABLED (CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG ) || + !ss_rng_algs[i].ss) +continue ; + +seq_printf (seq,"%s %s reqs=%lu\n" , + ss_rng_algs[i].alg.hash.halg.base.cra_driver_name, + ss_rng_algs[i].alg.hash.halg.base.cra_name, + ss_rng_algs[i].stat_req); + } +return 0 ; }DEFINE_SHOW_ATTRIBUTE (sun4i_ss_debugfs);
@@ -454,34 +465,36 @@ static int sun4i_ss_probe(struct platform_device *pdev)pm_runtime_put_sync (ss->dev); -for (i =0 ; i <ARRAY_SIZE (ss_algs); i++) { - ss_algs[i].ss = ss; -switch (ss_algs[i].type) { -case CRYPTO_ALG_TYPE_SKCIPHER : - err =crypto_register_skcipher (&ss_algs[i].alg.crypto); -if (err) { -dev_err (ss->dev,"Fail to register %s\n" , - ss_algs[i].alg.crypto.base.cra_name); - goto error_alg; - } -break ; -case CRYPTO_ALG_TYPE_AHASH : - err =crypto_register_ahash (&ss_algs[i].alg.hash); -if (err) { -dev_err (ss->dev,"Fail to register %s\n" , - ss_algs[i].alg.hash.halg.base.cra_name); - goto error_alg; - } -break ; -#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG -case CRYPTO_ALG_TYPE_RNG : - err =crypto_register_rng (&ss_algs[i].alg.rng); -if (err) { -dev_err (ss->dev,"Fail to register %s\n" , - ss_algs[i].alg.rng.base.cra_name); - } +for (i =0 ; i <ARRAY_SIZE (ss_skcipher_algs); i++) { + ss_skcipher_algs[i].ss = ss; + err =crypto_register_skcipher (&ss_skcipher_algs[i].alg.crypto); +if (err) { +dev_err (ss->dev,"Fail to register %s\n" , + ss_skcipher_algs[i].alg.crypto.base.cra_name); + goto error_skcipher_alg; + } + } + +for (i =0 ; i <ARRAY_SIZE (ss_ahash_algs); i++) { + ss_ahash_algs[i].ss = ss; + err =crypto_register_ahash (&ss_ahash_algs[i].alg.hash); +if (err) { +dev_err (ss->dev,"Fail to register %s\n" , + ss_ahash_algs[i].alg.hash.halg.base.cra_name); + goto error_ahash_alg; + } + } + +for (i =0 ; i <ARRAY_SIZE (ss_rng_algs); i++) { +if (!IS_ENABLED (CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG ))break ; -#endif + + ss_rng_algs[i].ss = ss; + err =crypto_register_rng (&ss_rng_algs[i].alg.rng); +if (err) { +dev_err (ss->dev,"Fail to register %s\n" , + ss_rng_algs[i].alg.rng.base.cra_name); + goto error_rng_alg; } }
@@ -491,23 +504,20 @@ static int sun4i_ss_probe(struct platform_device *pdev) &sun4i_ss_debugfs_fops);return 0 ; -error_alg: - i--; -for (; i >=0 ; i--) { -switch (ss_algs[i].type) { -case CRYPTO_ALG_TYPE_SKCIPHER : -crypto_unregister_skcipher (&ss_algs[i].alg.crypto); -break ; -case CRYPTO_ALG_TYPE_AHASH : -crypto_unregister_ahash (&ss_algs[i].alg.hash); -break ; -#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG -case CRYPTO_ALG_TYPE_RNG : -crypto_unregister_rng (&ss_algs[i].alg.rng); -break ; -#endif - } + +error_rng_alg: +if (IS_ENABLED (CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG )) { +for (i--; i >=0 ; i--) +crypto_unregister_rng (&ss_rng_algs[i].alg.rng); } + i =ARRAY_SIZE (ss_ahash_algs); +error_ahash_alg: +for (i--; i >=0 ; i--) +crypto_unregister_ahash (&ss_ahash_algs[i].alg.hash); + i =ARRAY_SIZE (ss_skcipher_algs); +error_skcipher_alg: +for (i--; i >=0 ; i--) +crypto_unregister_skcipher (&ss_skcipher_algs[i].alg.crypto); error_pm:sun4i_ss_pm_exit (ss);return err;
@@ -518,21 +528,14 @@ static void sun4i_ss_remove(struct platform_device *pdev)int i;struct sun4i_ss_ctx *ss =platform_get_drvdata (pdev); -for (i =0 ; i <ARRAY_SIZE (ss_algs); i++) { -switch (ss_algs[i].type) { -case CRYPTO_ALG_TYPE_SKCIPHER : -crypto_unregister_skcipher (&ss_algs[i].alg.crypto); -break ; -case CRYPTO_ALG_TYPE_AHASH : -crypto_unregister_ahash (&ss_algs[i].alg.hash); -break ; -#ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG -case CRYPTO_ALG_TYPE_RNG : -crypto_unregister_rng (&ss_algs[i].alg.rng); -break ; -#endif - } +if (IS_ENABLED (CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG )) { +for (i =ARRAY_SIZE (ss_rng_algs); i >=0 ; i--) +crypto_unregister_rng (&ss_rng_algs[i].alg.rng); } +for (i =ARRAY_SIZE (ss_ahash_algs); i >=0 ; i--) +crypto_unregister_ahash (&ss_ahash_algs[i].alg.hash); +for (i =ARRAY_SIZE (ss_skcipher_algs) -1 ; i >=0 ; i--) +crypto_unregister_skcipher (&ss_skcipher_algs[i].alg.crypto);sun4i_ss_pm_exit (ss); }
Herbert Xu
maintainerQuoted 10 lines · Arnd Bergmann
Sure, but I'm not adding new code here, I only reported a regression from Eric's (otherwise very nice) cleanup and tried to come up with a better workaround than adding another 'select'.
I've tried to rework one driver to use
IS_ENABLED()checks now instead of the #ifdef, and also replace the for()/switch() loop with three separate loops for simplicity. See below for what I ended up with compared with my first patch.
Quoted 7 lines
I'm still not entirely happy with that version either, especially since this is getting beyond a purely mechanical cleanup. If you think this is better, I can do it for all three drivers, otherwise I'd just send the oneline change to work around the third driver link failure the same way that Eric did for the other two, and let the sunxi maintainters worry about cleaning it up.
Sorry, I made my comment based on your original patch only which simply added ifdefs.
Now that I see the wider context in the driver, I'm happy to take your original patch as is.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerQuoted 25 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
While the sun4i-ss and sun8i-ce drivers started selecting
CRYPTO_RNG, the sun8i-ss variant does not, and causes a link failure:aarch64-linux-ld:
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.o: in function `sun8i_ss_unregister_algs':
sun8i-ss-core.c:(.text.sun8i_ss_unregister_algs+0x94): undefined reference to `crypto_unregister_rng'
aarch64-linux-ld:drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.o: in function `sun8i_ss_probe':
sun8i-ss-core.c:(.text.sun8i_ss_probe+0x40c): undefined reference to `crypto_register_rng'Looking more closely, I see that all of the allwinner crypto drivers have the same logic where the rng and hash parts of the driver are optional, but then the generic code is still selected, which is a bit inconsistent, aside from the missing
CRYPTO_RNGselect on sun8i-ss.Change the approach so only the bits that are actually used are built, using ifdef checks around the optional portions that match the optional references to the sub-drivers.
Ideally the drivers would get reworked in a way that keeps all the bits related to the skcipher/ahash/rng codecs in the respective sub-drivers, rather than having a common driver that knows about all of these.
Fixes cdadc1435937 ("crypto: cryptomgr - Select algorithm types only when CRYPTO_SELFTESTS")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 8 lines
---
The simpler approach would be to add even more 'select' statements--- drivers/crypto/allwinner/Kconfig | 2 -- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 8 ++++++++ drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 12 ++++++++++++ drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 12 ++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt