nvme/pci: Remove last_sq_tail
Keith Busch
maintainerPATCH 1/1 nvme/pci: Remove last_sq_tail
We don't allocate enough tags to wrap the submission queue. Remove tracking for this condition.
--- drivers/nvme/host/pci.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/nvme/host/pci.c +4 -16
@@ -174,7 +174,6 @@ struct nvme_queue {u16 q_depth;u16 cq_vector;u16 sq_tail; -u16 last_sq_tail;u16 cq_head;u16 qid;u8 cq_phase;
@@ -462,21 +461,11 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)/* * 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) +static inline void nvme_write_sq_db (struct nvme_queue *nvmeq) { -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, nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))writel (nvmeq->sq_tail, nvmeq->q_db); - nvmeq->last_sq_tail = nvmeq->sq_tail; }/**
@@ -493,7 +482,8 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, cmd, sizeof(*cmd));if (++nvmeq->sq_tail == nvmeq->q_depth) nvmeq->sq_tail =0 ; -nvme_write_sq_db (nvmeq, write_sq); +if (write_sq) +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock); }
@@ -502,8 +492,7 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)struct nvme_queue *nvmeq = hctx->driver_data;spin_lock (&nvmeq->sq_lock); -if (nvmeq->sq_tail != nvmeq->last_sq_tail) -nvme_write_sq_db (nvmeq, true); +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock); }
@@ -1511,7 +1500,6 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)struct nvme_dev *dev = nvmeq->dev; nvmeq->sq_tail =0 ; - nvmeq->last_sq_tail =0 ; nvmeq->cq_head =0 ; nvmeq->cq_phase =1 ; nvmeq->q_db = &dev->dbs[qid *2 * dev->db_stride];
Signature · 7 lines
2.21.0 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 2 lines · Keith Busch
We don't allocate enough tags to wrap the submission queue. Remove tracking for this condition.
Can we ensure that this presumption won't change?
Quoted 18 lines
Signed-off-by Keith Busch <[email protected]>--- drivers/nvme/host/pci.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)drivers/nvme/host/pci.c +0
-1@@ -174,7 +174,6 @@ struct nvme_queue {u16 q_depth;u16 cq_vector;u16 sq_tail; -u16 last_sq_tail;u16 cq_head;u16 qid;u8 cq_phase;
drivers/nvme/host/pci.c static int nvme_pci_map_queues(struct blk_mq_tag_set *set) · line 462
Quoted 2 lines
drivers/nvme/host/pci.c +0
-0@@ -462,21 +461,11 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)/* * Write sq tail if we are asked to, or if the next command would wrap.
Comment needs to be updated.
Ed
Quoted 42 lines
drivers/nvme/host/pci.c +4
-14*/ -static inline void nvme_write_sq_db (struct nvme_queue *nvmeq,bool write_sq) +static inline void nvme_write_sq_db (struct nvme_queue *nvmeq) { -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, nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))writel (nvmeq->sq_tail, nvmeq->q_db); - nvmeq->last_sq_tail = nvmeq->sq_tail; }/** @@ -493,7 +482,8 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, cmd, sizeof(*cmd));if (++nvmeq->sq_tail == nvmeq->q_depth) nvmeq->sq_tail =0 ; -nvme_write_sq_db (nvmeq, write_sq); +if (write_sq) +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock); }@@ -502,8 +492,7 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)struct nvme_queue *nvmeq = hctx->driver_data;spin_lock (&nvmeq->sq_lock); -if (nvmeq->sq_tail != nvmeq->last_sq_tail) -nvme_write_sq_db (nvmeq, true); +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock); }
drivers/nvme/host/pci.c static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid) · line 1505
Quoted 7 lines
drivers/nvme/host/pci.c +0
-1@@ -1511,7 +1500,6 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)struct nvme_dev *dev = nvmeq->dev; nvmeq->sq_tail =0 ; - nvmeq->last_sq_tail =0 ; nvmeq->cq_head =0 ; nvmeq->cq_phase =1 ; nvmeq->q_db = &dev->dbs[qid *2 * dev->db_stride];
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerQuoted 5 lines · Edmund
Quoted 2 lines · Keith Busch
We don't allocate enough tags to wrap the submission queue. Remove tracking for this condition.
Can we ensure that this presumption won't change?
If we did have more tags, there'd be no guarantee we could even dispatch them, and we'd have to track the CQE sq_head value to ensure an available slot. There's really no performance win to adding that overhead to the driver. On top of that, I'm aware there are more than a few controllers that will break if we wrap the submission queue. So I don't see this changing.
Quoted 5 lines
drivers/nvme/host/pci.c static int nvme_pci_map_queues(struct blk_mq_tag_set *set) · line 462
Quoted 3 lines
drivers/nvme/host/pci.c +0
-0@@ -462,21 +461,11 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)/* * Write sq tail if we are asked to, or if the next command would wrap. Comment needs to be updated.
Yep, that comment would be outdated with this patch.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 2 lines · Keith Busch
We don't allocate enough tags to wrap the submission queue. Remove tracking for this condition.
We can totally wrap the sq - just a single command at the end of the SQ will wrap it. We are however never going to wrap it around to the point that we'll overwrite other unsubmitted entries. So I think you change looks good, but the commit log needs a better explanation.
drivers/nvme/host/pci.c static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx) · line 496
Quoted 8 lines
drivers/nvme/host/pci.c +1
-2@@ -502,8 +492,7 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)struct nvme_queue *nvmeq = hctx->driver_data;spin_lock (&nvmeq->sq_lock); -if (nvmeq->sq_tail != nvmeq->last_sq_tail) -nvme_write_sq_db (nvmeq, true); +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock);
Also this change means we now always submit in commit_rqs. This makes total sense as we only commit after having submitted commands, but it is another thing worth mentioning in the commit log.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerQuoted 9 lines · Christoph Hellwig
Quoted 2 lines · Keith Busch
We don't allocate enough tags to wrap the submission queue. Remove tracking for this condition.
We can totally wrap the sq - just a single command at the end of the SQ will wrap it. We are however never going to wrap it around to the point that we'll overwrite other unsubmitted entries. So I think you change looks good, but the commit log needs a better explanation.
Right, I mean "wrap" to indicate the tail passes the head.
Quoted 12 lines
drivers/nvme/host/pci.c static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx) · line 496
Quoted 8 lines
drivers/nvme/host/pci.c +1
-2@@ -502,8 +492,7 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)struct nvme_queue *nvmeq = hctx->driver_data;spin_lock (&nvmeq->sq_lock); -if (nvmeq->sq_tail != nvmeq->last_sq_tail) -nvme_write_sq_db (nvmeq, true); +nvme_write_sq_db (nvmeq);spin_unlock (&nvmeq->sq_lock);Also this change means we now always submit in
commit_rqs. This makes total sense as we only commit after having submitted commands, but it is another thing worth mentioning in the commit log.
Yes, will update the comments.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
You can add:
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme