Skip to content

Commit c470ffa

Browse files
ovpanaitherbertx
authored andcommitted
crypto: engine - remove request batching support
Remove request batching support from crypto_engine, as there are no drivers using this feature and it doesn't really work that well. Instead of doing batching based on backlog, a more optimal approach would be for the user to handle the batching (similar to how IPsec can hook into GSO to get 64K of data each time or how block encryption can use unit sizes much greater than 4K). Suggested-by: Herbert Xu <[email protected]> Signed-off-by: Ovidiu Panait <[email protected]> Reviewed-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 3d4df40 commit c470ffa

File tree

7 files changed

+5
-34
lines changed

7 files changed

+5
-34
lines changed

arch/s390/crypto/paes_s390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ static int __init paes_s390_init(void)
16331633
/* with this pseudo devie alloc and start a crypto engine */
16341634
paes_crypto_engine =
16351635
crypto_engine_alloc_init_and_set(paes_dev.this_device,
1636-
true, NULL, false, MAX_QLEN);
1636+
true, false, MAX_QLEN);
16371637
if (!paes_crypto_engine) {
16381638
rc = -ENOMEM;
16391639
goto out_err;

arch/s390/crypto/phmac_s390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ static int __init s390_phmac_init(void)
10061006
/* with this pseudo device alloc and start a crypto engine */
10071007
phmac_crypto_engine =
10081008
crypto_engine_alloc_init_and_set(phmac_dev.this_device,
1009-
true, NULL, false, MAX_QLEN);
1009+
true, false, MAX_QLEN);
10101010
if (!phmac_crypto_engine) {
10111011
rc = -ENOMEM;
10121012
goto out_err;

crypto/crypto_engine.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,6 @@ static void crypto_pump_requests(struct crypto_engine *engine,
195195
out:
196196
spin_unlock_irqrestore(&engine->queue_lock, flags);
197197

198-
/*
199-
* Batch requests is possible only if
200-
* hardware can enqueue multiple requests
201-
*/
202-
if (engine->do_batch_requests) {
203-
ret = engine->do_batch_requests(engine);
204-
if (ret)
205-
dev_err(engine->dev, "failed to do batch requests: %d\n",
206-
ret);
207-
}
208-
209198
return;
210199
}
211200

@@ -462,12 +451,6 @@ EXPORT_SYMBOL_GPL(crypto_engine_stop);
462451
* crypto-engine queue.
463452
* @dev: the device attached with one hardware engine
464453
* @retry_support: whether hardware has support for retry mechanism
465-
* @cbk_do_batch: pointer to a callback function to be invoked when executing
466-
* a batch of requests.
467-
* This has the form:
468-
* callback(struct crypto_engine *engine)
469-
* where:
470-
* engine: the crypto engine structure.
471454
* @rt: whether this queue is set to run as a realtime task
472455
* @qlen: maximum size of the crypto-engine queue
473456
*
@@ -476,7 +459,6 @@ EXPORT_SYMBOL_GPL(crypto_engine_stop);
476459
*/
477460
struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
478461
bool retry_support,
479-
int (*cbk_do_batch)(struct crypto_engine *engine),
480462
bool rt, int qlen)
481463
{
482464
struct crypto_engine *engine;
@@ -495,11 +477,6 @@ struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
495477
engine->idling = false;
496478
engine->retry_support = retry_support;
497479
engine->priv_data = dev;
498-
/*
499-
* Batch requests is possible only if
500-
* hardware has support for retry mechanism.
501-
*/
502-
engine->do_batch_requests = retry_support ? cbk_do_batch : NULL;
503480

504481
snprintf(engine->name, sizeof(engine->name),
505482
"%s-engine", dev_name(dev));
@@ -534,7 +511,7 @@ EXPORT_SYMBOL_GPL(crypto_engine_alloc_init_and_set);
534511
*/
535512
struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt)
536513
{
537-
return crypto_engine_alloc_init_and_set(dev, false, NULL, rt,
514+
return crypto_engine_alloc_init_and_set(dev, false, rt,
538515
CRYPTO_ENGINE_MAX_QLEN);
539516
}
540517
EXPORT_SYMBOL_GPL(crypto_engine_alloc_init);

drivers/crypto/caam/jr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,7 @@ static int caam_jr_probe(struct platform_device *pdev)
629629
}
630630

631631
/* Initialize crypto engine */
632-
jrpriv->engine = crypto_engine_alloc_init_and_set(jrdev, true, NULL,
633-
false,
632+
jrpriv->engine = crypto_engine_alloc_init_and_set(jrdev, true, false,
634633
CRYPTO_ENGINE_MAX_QLEN);
635634
if (!jrpriv->engine) {
636635
dev_err(jrdev, "Could not init crypto-engine\n");

drivers/crypto/virtio/virtio_crypto_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
139139
spin_lock_init(&vi->data_vq[i].lock);
140140
vi->data_vq[i].vq = vqs[i];
141141
/* Initialize crypto engine */
142-
vi->data_vq[i].engine = crypto_engine_alloc_init_and_set(dev, true, NULL, true,
142+
vi->data_vq[i].engine = crypto_engine_alloc_init_and_set(dev, true, true,
143143
virtqueue_get_vring_size(vqs[i]));
144144
if (!vi->data_vq[i].engine) {
145145
ret = -ENOMEM;

include/crypto/engine.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ int crypto_engine_stop(struct crypto_engine *engine);
7676
struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
7777
struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
7878
bool retry_support,
79-
int (*cbk_do_batch)(struct crypto_engine *engine),
8079
bool rt, int qlen);
8180
void crypto_engine_exit(struct crypto_engine *engine);
8281

include/crypto/internal/engine.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ struct device;
3737
* @unprepare_crypt_hardware: there are currently no more requests on the
3838
* queue so the subsystem notifies the driver that it may relax the
3939
* hardware by issuing this call
40-
* @do_batch_requests: execute a batch of requests. Depends on multiple
41-
* requests support.
4240
* @kworker: kthread worker struct for request pump
4341
* @pump_requests: work struct for scheduling work to the request pump
4442
* @priv_data: the engine private data
@@ -60,8 +58,6 @@ struct crypto_engine {
6058

6159
int (*prepare_crypt_hardware)(struct crypto_engine *engine);
6260
int (*unprepare_crypt_hardware)(struct crypto_engine *engine);
63-
int (*do_batch_requests)(struct crypto_engine *engine);
64-
6561

6662
struct kthread_worker *kworker;
6763
struct kthread_work pump_requests;

0 commit comments

Comments
 (0)