From 3b066930ac02a483540050e84d4caa2ac581409c Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 13 Jan 2022 21:28:31 +0800 Subject: [PATCH] nvmf/vfio-user: add memory barrier after posting a completion We met an issue that client got a NVMe completion with old SC bit, so we add a memory barrier here to ensure the NVMe completion is fully populated. Fix issue #2323. Change-Id: I7887d789a0acd3634a10aa7dc8de81a153137ae7 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11076 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: John Levon Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/vfio_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 1102076fd..a86541647 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -939,9 +939,11 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvme_q *cq, cpl->status.dnr = 0x0; cpl->status.m = 0x0; cpl->status.sct = sct; - cpl->status.p = cq->phase; cpl->status.sc = sc; + cpl->status.p = cq->phase; + /* Ensure the Completion Queue Entry is visible. */ + spdk_wmb(); cq_tail_advance(cq); /*