Skip to content

Commit d3f64e4

Browse files
klassertherbertx
authored andcommitted
crypto: pcrypt - Update pcrypt cpumask according to the padata cpumask notifier
The padata cpumask change notifier passes a padata_cpumask to the notifier chain. So we use this cpumask instead of asking padata for the cpumask. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c57e842 commit d3f64e4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎crypto/pcrypt.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/slab.h>
2727
#include <linux/notifier.h>
2828
#include <linux/kobject.h>
29+
#include <linux/cpu.h>
2930
#include <crypto/pcrypt.h>
3031

3132
struct padata_pcrypt {
@@ -409,6 +410,7 @@ static int pcrypt_cpumask_change_notify(struct notifier_block *self,
409410
{
410411
struct padata_pcrypt *pcrypt;
411412
struct pcrypt_cpumask *new_mask, *old_mask;
413+
struct padata_cpumask *cpumask = (struct padata_cpumask *)data;
412414

413415
if (!(val & PADATA_CPU_SERIAL))
414416
return 0;
@@ -424,7 +426,7 @@ static int pcrypt_cpumask_change_notify(struct notifier_block *self,
424426

425427
old_mask = pcrypt->cb_cpumask;
426428

427-
padata_get_cpumask(pcrypt->pinst, PADATA_CPU_SERIAL, new_mask->mask);
429+
cpumask_copy(new_mask->mask, cpumask->cbcpu);
428430
rcu_assign_pointer(pcrypt->cb_cpumask, new_mask);
429431
synchronize_rcu_bh();
430432

@@ -451,6 +453,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
451453
int ret = -ENOMEM;
452454
struct pcrypt_cpumask *mask;
453455

456+
get_online_cpus();
457+
454458
pcrypt->wq = create_workqueue(name);
455459
if (!pcrypt->wq)
456460
goto err;
@@ -467,7 +471,7 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
467471
goto err_free_padata;
468472
}
469473

470-
padata_get_cpumask(pcrypt->pinst, PADATA_CPU_SERIAL, mask->mask);
474+
cpumask_and(mask->mask, cpu_possible_mask, cpu_active_mask);
471475
rcu_assign_pointer(pcrypt->cb_cpumask, mask);
472476

473477
pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify;
@@ -479,7 +483,10 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
479483
if (ret)
480484
goto err_unregister_notifier;
481485

486+
put_online_cpus();
487+
482488
return ret;
489+
483490
err_unregister_notifier:
484491
padata_unregister_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock);
485492
err_free_cpumask:
@@ -490,6 +497,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
490497
err_destroy_workqueue:
491498
destroy_workqueue(pcrypt->wq);
492499
err:
500+
put_online_cpus();
501+
493502
return ret;
494503
}
495504

0 commit comments

Comments
 (0)