aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/pcrypt.c19
-rw-r--r--include/linux/padata.h3
-rw-r--r--kernel/padata.c18
3 files changed, 32 insertions, 8 deletions
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index 247178cb98ec..71ae2b2ae33b 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -385,6 +385,7 @@ static struct crypto_template pcrypt_tmpl = {
385 385
386static int __init pcrypt_init(void) 386static int __init pcrypt_init(void)
387{ 387{
388 int err = -ENOMEM;
388 encwq = create_workqueue("pencrypt"); 389 encwq = create_workqueue("pencrypt");
389 if (!encwq) 390 if (!encwq)
390 goto err; 391 goto err;
@@ -400,14 +401,22 @@ static int __init pcrypt_init(void)
400 401
401 pcrypt_dec_padata = padata_alloc(cpu_possible_mask, decwq); 402 pcrypt_dec_padata = padata_alloc(cpu_possible_mask, decwq);
402 if (!pcrypt_dec_padata) 403 if (!pcrypt_dec_padata)
403 goto err_free_padata; 404 goto err_free_enc_padata;
404 405
405 padata_start(pcrypt_enc_padata); 406 err = padata_start(pcrypt_enc_padata);
406 padata_start(pcrypt_dec_padata); 407 if (err)
408 goto err_free_dec_padata;
409
410 err = padata_start(pcrypt_dec_padata);
411 if (err)
412 goto err_free_dec_padata;
407 413
408 return crypto_register_template(&pcrypt_tmpl); 414 return crypto_register_template(&pcrypt_tmpl);
409 415
410err_free_padata: 416err_free_dec_padata:
417 padata_free(pcrypt_dec_padata);
418
419err_free_enc_padata:
411 padata_free(pcrypt_enc_padata); 420 padata_free(pcrypt_enc_padata);
412 421
413err_destroy_decwq: 422err_destroy_decwq:
@@ -417,7 +426,7 @@ err_destroy_encwq:
417 destroy_workqueue(encwq); 426 destroy_workqueue(encwq);
418 427
419err: 428err:
420 return -ENOMEM; 429 return err;
421} 430}
422 431
423static void __exit pcrypt_exit(void) 432static void __exit pcrypt_exit(void)
diff --git a/include/linux/padata.h b/include/linux/padata.h
index 8d8406246eef..e4c17f9b7c9e 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -126,6 +126,7 @@ struct padata_instance {
126 u8 flags; 126 u8 flags;
127#define PADATA_INIT 1 127#define PADATA_INIT 1
128#define PADATA_RESET 2 128#define PADATA_RESET 2
129#define PADATA_INVALID 4
129}; 130};
130 131
131extern struct padata_instance *padata_alloc(const struct cpumask *cpumask, 132extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
@@ -138,6 +139,6 @@ extern int padata_set_cpumask(struct padata_instance *pinst,
138 cpumask_var_t cpumask); 139 cpumask_var_t cpumask);
139extern int padata_add_cpu(struct padata_instance *pinst, int cpu); 140extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
140extern int padata_remove_cpu(struct padata_instance *pinst, int cpu); 141extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
141extern void padata_start(struct padata_instance *pinst); 142extern int padata_start(struct padata_instance *pinst);
142extern void padata_stop(struct padata_instance *pinst); 143extern void padata_stop(struct padata_instance *pinst);
143#endif 144#endif
diff --git a/kernel/padata.c b/kernel/padata.c
index ff8de1b71e4e..e7d723a3e31d 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -485,6 +485,11 @@ static void padata_flush_queues(struct parallel_data *pd)
485 BUG_ON(atomic_read(&pd->refcnt) != 0); 485 BUG_ON(atomic_read(&pd->refcnt) != 0);
486} 486}
487 487
488static void __padata_start(struct padata_instance *pinst)
489{
490 pinst->flags |= PADATA_INIT;
491}
492
488/* Replace the internal control stucture with a new one. */ 493/* Replace the internal control stucture with a new one. */
489static void padata_replace(struct padata_instance *pinst, 494static void padata_replace(struct padata_instance *pinst,
490 struct parallel_data *pd_new) 495 struct parallel_data *pd_new)
@@ -619,11 +624,20 @@ EXPORT_SYMBOL(padata_remove_cpu);
619 * 624 *
620 * @pinst: padata instance to start 625 * @pinst: padata instance to start
621 */ 626 */
622void padata_start(struct padata_instance *pinst) 627int padata_start(struct padata_instance *pinst)
623{ 628{
629 int err = 0;
630
624 mutex_lock(&pinst->lock); 631 mutex_lock(&pinst->lock);
625 pinst->flags |= PADATA_INIT; 632
633 if (pinst->flags & PADATA_INVALID)
634 err =-EINVAL;
635
636 __padata_start(pinst);
637
626 mutex_unlock(&pinst->lock); 638 mutex_unlock(&pinst->lock);
639
640 return err;
627} 641}
628EXPORT_SYMBOL(padata_start); 642EXPORT_SYMBOL(padata_start);
629 643