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 <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
		
							parent
							
								
									d4047cf994
								
							
						
					
					
						commit
						61f3b89630
					
				| @ -61,10 +61,10 @@ MODULE_PARM_DESC(sgl_threshold, | ||||
| static int io_queue_depth_set(const char *val, const struct kernel_param *kp); | ||||
| static const struct kernel_param_ops io_queue_depth_ops = { | ||||
| 	.set = io_queue_depth_set, | ||||
| 	.get = param_get_int, | ||||
| 	.get = param_get_uint, | ||||
| }; | ||||
| 
 | ||||
| static int io_queue_depth = 1024; | ||||
| static unsigned int io_queue_depth = 1024; | ||||
| module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 0644); | ||||
| MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >= 2"); | ||||
| 
 | ||||
| @ -115,7 +115,7 @@ struct nvme_dev { | ||||
| 	unsigned max_qid; | ||||
| 	unsigned io_queues[HCTX_MAX_TYPES]; | ||||
| 	unsigned int num_vecs; | ||||
| 	int q_depth; | ||||
| 	u16 q_depth; | ||||
| 	int io_sqes; | ||||
| 	u32 db_stride; | ||||
| 	void __iomem *bar; | ||||
| @ -151,13 +151,14 @@ struct nvme_dev { | ||||
| 
 | ||||
| static int io_queue_depth_set(const char *val, const struct kernel_param *kp) | ||||
| { | ||||
| 	int n = 0, ret; | ||||
| 	int ret; | ||||
| 	u16 n; | ||||
| 
 | ||||
| 	ret = kstrtoint(val, 10, &n); | ||||
| 	ret = kstrtou16(val, 10, &n); | ||||
| 	if (ret != 0 || n < 2) | ||||
| 		return -EINVAL; | ||||
| 
 | ||||
| 	return param_set_int(val, kp); | ||||
| 	return param_set_ushort(val, kp); | ||||
| } | ||||
| 
 | ||||
| static inline unsigned int sq_idx(unsigned int qid, u32 stride) | ||||
| @ -2261,8 +2262,8 @@ static void nvme_dev_add(struct nvme_dev *dev) | ||||
| 			dev->tagset.nr_maps++; | ||||
| 		dev->tagset.timeout = NVME_IO_TIMEOUT; | ||||
| 		dev->tagset.numa_node = dev->ctrl.numa_node; | ||||
| 		dev->tagset.queue_depth = | ||||
| 				min_t(int, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1; | ||||
| 		dev->tagset.queue_depth = min_t(unsigned int, dev->q_depth, | ||||
| 						BLK_MQ_MAX_DEPTH) - 1; | ||||
| 		dev->tagset.cmd_size = sizeof(struct nvme_iod); | ||||
| 		dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE; | ||||
| 		dev->tagset.driver_data = dev; | ||||
| @ -2321,7 +2322,7 @@ static int nvme_pci_enable(struct nvme_dev *dev) | ||||
| 
 | ||||
| 	dev->ctrl.cap = lo_hi_readq(dev->bar + NVME_REG_CAP); | ||||
| 
 | ||||
| 	dev->q_depth = min_t(int, NVME_CAP_MQES(dev->ctrl.cap) + 1, | ||||
| 	dev->q_depth = min_t(u16, NVME_CAP_MQES(dev->ctrl.cap) + 1, | ||||
| 				io_queue_depth); | ||||
| 	dev->ctrl.sqsize = dev->q_depth - 1; /* 0's based queue depth */ | ||||
| 	dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user