HomeFreeBSD

nvme: coherently read status of completion records

Description

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)

Details

Provenance
impAuthored on Jul 2 2021, 10:00 PM
Reviewer
D30995: nvme: Fix race condition in nvme_qpair_process_completions
Differential Revision
D31002: nvme: coherently read status
Parents
rGd85d7244d8bb: nvme: Fix alignment on nvme structures
Branches
Unknown
Tags
Unknown