Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NVMe: Memory barrier before queue_count is incremented
@ 2015-05-27 18:26 Jon Derrick
  2015-05-28 22:32 ` Keith Busch
  2015-06-03 16:26 ` Jon Derrick
  0 siblings, 2 replies; 4+ messages in thread
From: Jon Derrick @ 2015-05-27 18:26 UTC (permalink / raw)


Protects against reordering and/or preempting which would allow the
kthread to access the queue descriptor before it is set up

Signed-off-by: Jon Derrick <jonathan.derrick at intel.com>
---
 drivers/block/nvme-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index c42bc53..2b0c817 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1463,9 +1463,12 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
 	nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
 	nvmeq->q_depth = depth;
 	nvmeq->qid = qid;
-	dev->queue_count++;
 	dev->queues[qid] = nvmeq;
 
+	/* make sure queue descriptor is set before queue count, for kthread */
+	mb();
+	dev->queue_count++;
+
 	return nvmeq;
 
  free_cqdma:
-- 
2.1.4

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

end of thread, other threads:[~2015-06-05 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 18:26 [PATCH] NVMe: Memory barrier before queue_count is incremented Jon Derrick
2015-05-28 22:32 ` Keith Busch
2015-06-05 16:34   ` Jens Axboe
2015-06-03 16:26 ` Jon Derrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox