git: 804d63c0ee8f - stable/12 - safexcel: Handle command/result descriptor exhaustion gracefully
Mark Johnston
markj at FreeBSD.org
Mon Jan 25 14:21:48 UTC 2021
The branch stable/12 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=804d63c0ee8f56dfac29e1fe5879740a3549d0cb
commit 804d63c0ee8f56dfac29e1fe5879740a3549d0cb
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-01-18 22:07:56 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-01-25 14:20:01 +0000
safexcel: Handle command/result descriptor exhaustion gracefully
Rather than returning a hard error in this case, return ERESTART so that
upper layers get a chance to retry the request (or drop it, depending on
the desired policy).
This case is hard to hit due to the somewhat low bound on queued
requests, but that will no longer be true after an upcoming change.
Sponsored by: Rubicon Communications, LLC (Netgate)
(cherry picked from commit b7e27af36b7df05f4b6cdc706750413f3a048640)
---
sys/dev/safexcel/safexcel.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/sys/dev/safexcel/safexcel.c b/sys/dev/safexcel/safexcel.c
index 467b118dacdf..db7bc9d90a00 100644
--- a/sys/dev/safexcel/safexcel.c
+++ b/sys/dev/safexcel/safexcel.c
@@ -2084,7 +2084,7 @@ safexcel_create_chain_cb(void *arg, bus_dma_segment_t *segs, int nseg,
if (cdesc == NULL) {
safexcel_cmd_descr_rollback(ring, i);
counter_u64_add(req->sc->sc_cdesc_alloc_failures, 1);
- req->error = EAGAIN;
+ req->error = ERESTART;
return;
}
if (i == 0)
@@ -2112,7 +2112,7 @@ safexcel_create_chain_cb(void *arg, bus_dma_segment_t *segs, int nseg,
ring->cmd_data->sg_nseg);
safexcel_res_descr_rollback(ring, i);
counter_u64_add(req->sc->sc_rdesc_alloc_failures, 1);
- req->error = EAGAIN;
+ req->error = ERESTART;
return;
}
}
@@ -2724,10 +2724,16 @@ safexcel_process(device_t dev, struct cryptop *crp, int hint)
error = safexcel_create_chain(ring, req);
if (__predict_false(error != 0)) {
safexcel_free_request(ring, req);
+ if (error == ERESTART)
+ ring->blocked = CRYPTO_SYMQ;
mtx_unlock(&ring->mtx);
- crp->crp_etype = error;
- crypto_done(crp);
- return (0);
+ if (error != ERESTART) {
+ crp->crp_etype = error;
+ crypto_done(crp);
+ return (0);
+ } else {
+ return (ERESTART);
+ }
}
safexcel_set_token(req);
More information about the dev-commits-src-all
mailing list