|
| 1 | +crypto: engine - Remove prepare/unprepare request |
| 2 | + |
| 3 | +jira LE-4159 |
| 4 | +Rebuild_History Non-Buildable kernel-5.14.0-570.41.1.el9_6 |
| 5 | +commit-author Herbert Xu <herbert@gondor.apana.org.au> |
| 6 | +commit bcd6e41d983621954dfc3f1f64249a55838b3e6a |
| 7 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 8 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 9 | +ciq/ciq_backports/kernel-5.14.0-570.41.1.el9_6/bcd6e41d.failed |
| 10 | + |
| 11 | +The callbacks for prepare and unprepare request in crypto_engine |
| 12 | +is superfluous. They can be done directly from do_one_request. |
| 13 | + |
| 14 | +Move the code into do_one_request and remove the unused callbacks. |
| 15 | + |
| 16 | + Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
| 17 | +(cherry picked from commit bcd6e41d983621954dfc3f1f64249a55838b3e6a) |
| 18 | + Signed-off-by: Jonathan Maple <jmaple@ciq.com> |
| 19 | + |
| 20 | +# Conflicts: |
| 21 | +# crypto/crypto_engine.c |
| 22 | +# include/crypto/engine.h |
| 23 | +diff --cc crypto/crypto_engine.c |
| 24 | +index 5c4b4f02100a,17f7955500a0..000000000000 |
| 25 | +--- a/crypto/crypto_engine.c |
| 26 | ++++ b/crypto/crypto_engine.c |
| 27 | +@@@ -59,16 -40,8 +55,21 @@@ static void crypto_finalize_request(str |
| 28 | + spin_unlock_irqrestore(&engine->queue_lock, flags); |
| 29 | + } |
| 30 | + |
| 31 | +++<<<<<<< HEAD |
| 32 | + + if (finalize_req || engine->retry_support) { |
| 33 | + + enginectx = crypto_tfm_ctx(req->tfm); |
| 34 | + + if (enginectx->op.prepare_request && |
| 35 | + + enginectx->op.unprepare_request) { |
| 36 | + + ret = enginectx->op.unprepare_request(engine, req); |
| 37 | + + if (ret) |
| 38 | + + dev_err(engine->dev, "failed to unprepare request\n"); |
| 39 | + + } |
| 40 | + + } |
| 41 | + + req->complete(req, err); |
| 42 | +++======= |
| 43 | ++ lockdep_assert_in_softirq(); |
| 44 | ++ crypto_request_complete(req, err); |
| 45 | +++>>>>>>> bcd6e41d9836 (crypto: engine - Remove prepare/unprepare request) |
| 46 | + |
| 47 | + kthread_queue_work(engine->kworker, &engine->pump_requests); |
| 48 | + } |
| 49 | +@@@ -164,30 -132,15 +165,37 @@@ start_request |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + - enginectx = crypto_tfm_ctx(async_req->tfm); |
| 54 | + - |
| 55 | + + if (async_req->tfm->__crt_alg->cra_flags & CRYPTO_ALG_ENGINE) { |
| 56 | + + alg = container_of(async_req->tfm->__crt_alg, |
| 57 | + + struct crypto_engine_alg, base); |
| 58 | + + op = &alg->op; |
| 59 | + + } else { |
| 60 | + + enginectx = crypto_tfm_ctx(async_req->tfm); |
| 61 | + + op = &enginectx->op; |
| 62 | + + |
| 63 | +++<<<<<<< HEAD |
| 64 | + + if (op->prepare_request) { |
| 65 | + + ret = op->prepare_request(engine, async_req); |
| 66 | + + if (ret) { |
| 67 | + + dev_err(engine->dev, "failed to prepare request: %d\n", |
| 68 | + + ret); |
| 69 | + + goto req_err_2; |
| 70 | + + } |
| 71 | + + } |
| 72 | + + if (!op->do_one_request) { |
| 73 | + + dev_err(engine->dev, "failed to do request\n"); |
| 74 | + + ret = -EINVAL; |
| 75 | + + goto req_err_1; |
| 76 | + + } |
| 77 | +++======= |
| 78 | ++ if (!enginectx->op.do_one_request) { |
| 79 | ++ dev_err(engine->dev, "failed to do request\n"); |
| 80 | ++ ret = -EINVAL; |
| 81 | ++ goto req_err_1; |
| 82 | +++>>>>>>> bcd6e41d9836 (crypto: engine - Remove prepare/unprepare request) |
| 83 | + } |
| 84 | + |
| 85 | + - ret = enginectx->op.do_one_request(engine, async_req); |
| 86 | + + ret = op->do_one_request(engine, async_req); |
| 87 | + |
| 88 | + /* Request unsuccessfully executed by hardware */ |
| 89 | + if (ret < 0) { |
| 90 | +@@@ -230,16 -171,12 +226,20 @@@ |
| 91 | + goto retry; |
| 92 | + |
| 93 | + req_err_1: |
| 94 | +++<<<<<<< HEAD |
| 95 | + + if (enginectx->op.unprepare_request) { |
| 96 | + + ret = enginectx->op.unprepare_request(engine, async_req); |
| 97 | + + if (ret) |
| 98 | + + dev_err(engine->dev, "failed to unprepare request\n"); |
| 99 | + + } |
| 100 | + + |
| 101 | + +req_err_2: |
| 102 | + + async_req->complete(async_req, ret); |
| 103 | +++======= |
| 104 | ++ crypto_request_complete(async_req, ret); |
| 105 | +++>>>>>>> bcd6e41d9836 (crypto: engine - Remove prepare/unprepare request) |
| 106 | + |
| 107 | + retry: |
| 108 | + - if (backlog) |
| 109 | + - crypto_request_complete(backlog, -EINPROGRESS); |
| 110 | + - |
| 111 | + /* If retry mechanism is supported, send new requests to engine */ |
| 112 | + if (engine->retry_support) { |
| 113 | + spin_lock_irqsave(&engine->queue_lock, flags); |
| 114 | +diff --cc include/crypto/engine.h |
| 115 | +index 7db1bae33021,1b02f69e0a79..000000000000 |
| 116 | +--- a/include/crypto/engine.h |
| 117 | ++++ b/include/crypto/engine.h |
| 118 | +@@@ -10,17 -10,74 +10,20 @@@ |
| 119 | + #include <crypto/aead.h> |
| 120 | + #include <crypto/akcipher.h> |
| 121 | + #include <crypto/hash.h> |
| 122 | + -#include <crypto/skcipher.h> |
| 123 | + #include <crypto/kpp.h> |
| 124 | + +#include <crypto/skcipher.h> |
| 125 | + +#include <linux/types.h> |
| 126 | + |
| 127 | + +struct crypto_engine; |
| 128 | + struct device; |
| 129 | + |
| 130 | + -#define ENGINE_NAME_LEN 30 |
| 131 | + -/* |
| 132 | + - * struct crypto_engine - crypto hardware engine |
| 133 | + - * @name: the engine name |
| 134 | + - * @idling: the engine is entering idle state |
| 135 | + - * @busy: request pump is busy |
| 136 | + - * @running: the engine is on working |
| 137 | + - * @retry_support: indication that the hardware allows re-execution |
| 138 | + - * of a failed backlog request |
| 139 | + - * crypto-engine, in head position to keep order |
| 140 | + - * @list: link with the global crypto engine list |
| 141 | + - * @queue_lock: spinlock to synchronise access to request queue |
| 142 | + - * @queue: the crypto queue of the engine |
| 143 | + - * @rt: whether this queue is set to run as a realtime task |
| 144 | + - * @prepare_crypt_hardware: a request will soon arrive from the queue |
| 145 | + - * so the subsystem requests the driver to prepare the hardware |
| 146 | + - * by issuing this call |
| 147 | + - * @unprepare_crypt_hardware: there are currently no more requests on the |
| 148 | + - * queue so the subsystem notifies the driver that it may relax the |
| 149 | + - * hardware by issuing this call |
| 150 | + - * @do_batch_requests: execute a batch of requests. Depends on multiple |
| 151 | + - * requests support. |
| 152 | + - * @kworker: kthread worker struct for request pump |
| 153 | + - * @pump_requests: work struct for scheduling work to the request pump |
| 154 | + - * @priv_data: the engine private data |
| 155 | + - * @cur_req: the current request which is on processing |
| 156 | + - */ |
| 157 | + -struct crypto_engine { |
| 158 | + - char name[ENGINE_NAME_LEN]; |
| 159 | + - bool idling; |
| 160 | + - bool busy; |
| 161 | + - bool running; |
| 162 | + - |
| 163 | + - bool retry_support; |
| 164 | + - |
| 165 | + - struct list_head list; |
| 166 | + - spinlock_t queue_lock; |
| 167 | + - struct crypto_queue queue; |
| 168 | + - struct device *dev; |
| 169 | + - |
| 170 | + - bool rt; |
| 171 | + - |
| 172 | + - int (*prepare_crypt_hardware)(struct crypto_engine *engine); |
| 173 | + - int (*unprepare_crypt_hardware)(struct crypto_engine *engine); |
| 174 | + - int (*do_batch_requests)(struct crypto_engine *engine); |
| 175 | + - |
| 176 | + - |
| 177 | + - struct kthread_worker *kworker; |
| 178 | + - struct kthread_work pump_requests; |
| 179 | + - |
| 180 | + - void *priv_data; |
| 181 | + - struct crypto_async_request *cur_req; |
| 182 | + -}; |
| 183 | + - |
| 184 | + /* |
| 185 | + * struct crypto_engine_op - crypto hardware engine operations |
| 186 | +++<<<<<<< HEAD |
| 187 | + + * @prepare__request: do some prepare if need before handle the current request |
| 188 | + + * @unprepare_request: undo any work done by prepare_request() |
| 189 | +++======= |
| 190 | +++>>>>>>> bcd6e41d9836 (crypto: engine - Remove prepare/unprepare request) |
| 191 | + * @do_one_request: do encryption for current request |
| 192 | + */ |
| 193 | + struct crypto_engine_op { |
| 194 | +* Unmerged path crypto/crypto_engine.c |
| 195 | +* Unmerged path include/crypto/engine.h |
0 commit comments