From owner-dev-commits-src-main@freebsd.org Mon Jan 18 22:08:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E1D944F728E; Mon, 18 Jan 2021 22:08:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKQsC3DVSz3KCr; Mon, 18 Jan 2021 22:08:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3E2E1B542; Mon, 18 Jan 2021 22:08:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10IM8EhO039227; Mon, 18 Jan 2021 22:08:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10IM8Ei2039226; Mon, 18 Jan 2021 22:08:14 GMT (envelope-from git) Date: Mon, 18 Jan 2021 22:08:14 GMT Message-Id: <202101182208.10IM8Ei2039226@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b7e27af36b7d - main - safexcel: Handle command/result descriptor exhaustion gracefully MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7e27af36b7df05f4b6cdc706750413f3a048640 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2021 22:08:17 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b7e27af36b7df05f4b6cdc706750413f3a048640 commit b7e27af36b7df05f4b6cdc706750413f3a048640 Author: Mark Johnston AuthorDate: 2021-01-18 22:07:56 +0000 Commit: Mark Johnston CommitDate: 2021-01-18 22:07:56 +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. MFC after: 1 week Sponsored by: Rubicon Communications, LLC (Netgate) --- 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 c30b8178efb1..2f0f10f1d5e8 100644 --- a/sys/dev/safexcel/safexcel.c +++ b/sys/dev/safexcel/safexcel.c @@ -2093,7 +2093,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) @@ -2121,7 +2121,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; } } @@ -2608,10 +2608,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);