crypto: engine - Remove prepare/unprepare request

The callbacks for prepare and unprepare request in crypto_engine
is superfluous.  They can be done directly from do_one_request.

Move the code into do_one_request and remove the unused callbacks.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu 2023-08-13 14:54:32 +08:00
parent be8b8a950f
commit bcd6e41d98
2 changed files with 1 additions and 47 deletions

View File

@ -26,9 +26,6 @@ static void crypto_finalize_request(struct crypto_engine *engine,
struct crypto_async_request *req, int err) struct crypto_async_request *req, int err)
{ {
unsigned long flags; unsigned long flags;
bool finalize_req = false;
int ret;
struct crypto_engine_ctx *enginectx;
/* /*
* If hardware cannot enqueue more requests * If hardware cannot enqueue more requests
@ -38,21 +35,11 @@ static void crypto_finalize_request(struct crypto_engine *engine,
if (!engine->retry_support) { if (!engine->retry_support) {
spin_lock_irqsave(&engine->queue_lock, flags); spin_lock_irqsave(&engine->queue_lock, flags);
if (engine->cur_req == req) { if (engine->cur_req == req) {
finalize_req = true;
engine->cur_req = NULL; engine->cur_req = NULL;
} }
spin_unlock_irqrestore(&engine->queue_lock, flags); spin_unlock_irqrestore(&engine->queue_lock, flags);
} }
if (finalize_req || engine->retry_support) {
enginectx = crypto_tfm_ctx(req->tfm);
if (enginectx->op.prepare_request &&
enginectx->op.unprepare_request) {
ret = enginectx->op.unprepare_request(engine, req);
if (ret)
dev_err(engine->dev, "failed to unprepare request\n");
}
}
lockdep_assert_in_softirq(); lockdep_assert_in_softirq();
crypto_request_complete(req, err); crypto_request_complete(req, err);
@ -141,20 +128,12 @@ start_request:
ret = engine->prepare_crypt_hardware(engine); ret = engine->prepare_crypt_hardware(engine);
if (ret) { if (ret) {
dev_err(engine->dev, "failed to prepare crypt hardware\n"); dev_err(engine->dev, "failed to prepare crypt hardware\n");
goto req_err_2; goto req_err_1;
} }
} }
enginectx = crypto_tfm_ctx(async_req->tfm); enginectx = crypto_tfm_ctx(async_req->tfm);
if (enginectx->op.prepare_request) {
ret = enginectx->op.prepare_request(engine, async_req);
if (ret) {
dev_err(engine->dev, "failed to prepare request: %d\n",
ret);
goto req_err_2;
}
}
if (!enginectx->op.do_one_request) { if (!enginectx->op.do_one_request) {
dev_err(engine->dev, "failed to do request\n"); dev_err(engine->dev, "failed to do request\n");
ret = -EINVAL; ret = -EINVAL;
@ -177,18 +156,6 @@ start_request:
ret); ret);
goto req_err_1; goto req_err_1;
} }
/*
* If retry mechanism is supported,
* unprepare current request and
* enqueue it back into crypto-engine queue.
*/
if (enginectx->op.unprepare_request) {
ret = enginectx->op.unprepare_request(engine,
async_req);
if (ret)
dev_err(engine->dev,
"failed to unprepare request\n");
}
spin_lock_irqsave(&engine->queue_lock, flags); spin_lock_irqsave(&engine->queue_lock, flags);
/* /*
* If hardware was unable to execute request, enqueue it * If hardware was unable to execute request, enqueue it
@ -204,13 +171,6 @@ start_request:
goto retry; goto retry;
req_err_1: req_err_1:
if (enginectx->op.unprepare_request) {
ret = enginectx->op.unprepare_request(engine, async_req);
if (ret)
dev_err(engine->dev, "failed to unprepare request\n");
}
req_err_2:
crypto_request_complete(async_req, ret); crypto_request_complete(async_req, ret);
retry: retry:

View File

@ -78,15 +78,9 @@ struct crypto_engine {
/* /*
* struct crypto_engine_op - crypto hardware engine operations * struct crypto_engine_op - crypto hardware engine operations
* @prepare_request: do some preparation if needed before handling the current request
* @unprepare_request: undo any work done by prepare_request()
* @do_one_request: do encryption for current request * @do_one_request: do encryption for current request
*/ */
struct crypto_engine_op { struct crypto_engine_op {
int (*prepare_request)(struct crypto_engine *engine,
void *areq);
int (*unprepare_request)(struct crypto_engine *engine,
void *areq);
int (*do_one_request)(struct crypto_engine *engine, int (*do_one_request)(struct crypto_engine *engine,
void *areq); void *areq);
}; };