forked from Minki/linux
Revert "nvme-pci: remove last_sq_tail"
Multiple CPUs may be mapped to the same hctx, allowing mulitple
submission contexts to attempt commit_rqs(). We need to verify we're
not writing the same doorbell value multiple times since that's a spec
violation.
Revert commit 54b2fcee1d
.
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1878596
Reported-by: "B.L. Jones" <brandon.gustav@googlemail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
65ff5cd045
commit
38210800bf
@ -198,6 +198,7 @@ struct nvme_queue {
|
|||||||
u32 q_depth;
|
u32 q_depth;
|
||||||
u16 cq_vector;
|
u16 cq_vector;
|
||||||
u16 sq_tail;
|
u16 sq_tail;
|
||||||
|
u16 last_sq_tail;
|
||||||
u16 cq_head;
|
u16 cq_head;
|
||||||
u16 qid;
|
u16 qid;
|
||||||
u8 cq_phase;
|
u8 cq_phase;
|
||||||
@ -455,11 +456,24 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void nvme_write_sq_db(struct nvme_queue *nvmeq)
|
/*
|
||||||
|
* Write sq tail if we are asked to, or if the next command would wrap.
|
||||||
|
*/
|
||||||
|
static inline void nvme_write_sq_db(struct nvme_queue *nvmeq, bool write_sq)
|
||||||
{
|
{
|
||||||
|
if (!write_sq) {
|
||||||
|
u16 next_tail = nvmeq->sq_tail + 1;
|
||||||
|
|
||||||
|
if (next_tail == nvmeq->q_depth)
|
||||||
|
next_tail = 0;
|
||||||
|
if (next_tail != nvmeq->last_sq_tail)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (nvme_dbbuf_update_and_check_event(nvmeq->sq_tail,
|
if (nvme_dbbuf_update_and_check_event(nvmeq->sq_tail,
|
||||||
nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))
|
nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))
|
||||||
writel(nvmeq->sq_tail, nvmeq->q_db);
|
writel(nvmeq->sq_tail, nvmeq->q_db);
|
||||||
|
nvmeq->last_sq_tail = nvmeq->sq_tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,8 +490,7 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd,
|
|||||||
cmd, sizeof(*cmd));
|
cmd, sizeof(*cmd));
|
||||||
if (++nvmeq->sq_tail == nvmeq->q_depth)
|
if (++nvmeq->sq_tail == nvmeq->q_depth)
|
||||||
nvmeq->sq_tail = 0;
|
nvmeq->sq_tail = 0;
|
||||||
if (write_sq)
|
nvme_write_sq_db(nvmeq, write_sq);
|
||||||
nvme_write_sq_db(nvmeq);
|
|
||||||
spin_unlock(&nvmeq->sq_lock);
|
spin_unlock(&nvmeq->sq_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +499,8 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)
|
|||||||
struct nvme_queue *nvmeq = hctx->driver_data;
|
struct nvme_queue *nvmeq = hctx->driver_data;
|
||||||
|
|
||||||
spin_lock(&nvmeq->sq_lock);
|
spin_lock(&nvmeq->sq_lock);
|
||||||
nvme_write_sq_db(nvmeq);
|
if (nvmeq->sq_tail != nvmeq->last_sq_tail)
|
||||||
|
nvme_write_sq_db(nvmeq, true);
|
||||||
spin_unlock(&nvmeq->sq_lock);
|
spin_unlock(&nvmeq->sq_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1496,6 +1510,7 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
|
|||||||
struct nvme_dev *dev = nvmeq->dev;
|
struct nvme_dev *dev = nvmeq->dev;
|
||||||
|
|
||||||
nvmeq->sq_tail = 0;
|
nvmeq->sq_tail = 0;
|
||||||
|
nvmeq->last_sq_tail = 0;
|
||||||
nvmeq->cq_head = 0;
|
nvmeq->cq_head = 0;
|
||||||
nvmeq->cq_phase = 1;
|
nvmeq->cq_phase = 1;
|
||||||
nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
|
nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
|
||||||
|
Loading…
Reference in New Issue
Block a user