summaryrefslogtreecommitdiff
path: root/crypto/cryptd.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2022-07-14 09:57:37 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2022-07-14 09:57:37 +0200
commit7039637e25cd70490ab4d04a7b331efc733fe6e8 (patch)
tree4631919f50b92a6eaece955640727707513cc0f8 /crypto/cryptd.c
parent6cc10d30a2da07223b153bd87beebd63412ff5b9 (diff)
parent922de3665750792ad48a89321d68daf5d267ef5a (diff)
downloadlinux-crypto-7039637e25cd70490ab4d04a7b331efc733fe6e8.tar.gz
linux-crypto-7039637e25cd70490ab4d04a7b331efc733fe6e8.zip
Merge drm/drm-next into drm-misc-next-fixes
Backmerging from drm/drm-next for the final fixes that will go into v5.20. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Diffstat (limited to 'crypto/cryptd.c')
-rw-r--r--crypto/cryptd.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index a1bea0f4..668095ec 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -39,6 +39,10 @@ struct cryptd_cpu_queue {
};
struct cryptd_queue {
+ /*
+ * Protected by disabling BH to allow enqueueing from softinterrupt and
+ * dequeuing from kworker (cryptd_queue_worker()).
+ */
struct cryptd_cpu_queue __percpu *cpu_queue;
};
@@ -125,28 +129,28 @@ static void cryptd_fini_queue(struct cryptd_queue *queue)
static int cryptd_enqueue_request(struct cryptd_queue *queue,
struct crypto_async_request *request)
{
- int cpu, err;
+ int err;
struct cryptd_cpu_queue *cpu_queue;
refcount_t *refcnt;
- cpu = get_cpu();
+ local_bh_disable();
cpu_queue = this_cpu_ptr(queue->cpu_queue);
err = crypto_enqueue_request(&cpu_queue->queue, request);
refcnt = crypto_tfm_ctx(request->tfm);
if (err == -ENOSPC)
- goto out_put_cpu;
+ goto out;
- queue_work_on(cpu, cryptd_wq, &cpu_queue->work);
+ queue_work_on(smp_processor_id(), cryptd_wq, &cpu_queue->work);
if (!refcount_read(refcnt))
- goto out_put_cpu;
+ goto out;
refcount_inc(refcnt);
-out_put_cpu:
- put_cpu();
+out:
+ local_bh_enable();
return err;
}
@@ -162,15 +166,10 @@ static void cryptd_queue_worker(struct work_struct *work)
cpu_queue = container_of(work, struct cryptd_cpu_queue, work);
/*
* Only handle one request at a time to avoid hogging crypto workqueue.
- * preempt_disable/enable is used to prevent being preempted by
- * cryptd_enqueue_request(). local_bh_disable/enable is used to prevent
- * cryptd_enqueue_request() being accessed from software interrupts.
*/
local_bh_disable();
- preempt_disable();
backlog = crypto_get_backlog(&cpu_queue->queue);
req = crypto_dequeue_request(&cpu_queue->queue);
- preempt_enable();
local_bh_enable();
if (!req)