]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
nvme: coherently read status of completion records
authorWarner Losh <imp@FreeBSD.org>
Fri, 2 Jul 2021 22:00:42 +0000 (16:00 -0600)
committerWarner Losh <imp@FreeBSD.org>
Sat, 31 Jul 2021 00:02:53 +0000 (18:02 -0600)
commitf76c34659f9d94683e1161b8913b6466a2fdbaba
treeceb81875389dc9c4b50b82f801151fd37e8550b8
parentd85d7244d8bb20d5d5040045856c8038333736ce
nvme: coherently read status of completion records

Coherently read the phase bit of the status completion record. We loop
over the completion record array, looking for all the transactions in
the same phase that have been completed. In doing that, we have to be
careful to read the status field first, and if it indicates a complete
record, we need to read and process that record. Otherwise, the host
might be overtaken by device when reading this completion record,
leading to a mistaken belief that the record is in phase. This leads to
the code using old values and looking at an already completed entry, which
has no current tracker.

To work around this problem, we read the status and make sure it is in
phase, we then re-read the entire completion record guaranteeing it's
complete, valid, and consistent . In addition we resync the dmatag to
reflect changes since the prior loop for the bouncing dma case.

Reviewed by: jrtc27@, chuck@
Found by: jrtc27 (this fix is based in part on her D30995 fix)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31002

(cherry picked from commit aa0ab681ae755e01cd69435fab50f6852f248c42)
sys/dev/nvme/nvme_qpair.c