diff options
author | Jon Derrick <jonathan.derrick@intel.com> | 2015-05-27 14:26:23 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-06-05 12:33:34 -0400 |
commit | 36a7e993eedb2c3f11de3b686b351f75e1edbbb5 (patch) | |
tree | f073262e2a058db7a77d4490d422711e8e3c6e46 /drivers/block | |
parent | 4cc06521ee1f153e0d292413a5bff7bbbdee92d0 (diff) |
NVMe: Memory barrier before queue_count is incremented
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@intel.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nvme-core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 9682e29b4171..cae7cac6cc43 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -1453,9 +1453,12 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid, | |||
1453 | nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride]; | 1453 | nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride]; |
1454 | nvmeq->q_depth = depth; | 1454 | nvmeq->q_depth = depth; |
1455 | nvmeq->qid = qid; | 1455 | nvmeq->qid = qid; |
1456 | dev->queue_count++; | ||
1457 | dev->queues[qid] = nvmeq; | 1456 | dev->queues[qid] = nvmeq; |
1458 | 1457 | ||
1458 | /* make sure queue descriptor is set before queue count, for kthread */ | ||
1459 | mb(); | ||
1460 | dev->queue_count++; | ||
1461 | |||
1459 | return nvmeq; | 1462 | return nvmeq; |
1460 | 1463 | ||
1461 | free_cqdma: | 1464 | free_cqdma: |