Lines Matching refs:engine
37 static void crypto_finalize_request(struct crypto_engine *engine, in crypto_finalize_request() argument
47 if (!engine->retry_support) { in crypto_finalize_request()
48 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_finalize_request()
49 if (engine->cur_req == req) { in crypto_finalize_request()
50 engine->cur_req = NULL; in crypto_finalize_request()
52 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_finalize_request()
58 kthread_queue_work(engine->kworker, &engine->pump_requests); in crypto_finalize_request()
70 static void crypto_pump_requests(struct crypto_engine *engine, in crypto_pump_requests() argument
79 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_pump_requests()
82 if (!engine->retry_support && engine->cur_req) in crypto_pump_requests()
86 if (!crypto_queue_len(&engine->queue) || !engine->running) { in crypto_pump_requests()
87 if (!engine->busy) in crypto_pump_requests()
92 kthread_queue_work(engine->kworker, in crypto_pump_requests()
93 &engine->pump_requests); in crypto_pump_requests()
97 engine->busy = false; in crypto_pump_requests()
103 backlog = crypto_get_backlog(&engine->queue); in crypto_pump_requests()
104 async_req = crypto_dequeue_request(&engine->queue); in crypto_pump_requests()
113 if (!engine->retry_support) in crypto_pump_requests()
114 engine->cur_req = async_req; in crypto_pump_requests()
116 if (!engine->busy) in crypto_pump_requests()
117 engine->busy = true; in crypto_pump_requests()
119 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_pump_requests()
124 ret = op->do_one_request(engine, async_req); in crypto_pump_requests()
133 if (!engine->retry_support || in crypto_pump_requests()
135 dev_err(engine->dev, in crypto_pump_requests()
140 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_pump_requests()
146 crypto_enqueue_request_head(&engine->queue, async_req); in crypto_pump_requests()
148 kthread_queue_work(engine->kworker, &engine->pump_requests); in crypto_pump_requests()
162 if (engine->retry_support) { in crypto_pump_requests()
163 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_pump_requests()
169 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_pump_requests()
176 struct crypto_engine *engine = in crypto_pump_work() local
179 crypto_pump_requests(engine, true); in crypto_pump_work()
188 static int crypto_transfer_request(struct crypto_engine *engine, in crypto_transfer_request() argument
195 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_transfer_request()
197 if (!engine->running) { in crypto_transfer_request()
198 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_transfer_request()
202 ret = crypto_enqueue_request(&engine->queue, req); in crypto_transfer_request()
204 if (!engine->busy && need_pump) in crypto_transfer_request()
205 kthread_queue_work(engine->kworker, &engine->pump_requests); in crypto_transfer_request()
207 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_transfer_request()
217 static int crypto_transfer_request_to_engine(struct crypto_engine *engine, in crypto_transfer_request_to_engine() argument
220 return crypto_transfer_request(engine, req, true); in crypto_transfer_request_to_engine()
229 int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine, in crypto_transfer_aead_request_to_engine() argument
232 return crypto_transfer_request_to_engine(engine, &req->base); in crypto_transfer_aead_request_to_engine()
242 int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine, in crypto_transfer_akcipher_request_to_engine() argument
245 return crypto_transfer_request_to_engine(engine, &req->base); in crypto_transfer_akcipher_request_to_engine()
255 int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine, in crypto_transfer_hash_request_to_engine() argument
258 return crypto_transfer_request_to_engine(engine, &req->base); in crypto_transfer_hash_request_to_engine()
268 int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine, in crypto_transfer_kpp_request_to_engine() argument
271 return crypto_transfer_request_to_engine(engine, &req->base); in crypto_transfer_kpp_request_to_engine()
281 int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine, in crypto_transfer_skcipher_request_to_engine() argument
284 return crypto_transfer_request_to_engine(engine, &req->base); in crypto_transfer_skcipher_request_to_engine()
295 void crypto_finalize_aead_request(struct crypto_engine *engine, in crypto_finalize_aead_request() argument
298 return crypto_finalize_request(engine, &req->base, err); in crypto_finalize_aead_request()
309 void crypto_finalize_akcipher_request(struct crypto_engine *engine, in crypto_finalize_akcipher_request() argument
312 return crypto_finalize_request(engine, &req->base, err); in crypto_finalize_akcipher_request()
323 void crypto_finalize_hash_request(struct crypto_engine *engine, in crypto_finalize_hash_request() argument
326 return crypto_finalize_request(engine, &req->base, err); in crypto_finalize_hash_request()
336 void crypto_finalize_kpp_request(struct crypto_engine *engine, in crypto_finalize_kpp_request() argument
339 return crypto_finalize_request(engine, &req->base, err); in crypto_finalize_kpp_request()
350 void crypto_finalize_skcipher_request(struct crypto_engine *engine, in crypto_finalize_skcipher_request() argument
353 return crypto_finalize_request(engine, &req->base, err); in crypto_finalize_skcipher_request()
363 int crypto_engine_start(struct crypto_engine *engine) in crypto_engine_start() argument
367 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_engine_start()
369 if (engine->running || engine->busy) { in crypto_engine_start()
370 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_engine_start()
374 engine->running = true; in crypto_engine_start()
375 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_engine_start()
377 kthread_queue_work(engine->kworker, &engine->pump_requests); in crypto_engine_start()
389 int crypto_engine_stop(struct crypto_engine *engine) in crypto_engine_stop() argument
395 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_engine_stop()
401 while ((crypto_queue_len(&engine->queue) || engine->busy) && limit--) { in crypto_engine_stop()
402 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_engine_stop()
404 spin_lock_irqsave(&engine->queue_lock, flags); in crypto_engine_stop()
407 if (crypto_queue_len(&engine->queue) || engine->busy) in crypto_engine_stop()
410 engine->running = false; in crypto_engine_stop()
412 spin_unlock_irqrestore(&engine->queue_lock, flags); in crypto_engine_stop()
415 dev_warn(engine->dev, "could not stop engine\n"); in crypto_engine_stop()
437 struct crypto_engine *engine; in crypto_engine_alloc_init_and_set() local
442 engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL); in crypto_engine_alloc_init_and_set()
443 if (!engine) in crypto_engine_alloc_init_and_set()
446 engine->dev = dev; in crypto_engine_alloc_init_and_set()
447 engine->rt = rt; in crypto_engine_alloc_init_and_set()
448 engine->running = false; in crypto_engine_alloc_init_and_set()
449 engine->busy = false; in crypto_engine_alloc_init_and_set()
450 engine->retry_support = retry_support; in crypto_engine_alloc_init_and_set()
451 engine->priv_data = dev; in crypto_engine_alloc_init_and_set()
453 snprintf(engine->name, sizeof(engine->name), in crypto_engine_alloc_init_and_set()
456 crypto_init_queue(&engine->queue, qlen); in crypto_engine_alloc_init_and_set()
457 spin_lock_init(&engine->queue_lock); in crypto_engine_alloc_init_and_set()
459 engine->kworker = kthread_run_worker(0, "%s", engine->name); in crypto_engine_alloc_init_and_set()
460 if (IS_ERR(engine->kworker)) { in crypto_engine_alloc_init_and_set()
464 kthread_init_work(&engine->pump_requests, crypto_pump_work); in crypto_engine_alloc_init_and_set()
466 if (engine->rt) { in crypto_engine_alloc_init_and_set()
468 sched_set_fifo(engine->kworker->task); in crypto_engine_alloc_init_and_set()
471 return engine; in crypto_engine_alloc_init_and_set()
495 void crypto_engine_exit(struct crypto_engine *engine) in crypto_engine_exit() argument
499 ret = crypto_engine_stop(engine); in crypto_engine_exit()
503 kthread_destroy_worker(engine->kworker); in crypto_engine_exit()