nvmf/vfio-user: don't use Guest's phase bit for completion response
We should maintain phase bit in vfio-user target, it's not safe to use Guest completion queue's phase bit. Change-Id: I94856853784802f7695a0484b783d8de4042f8a6 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8988 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
This commit is contained in:
parent
a93387f69f
commit
2f85499e43
@ -122,6 +122,7 @@ struct nvme_q {
|
||||
uint32_t tail;
|
||||
uint16_t iv;
|
||||
bool ien;
|
||||
bool phase;
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -739,7 +740,13 @@ cq_tail_advance(struct nvme_q *q)
|
||||
assert(q != NULL);
|
||||
assert(q->is_cq);
|
||||
|
||||
q->tail = cq_next(q);
|
||||
assert(q->tail < q->size);
|
||||
q->tail++;
|
||||
|
||||
if (spdk_unlikely(q->tail == q->size)) {
|
||||
q->tail = 0;
|
||||
q->phase = !q->phase;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
@ -761,6 +768,7 @@ acq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
|
||||
cq->tail = 0;
|
||||
cq->is_cq = true;
|
||||
cq->ien = true;
|
||||
cq->phase = true;
|
||||
|
||||
ret = map_q(ctrlr, cq, true, true);
|
||||
if (ret) {
|
||||
@ -873,7 +881,7 @@ 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 = ~cpl->status.p;
|
||||
cpl->status.p = cq->phase;
|
||||
cpl->status.sc = sc;
|
||||
|
||||
cq_tail_advance(cq);
|
||||
@ -1150,6 +1158,7 @@ handle_create_io_q(struct nvmf_vfio_user_ctrlr *ctrlr,
|
||||
}
|
||||
io_q->ien = cmd->cdw11_bits.create_io_cq.ien;
|
||||
io_q->iv = cmd->cdw11_bits.create_io_cq.iv;
|
||||
io_q->phase = true;
|
||||
} else {
|
||||
/* CQ must be created before SQ */
|
||||
if (!lookup_io_q(ctrlr, cmd->cdw11_bits.create_io_sq.cqid, true)) {
|
||||
|
Loading…
Reference in New Issue
Block a user