linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rfc] nvme-pci: make sure to flush sqe writes before db record update
@ 2018-03-07 17:56 Sagi Grimberg
  2018-03-08  7:56 ` Christoph Hellwig
  2018-03-08 15:51 ` Keith Busch
  0 siblings, 2 replies; 12+ messages in thread
From: Sagi Grimberg @ 2018-03-07 17:56 UTC (permalink / raw)


A wmb() is always required before operations that trigger DMA
(e.g. mmio write to a doorbell record). Not having it might result
in write reordering causing the device to fetch partly updated
submission queue entries.

Reported-by: Jason Gunthorpe <jgg at ziepe.ca>
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
Note that this is stable material, We could add stable
tag when applying it to the nvme tree.

 drivers/nvme/host/pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index db4dedb1cc8f..6c2dcef1ff91 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -437,8 +437,14 @@ static void __nvme_submit_cmd(struct nvme_queue *nvmeq,
 	if (++tail == nvmeq->q_depth)
 		tail = 0;
 	if (nvme_dbbuf_update_and_check_event(tail, nvmeq->dbbuf_sq_db,
-					      nvmeq->dbbuf_sq_ei))
+					      nvmeq->dbbuf_sq_ei)) {
+		/*
+		 * Make sure that descriptors are written before
+		 * doorbell record.
+		 */
+		wmb();
 		writel(tail, nvmeq->q_db);
+	}
 	nvmeq->sq_tail = tail;
 }
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-05-31 15:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-07 17:56 [PATCH rfc] nvme-pci: make sure to flush sqe writes before db record update Sagi Grimberg
2018-03-08  7:56 ` Christoph Hellwig
2018-03-08 15:51 ` Keith Busch
2018-03-08 17:20   ` Jason Gunthorpe
2018-03-08 17:37     ` Keith Busch
2018-03-08 17:56     ` Sagi Grimberg
2018-03-08 18:36       ` Jason Gunthorpe
2018-03-08 18:42         ` Keith Busch
2018-05-30 23:34       ` Sagi Grimberg
2018-05-31  5:47         ` Christoph Hellwig
2018-05-31  7:53           ` Sagi Grimberg
2018-05-31 15:20             ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).