Clean up crypto_init().
The function is called from a KLD load handler, so it may sleep. - Stop checking for errors from uma_zcreate(), they don't happen. - Convert M_NOWAIT allocations to M_WAITOK. - Remove error handling for existing M_WAITOK allocations. - Fix style. Reviewed by: cem, delphij, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25696
This commit is contained in:
parent
256c5d705a
commit
e5587cbbc2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363273
@ -325,38 +325,22 @@ crypto_init(void)
|
||||
TAILQ_INIT(&crp_kq);
|
||||
mtx_init(&crypto_q_mtx, "crypto", "crypto op queues", MTX_DEF);
|
||||
|
||||
cryptop_zone = uma_zcreate("cryptop", sizeof (struct cryptop),
|
||||
0, 0, 0, 0,
|
||||
cryptop_zone = uma_zcreate("cryptop",
|
||||
sizeof(struct cryptop), NULL, NULL, NULL, NULL,
|
||||
UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
|
||||
cryptoses_zone = uma_zcreate("crypto_session",
|
||||
sizeof(struct crypto_session), NULL, NULL, NULL, NULL,
|
||||
UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
|
||||
|
||||
if (cryptop_zone == NULL || cryptoses_zone == NULL) {
|
||||
printf("crypto_init: cannot setup crypto zones\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
crypto_drivers_size = CRYPTO_DRIVERS_INITIAL;
|
||||
crypto_drivers = malloc(crypto_drivers_size *
|
||||
sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT | M_ZERO);
|
||||
if (crypto_drivers == NULL) {
|
||||
printf("crypto_init: cannot setup crypto drivers\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
sizeof(struct cryptocap), M_CRYPTO_DATA, M_WAITOK | M_ZERO);
|
||||
|
||||
if (crypto_workers_num < 1 || crypto_workers_num > mp_ncpus)
|
||||
crypto_workers_num = mp_ncpus;
|
||||
|
||||
crypto_tq = taskqueue_create("crypto", M_WAITOK|M_ZERO,
|
||||
crypto_tq = taskqueue_create("crypto", M_WAITOK | M_ZERO,
|
||||
taskqueue_thread_enqueue, &crypto_tq);
|
||||
if (crypto_tq == NULL) {
|
||||
printf("crypto init: cannot setup crypto taskqueue\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
taskqueue_start_threads(&crypto_tq, crypto_workers_num, PRI_MIN_KERN,
|
||||
"crypto");
|
||||
@ -369,14 +353,8 @@ crypto_init(void)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
crypto_ret_workers = malloc(crypto_workers_num * sizeof(struct crypto_ret_worker),
|
||||
M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
|
||||
if (crypto_ret_workers == NULL) {
|
||||
error = ENOMEM;
|
||||
printf("crypto_init: cannot allocate ret workers\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
crypto_ret_workers = mallocarray(crypto_workers_num,
|
||||
sizeof(struct crypto_ret_worker), M_CRYPTO_DATA, M_WAITOK | M_ZERO);
|
||||
|
||||
FOREACH_CRYPTO_RETW(ret_worker) {
|
||||
TAILQ_INIT(&ret_worker->crp_ordered_ret_q);
|
||||
|
Loading…
Reference in New Issue
Block a user