Skip to content

Commit

Permalink
crypto: cryptd - move kcrypto_wq into cryptd
Browse files Browse the repository at this point in the history
kcrypto_wq is only used by cryptd, so move it into cryptd.c and change
the workqueue name from "crypto" to "cryptd".

Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed May 30, 2019
1 parent e590e13 commit 3e56e16
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 61 deletions.
5 changes: 0 additions & 5 deletions crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ config CRYPTO_BLKCIPHER2
tristate
select CRYPTO_ALGAPI2
select CRYPTO_RNG2
select CRYPTO_WORKQUEUE

config CRYPTO_HASH
tristate
Expand Down Expand Up @@ -183,15 +182,11 @@ config CRYPTO_PCRYPT
This converts an arbitrary crypto algorithm into a parallel
algorithm that executes in kernel threads.

config CRYPTO_WORKQUEUE
tristate

config CRYPTO_CRYPTD
tristate "Software async crypto daemon"
select CRYPTO_BLKCIPHER
select CRYPTO_HASH
select CRYPTO_MANAGER
select CRYPTO_WORKQUEUE
help
This is a generic software asynchronous crypto daemon that
converts an arbitrary synchronous software crypto algorithm
Expand Down
2 changes: 0 additions & 2 deletions crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
obj-$(CONFIG_CRYPTO) += crypto.o
crypto-y := api.o cipher.o compress.o memneq.o

obj-$(CONFIG_CRYPTO_WORKQUEUE) += crypto_wq.o

obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
obj-$(CONFIG_CRYPTO_FIPS) += fips.o

Expand Down
24 changes: 19 additions & 5 deletions crypto/cryptd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include <crypto/cryptd.h>
#include <crypto/crypto_wq.h>
#include <linux/atomic.h>
#include <linux/err.h>
#include <linux/init.h>
Expand All @@ -31,11 +30,14 @@
#include <linux/scatterlist.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/workqueue.h>

static unsigned int cryptd_max_cpu_qlen = 1000;
module_param(cryptd_max_cpu_qlen, uint, 0);
MODULE_PARM_DESC(cryptd_max_cpu_qlen, "Set cryptd Max queue depth");

static struct workqueue_struct *cryptd_wq;

struct cryptd_cpu_queue {
struct crypto_queue queue;
struct work_struct work;
Expand Down Expand Up @@ -141,7 +143,7 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue,
if (err == -ENOSPC)
goto out_put_cpu;

queue_work_on(cpu, kcrypto_wq, &cpu_queue->work);
queue_work_on(cpu, cryptd_wq, &cpu_queue->work);

if (!atomic_read(refcnt))
goto out_put_cpu;
Expand Down Expand Up @@ -184,7 +186,7 @@ static void cryptd_queue_worker(struct work_struct *work)
req->complete(req, 0);

if (cpu_queue->queue.qlen)
queue_work(kcrypto_wq, &cpu_queue->work);
queue_work(cryptd_wq, &cpu_queue->work);
}

static inline struct cryptd_queue *cryptd_get_queue(struct crypto_tfm *tfm)
Expand Down Expand Up @@ -1123,19 +1125,31 @@ static int __init cryptd_init(void)
{
int err;

cryptd_wq = alloc_workqueue("cryptd", WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE,
1);
if (!cryptd_wq)
return -ENOMEM;

err = cryptd_init_queue(&queue, cryptd_max_cpu_qlen);
if (err)
return err;
goto err_destroy_wq;

err = crypto_register_template(&cryptd_tmpl);
if (err)
cryptd_fini_queue(&queue);
goto err_fini_queue;

return 0;

err_fini_queue:
cryptd_fini_queue(&queue);
err_destroy_wq:
destroy_workqueue(cryptd_wq);
return err;
}

static void __exit cryptd_exit(void)
{
destroy_workqueue(cryptd_wq);
cryptd_fini_queue(&queue);
crypto_unregister_template(&cryptd_tmpl);
}
Expand Down
40 changes: 0 additions & 40 deletions crypto/crypto_wq.c

This file was deleted.

1 change: 0 additions & 1 deletion drivers/crypto/cavium/cpt/cptvf_algs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <crypto/aes.h>
#include <crypto/algapi.h>
#include <crypto/authenc.h>
#include <crypto/crypto_wq.h>
#include <crypto/des.h>
#include <crypto/xts.h>
#include <linux/crypto.h>
Expand Down
8 changes: 0 additions & 8 deletions include/crypto/crypto_wq.h

This file was deleted.

0 comments on commit 3e56e16

Please sign in to comment.