git: c91485376bb0 - main - nvme: enforce the Abort Command Limit

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Fri, 13 Nov 2026 19:08:30 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=c91485376bb07990abe24ccdbbbf330820f35e7c

commit c91485376bb07990abe24ccdbbbf330820f35e7c
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-13 18:24:11 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-13 19:06:20 +0000

    nvme: enforce the Abort Command Limit
    
    Each watchdog pass submitted an Abort for every timed-out command
    with nothing counting them against the controller's ACL. A
    controller may complete excess Aborts with Abort Command Limit
    Exceeded status.
    
    Reviewed by:    imp, adrian
    Differential Revision:  https://reviews.freebsd.org/D59636
---
 sys/dev/nvme/nvme_private.h | 1 +
 sys/dev/nvme/nvme_qpair.c   | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 7ed3d61bd6ce..2244ae6b7d96 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -270,6 +270,7 @@ struct nvme_controller {
 	int			msi_count;
 	bool			is_msix;
 	uint32_t		enable_aborts;
+	int			outstanding_aborts;
 
 	uint32_t		num_io_queues;
 	uint32_t		max_hw_pend_io;
diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 1fd853513fcb..c581cbb39ffb 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -818,6 +818,7 @@ nvme_abort_complete(void *arg, const struct nvme_completion *status)
 	 * a deferred abort: the tracker stays live to keep its CID
 	 * reserved, and the timeout handler escalates to a reset.
 	 */
+	atomic_subtract_int(&tr->qpair->ctrlr->outstanding_aborts, 1);
 	mtx_lock(&tr->qpair->lock);
 	if ((nvme_completion_is_error(status) || (status->cdw0 & 1) == 1) &&
 	    tr->qpair->act_tr[tr->cid] == tr &&
@@ -978,6 +979,13 @@ do_reset:
 			if (ctrlr->enable_aborts &&
 			    tr->abort_state == NVME_ABORT_NONE &&
 			    tr->req->cb_fn != nvme_abort_complete) {
+				if (atomic_fetchadd_int(
+				    &ctrlr->outstanding_aborts, 1) >
+				    (int)ctrlr->cdata.acl) {
+					atomic_subtract_int(
+					    &ctrlr->outstanding_aborts, 1);
+					continue;
+				}
 				/*
 				 * This isn't an abort command, ask for a
 				 * hardware abort. This goes to the admin