aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaiyan Hu <huhaiyan@huawei.com>2013-09-09 23:25:37 -0400
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2013-11-18 17:10:51 -0500
commitb80d5ccca3a012e91ca64a2a0b13049163a6a698 (patch)
tree97d64d8d70ecc42f04ee52023c636d84c05e7a21
parent2d3c627502f2a9b0a7de06a5a2df2365542a72c9 (diff)
NVMe: Avoid shift operation when writing cq head doorbell
Changes the type of dev->db_stride to unsigned and changes the value stored there to be 1 << the current value. Then there is less calculation to be done at completion time. Signed-off-by: Haiyan Hu <huhaiyan@huawei.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
-rw-r--r--drivers/block/nvme-core.c10
-rw-r--r--include/linux/nvme.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 26d03fa0bf26..073aec913c78 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -775,7 +775,7 @@ static int nvme_process_cq(struct nvme_queue *nvmeq)
775 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase) 775 if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
776 return 0; 776 return 0;
777 777
778 writel(head, nvmeq->q_db + (1 << nvmeq->dev->db_stride)); 778 writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
779 nvmeq->cq_head = head; 779 nvmeq->cq_head = head;
780 nvmeq->cq_phase = phase; 780 nvmeq->cq_phase = phase;
781 781
@@ -1113,7 +1113,7 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
1113 init_waitqueue_head(&nvmeq->sq_full); 1113 init_waitqueue_head(&nvmeq->sq_full);
1114 init_waitqueue_entry(&nvmeq->sq_cong_wait, nvme_thread); 1114 init_waitqueue_entry(&nvmeq->sq_cong_wait, nvme_thread);
1115 bio_list_init(&nvmeq->sq_cong); 1115 bio_list_init(&nvmeq->sq_cong);
1116 nvmeq->q_db = &dev->dbs[qid << (dev->db_stride + 1)]; 1116 nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
1117 nvmeq->q_depth = depth; 1117 nvmeq->q_depth = depth;
1118 nvmeq->cq_vector = vector; 1118 nvmeq->cq_vector = vector;
1119 nvmeq->q_suspended = 1; 1119 nvmeq->q_suspended = 1;
@@ -1149,7 +1149,7 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
1149 nvmeq->sq_tail = 0; 1149 nvmeq->sq_tail = 0;
1150 nvmeq->cq_head = 0; 1150 nvmeq->cq_head = 0;
1151 nvmeq->cq_phase = 1; 1151 nvmeq->cq_phase = 1;
1152 nvmeq->q_db = &dev->dbs[qid << (dev->db_stride + 1)]; 1152 nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
1153 memset(nvmeq->cmdid_data, 0, extra); 1153 memset(nvmeq->cmdid_data, 0, extra);
1154 memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth)); 1154 memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth));
1155 nvme_cancel_ios(nvmeq, false); 1155 nvme_cancel_ios(nvmeq, false);
@@ -1741,7 +1741,7 @@ static int set_queue_count(struct nvme_dev *dev, int count)
1741 1741
1742static size_t db_bar_size(struct nvme_dev *dev, unsigned nr_io_queues) 1742static size_t db_bar_size(struct nvme_dev *dev, unsigned nr_io_queues)
1743{ 1743{
1744 return 4096 + ((nr_io_queues + 1) << (dev->db_stride + 3)); 1744 return 4096 + ((nr_io_queues + 1) * 8 * dev->db_stride);
1745} 1745}
1746 1746
1747static int nvme_setup_io_queues(struct nvme_dev *dev) 1747static int nvme_setup_io_queues(struct nvme_dev *dev)
@@ -1958,7 +1958,7 @@ static int nvme_dev_map(struct nvme_dev *dev)
1958 if (!dev->bar) 1958 if (!dev->bar)
1959 goto disable; 1959 goto disable;
1960 1960
1961 dev->db_stride = NVME_CAP_STRIDE(readq(&dev->bar->cap)); 1961 dev->db_stride = 1 << NVME_CAP_STRIDE(readq(&dev->bar->cap));
1962 dev->dbs = ((void __iomem *)dev->bar) + 4096; 1962 dev->dbs = ((void __iomem *)dev->bar) + 4096;
1963 1963
1964 return 0; 1964 return 0;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 26ebcf41c213..8119a476cb29 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -80,7 +80,7 @@ struct nvme_dev {
80 struct dma_pool *prp_small_pool; 80 struct dma_pool *prp_small_pool;
81 int instance; 81 int instance;
82 int queue_count; 82 int queue_count;
83 int db_stride; 83 u32 db_stride;
84 u32 ctrl_config; 84 u32 ctrl_config;
85 struct msix_entry *entry; 85 struct msix_entry *entry;
86 struct nvme_bar __iomem *bar; 86 struct nvme_bar __iomem *bar;