nvme: Reduce traffic to the doorbell register

Reduce traffic to doorbell register when processing multiple completion
events at once. Only write it at the end of the loop after we've
processed everything (assuming we found at least one completion,
even if that completion wasn't valid).

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32470
This commit is contained in:
Warner Losh 2021-10-14 08:44:37 -06:00
parent 76384bd10f
commit 2ec165e3f0

View File

@ -629,10 +629,10 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair)
else
tr = NULL;
done++;
if (tr != NULL) {
nvme_qpair_complete_tracker(tr, &cpl, ERROR_PRINT_ALL);
qpair->sq_head = cpl.sqhd;
done++;
} else if (!in_panic) {
/*
* A missing tracker is normally an error. However, a
@ -664,10 +664,13 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair)
atomic_store_rel_int(&qpair->cq_head, 0); /* 2 */
qpair->phase = !qpair->phase; /* 3 */
}
}
if (done != 0) {
bus_space_write_4(qpair->ctrlr->bus_tag, qpair->ctrlr->bus_handle,
qpair->cq_hdbl_off, qpair->cq_head);
}
return (done != 0);
}