Skip to content

Commit 61f3b89

Browse files
ChaitanayaKulkarniChristoph Hellwig
authored andcommitted
nvme-pci: use unsigned for io queue depth
The NVMe PCIe declares module parameter io_queue_depth as int. Change this to u16 as queue depth can never be negative. Now to reflect this update module parameter getter function from param_get_int() -> param_get_uint() and respective setter function with type of n changed from int to u16 with param_set_int() to param_set_ushort(). Finally update struct nvme_dev q_depth member to u16 and use u16 in min_t() when calculating dev->q_depth in the nvme_pci_enable() (since q_depth is now u16) and use unsigned int instead of int when calculating dev->tagset.queue_depth as target variable tagset->queue_depth is of type unsigned int in nvme_dev_add(). Signed-off-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent d4047cf commit 61f3b89

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/nvme/host/pci.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ MODULE_PARM_DESC(sgl_threshold,
6161
static int io_queue_depth_set(const char *val, const struct kernel_param *kp);
6262
static const struct kernel_param_ops io_queue_depth_ops = {
6363
.set = io_queue_depth_set,
64-
.get = param_get_int,
64+
.get = param_get_uint,
6565
};
6666

67-
static int io_queue_depth = 1024;
67+
static unsigned int io_queue_depth = 1024;
6868
module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 0644);
6969
MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >= 2");
7070

@@ -115,7 +115,7 @@ struct nvme_dev {
115115
unsigned max_qid;
116116
unsigned io_queues[HCTX_MAX_TYPES];
117117
unsigned int num_vecs;
118-
int q_depth;
118+
u16 q_depth;
119119
int io_sqes;
120120
u32 db_stride;
121121
void __iomem *bar;
@@ -151,13 +151,14 @@ struct nvme_dev {
151151

152152
static int io_queue_depth_set(const char *val, const struct kernel_param *kp)
153153
{
154-
int n = 0, ret;
154+
int ret;
155+
u16 n;
155156

156-
ret = kstrtoint(val, 10, &n);
157+
ret = kstrtou16(val, 10, &n);
157158
if (ret != 0 || n < 2)
158159
return -EINVAL;
159160

160-
return param_set_int(val, kp);
161+
return param_set_ushort(val, kp);
161162
}
162163

163164
static inline unsigned int sq_idx(unsigned int qid, u32 stride)
@@ -2261,8 +2262,8 @@ static void nvme_dev_add(struct nvme_dev *dev)
22612262
dev->tagset.nr_maps++;
22622263
dev->tagset.timeout = NVME_IO_TIMEOUT;
22632264
dev->tagset.numa_node = dev->ctrl.numa_node;
2264-
dev->tagset.queue_depth =
2265-
min_t(int, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1;
2265+
dev->tagset.queue_depth = min_t(unsigned int, dev->q_depth,
2266+
BLK_MQ_MAX_DEPTH) - 1;
22662267
dev->tagset.cmd_size = sizeof(struct nvme_iod);
22672268
dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
22682269
dev->tagset.driver_data = dev;
@@ -2321,7 +2322,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)
23212322

23222323
dev->ctrl.cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
23232324

2324-
dev->q_depth = min_t(int, NVME_CAP_MQES(dev->ctrl.cap) + 1,
2325+
dev->q_depth = min_t(u16, NVME_CAP_MQES(dev->ctrl.cap) + 1,
23252326
io_queue_depth);
23262327
dev->ctrl.sqsize = dev->q_depth - 1; /* 0's based queue depth */
23272328
dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap);

0 commit comments

Comments
 (0)